Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/8196 remove duplicate tag snippet functionality #8311

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e430660
Remove gaPropertyID from TagManager datastore.
jimmymadon Feb 24, 2024
c78d28e
Remove useGAPropertyIDEffect usage from SettingsEdit.
jimmymadon Feb 24, 2024
e060a7c
Remove useGAPropertyIDEffect usage from SetupMain.
jimmymadon Feb 24, 2024
495f735
Remove useGAPropertyIDEffect.
jimmymadon Feb 24, 2024
895a001
Remove the test for useGAPropertyIDEffect.
jimmymadon Feb 24, 2024
05ecf08
Remove disabling analytics tag output when propertyIDs match in GTM a…
jimmymadon Feb 24, 2024
760cfa8
Remove the googlesitekit_analytics_can_use_snippet filter.
jimmymadon Feb 24, 2024
1dd0d9f
Remove GTM ability to allow disabling tracking.
jimmymadon Feb 24, 2024
150a2bc
Remove GTM ability to render GA opt-out snippet.
jimmymadon Feb 24, 2024
4b5ddb8
Remove unused import.
jimmymadon Feb 24, 2024
a351f60
Remove gaPropertyID setting from TagManager backend.
jimmymadon Feb 24, 2024
577d99f
Remove phpunit tests for canUseSnippet filter in GTM.
jimmymadon Feb 24, 2024
3bf4ad9
Remove phpunit test for gaPropertyID setting in GTM.
jimmymadon Feb 24, 2024
23dd022
Remove the getCanUseSnippet selector.
jimmymadon Feb 24, 2024
7d59f1f
Remove jest test for getCanUseSnippet selector.
jimmymadon Feb 24, 2024
c677876
Remove jest test for gaPropertyID setting in GTM.
jimmymadon Feb 24, 2024
972900a
Remove the canUseSnippet setting from analytics-4 datastore.
jimmymadon Feb 24, 2024
d3b88dc
Remove the canUseSnippet setting from Analytics4 backend.
jimmymadon Feb 24, 2024
af0d8ba
Remove unused import.
jimmymadon Feb 24, 2024
0f4343f
Remove canUseSnippet from the Analytics (UA) backend.
jimmymadon Feb 24, 2024
10e122a
Remove phpunit tests for the getCanUseSnippet UA setting.
jimmymadon Feb 24, 2024
53accc8
Remove the UA tag guard solely based on canUseSnippet setting.
jimmymadon Feb 24, 2024
1aa0197
Remove the canUseSnippet and its selector from old analytics datastore.
jimmymadon Feb 24, 2024
7910833
Remove usage of canUseSnippet from analytics settings frontend.
jimmymadon Feb 24, 2024
0497f00
Remove usage of canUseSnippet from UA frontend switch.
jimmymadon Feb 24, 2024
04b3106
Remove canUseSnippet from UA setup form.
jimmymadon Feb 24, 2024
3d8882e
Remove canUseSnippet checks from legacy UA forms.
jimmymadon Feb 24, 2024
493a0dc
Remove canUseSnippet from old analytics fixtures.
jimmymadon Feb 24, 2024
50ddfe0
Remove jest test for the canUseSnippet setting.
jimmymadon Feb 24, 2024
bf5c2bc
Remove the canUseSnippet setting from legacy UA stories.
jimmymadon Feb 24, 2024
fc8d26a
Remove phpunit test for canUseSnippet tag guard.
jimmymadon Feb 24, 2024
faa0e56
Remove validation for legacy getSingleAnalyticsPropertyID selector.
jimmymadon Feb 24, 2024
e550190
Remove the getSingleAnalyticsPropertyID selector.
jimmymadon Feb 24, 2024
18d1826
Remove jest tests for getSingleAnalyticsPropertyID.
jimmymadon Feb 24, 2024
381b2d2
Remove the legacy hasAnyAnalyticsPropertyID selector.
jimmymadon Feb 24, 2024
8f50606
Remove jest tests for hasAnyAnalyticsPropertyID selector.
jimmymadon Feb 24, 2024
d8b95bf
Remove the legacy getAnalyticsPropertyIDs selector.
jimmymadon Feb 24, 2024
64900b9
Remove jest tests for getAnalyticsPropertyIDs.
jimmymadon Feb 24, 2024
9d8154a
Remove the legacy getLiveContainerAnalyticsPropertyID selector.
jimmymadon Feb 24, 2024
1439b36
Remove jest tests for the legacy getLiveContainerAnalyticsPropertyID …
jimmymadon Feb 24, 2024
fc90622
Remove the legacy getLiveContainerAnalyticsTag selector.
jimmymadon Feb 24, 2024
7e3e299
Remove jest tests for the legacy getLiveContainerAnalyticsTag selector.
jimmymadon Feb 24, 2024
708e753
Remove additional jest tests for legacy GTM and UA integration.
jimmymadon Feb 24, 2024
837506c
Fix jest test.
kuasha420 Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ export default {
webDataStreamID,
measurementID,
useSnippet: true,
canUseSnippet: true,
anonymizeIP: true,
trackingDisabled: [ 'loggedinUsers' ],
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default {
webDataStreamID,
measurementID,
useSnippet: true,
canUseSnippet: true,
...googleTagSettings,
} );

