@reuters-graphics/graphics-components 3.0.16 → 3.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,10 @@
1
1
  <!-- @component `Analytics` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytics-analytics--docs) -->
2
2
 
3
3
  <script module>
4
+ // GTM configuration
5
+ const GTM_ID = 'GTM-P9TTSWG2';
6
+ const GTM_SCRIPT = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${GTM_ID}');`;
7
+
4
8
  import { registerPageview as registerChartbeatPageview } from './providers/chartbeat';
5
9
  import { registerPageview as registerGAPageview } from './providers/ga';
6
10
 
@@ -34,3 +38,21 @@
34
38
  chartbeat(authors);
35
39
  });
36
40
  </script>
41
+
42
+ <svelte:head>
43
+ <!-- Google Tag Manager -->
44
+ {@html `<${'script'}>${GTM_SCRIPT}</script>`}
45
+ <!-- End Google Tag Manager -->
46
+ </svelte:head>
47
+
48
+ <!-- Google Tag Manager (noscript) -->
49
+ <noscript>
50
+ <iframe
51
+ src="https://www.googletagmanager.com/ns.html?id={GTM_ID}"
52
+ height="0"
53
+ width="0"
54
+ style="display:none;visibility:hidden"
55
+ title=""
56
+ ></iframe>
57
+ </noscript>
58
+ <!-- End Google Tag Manager (noscript) -->
@@ -1,18 +1,5 @@
1
1
  // Reuters Chartbeat UID
2
2
  const UID = 52639;
3
- const URL = '//static.chartbeat.com/js/chartbeat.js';
4
- const attachScript = () => {
5
- // If script is already attached, skip
6
- if (document.querySelector(`script[src="${URL}"]`))
7
- return;
8
- // ... else attach it.
9
- const e = document.createElement('script');
10
- const n = document.getElementsByTagName('script')[0];
11
- e.type = 'text/javascript';
12
- e.async = true;
13
- e.src = URL;
14
- n.parentNode.insertBefore(e, n);
15
- };
16
3
  export default (authors) => {
17
4
  window._sf_async_config = {
18
5
  uid: UID,
@@ -24,12 +11,6 @@ export default (authors) => {
24
11
  authors: authors.map((a) => a?.name || '').join(','),
25
12
  ...(window._sf_async_config || {}),
26
13
  };
27
- try {
28
- attachScript();
29
- }
30
- catch (e) {
31
- console.warn(`Error initialising Chartbeat Analytics: ${e}`);
32
- }
33
14
  };
34
15
  export const registerPageview = () => {
35
16
  if (typeof window === 'undefined' || !window.pSUPERFLY)
@@ -1,23 +1,9 @@
1
1
  // Reuters Google Tag ID
2
2
  const GOOGLE_TAG_ID = 'G-WBSR7WLTGD';
3
- const URL = `https://www.googletagmanager.com/gtag/js?id=${GOOGLE_TAG_ID}`;
4
- const attachScript = () => {
5
- // If script is already attached, skip
6
- if (document.querySelector(`script[src="${URL}"]`))
7
- return;
8
- // ... else attach it.
9
- const e = document.createElement('script');
10
- const n = document.getElementsByTagName('script')[0];
11
- e.type = 'text/javascript';
12
- e.async = true;
13
- e.src = URL;
14
- n.parentNode.insertBefore(e, n);
15
- };
16
3
  export default () => {
17
4
  try {
18
5
  window.dataLayer = window.dataLayer || [];
19
6
  if (!window.gtag) {
20
- attachScript();
21
7
  /** @type {Gtag.Gtag} */
22
8
  window.gtag = function () {
23
9
  // eslint-disable-next-line prefer-rest-params
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuters-graphics/graphics-components",
3
- "version": "3.0.16",
3
+ "version": "3.0.17",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",