@financial-times/dotcom-ui-shell 11.1.0-beta.0 → 11.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,11 +9,16 @@ const GTMHead = ({ flags }) => {
9
9
  if (!flags.enableGTM) {
10
10
  return null;
11
11
  }
12
- const tagManager = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
13
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
14
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
15
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
16
- })(window,document,'script','dataLayer','GTM-NWQJW68');`;
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": "e31c080c54a82d396a1c61617c923e6866b3cf7e706dda178ca0cd905c50376c",
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": "e74998d5cefc2f29d583c10b99c1478fb810f1e46fbb06535bfb0bbba3c84aa5",
321
- "signature": "e74998d5cefc2f29d583c10b99c1478fb810f1e46fbb06535bfb0bbba3c84aa5",
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": "43d058146b002d075f5d0033a6870321048297f1658eb0db559ba028383803a6",
331
- "signature": "43d058146b002d075f5d0033a6870321048297f1658eb0db559ba028383803a6",
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.1.0-beta.0",
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.1.0-beta.0",
24
- "@financial-times/dotcom-ui-base-styles": "^11.1.0-beta.0",
25
- "@financial-times/dotcom-ui-bootstrap": "^11.1.0-beta.0",
26
- "@financial-times/dotcom-ui-flags": "^11.1.0-beta.0",
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,i){w[l]=w[l]||[];w[l].push({'gtm.start':
10
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
11
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
12
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
13
- })(window,document,'script','dataLayer','GTM-NWQJW68');",
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,i){w[l]=w[l]||[];w[l].push({'gtm.start':
250
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
251
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
252
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
253
- })(window,document,'script','dataLayer','GTM-NWQJW68');",
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 tagManager = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
11
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
12
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
13
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
14
- })(window,document,'script','dataLayer','GTM-NWQJW68');`
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
  }