Skip to content

Commit

Permalink
Merge branch 'develop' into enhance/#6252-km-top-cities-driving-traffic.
Browse files Browse the repository at this point in the history
  • Loading branch information
hussain-t committed Jul 18, 2023
2 parents 1aefc4b + 3d7b470 commit 672b200
Show file tree
Hide file tree
Showing 35 changed files with 256 additions and 262 deletions.
7 changes: 6 additions & 1 deletion assets/js/components/DashboardEntryPoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
/**
* Internal dependencies
*/
import { provideModules, render } from '../../../tests/js/test-utils';
import {
provideModules,
provideUserAuthentication,
render,
} from '../../../tests/js/test-utils';
import { mockCreateComponent } from '../../../tests/js/mock-component-utils';
import DashboardEntryPoint from './DashboardEntryPoint';
import { MODULES_ANALYTICS_4 } from '../modules/analytics-4/datastore/constants';
Expand All @@ -31,6 +35,7 @@ jest.mock( './DashboardMainApp', () =>

describe( 'DashboardEntryPoint', () => {
const setupRegistry = ( registry ) => {
provideUserAuthentication( registry );
provideModules( registry );
registry.dispatch( MODULES_ANALYTICS_4 ).receiveGetSettings( {} );
};
Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/DashboardNavigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default function Navigation() {
const margin = 20;

const areas = [
...( showKeyMetrics ? [ ANCHOR_ID_TRAFFIC ] : [] ),
...( showKeyMetrics ? [ ANCHOR_ID_KEY_METRICS ] : [] ),
...( showTraffic ? [ ANCHOR_ID_TRAFFIC ] : [] ),
...( showContent ? [ ANCHOR_ID_CONTENT ] : [] ),
...( showSpeed ? [ ANCHOR_ID_SPEED ] : [] ),
Expand Down
11 changes: 10 additions & 1 deletion assets/js/components/DashboardNavigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Data from 'googlesitekit-data';
import { CORE_USER } from '../../googlesitekit/datastore/user/constants';
import useViewOnly from '../../hooks/useViewOnly';
import Navigation from './Navigation';
import { useFeature } from '../../hooks/useFeature';
const { useSelect } = Data;

export default function DashboardNavigation() {
Expand All @@ -36,7 +37,15 @@ export default function DashboardNavigation() {
return select( CORE_USER ).getViewableModules();
} );

if ( viewableModules === undefined ) {
const userInputEnabled = useFeature( 'userInput' );
const keyMetrics = useSelect(
( select ) => userInputEnabled && select( CORE_USER ).getKeyMetrics()
);

// The Navigation component relies on the resolution of the above selectors to check if individual
// widgetContexts are active. The results of these checks are used to determine the `defaultChipID`
// which 'highlights' the first chip and sets the corresponding hash on page load.
if ( viewableModules === undefined || keyMetrics === undefined ) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function AdBlockingRecoveryNotification() {
id={ NOTIFICATION_ID }
className="googlesitekit-ad-blocking-recovery-notification"
title={ __(
'You successfully added the ad blocking recovery tag',
'You successfully enabled the ad blocking recovery message',
'google-site-kit'
) }
description={ createInterpolateElement(
Expand Down
16 changes: 6 additions & 10 deletions assets/js/components/notifications/BannerNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const { useSelect } = Data;

export default function BannerNotifications() {
const dashboardSharingEnabled = useFeature( 'dashboardSharing' );
const gteSupportEnabled = useFeature( 'gteSupport' );
const ga4ReportingEnabled = useFeature( 'ga4Reporting' );
const adBlockerDetectionEnabled = useFeature( 'adBlockerDetection' );

Expand Down Expand Up @@ -111,15 +110,12 @@ export default function BannerNotifications() {
analyticsModuleConnected &&
ga4ModuleConnected && <SwitchedToGA4Banner /> }
<ActivationBanner />
{ gteSupportEnabled &&
ga4ModuleConnected &&
hasGTMScope &&
isGA4ModuleOwner && (
<Fragment>
<GoogleTagIDMismatchNotification />
<WebDataStreamNotAvailableNotification />
</Fragment>
) }
{ ga4ModuleConnected && hasGTMScope && isGA4ModuleOwner && (
<Fragment>
<GoogleTagIDMismatchNotification />
<WebDataStreamNotAvailableNotification />
</Fragment>
) }
<OptimizeRemovalNotification />
<ZeroDataStateNotifications />
{ adBlockerDetectionEnabled && <AdBlockingRecoveryNotification /> }
Expand Down
5 changes: 1 addition & 4 deletions assets/js/components/notifications/ErrorNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ import { CORE_USER } from '../../googlesitekit/datastore/user/constants';
import { CORE_SITE } from '../../googlesitekit/datastore/site/constants';
import { READ_SCOPE as TAGMANAGER_READ_SCOPE } from '../../modules/tagmanager/datastore/constants';
import BannerNotification from './BannerNotification';
import { useFeature } from '../../hooks/useFeature';
const { useSelect } = Data;

export default function ErrorNotifications() {
const gteSupportEnabled = useFeature( 'gteSupport' );

const isAuthenticated = useSelect( ( select ) =>
select( CORE_USER ).isAuthenticated()
);
Expand Down Expand Up @@ -68,7 +65,7 @@ export default function ErrorNotifications() {
);

const showUnsatisfiedScopesAlertGTE =
gteSupportEnabled && ga4ModuleConnected && ! hasTagManagerReadScope;
ga4ModuleConnected && ! hasTagManagerReadScope;

return (
<Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ UnsatisfiedScopeGTESupport.args = {
} );
},
};
UnsatisfiedScopeGTESupport.parameters = {
features: [ 'gteSupport' ],
};
UnsatisfiedScopeGTESupport.scenario = {
label: 'Global/ErrorNotifications/UnsatisfiedScopeGTESupport',
};
Expand Down
2 changes: 0 additions & 2 deletions assets/js/components/notifications/ErrorNotifications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ describe( 'ErrorNotifications', () => {

const { container } = render( <ErrorNotifications />, {
registry,
features: [ 'gteSupport' ],
} );

expect( container ).toHaveTextContent(
Expand All @@ -127,7 +126,6 @@ describe( 'ErrorNotifications', () => {

const { container } = render( <ErrorNotifications />, {
registry,
features: [ 'gteSupport' ],
} );

expect( container ).toHaveTextContent(
Expand Down
2 changes: 1 addition & 1 deletion assets/js/feature-tours/ga4-reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ga4Reporting = {
),
content: createInterpolateElement(
__(
'"Conversions" have replaced "Goals", since "Goals" no longer exist in GA4. <a>Learn how to set up Conversions</a>',
'"Conversions" have replaced "Goals," since "Goals" no longer exist in GA4. <a>Learn how to set up Conversions</a>',
'google-site-kit'
),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function AdBlockingRecoveryToggle() {
existingAdBlockingRecoveryTag === accountID
) {
existingAdBlockingRecoveryTagMessage = __(
'You’ve already got an Ad Blocking Recovery code on your site. We recommend you use Site Kit to manage this to get the most out of AdSense.',
'You’ve already enabled an ad blocking recovery message on your site. We recommend using Site Kit to manage this to get the most out of AdSense.',
'google-site-kit'
);
} else if ( existingAdBlockingRecoveryTag ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe( 'AdBlockingRecoveryToggle', () => {
expect(
container.querySelector( '.googlesitekit-settings-notice__text' )
).toHaveTextContent(
'You’ve already got an Ad Blocking Recovery code on your site. We recommend you use Site Kit to manage this to get the most out of AdSense.'
'You’ve already enabled an ad blocking recovery message on your site. We recommend using Site Kit to manage this to get the most out of AdSense.'
);
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default function PlaceTagsStep( { setActiveStep } ) {
isSaving={ isSaving }
disabled={ isSaving }
>
{ __( 'Place tag', 'google-site-kit' ) }
{ __( 'Enable message', 'google-site-kit' ) }
</SpinnerButton>
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,25 @@ import { MODULES_ANALYTICS_4 } from '../../datastore/constants';
import { CORE_SITE } from '../../../../googlesitekit/datastore/site/constants';
import * as fixtures from '../../datastore/__fixtures__';
import * as analyticsFixtures from '../../../analytics/datastore/__fixtures__';
import { fireEvent, act, render } from '../../../../../../tests/js/test-utils';
import {
fireEvent,
act,
render,
provideUserAuthentication,
} from '../../../../../../tests/js/test-utils';

const { createProperty, properties, webDataStreamsBatch } = fixtures;
const { accounts } = analyticsFixtures.accountsPropertiesProfiles;
const accountID = createProperty._accountID;
const propertyIDs = properties.map( ( { _id } ) => _id );

const setupRegistry = ( { dispatch } ) => {
const setupRegistry = ( registry ) => {
const { dispatch } = registry;

dispatch( CORE_SITE ).receiveSiteInfo( {
referenceSiteURL: 'http://example.com',
} );
provideUserAuthentication( registry );
dispatch( MODULES_ANALYTICS ).receiveGetSettings( {} );
dispatch( MODULES_ANALYTICS_4 ).receiveGetSettings( {} );
dispatch( MODULES_ANALYTICS ).setAccountID( accountID );
Expand Down
8 changes: 0 additions & 8 deletions assets/js/modules/analytics-4/datastore/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { isValidPropertySelection } from '../utils/validation';
import { actions as webDataStreamActions } from './webdatastreams';
import { isValidAccountID } from '../../analytics/util';
import { createValidatedAction } from '../../../googlesitekit/data/utils';
import { isFeatureEnabled } from '../../../features';
const { commonActions, createRegistryControl } = Data;

const fetchGetPropertyStore = createFetchStore( {
Expand Down Expand Up @@ -473,9 +472,6 @@ const baseActions = {

dispatch( MODULES_ANALYTICS_4 ).setMeasurementID( measurementID );

if ( ! isFeatureEnabled( 'gteSupport' ) ) {
return;
}
// Wait for authentication to be resolved to check scopes.
yield commonActions.await(
__experimentalResolveSelect( CORE_USER ).getAuthentication()
Expand Down Expand Up @@ -554,10 +550,6 @@ const baseActions = {
* @since 1.95.0
*/
*syncGoogleTagSettings() {
if ( ! isFeatureEnabled( 'gteSupport' ) ) {
return;
}

const { select, dispatch, __experimentalResolveSelect } =
yield Data.commonActions.getRegistry();

Expand Down
17 changes: 9 additions & 8 deletions assets/js/modules/analytics-4/datastore/properties.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
WEBDATASTREAM_CREATE,
} from './constants';
import * as fixtures from './__fixtures__';
import { enabledFeatures } from '../../../features';

describe( 'modules/analytics-4 properties', () => {
let registry;
Expand Down Expand Up @@ -165,6 +164,8 @@ describe( 'modules/analytics-4 properties', () => {
measurementID: 'abcd',
};

provideUserAuthentication( registry );

registry
.dispatch( MODULES_ANALYTICS_4 )
.receiveGetSettings( settings );
Expand Down Expand Up @@ -194,6 +195,7 @@ describe( 'modules/analytics-4 properties', () => {
provideSiteInfo( registry, {
referenceSiteURL: 'https://www.example.io',
} );
provideUserAuthentication( registry );

registry
.dispatch( MODULES_ANALYTICS_4 )
Expand Down Expand Up @@ -229,6 +231,7 @@ describe( 'modules/analytics-4 properties', () => {
provideSiteInfo( registry, {
referenceSiteURL: 'https://www.example.org',
} );
provideUserAuthentication( registry );

registry
.dispatch( MODULES_ANALYTICS_4 )
Expand Down Expand Up @@ -277,6 +280,8 @@ describe( 'modules/analytics-4 properties', () => {
provideSiteInfo( registry, {
referenceSiteURL: 'https://www.example.org',
} );
provideUserAuthentication( registry );

registry
.dispatch( MODULES_ANALYTICS_4 )
.receiveGetSettings( settings );
Expand Down Expand Up @@ -399,6 +404,7 @@ describe( 'modules/analytics-4 properties', () => {

beforeEach( () => {
provideSiteInfo( registry );
provideUserAuthentication( registry );

const properties = [
{
Expand Down Expand Up @@ -546,6 +552,8 @@ describe( 'modules/analytics-4 properties', () => {
it( 'should update the settings with the measurement ID.', async () => {
const measurementID = 'G-1A2BCD346E';

provideUserAuthentication( registry );

await registry
.dispatch( MODULES_ANALYTICS_4 )
.updateSettingsForMeasurementID( measurementID );
Expand All @@ -556,7 +564,6 @@ describe( 'modules/analytics-4 properties', () => {
} );

it( 'dispatches a request to get and populate Google Tag settings', async () => {
enabledFeatures.add( 'gteSupport' );
provideUserAuthentication( registry, {
grantedScopes: [ TAGMANAGER_READ_SCOPE ],
} );
Expand Down Expand Up @@ -586,7 +593,6 @@ describe( 'modules/analytics-4 properties', () => {
} );

it( 'requires the GTM readonly scope to dispatch a request for Google Tag settings', async () => {
enabledFeatures.add( 'gteSupport' );
provideUserAuthentication( registry );

await registry
Expand All @@ -597,7 +603,6 @@ describe( 'modules/analytics-4 properties', () => {
} );

it( 'empties the Google Tag Settings if measurement ID is an empty string', async () => {
enabledFeatures.add( 'gteSupport' );
provideUserAuthentication( registry, {
grantedScopes: [ TAGMANAGER_READ_SCOPE ],
} );
Expand Down Expand Up @@ -674,10 +679,6 @@ describe( 'modules/analytics-4 properties', () => {
} );

describe( 'syncGoogleTagSettings', () => {
beforeEach( () => {
enabledFeatures.add( 'gteSupport' );
} );

it( 'should not execute if the Tag Manager readonly scope is not granted', async () => {
provideUserAuthentication( registry );

Expand Down
3 changes: 3 additions & 0 deletions assets/js/modules/analytics-4/datastore/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import API from 'googlesitekit-api';
import {
createTestRegistry,
provideUserAuthentication,
unsubscribeFromAll,
} from '../../../../../tests/js/utils';
import { withActive } from '../../../googlesitekit/modules/datastore/__fixtures__';
Expand Down Expand Up @@ -73,6 +74,8 @@ describe( 'modules/analytics-4 settings', () => {
describe( 'actions', () => {
describe( 'submitChanges', () => {
beforeEach( () => {
provideUserAuthentication( registry );

registry.dispatch( MODULES_ANALYTICS ).setSettings( {
accountID: fixtures.createProperty._accountID,
} );
Expand Down
Loading

0 comments on commit 672b200

Please sign in to comment.