@guardian/ophan-tracker-js 2.5.0 → 2.6.1
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.
- package/NPM-dist/core.js +0 -6
- package/NPM-dist/manage-my-account.js +25 -7
- package/NPM-dist/support.js +21 -3
- package/NPM-dist/tests/core.test.js +0 -54
- package/NPM-dist/types/contribution.d.ts +1 -1
- package/NPM-dist/types/embed.d.ts +1 -1
- package/NPM-dist/types/holidays.d.ts +1 -1
- package/NPM-dist/types/jobs-courses.d.ts +1 -1
- package/NPM-dist/types/jobs.d.ts +1 -1
- package/NPM-dist/types/manage-my-account.d.ts +28 -6
- package/NPM-dist/types/membership.d.ts +1 -1
- package/NPM-dist/types/smart-news.d.ts +1 -1
- package/NPM-dist/types/support.d.ts +28 -8
- package/NPM-dist/types/types/component-type.d.ts +1 -1
- package/NPM-dist/types/witness.d.ts +1 -1
- package/package.json +10 -2
package/NPM-dist/core.js
CHANGED
|
@@ -9,12 +9,6 @@ let platform = null;
|
|
|
9
9
|
const MaximumComponentNameLength = 50;
|
|
10
10
|
init = function (servingPlatform, httpStatus) {
|
|
11
11
|
platform = servingPlatform;
|
|
12
|
-
window.addEventListener('pageshow', function (event) {
|
|
13
|
-
if (event.persisted) {
|
|
14
|
-
transmit.bumpViewId();
|
|
15
|
-
sendInitialEvent(httpStatus, location.href, window.document.referrer, 'bfcache');
|
|
16
|
-
}
|
|
17
|
-
}, false);
|
|
18
12
|
if (visibility.state() !== 'prerender') {
|
|
19
13
|
return sendInitialEvent(httpStatus);
|
|
20
14
|
}
|
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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';
|
package/NPM-dist/support.js
CHANGED
|
@@ -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
|
-
|
|
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';
|
|
@@ -163,57 +163,3 @@ describe('appendContentType', () => {
|
|
|
163
163
|
expect(event.contentType).toBeUndefined();
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
|
-
describe('loadType pageshow handling', () => {
|
|
167
|
-
let mockAddEventListener;
|
|
168
|
-
let pageShowHandler;
|
|
169
|
-
let originalSendInitial;
|
|
170
|
-
beforeEach(() => {
|
|
171
|
-
jest.clearAllMocks();
|
|
172
|
-
mockAddEventListener = jest.fn();
|
|
173
|
-
window.addEventListener = mockAddEventListener;
|
|
174
|
-
originalSendInitial = transmit.sendInitial;
|
|
175
|
-
transmit.sendInitial = jest.fn();
|
|
176
|
-
const core = require('../core.js').default;
|
|
177
|
-
core.init('next-gen', 200);
|
|
178
|
-
const pageShowCall = mockAddEventListener.mock.calls.find(call => call[0] === 'pageshow');
|
|
179
|
-
pageShowHandler = pageShowCall ? pageShowCall[1] : null;
|
|
180
|
-
});
|
|
181
|
-
afterEach(() => {
|
|
182
|
-
transmit.sendInitial = originalSendInitial;
|
|
183
|
-
});
|
|
184
|
-
it('should register pageshow event listener during init', () => {
|
|
185
|
-
expect(mockAddEventListener).toHaveBeenCalledWith('pageshow', expect.any(Function), false);
|
|
186
|
-
});
|
|
187
|
-
it('should call sendInitialEvent with loadType=bfcache when pageshow event has persisted=true', () => {
|
|
188
|
-
expect(pageShowHandler).toBeTruthy();
|
|
189
|
-
transmit.sendInitial.mockClear();
|
|
190
|
-
// Simulate a bfcache restore event
|
|
191
|
-
const mockEvent = { persisted: true };
|
|
192
|
-
pageShowHandler(mockEvent);
|
|
193
|
-
expect(transmit.sendInitial).toHaveBeenCalledWith(expect.objectContaining({
|
|
194
|
-
loadType: 'bfcache'
|
|
195
|
-
}));
|
|
196
|
-
});
|
|
197
|
-
it('should call bumpViewId when pageshow event has persisted=true', () => {
|
|
198
|
-
expect(pageShowHandler).toBeTruthy();
|
|
199
|
-
transmit.bumpViewId.mockClear();
|
|
200
|
-
// Simulate a bfcache restore event
|
|
201
|
-
const mockEvent = { persisted: true };
|
|
202
|
-
pageShowHandler(mockEvent);
|
|
203
|
-
expect(transmit.bumpViewId).toHaveBeenCalledTimes(1);
|
|
204
|
-
});
|
|
205
|
-
it('should not call sendInitialEvent when pageshow event has persisted=false', () => {
|
|
206
|
-
expect(pageShowHandler).toBeTruthy();
|
|
207
|
-
transmit.sendInitial.mockClear();
|
|
208
|
-
const mockEvent = { persisted: false };
|
|
209
|
-
pageShowHandler(mockEvent);
|
|
210
|
-
expect(transmit.sendInitial).not.toHaveBeenCalled();
|
|
211
|
-
});
|
|
212
|
-
it('should handle pageshow event without persisted property', () => {
|
|
213
|
-
expect(pageShowHandler).toBeTruthy();
|
|
214
|
-
transmit.sendInitial.mockClear();
|
|
215
|
-
const mockEvent = {};
|
|
216
|
-
pageShowHandler(mockEvent);
|
|
217
|
-
expect(transmit.sendInitial).not.toHaveBeenCalled();
|
|
218
|
-
});
|
|
219
|
-
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace _default {
|
|
2
|
-
let record: (obj: import("./
|
|
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("./
|
|
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("./
|
|
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("./
|
|
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/NPM-dist/types/jobs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace _default {
|
|
2
|
-
let record: (obj: import("./
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
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("./
|
|
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("./
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
declare
|
|
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' | 'SIGN_IN_GOOGLE_ONE_TAP';
|
|
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' | 'BF_CACHE';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace _default {
|
|
2
|
-
let record: (obj: import("./
|
|
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.
|
|
3
|
+
"version": "2.6.1",
|
|
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"
|