@guardian/ophan-tracker-js 2.4.4 → 2.6.0

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.
@@ -6,11 +6,13 @@ import visibility from './visibility.js';
6
6
  import './click-path-capture.js';
7
7
  import './perf.js';
8
8
  import './campaign.js';
9
- core.init('manage-my-account');
10
- if (window.addEventListener) {
11
- attention.init(visibility);
12
- }
13
- const sendInitialEvent = (url = location.href, referrer = document.referrer) => {
9
+ export const init = () => {
10
+ core.init('manage-my-account');
11
+ if (window.addEventListener) {
12
+ attention.init(visibility);
13
+ }
14
+ };
15
+ export const sendInitialEvent = (url = location.href, referrer = document.referrer) => {
14
16
  try {
15
17
  transmit.bumpViewId();
16
18
  core.sendInitialEvent(null, url, referrer);
@@ -20,10 +22,26 @@ const sendInitialEvent = (url = location.href, referrer = document.referrer) =>
20
22
  }
21
23
  };
22
24
  const exports = {
25
+ init,
23
26
  sendInitialEvent,
24
27
  record: transmit.sendMore,
25
28
  get viewId() { return transmit.viewId; },
26
29
  };
27
- window.guardian = window.guardian || {};
28
- window.guardian.ophan = exports;
29
30
  export default exports;
31
+ // Named exports for convenience
32
+ export const record = exports.record;
33
+ export const viewId = exports.viewId;
34
+ // Type exports
35
+ export * from './types/abtest.js';
36
+ export * from './types/acquisition.js';
37
+ export * from './types/subscription.js';
38
+ export * from './types/interaction.js';
39
+ export * from './types/inpageclick.js';
40
+ export * from './types/printproduct.js';
41
+ export * from './types/product.js';
42
+ export * from './types/platform.js';
43
+ export * from './types/media.js';
44
+ export * from './types/consent.js';
45
+ export * from './types/component-type.js';
46
+ export * from './types/component-event.js';
47
+ export * from './types/event.js';
@@ -5,13 +5,13 @@ import visibility from './visibility.js';
5
5
  import './click-path-capture.js';
6
6
  import './perf.js';
7
7
  import './campaign.js';
8
- const init = () => {
8
+ export const init = () => {
9
9
  core.init('support');
10
10
  if (window.addEventListener) {
11
11
  attention.init(visibility);
12
12
  }
13
13
  };
14
- const sendInitialEvent = (url = location.href, referrer = document.referrer) => {
14
+ export const sendInitialEvent = (url = location.href, referrer = document.referrer) => {
15
15
  try {
16
16
  transmit.bumpViewId();
17
17
  core.sendInitialEvent(null, url, referrer);
@@ -20,9 +20,27 @@ const sendInitialEvent = (url = location.href, referrer = document.referrer) =>
20
20
  console.log(error);
21
21
  }
22
22
  };
23
- export default {
23
+ const supportExports = {
24
24
  init,
25
25
  sendInitialEvent,
26
26
  record: transmit.sendMore,
27
27
  get viewId() { return transmit.viewId; },
28
28
  };
29
+ export default supportExports;
30
+ // Named exports for convenience
31
+ export const record = supportExports.record;
32
+ export const viewId = supportExports.viewId;
33
+ // Type exports
34
+ export * from './types/abtest.js';
35
+ export * from './types/acquisition.js';
36
+ export * from './types/subscription.js';
37
+ export * from './types/interaction.js';
38
+ export * from './types/inpageclick.js';
39
+ export * from './types/printproduct.js';
40
+ export * from './types/product.js';
41
+ export * from './types/platform.js';
42
+ export * from './types/media.js';
43
+ export * from './types/consent.js';
44
+ export * from './types/component-type.js';
45
+ export * from './types/component-event.js';
46
+ export * from './types/event.js';
@@ -1,5 +1,5 @@
1
1
  declare namespace _default {
2
- let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
2
+ let record: (obj: import("./manage-my-account.js").EventPayload, f?: (() => void) | undefined) => void;
3
3
  const viewId: string;
4
4
  }
5
5
  export default _default;
@@ -1,5 +1,5 @@
1
1
  declare namespace _default {
2
- let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
2
+ let record: (obj: import("./manage-my-account.js").EventPayload, f?: (() => void) | undefined) => void;
3
3
  const viewId: string;
4
4
  }
5
5
  export default _default;
@@ -1,5 +1,5 @@
1
1
  declare namespace _default {
2
- let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
2
+ let record: (obj: import("./manage-my-account.js").EventPayload, f?: (() => void) | undefined) => void;
3
3
  const viewId: string;
4
4
  }
5
5
  export default _default;
@@ -1,5 +1,5 @@
1
1
  declare namespace _default {
2
- let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
2
+ let record: (obj: import("./manage-my-account.js").EventPayload, f?: (() => void) | undefined) => void;
3
3
  const viewId: string;
4
4
  }
5
5
  export default _default;
@@ -1,5 +1,5 @@
1
1
  declare namespace _default {
2
- let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
2
+ let record: (obj: import("./manage-my-account.js").EventPayload, f?: (() => void) | undefined) => void;
3
3
  const viewId: string;
4
4
  }
5
5
  export default _default;
@@ -1,7 +1,29 @@
1
- export default exports;
2
- declare namespace exports {
3
- export { sendInitialEvent };
4
- export let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
5
- export const viewId: string;
1
+ import './click-path-capture.js';
2
+ import './perf.js';
3
+ import './campaign.js';
4
+ import { EventPayload } from './types/event.js';
5
+ export declare const init: () => void;
6
+ export declare const sendInitialEvent: (url?: string, referrer?: string) => void;
7
+ interface MMAExports {
8
+ init: () => void;
9
+ sendInitialEvent: (url?: string, referrer?: string) => void;
10
+ record: (event: EventPayload, callback?: () => void) => void;
11
+ viewId: string;
6
12
  }
7
- declare function sendInitialEvent(url?: string, referrer?: string): void;
13
+ declare const exports: MMAExports;
14
+ export default exports;
15
+ export declare const record: (event: EventPayload, callback?: () => void) => void;
16
+ export declare const viewId: string;
17
+ export * from './types/abtest.js';
18
+ export * from './types/acquisition.js';
19
+ export * from './types/subscription.js';
20
+ export * from './types/interaction.js';
21
+ export * from './types/inpageclick.js';
22
+ export * from './types/printproduct.js';
23
+ export * from './types/product.js';
24
+ export * from './types/platform.js';
25
+ export * from './types/media.js';
26
+ export * from './types/consent.js';
27
+ export * from './types/component-type.js';
28
+ export * from './types/component-event.js';
29
+ export * from './types/event.js';
@@ -1,5 +1,5 @@
1
1
  declare namespace _default {
2
- let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
2
+ let record: (obj: import("./manage-my-account.js").EventPayload, f?: (() => void) | undefined) => void;
3
3
  const viewId: string;
4
4
  }
5
5
  export default _default;
@@ -1,5 +1,5 @@
1
1
  declare namespace _default {
2
- let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
2
+ let record: (obj: import("./manage-my-account.js").EventPayload, f?: (() => void) | undefined) => void;
3
3
  const viewId: string;
4
4
  }
5
5
  export default _default;
@@ -1,9 +1,29 @@
1
- declare namespace _default {
2
- export { init };
3
- export { sendInitialEvent };
4
- export let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
5
- export const viewId: string;
1
+ import './click-path-capture.js';
2
+ import './perf.js';
3
+ import './campaign.js';
4
+ import { EventPayload } from './types/event.js';
5
+ export declare const init: () => void;
6
+ export declare const sendInitialEvent: (url?: string, referrer?: string) => void;
7
+ interface SupportExports {
8
+ init: () => void;
9
+ sendInitialEvent: (url?: string, referrer?: string) => void;
10
+ record: (event: EventPayload, callback?: () => void) => void;
11
+ viewId: string;
6
12
  }
7
- export default _default;
8
- declare function init(): void;
9
- declare function sendInitialEvent(url?: string, referrer?: string): void;
13
+ declare const supportExports: SupportExports;
14
+ export default supportExports;
15
+ export declare const record: (event: EventPayload, callback?: () => void) => void;
16
+ export declare const viewId: string;
17
+ export * from './types/abtest.js';
18
+ export * from './types/acquisition.js';
19
+ export * from './types/subscription.js';
20
+ export * from './types/interaction.js';
21
+ export * from './types/inpageclick.js';
22
+ export * from './types/printproduct.js';
23
+ export * from './types/product.js';
24
+ export * from './types/platform.js';
25
+ export * from './types/media.js';
26
+ export * from './types/consent.js';
27
+ export * from './types/component-type.js';
28
+ export * from './types/component-event.js';
29
+ export * from './types/event.js';
@@ -1 +1 @@
1
- export type TComponentType = 'READERS_QUESTIONS_ATOM' | 'QANDA_ATOM' | 'PROFILE_ATOM' | 'GUIDE_ATOM' | 'TIMELINE_ATOM' | 'NEWSLETTER_SUBSCRIPTION' | 'SURVEYS_QUESTIONS' | 'ACQUISITIONS_EPIC' | 'ACQUISITIONS_ENGAGEMENT_BANNER' | 'ACQUISITIONS_THANK_YOU_EPIC' | 'ACQUISITIONS_HEADER' | 'ACQUISITIONS_FOOTER' | 'ACQUISITIONS_INTERACTIVE_SLICE' | 'ACQUISITIONS_NUGGET' | 'ACQUISITIONS_STANDFIRST' | 'ACQUISITIONS_THRASHER' | 'ACQUISITIONS_EDITORIAL_LINK' | 'ACQUISITIONS_MANAGE_MY_ACCOUNT' | 'ACQUISITIONS_BUTTON' | 'ACQUISITIONS_OTHER' | 'APP_ADVERT' | 'APP_AUDIO' | 'APP_BUTTON' | 'APP_CARD' | 'APP_CROSSWORDS' | 'APP_ENGAGEMENT_BANNER' | 'APP_EPIC' | 'APP_GALLERY' | 'APP_LINK' | 'APP_NAVIGATION_ITEM' | 'APP_SCREEN' | 'APP_THRASHER' | 'APP_VIDEO' | 'AUDIO_ATOM' | 'CHART_ATOM' | 'ACQUISITIONS_MERCHANDISING' | 'ACQUISITIONS_HOUSE_ADS' | 'SIGN_IN_GATE' | 'ACQUISITIONS_SUBSCRIPTIONS_BANNER' | 'MOBILE_STICKY_AD' | 'IDENTITY_AUTHENTICATION' | 'RETENTION_ENGAGEMENT_BANNER' | 'ACQUISITION_SUPPORT_SITE' | 'RETENTION_EPIC' | 'CONSENT' | 'LIVE_BLOG_PINNED_POST' | 'STICKY_VIDEO' | 'KEY_EVENT_CARD' | 'RETENTION_HEADER' | 'SLIDESHOW' | 'APP_FEATURE' | 'CARD' | 'CAROUSEL' | 'CONTAINER' | 'MENU' | 'ACQUISITIONS_GUTTER' | 'INTERACTIVE_ATOM' | 'LOOP_VIDEO' | 'AD_BLOCK_RECOVERY';
1
+ export type TComponentType = 'READERS_QUESTIONS_ATOM' | 'QANDA_ATOM' | 'PROFILE_ATOM' | 'GUIDE_ATOM' | 'TIMELINE_ATOM' | 'NEWSLETTER_SUBSCRIPTION' | 'SURVEYS_QUESTIONS' | 'ACQUISITIONS_EPIC' | 'ACQUISITIONS_ENGAGEMENT_BANNER' | 'ACQUISITIONS_THANK_YOU_EPIC' | 'ACQUISITIONS_HEADER' | 'ACQUISITIONS_FOOTER' | 'ACQUISITIONS_INTERACTIVE_SLICE' | 'ACQUISITIONS_NUGGET' | 'ACQUISITIONS_STANDFIRST' | 'ACQUISITIONS_THRASHER' | 'ACQUISITIONS_EDITORIAL_LINK' | 'ACQUISITIONS_MANAGE_MY_ACCOUNT' | 'ACQUISITIONS_BUTTON' | 'ACQUISITIONS_OTHER' | 'APP_ADVERT' | 'APP_AUDIO' | 'APP_BUTTON' | 'APP_CARD' | 'APP_CROSSWORDS' | 'APP_ENGAGEMENT_BANNER' | 'APP_EPIC' | 'APP_GALLERY' | 'APP_LINK' | 'APP_NAVIGATION_ITEM' | 'APP_SCREEN' | 'APP_THRASHER' | 'APP_VIDEO' | 'AUDIO_ATOM' | 'CHART_ATOM' | 'ACQUISITIONS_MERCHANDISING' | 'ACQUISITIONS_HOUSE_ADS' | 'SIGN_IN_GATE' | 'ACQUISITIONS_SUBSCRIPTIONS_BANNER' | 'MOBILE_STICKY_AD' | 'IDENTITY_AUTHENTICATION' | 'RETENTION_ENGAGEMENT_BANNER' | 'ACQUISITION_SUPPORT_SITE' | 'RETENTION_EPIC' | 'CONSENT' | 'LIVE_BLOG_PINNED_POST' | 'STICKY_VIDEO' | 'KEY_EVENT_CARD' | 'RETENTION_HEADER' | 'SLIDESHOW' | 'APP_FEATURE' | 'CARD' | 'CAROUSEL' | 'CONTAINER' | 'MENU' | 'ACQUISITIONS_GUTTER' | 'INTERACTIVE_ATOM' | 'LOOP_VIDEO' | 'AD_BLOCK_RECOVERY' | 'SIGN_IN_GOOGLE_ONE_TAP';
@@ -1,5 +1,5 @@
1
1
  declare namespace _default {
2
- let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
2
+ let record: (obj: import("./manage-my-account.js").EventPayload, f?: (() => void) | undefined) => void;
3
3
  const viewId: string;
4
4
  }
5
5
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/ophan-tracker-js",
3
- "version": "2.4.4",
3
+ "version": "2.6.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -19,12 +19,19 @@
19
19
  "./MMA": {
20
20
  "types": "./NPM-dist/types/manage-my-account.d.ts",
21
21
  "default": "./NPM-dist/manage-my-account.js"
22
+ },
23
+ "./support": {
24
+ "types": "./NPM-dist/types/support.d.ts",
25
+ "default": "./NPM-dist/support.js"
22
26
  }
23
27
  },
24
28
  "typesVersions": {
25
29
  "*": {
26
30
  "MMA": [
27
31
  "NPM-dist/types/manage-my-account.d.ts"
32
+ ],
33
+ "support": [
34
+ "NPM-dist/types/support.d.ts"
28
35
  ]
29
36
  }
30
37
  },
@@ -50,7 +57,8 @@
50
57
  "build-for-npm": "tsc",
51
58
  "pretest": "tsc",
52
59
  "test": "jest",
53
- "format": "npx prettier --write ."
60
+ "format": "npx prettier --write .",
61
+ "changeset:publish:canary": "changeset publish --tag canary"
54
62
  },
55
63
  "dependencies": {
56
64
  "@guardian/tsconfig": "^1.0.0"
package/readme.md CHANGED
@@ -129,11 +129,11 @@ The TypeScript compiler is configured to generate compiled JavaScript files and
129
129
 
130
130
  ## Publish
131
131
 
132
- #### Two formats for release
132
+ ### Two formats for release
133
133
 
134
134
  When you make a change to Tracker JS, you must release on *both* these systems:
135
135
 
136
- ##### NPM
136
+ #### NPM
137
137
 
138
138
  We use `changesets` for automated publishing of the NPM package:
139
139
 
@@ -147,10 +147,17 @@ We use `changesets` for automated publishing of the NPM package:
147
147
 
148
148
  3. When the PR is merged, the [`changesets` github action](https://github.com/changesets/action) will create a new PR, [example here](https://github.com/guardian/ophan/pull/5626). On merging this generated PR, the action will publish to NPM. (This checks the subdirectory correctly.)
149
149
 
150
- ##### S3 Bucket
150
+ #### S3 Bucket
151
151
 
152
152
  * [https://j.ophan.co.uk/](https://j.ophan.co.uk/jobs.js) - CDN/S3, [deployed through RiffRaff](https://riffraff.gutools.co.uk/deployment/history?projectName=ophan%3A%3Aophan-tracker-js&page=1) and used by some Guardian sites like https://jobs.theguardian.com/. An advantage of this approach is that sites using it immediately get Tracker JS updates, without developer intervention.
153
153
 
154
- ##### Rollup
154
+ #### Rollup
155
155
 
156
- The generated files from Rollup (using the `build-for-cdn` script in `package.json`) are only used for publishing to the CDN to use SystemJS / AMD
156
+ The generated files from Rollup (using the `build-for-cdn` script in `package.json`) are only used for publishing to the CDN to use SystemJS / AMD
157
+
158
+ ## Post publish
159
+ Post publish it would be good practice to inform the teams using Tracker-JS about the update.
160
+
161
+ See the [google doc ](https://docs.google.com/document/d/1MndFG-DLDQAMHIi55T4kZkGq4ONcded1-MDd9QS_NZE/edit?tab=t.0) for a list of teams depending on tracker-js.
162
+
163
+ If the change to tracker-js is small, we could raise a quick PR in the relevant repo and ask the team to review it.