@reuters-graphics/graphics-components 0.0.20 → 0.0.22

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.
@@ -81,15 +81,11 @@ const getOrigin = (baseUrl) => {
81
81
  };
82
82
  $: origin = getOrigin(baseUrl);
83
83
  $: canonicalUrl = origin + pageUrl.pathname;
84
- let hasEnabledPublisherTags = false;
85
84
  // Only fire analytics on prod sites
86
85
  $: {
87
86
  if (typeof window !== 'undefined' && includeAnalytics) {
88
87
  analytics(canonicalUrl, seoTitle);
89
- if (!hasEnabledPublisherTags) {
90
- publisherTags();
91
- hasEnabledPublisherTags = true;
92
- }
88
+ publisherTags();
93
89
  }
94
90
  }
95
91
  const orgLdJson = {
@@ -16,30 +16,32 @@ const attachScript = function (i, s, o, g, r, a, m) {
16
16
  /* eslint-enable */
17
17
 
18
18
  export default (page, title) => {
19
- if (!window.ga) {
20
- attachScript(
21
- window,
22
- document,
23
- 'script',
24
- 'https://www.google-analytics.com/analytics.js',
25
- 'ga'
26
- );
27
-
28
- window.ga('create', 'UA-41619329-3', { cookieDomain: 'auto' });
29
- window.ga('require', 'linkid', 'linkid.js');
30
- }
31
-
32
- window.ga('send', 'pageview', {
33
- page,
34
- title,
35
- });
19
+ try {
20
+ if (!window.ga) {
21
+ attachScript(
22
+ window,
23
+ document,
24
+ 'script',
25
+ 'https://www.google-analytics.com/analytics.js',
26
+ 'ga'
27
+ );
28
+
29
+ window.ga('create', 'UA-41619329-3', { cookieDomain: 'auto' });
30
+ window.ga('require', 'linkid', 'linkid.js');
31
+ }
36
32
 
37
- if (!inIframe()) {
38
- // start time on page tracking if not in an iframe
39
- riveted.init({
40
- reportInterval: 30,
33
+ window.ga('send', 'pageview', {
34
+ page,
35
+ title,
41
36
  });
42
- }
37
+
38
+ if (!inIframe()) {
39
+ // start time on page tracking if not in an iframe
40
+ riveted.init({
41
+ reportInterval: 30,
42
+ });
43
+ }
44
+ } catch (e) {}
43
45
  };
44
46
 
45
47
  // checks if page is in an iframe
@@ -1,26 +1,34 @@
1
1
  export default () => {
2
- const googletag = window.googletag || {};
3
- googletag.cmd = googletag.cmd || [];
4
- (function() {
5
- const gads = document.createElement('script');
6
- gads.async = true;
7
- gads.type = 'text/javascript';
8
- const useSSL = document.location.protocol === 'https:';
9
- gads.src =
10
- (useSSL ? 'https:' : 'http:') +
11
- '//www.googletagservices.com/tag/js/gpt.js';
12
- const node = document.getElementsByTagName('script')[0];
13
- node.parentNode.insertBefore(gads, node);
14
- })();
15
- googletag.cmd.push(function() {
16
- googletag
17
- .defineSlot(
18
- '/4735792/reuters_investigates',
19
- [[300, 250]],
20
- 'div-gpt-ad-1441822201033-0'
21
- )
22
- .addService(googletag.pubads());
23
- googletag.pubads().enableSingleRequest();
24
- googletag.enableServices();
25
- });
2
+ try {
3
+ const { protocol } = document.location;
4
+ const gptScript = document.querySelector(
5
+ `script[src="${protocol}//www.googletagservices.com/tag/js/gpt.js"]`
6
+ );
7
+ // Only do this once.
8
+ if (gptScript) return;
9
+ const googletag = window.googletag || {};
10
+ googletag.cmd = googletag.cmd || [];
11
+ (function () {
12
+ const gads = document.createElement('script');
13
+ gads.async = true;
14
+ gads.type = 'text/javascript';
15
+ const useSSL = document.location.protocol === 'https:';
16
+ gads.src =
17
+ (useSSL ? 'https:' : 'http:') +
18
+ '//www.googletagservices.com/tag/js/gpt.js';
19
+ const node = document.getElementsByTagName('script')[0];
20
+ node.parentNode.insertBefore(gads, node);
21
+ })();
22
+ googletag.cmd.push(function () {
23
+ googletag
24
+ .defineSlot(
25
+ '/4735792/reuters_investigates',
26
+ [[300, 250]],
27
+ 'div-gpt-ad-1441822201033-0'
28
+ )
29
+ .addService(googletag.pubads());
30
+ googletag.pubads().enableSingleRequest();
31
+ googletag.enableServices();
32
+ });
33
+ } catch (e) {}
26
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuters-graphics/graphics-components",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",