Expand Down
1 change: 0 additions & 1 deletion assets/js/modules/analytics-4/datastore/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const baseModuleStore = Modules.createModuleStore( 'analytics-4', {
'webDataStreamID',
'measurementID',
'useSnippet',
'canUseSnippet',
'ownerID',
'googleTagID',
'googleTagAccountID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ export default function AdsConversionIDTextField() {
select( MODULES_ANALYTICS ).getAdsConversionID()
);
const snippetEnabled = useSelect( ( select ) => {
return (
select( MODULES_ANALYTICS ).getCanUseSnippet() &&
select( MODULES_ANALYTICS ).getUseSnippet()
);
return select( MODULES_ANALYTICS ).getUseSnippet();
} );
const ga4SnippetEnabled = useSelect( ( select ) =>
select( MODULES_ANALYTICS_4 ).getUseSnippet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export default function UseSnippetSwitch( { description } ) {
const useSnippet = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getUseSnippet()
);
const canUseSnippet = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getCanUseSnippet()
);
const hasExistingTag = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).hasExistingTag()
);
Expand All @@ -71,10 +68,9 @@ export default function UseSnippetSwitch( { description } ) {
'Place Universal Analytics code',
'google-site-kit'
) }
checked={ canUseSnippet === false ? false : useSnippet }
checked={ useSnippet }
onClick={ onChange }
hideLabel={ false }
disabled={ canUseSnippet === false }
/>
{ description }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export default function OptionalSettingsView() {
const useSnippet = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getUseSnippet()
);
const canUseSnippet = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getCanUseSnippet()
);
const propertyID = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getPropertyID()
);
Expand All @@ -64,7 +61,7 @@ export default function OptionalSettingsView() {
useSnippet && ampMode !== 'primary' && isUAConnected;

const showAdsConversionIDSettings =
canUseSnippet && ( ( isUAConnected && useSnippet ) || useGA4Snippet );
( isUAConnected && useSnippet ) || useGA4Snippet;

return (
<Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ export default {
} );
registry.dispatch( MODULES_ANALYTICS ).receiveGetSettings( {
useSnippet: true,
canUseSnippet: true,
anonymizeIP: true,
trackingDisabled: [ 'loggedinUsers' ],
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,13 @@ export default function SettingsUseSnippetSwitch() {
const useSnippet = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getUseSnippet()
);
const canUseSnippet = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getCanUseSnippet()
);

const existingTag = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getExistingTag()
);
const propertyID = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getPropertyID()
);

if ( canUseSnippet === undefined ) {
return null;
}

if ( canUseSnippet === false ) {
return (
<UseSnippetSwitch
description={
<p>
{ __(
'The code is controlled by the Tag Manager module',
'google-site-kit'
) }
</p>
}
/>
);
}

let description;

