@financial-times/dotcom-ui-shell 11.1.0 → 11.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/node/components/GTMHead.js +10 -5
- package/dist/tsconfig.tsbuildinfo +5 -5
- package/package.json +5 -5
- package/src/__test__/components/GTMHead.test.tsx +12 -0
- package/src/__test__/components/__snapshots__/GTMHead.test.tsx.snap +23 -5
- package/src/__test__/components/__snapshots__/Shell.test.tsx.snap +7 -5
- package/src/components/GTMHead.tsx +11 -5
@@ -9,11 +9,16 @@ const GTMHead = ({ flags }) => {
|
|
9
9
|
if (!flags.enableGTM) {
|
10
10
|
return null;
|
11
11
|
}
|
12
|
-
const
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
const src = flags['ads-first-party-gtm']
|
13
|
+
? 'https://www.ft.com/page-resources'
|
14
|
+
: 'https://www.googletagmanager.com/gtm.js?id=GTM-NWQJW68';
|
15
|
+
const tagManager = `(function(w,d,s,l){
|
16
|
+
w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
|
17
|
+
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
|
18
|
+
j.async=true;
|
19
|
+
j.src='${src}'+dl;
|
20
|
+
f.parentNode.insertBefore(j,f);
|
21
|
+
})(window,document,'script','dataLayer');`;
|
17
22
|
return react_1.default.createElement("script", { dangerouslySetInnerHTML: { __html: tagManager } });
|
18
23
|
};
|
19
24
|
GTMHead.defaultProps = {
|
@@ -292,7 +292,7 @@
|
|
292
292
|
"affectsGlobalScope": false
|
293
293
|
},
|
294
294
|
"../src/components/GTMHead.tsx": {
|
295
|
-
"version": "
|
295
|
+
"version": "5733c3cdecbf7c1730e584de72463644d1deb36ef67e41dcbcb8f377d28606fd",
|
296
296
|
"signature": "1249c5957984b42592b9f0859f51602874351c427acf3813b59524ce9946c065",
|
297
297
|
"affectsGlobalScope": false
|
298
298
|
},
|
@@ -317,8 +317,8 @@
|
|
317
317
|
"affectsGlobalScope": false
|
318
318
|
},
|
319
319
|
"../../../node_modules/@babel/types/lib/index.d.ts": {
|
320
|
-
"version": "
|
321
|
-
"signature": "
|
320
|
+
"version": "87141a0e8e193478dc3f1c33d380d899acd2df86a4e119e774df0156204d88cc",
|
321
|
+
"signature": "87141a0e8e193478dc3f1c33d380d899acd2df86a4e119e774df0156204d88cc",
|
322
322
|
"affectsGlobalScope": false
|
323
323
|
},
|
324
324
|
"../../../node_modules/@types/babel__generator/index.d.ts": {
|
@@ -327,8 +327,8 @@
|
|
327
327
|
"affectsGlobalScope": false
|
328
328
|
},
|
329
329
|
"../../../node_modules/@babel/parser/typings/babel-parser.d.ts": {
|
330
|
-
"version": "
|
331
|
-
"signature": "
|
330
|
+
"version": "9d16476349353974716bd2ad745830d0542c18c9edad4566d77ccd9d61c6cfb2",
|
331
|
+
"signature": "9d16476349353974716bd2ad745830d0542c18c9edad4566d77ccd9d61c6cfb2",
|
332
332
|
"affectsGlobalScope": false
|
333
333
|
},
|
334
334
|
"../../../node_modules/@types/babel__template/index.d.ts": {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@financial-times/dotcom-ui-shell",
|
3
|
-
"version": "11.
|
3
|
+
"version": "11.2.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "component.js",
|
6
6
|
"browser": "browser.js",
|
@@ -20,10 +20,10 @@
|
|
20
20
|
"author": "",
|
21
21
|
"license": "MIT",
|
22
22
|
"dependencies": {
|
23
|
-
"@financial-times/dotcom-ui-app-context": "^11.
|
24
|
-
"@financial-times/dotcom-ui-base-styles": "^11.
|
25
|
-
"@financial-times/dotcom-ui-bootstrap": "^11.
|
26
|
-
"@financial-times/dotcom-ui-flags": "^11.
|
23
|
+
"@financial-times/dotcom-ui-app-context": "^11.2.0",
|
24
|
+
"@financial-times/dotcom-ui-base-styles": "^11.2.0",
|
25
|
+
"@financial-times/dotcom-ui-bootstrap": "^11.2.0",
|
26
|
+
"@financial-times/dotcom-ui-flags": "^11.2.0",
|
27
27
|
"mime-types": "^2.1.26"
|
28
28
|
},
|
29
29
|
"peerDependencies": {
|
@@ -24,4 +24,16 @@ describe('dotcom-ui-shell/src/components/GTMHead', () => {
|
|
24
24
|
const tree = renderer.create(<GTMHead {...props} />).toJSON()
|
25
25
|
expect(tree).toMatchSnapshot()
|
26
26
|
})
|
27
|
+
|
28
|
+
it('renders the first party gtm script when the ads-first-party-gtm flag is on', () => {
|
29
|
+
const props = {
|
30
|
+
flags: {
|
31
|
+
enableGTM: true,
|
32
|
+
'ads-first-party-gtm': true
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
const tree = renderer.create(<GTMHead {...props} />).toJSON()
|
37
|
+
expect(tree).toMatchSnapshot()
|
38
|
+
})
|
27
39
|
})
|
@@ -2,15 +2,33 @@
|
|
2
2
|
|
3
3
|
exports[`dotcom-ui-shell/src/components/GTMHead renders null when the enableGTM flag is off 1`] = `null`;
|
4
4
|
|
5
|
+
exports[`dotcom-ui-shell/src/components/GTMHead renders the first party gtm script when the ads-first-party-gtm flag is on 1`] = `
|
6
|
+
<script
|
7
|
+
dangerouslySetInnerHTML={
|
8
|
+
Object {
|
9
|
+
"__html": "(function(w,d,s,l){
|
10
|
+
w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
|
11
|
+
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
|
12
|
+
j.async=true;
|
13
|
+
j.src='https://www.ft.com/page-resources'+dl;
|
14
|
+
f.parentNode.insertBefore(j,f);
|
15
|
+
})(window,document,'script','dataLayer');",
|
16
|
+
}
|
17
|
+
}
|
18
|
+
/>
|
19
|
+
`;
|
20
|
+
|
5
21
|
exports[`dotcom-ui-shell/src/components/GTMHead renders the gtm head script when the enableGTM flag is on 1`] = `
|
6
22
|
<script
|
7
23
|
dangerouslySetInnerHTML={
|
8
24
|
Object {
|
9
|
-
"__html": "(function(w,d,s,l
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
25
|
+
"__html": "(function(w,d,s,l){
|
26
|
+
w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
|
27
|
+
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
|
28
|
+
j.async=true;
|
29
|
+
j.src='https://www.googletagmanager.com/gtm.js?id=GTM-NWQJW68'+dl;
|
30
|
+
f.parentNode.insertBefore(j,f);
|
31
|
+
})(window,document,'script','dataLayer');",
|
14
32
|
}
|
15
33
|
}
|
16
34
|
/>
|
@@ -246,11 +246,13 @@ exports[`dotcom-ui-shell/src/components/Shell renders the GTM script when the en
|
|
246
246
|
<script
|
247
247
|
dangerouslySetInnerHTML={
|
248
248
|
Object {
|
249
|
-
"__html": "(function(w,d,s,l
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
249
|
+
"__html": "(function(w,d,s,l){
|
250
|
+
w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
|
251
|
+
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
|
252
|
+
j.async=true;
|
253
|
+
j.src='https://www.googletagmanager.com/gtm.js?id=GTM-NWQJW68'+dl;
|
254
|
+
f.parentNode.insertBefore(j,f);
|
255
|
+
})(window,document,'script','dataLayer');",
|
254
256
|
}
|
255
257
|
}
|
256
258
|
/>
|
@@ -7,11 +7,17 @@ const GTMHead = ({ flags }: { flags: TFlagsData }) => {
|
|
7
7
|
return null
|
8
8
|
}
|
9
9
|
|
10
|
-
const
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
const src = flags['ads-first-party-gtm']
|
11
|
+
? 'https://www.ft.com/page-resources'
|
12
|
+
: 'https://www.googletagmanager.com/gtm.js?id=GTM-NWQJW68'
|
13
|
+
|
14
|
+
const tagManager = `(function(w,d,s,l){
|
15
|
+
w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
|
16
|
+
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
|
17
|
+
j.async=true;
|
18
|
+
j.src='${src}'+dl;
|
19
|
+
f.parentNode.insertBefore(j,f);
|
20
|
+
})(window,document,'script','dataLayer');`
|
15
21
|
|
16
22
|
return <script dangerouslySetInnerHTML={{ __html: tagManager }} />
|
17
23
|
}
|