@reuters-graphics/graphics-components 3.0.16 → 3.0.18

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.
@@ -7,7 +7,7 @@
7
7
  onMount(() => {
8
8
  window.graphicsAdQueue = window.graphicsAdQueue || [];
9
9
  loadScript(
10
- 'https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js',
10
+ 'https://www.reuters.com/static/js/bootstrap/v1.1.2/bootstrap.static.js',
11
11
  { onload: loadBootstrap, async: false }
12
12
  );
13
13
  // Load Freestar script
@@ -1,5 +1,4 @@
1
1
  <!-- @component `Analytics` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytics-analytics--docs) -->
2
-
3
2
  <script module>
4
3
  import { registerPageview as registerChartbeatPageview } from './providers/chartbeat';
5
4
  import { registerPageview as registerGAPageview } from './providers/ga';
@@ -20,6 +19,8 @@
20
19
 
21
20
  import { onMount } from 'svelte';
22
21
  import { ga, chartbeat } from './providers';
22
+ import GoogleTagManager from './GTM.svelte';
23
+
23
24
  interface Props {
24
25
  /**
25
26
  * Used to associate a page with its author(s) in Chartbeat.
@@ -34,3 +35,5 @@
34
35
  chartbeat(authors);
35
36
  });
36
37
  </script>
38
+
39
+ <GoogleTagManager />
@@ -0,0 +1,30 @@
1
+ <script lang="ts">
2
+ const GTM_ID = 'GTM-P9TTSWG2';
3
+ </script>
4
+
5
+ <svelte:head>
6
+ <!-- Google Tag Manager -->
7
+ <link href="https://www.googletagmanager.com" rel="preconnect" />
8
+ <script>
9
+ window.dataLayer = window.dataLayer || [];
10
+ window.dataLayer.push({
11
+ 'gtm.start': new Date().getTime(),
12
+ event: 'gtm.js',
13
+ });
14
+ </script>
15
+ <script async src={`https://www.googletagmanager.com/gtm.js?id=${GTM_ID}`}>
16
+ </script>
17
+ <!-- End Google Tag Manager -->
18
+ </svelte:head>
19
+
20
+ <!-- Google Tag Manager (noscript) -->
21
+ <noscript>
22
+ <iframe
23
+ src={`https://www.googletagmanager.com/ns.html?id=${GTM_ID}`}
24
+ height="0"
25
+ width="0"
26
+ style="display:none;visibility:hidden"
27
+ title=""
28
+ ></iframe>
29
+ </noscript>
30
+ <!-- End Google Tag Manager (noscript) -->
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Gtm: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type Gtm = InstanceType<typeof Gtm>;
18
+ export default Gtm;
@@ -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.18",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",