if ( existingTag ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export default {
} );
registry.dispatch( MODULES_ANALYTICS ).receiveGetSettings( {
useSnippet: true,
canUseSnippet: true,
} );
registry
.dispatch( MODULES_ANALYTICS )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export default {
.receiveGetExistingTag( null );
registry.dispatch( MODULES_ANALYTICS ).receiveGetSettings( {
adsConversionID: '',
canUseSnippet: true,
} );
registry
.dispatch( MODULES_ANALYTICS )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ export default {
.receiveGetExistingTag( null );
registry.dispatch( MODULES_ANALYTICS ).receiveGetSettings( {
adsConversionID: '',
canUseSnippet: true,
} );
registry
.dispatch( MODULES_ANALYTICS )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default {
.receiveGetExistingTag( null );
registry.dispatch( MODULES_ANALYTICS ).receiveGetSettings( {
adsConversionID: '',
canUseSnippet: true,
} );
registry
.dispatch( MODULES_ANALYTICS )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,15 @@ export default function SetupUseSnippetSwitch() {
select( MODULES_ANALYTICS ).getExistingTag()
);

const canUseSnippet = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getCanUseSnippet()
);

const propertyID = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getPropertyID()
);

// Only render if there is an existing tag or the snippet has been disabled by GTM.
if ( ! ( Boolean( existingTag ) || canUseSnippet === false ) ) {
if ( ! Boolean( existingTag ) ) {
return null;
}

if ( canUseSnippet === false ) {
return (
<UseSnippetSwitch
description={
<p>
{ __(
'The code is controlled by the Tag Manager module',
'google-site-kit'
) }
</p>
}
/>
);
}

const description =
existingTag === propertyID ? (
<Fragment>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"ownerID": 0,
"accountID": "",
"adsConversionID": "",
"adsenseLinked": false,
"anonymizeIP": true,
"internalWebPropertyID": "",
"ownerID": 0,
"profileID": "",
"propertyID": "",
"trackingDisabled": [
"loggedinUsers"
],
"useSnippet": true,
"canUseSnippet": true
}
"useSnippet": true
}
4 changes: 0 additions & 4 deletions assets/js/modules/analytics/datastore/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import Modules from 'googlesitekit-modules';
import { MODULES_ANALYTICS } from './constants';
import {
getCanUseSnippet,
rollbackChanges,
submitChanges,
validateCanSubmitChanges,
Expand All @@ -40,7 +39,6 @@ const baseModuleStore = Modules.createModuleStore( 'analytics', {
'accountID',
'adsConversionID',
'anonymizeIP',
'canUseSnippet',
'internalWebPropertyID',
'ownerID',
'profileID',
Expand All @@ -53,6 +51,4 @@ const baseModuleStore = Modules.createModuleStore( 'analytics', {
validateCanSubmitChanges,
} );

baseModuleStore.selectors.getCanUseSnippet = getCanUseSnippet;

export default baseModuleStore;
44 changes: 0 additions & 44 deletions assets/js/modules/analytics/datastore/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import invariant from 'invariant';
/**
* Internal dependencies
*/
import Data from 'googlesitekit-data';
import API from 'googlesitekit-api';
import { CORE_FORMS } from '../../../googlesitekit/datastore/forms/constants';
import { CORE_USER } from '../../../googlesitekit/datastore/user/constants';
Expand Down Expand Up @@ -53,12 +52,8 @@ import {
FORM_SETUP,
} from './constants';
import { createStrictSelect } from '../../../googlesitekit/data/utils';
import { CORE_MODULES } from '../../../googlesitekit/modules/datastore/constants';
import { MODULES_TAGMANAGER } from '../../tagmanager/datastore/constants';
import ga4ReportingTour from '../../../feature-tours/ga4-reporting';

const { createRegistrySelector } = Data;

// Invariant error messages.
export const INVARIANT_INVALID_ACCOUNT_ID =
'a valid accountID is required to submit changes';
Expand Down Expand Up @@ -240,42 +235,3 @@ export function validateCanSubmitChanges( select ) {
select( MODULES_ANALYTICS_4 ).__dangerousCanSubmitChanges();
}
}

/**
* Gets the value of canUseSnippet based on the gaPropertyID of tagmanager module and propertyID.
*
* @since 1.75.0
*
* @return {boolean|undefined} Computed value of canUseSnippet. `undefined` if not loaded.
*/
export const getCanUseSnippet = createRegistrySelector( ( select ) => () => {
const analyticsSettings = select( MODULES_ANALYTICS ).getSettings();

if ( ! analyticsSettings ) {
return undefined;
}

const isTagManagerAvailable =
select( CORE_MODULES ).isModuleAvailable( 'tagmanager' );
const isTagManagerConnected =
isTagManagerAvailable &&
select( CORE_MODULES ).isModuleConnected( 'tagmanager' );

if ( ! isTagManagerConnected || ! select( MODULES_TAGMANAGER ) ) {
return analyticsSettings.canUseSnippet;
}

const tagManagerUseSnippet = select( MODULES_TAGMANAGER ).getUseSnippet();

if ( ! tagManagerUseSnippet ) {
return analyticsSettings.canUseSnippet;
}

const gtmGAPropertyID = select( MODULES_TAGMANAGER ).getGAPropertyID();

if ( isValidPropertyID( gtmGAPropertyID ) ) {
return gtmGAPropertyID !== analyticsSettings.propertyID;
}

return analyticsSettings.canUseSnippet;
} );
Loading
Loading