@reuters-graphics/graphics-components 0.0.18 → 0.0.19

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,10 +81,16 @@ const getOrigin = (baseUrl) => {
81
81
  };
82
82
  $: origin = getOrigin(baseUrl);
83
83
  $: canonicalUrl = origin + pageUrl.pathname;
84
+ let hasEnabledPublisherTags = false;
84
85
  // Only fire analytics on prod sites
85
- if (typeof window !== 'undefined' && includeAnalytics) {
86
- analytics(canonicalUrl, seoTitle);
87
- publisherTags();
86
+ $: {
87
+ if (typeof window !== 'undefined' && includeAnalytics) {
88
+ analytics(canonicalUrl, seoTitle);
89
+ if (!hasEnabledPublisherTags) {
90
+ publisherTags();
91
+ hasEnabledPublisherTags = true;
92
+ }
93
+ }
88
94
  }
89
95
  const orgLdJson = {
90
96
  '@context': 'http://schema.org',
@@ -99,7 +105,7 @@ const orgLdJson = {
99
105
  },
100
106
  url: 'https://www.reuters.com/',
101
107
  };
102
- const articleLdJson = {
108
+ $: articleLdJson = {
103
109
  '@context': 'http://schema.org',
104
110
  '@type': 'NewsArticle',
105
111
  headline: seoTitle,
@@ -16,32 +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
- attachScript(
20
- window,
21
- document,
22
- 'script',
23
- 'https://www.google-analytics.com/analytics.js',
24
- 'ga'
25
- );
26
-
27
- window.ga('create', 'UA-41619329-3', { cookieDomain: 'auto' });
28
- window.ga('require', 'linkid', 'linkid.js');
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
+
29
32
  window.ga('send', 'pageview', {
30
33
  page,
31
34
  title,
32
35
  });
33
36
 
34
37
  if (!inIframe()) {
35
- //start time on page tracking if not in an iframe
38
+ // start time on page tracking if not in an iframe
36
39
  riveted.init({
37
40
  reportInterval: 30,
38
41
  });
39
42
  }
40
43
  };
41
44
 
42
-
43
-
44
-
45
45
  // checks if page is in an iframe
46
46
  function inIframe() {
47
47
  try {
@@ -51,28 +51,27 @@ function inIframe() {
51
51
  }
52
52
  }
53
53
 
54
-
55
54
  /*
56
55
  * START: Riveted time on page tracking code
57
56
  * see aditional documentation here: https://riveted.parsnip.io/
58
57
  */
59
-
58
+ /* eslint-disable */
60
59
  var riveted = (function () {
61
- var started = false;
62
- var stopped = false;
63
- var turnedOff = false;
64
- var clockTime = 0;
65
- var startTime = new Date();
66
- var clockTimer = null;
67
- var idleTimer = null;
68
- var sendEvent;
69
- var sendUserTiming;
70
- var reportInterval;
71
- var idleTimeout;
72
- var nonInteraction;
73
- var universalGA;
74
- var classicGA;
75
- var googleTagManager;
60
+ let started = false;
61
+ let stopped = false;
62
+ let turnedOff = false;
63
+ let clockTime = 0;
64
+ const startTime = new Date();
65
+ let clockTimer = null;
66
+ let idleTimer = null;
67
+ let sendEvent;
68
+ let sendUserTiming;
69
+ let reportInterval;
70
+ let idleTimeout;
71
+ let nonInteraction;
72
+ let universalGA;
73
+ let classicGA;
74
+ let googleTagManager;
76
75
 
77
76
  function init(options) {
78
77
  /*
@@ -126,8 +125,8 @@ var riveted = (function () {
126
125
  // Page visibility listeners
127
126
  addListener(document, 'visibilitychange', visibilityChange);
128
127
  addListener(document, 'webkitvisibilitychange', visibilityChange);
129
-
130
- //sends initial zero value
128
+
129
+ // sends initial zero value
131
130
  sendEvent(0);
132
131
  }
133
132
 
@@ -140,18 +139,18 @@ var riveted = (function () {
140
139
  */
141
140
 
142
141
  function throttle(func, wait) {
143
- var context, args, result;
144
- var timeout = null;
145
- var previous = 0;
146
- var later = function () {
142
+ let context, args, result;
143
+ let timeout = null;
144
+ let previous = 0;
145
+ const later = function () {
147
146
  previous = new Date();
148
147
  timeout = null;
149
148
  result = func.apply(context, args);
150
149
  };
151
150
  return function () {
152
- var now = new Date();
151
+ const now = new Date();
153
152
  if (!previous) previous = now;
154
- var remaining = wait - (now - previous);
153
+ const remaining = wait - (now - previous);
155
154
  context = this;
156
155
  args = arguments;
157
156
  if (remaining <= 0) {
@@ -190,7 +189,7 @@ var riveted = (function () {
190
189
  event: 'RivetedTiming',
191
190
  eventCategory: 'Riveted',
192
191
  timingVar: 'First Interaction',
193
- timingValue: timingValue,
192
+ timingValue,
194
193
  });
195
194
  } else {
196
195
  if (universalGA) {
@@ -233,7 +232,7 @@ var riveted = (function () {
233
232
  'Time Spent',
234
233
  time.toString(),
235
234
  reportInterval,
236
- { nonInteraction: nonInteraction }
235
+ { nonInteraction }
237
236
  );
238
237
  }
239
238
 
@@ -290,8 +289,8 @@ var riveted = (function () {
290
289
 
291
290
  function startRiveted() {
292
291
  // Calculate seconds from start to first interaction
293
- var currentTime = new Date();
294
- var diff = currentTime - startTime;
292
+ const currentTime = new Date();
293
+ const diff = currentTime - startTime;
295
294
 
296
295
  // Set global
297
296
  started = true;
@@ -321,12 +320,12 @@ var riveted = (function () {
321
320
  }
322
321
 
323
322
  return {
324
- init: init,
325
- trigger: trigger,
326
- setIdle: setIdle,
323
+ init,
324
+ trigger,
325
+ setIdle,
327
326
  on: turnOn,
328
327
  off: turnOff,
329
328
  };
330
329
  })();
331
-
330
+ /* eslint-enable */
332
331
  /* END: Riveted time on page tracking code */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuters-graphics/graphics-components",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",