@reuters-graphics/graphics-components 1.1.5 → 1.1.6

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,20 +1,23 @@
1
1
  <script context="module">
2
2
  import { registerPageview as registerChartbeatPageview } from './providers/chartbeat';
3
3
  import { registerPageview as registerGAPageview } from './providers/ga';
4
+ import { registerPageview as registerParselyPageview } from './providers/parsely';
4
5
 
5
6
  /** Register virtual pageviews when using client-side routing in multipage applications. */
6
7
  export function registerPageview() {
7
8
  registerChartbeatPageview();
8
9
  registerGAPageview();
10
+ registerParselyPageview();
9
11
  }
10
12
  </script>
11
13
 
12
14
  <!-- @component `Analytics` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-Analytics--default) -->
13
15
  <script>export let authors = [];
14
16
  import { onMount } from "svelte";
15
- import { ga, chartbeat } from "./providers";
17
+ import { ga, chartbeat, parsely } from "./providers";
16
18
  onMount(() => {
17
19
  ga();
18
20
  chartbeat(authors);
21
+ parsely();
19
22
  });
20
23
  </script>
@@ -1,2 +1,3 @@
1
1
  export { default as ga } from './ga';
2
2
  export { default as chartbeat } from './chartbeat';
3
+ export { default as parsely } from './parsely';
@@ -1,2 +1,3 @@
1
1
  export { default as ga } from './ga';
2
2
  export { default as chartbeat } from './chartbeat';
3
+ export { default as parsely } from './parsely';
@@ -0,0 +1,3 @@
1
+ declare const _default: () => void;
2
+ export default _default;
3
+ export declare const registerPageview: () => void;
@@ -0,0 +1,29 @@
1
+ const SITE_ID = 'reuters.com';
2
+ const attachScript = () => {
3
+ const b = document.body;
4
+ const e = document.createElement('script');
5
+ e.id = 'parsely-cfg';
6
+ e.src = `//cdn.parsely.com/keys/${SITE_ID}/p.js`;
7
+ e.setAttribute('async', '');
8
+ e.setAttribute('defer', '');
9
+ b.appendChild(e);
10
+ };
11
+ export default () => {
12
+ window.PARSELY = window.PARSELY || {
13
+ autotrack: false,
14
+ onReady() {
15
+ window.PARSELY.updateDefaults({
16
+ data: {
17
+ is_logged_in: false,
18
+ },
19
+ });
20
+ window.PARSELY.beacon.trackPageView();
21
+ },
22
+ };
23
+ attachScript();
24
+ };
25
+ export const registerPageview = () => {
26
+ if (typeof window === 'undefined' || !window.PARSELY)
27
+ return;
28
+ window.PARSELY.beacon.trackPageView();
29
+ };
@@ -19,7 +19,7 @@ const getOrigin = (baseUrl2) => {
19
19
  }
20
20
  };
21
21
  $: origin = getOrigin(baseUrl);
22
- $: canonicalUrl = (origin + pageUrl.pathname).replace(/index\.html\/$/, "");
22
+ $: canonicalUrl = (origin + pageUrl?.pathname).replace(/index\.html\/$/, "");
23
23
  const orgLdJson = {
24
24
  "@context": "http://schema.org",
25
25
  "@type": "NewsMediaOrganization",
@@ -62,9 +62,9 @@ $: articleLdJson = {
62
62
  name,
63
63
  url
64
64
  })),
65
+ creator: authors.map(({ name }) => name),
65
66
  articleSection: "Graphics",
66
67
  isAccessibleForFree: true,
67
- creator: ["Reuters Graphics"],
68
68
  keywords: ["Reuters graphics", "Reuters", "graphics", "Interactives"]
69
69
  };
70
70
  </script>
package/dist/globals.d.ts CHANGED
@@ -21,6 +21,14 @@ declare global {
21
21
  };
22
22
  /** Graphics ads */
23
23
  graphicsAdQueue: any[];
24
+ /** Parsely */
25
+ PARSELY: {
26
+ onLoad: () => void;
27
+ beacon: {
28
+ trackPageView: () => void;
29
+ };
30
+ updateDefaults: (params: any) => void;
31
+ };
24
32
  }
25
33
  }
26
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuters-graphics/graphics-components",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",