@reuters-graphics/graphics-components 0.0.18 → 0.0.20

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,
@@ -136,64 +142,66 @@ const articleLdJson = {
136
142
  </script>
137
143
 
138
144
  <svelte:head>
139
- <title>{seoTitle}</title>
140
- <meta name="description" content="{seoDescription}" />
141
- <link rel="canonical" href="{canonicalUrl}" />
142
- <link
143
- rel="shortcut icon"
144
- type="image/x-icon"
145
- href="https://s3.reutersmedia.net/resources_v2/images/favicon/favicon.ico"
146
- />
147
- <link
148
- rel="icon"
149
- type="image/png"
150
- href="https://s3.reutersmedia.net/resources_v2/images/favicon/favicon-16x16.png"
151
- sizes="16x16"
152
- />
153
- <link
154
- rel="icon"
155
- type="image/png"
156
- href="https://s1.reutersmedia.net/resources_v2/images/favicon/favicon-32x32.png"
157
- sizes="32x32"
158
- />
159
- <link
160
- rel="icon"
161
- type="image/png"
162
- href="https://s3.reutersmedia.net/resources_v2/images/favicon/favicon-96x96.png"
163
- sizes="96x96"
164
- />
145
+ {#key canonicalUrl}
146
+ <title>{seoTitle}</title>
147
+ <meta name="description" content="{seoDescription}" />
148
+ <link rel="canonical" href="{canonicalUrl}" />
149
+ <link
150
+ rel="shortcut icon"
151
+ type="image/x-icon"
152
+ href="https://s3.reutersmedia.net/resources_v2/images/favicon/favicon.ico"
153
+ />
154
+ <link
155
+ rel="icon"
156
+ type="image/png"
157
+ href="https://s3.reutersmedia.net/resources_v2/images/favicon/favicon-16x16.png"
158
+ sizes="16x16"
159
+ />
160
+ <link
161
+ rel="icon"
162
+ type="image/png"
163
+ href="https://s1.reutersmedia.net/resources_v2/images/favicon/favicon-32x32.png"
164
+ sizes="32x32"
165
+ />
166
+ <link
167
+ rel="icon"
168
+ type="image/png"
169
+ href="https://s3.reutersmedia.net/resources_v2/images/favicon/favicon-96x96.png"
170
+ sizes="96x96"
171
+ />
165
172
 
166
- <meta property="og:url" content="{canonicalUrl}" />
167
- <meta property="og:type" content="article" />
168
- <meta property="og:title" content="{shareTitle}" itemprop="name" />
169
- <meta
170
- property="og:description"
171
- content="{shareDescription}"
172
- itemprop="description"
173
- />
174
- <meta property="og:image" content="{shareImgPath}" itemprop="image" />
175
- <meta property="og:site_name" content="Reuters" />
173
+ <meta property="og:url" content="{canonicalUrl}" />
174
+ <meta property="og:type" content="article" />
175
+ <meta property="og:title" content="{shareTitle}" itemprop="name" />
176
+ <meta
177
+ property="og:description"
178
+ content="{shareDescription}"
179
+ itemprop="description"
180
+ />
181
+ <meta property="og:image" content="{shareImgPath}" itemprop="image" />
182
+ <meta property="og:site_name" content="Reuters" />
176
183
 
177
- <meta name="twitter:card" content="summary_large_image" />
178
- <meta name="twitter:site" content="@ReutersGraphics" />
179
- <meta name="twitter:creator" content="@ReutersGraphics" />
180
- <meta name="twitter:domain" content="{origin}" />
181
- <meta name="twitter:title" content="{shareTitle}" />
182
- <meta name="twitter:description" content="{shareDescription}" />
183
- <meta name="twitter:image" content="{shareImgPath}" />
184
- {#if shareImgAlt}
185
- <meta name="twitter:image:alt" content="{shareImgAlt}" />
186
- {/if}
184
+ <meta name="twitter:card" content="summary_large_image" />
185
+ <meta name="twitter:site" content="@ReutersGraphics" />
186
+ <meta name="twitter:creator" content="@ReutersGraphics" />
187
+ <meta name="twitter:domain" content="{origin}" />
188
+ <meta name="twitter:title" content="{shareTitle}" />
189
+ <meta name="twitter:description" content="{shareDescription}" />
190
+ <meta name="twitter:image" content="{shareImgPath}" />
191
+ {#if shareImgAlt}
192
+ <meta name="twitter:image:alt" content="{shareImgAlt}" />
193
+ {/if}
187
194
 
188
- <meta property="fb:app_id" content="319194411438328" />
189
- <meta property="fb:admins" content="616167736" />
190
- <meta property="fb:admins" content="625796953" />
191
- <meta property="fb:admins" content="571759798" />
195
+ <meta property="fb:app_id" content="319194411438328" />
196
+ <meta property="fb:admins" content="616167736" />
197
+ <meta property="fb:admins" content="625796953" />
198
+ <meta property="fb:admins" content="571759798" />
192
199
 
193
- {@html `<${'script'} type="application/ld+json">${JSON.stringify(
194
- orgLdJson
195
- )}</script>`}
196
- {@html `<${'script'} type="application/ld+json">${JSON.stringify(
197
- articleLdJson
198
- )}</script>`}
200
+ {@html `<${'script'} type="application/ld+json">${JSON.stringify(
201
+ orgLdJson
202
+ )}</script>`}
203
+ {@html `<${'script'} type="application/ld+json">${JSON.stringify(
204
+ articleLdJson
205
+ )}</script>`}
206
+ {/key}
199
207
  </svelte:head>
@@ -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.20",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",