@schibsted/pulse-sdk 8.0.0-rc.0 → 8.0.0-rc.10
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/dist/cjs/Tracker.js +201 -209
- package/dist/cjs/Tracker.test-d.js +2 -2
- package/dist/cjs/builders/actor.js +3 -3
- package/dist/cjs/builders/consents.js +2 -2
- package/dist/cjs/builders/events-anonymous-node.js +1 -1
- package/dist/cjs/builders/events-node.js +3 -3
- package/dist/cjs/builders/experiments.js +1 -0
- package/dist/cjs/builders/tracker-node.js +2 -5
- package/dist/cjs/identity/actor.js +18 -6
- package/dist/cjs/identity/cis.js +4 -6
- package/dist/cjs/leaveTrackingTpaas/constants.js +2 -7
- package/dist/cjs/leaveTrackingTpaas/index.js +52 -40
- package/dist/cjs/tracker-proxy/consts.js +12 -6
- package/dist/cjs/tracker-proxy/proxy-provider.js +6 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/visibility-observer/index.js +9 -7
- package/dist/cjs/wrapper/types/event.js +5 -0
- package/dist/ejs/Tracker.js +203 -211
- package/dist/ejs/Tracker.test-d.js +2 -2
- package/dist/ejs/builders/actor.js +2 -2
- package/dist/ejs/builders/consents.js +2 -2
- package/dist/ejs/builders/events-anonymous-node.js +1 -1
- package/dist/ejs/builders/events-node.js +3 -3
- package/dist/ejs/builders/experiments.js +1 -1
- package/dist/ejs/builders/tracker-node.js +2 -2
- package/dist/ejs/identity/actor.js +19 -7
- package/dist/ejs/identity/cis.js +4 -3
- package/dist/ejs/leaveTrackingTpaas/constants.js +1 -5
- package/dist/ejs/leaveTrackingTpaas/index.js +53 -41
- package/dist/ejs/tracker-proxy/consts.js +12 -6
- package/dist/ejs/tracker-proxy/proxy-provider.js +6 -0
- package/dist/ejs/version.js +2 -0
- package/dist/ejs/visibility-observer/index.js +9 -7
- package/dist/ejs/wrapper/types/event.js +4 -1
- package/dist/types/Tracker.d.ts +92 -87
- package/dist/types/builders/actor.d.ts +3 -2
- package/dist/types/builders/consents.d.ts +2 -2
- package/dist/types/builders/experiments.d.ts +1 -0
- package/dist/types/builders/index.d.ts +1 -1
- package/dist/types/identity/actor.d.ts +2 -2
- package/dist/types/identity/cis.d.ts +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/leaveTrackingTpaas/constants.d.ts +1 -5
- package/dist/types/leaveTrackingTpaas/index.d.ts +6 -6
- package/dist/types/leaveTrackingTpaas/types.d.ts +1 -9
- package/dist/types/tracker-proxy/consts.d.ts +1 -1
- package/dist/types/types.d.ts +19 -13
- package/dist/types/version.d.ts +1 -0
- package/dist/types/visibility-observer/index.d.ts +6 -1
- package/dist/types/wrapper/engagement/ui-element/types.d.ts +1 -0
- package/dist/types/wrapper/types/event.d.ts +3 -1
- package/dist/types/wrapper/view/ui-element/types.d.ts +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.d.ts +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js +17 -3
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js.map +1 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.d.ts +4 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.js +15 -5
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.js.map +1 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.d.ts +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js +5 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js.map +1 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.d.ts +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.js +16 -2
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.js.map +1 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.d.ts +4 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.js +12 -3
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.js.map +1 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.d.ts +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.js +5 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.js.map +1 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/cis-browser.d.ts +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/storage/pulseStorage.d.ts +4 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/storage/storage.d.ts +1 -0
- package/node_modules/@schibsted/pulse-utils/package.json +1 -1
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/catalogVersion.js +9 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/device.js +8 -2
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/provider.js +3 -1
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/session.js +19 -6
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders.js +75 -76
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/guards.js +7 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/index.js +3 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/catalogVersion.js +6 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/device.js +8 -2
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/provider.js +3 -1
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/session.js +19 -6
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders.js +74 -71
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/guards.js +4 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/index.js +1 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/index.d.ts +1730 -1127
- package/node_modules/@schibsted/tpaas-event-builder/package.json +3 -2
- package/node_modules/@schibsted/tpaas-schemas/dist/cjs/constants.js +136 -103
- package/node_modules/@schibsted/tpaas-schemas/dist/cjs/index.js +1 -0
- package/node_modules/@schibsted/tpaas-schemas/dist/cjs/types.js +2 -0
- package/node_modules/@schibsted/tpaas-schemas/dist/ejs/constants.js +134 -101
- package/node_modules/@schibsted/tpaas-schemas/dist/ejs/index.js +1 -0
- package/node_modules/@schibsted/tpaas-schemas/dist/ejs/types.js +1 -0
- package/node_modules/@schibsted/tpaas-schemas/dist/index.d.ts +1940 -1266
- package/node_modules/@schibsted/tpaas-schemas/package.json +1 -1
- package/package.json +7 -6
- package/dist/cjs/version.json +0 -1
- package/dist/ejs/version.json +0 -1
package/dist/cjs/Tracker.js
CHANGED
|
@@ -53,6 +53,7 @@ const consent_manager_1 = require("./builders/consent-manager");
|
|
|
53
53
|
const consents_1 = require("./builders/consents");
|
|
54
54
|
const events_1 = require("./builders/events");
|
|
55
55
|
const events_anonymous_node_1 = require("./builders/events-anonymous-node");
|
|
56
|
+
const experiments_1 = require("./builders/experiments");
|
|
56
57
|
const session_browser_1 = require("./builders/session-browser");
|
|
57
58
|
const config_1 = require("./config");
|
|
58
59
|
const config_browser_1 = require("./config-browser");
|
|
@@ -64,10 +65,11 @@ const leaveTrackingTpaas_1 = require("./leaveTrackingTpaas");
|
|
|
64
65
|
const network_1 = __importDefault(require("./network"));
|
|
65
66
|
const config = __importStar(require("./remoteConfig"));
|
|
66
67
|
const proxy_provider_1 = require("./tracker-proxy/proxy-provider");
|
|
67
|
-
const
|
|
68
|
+
const version_1 = require("./version");
|
|
68
69
|
const visibility_observer_1 = require("./visibility-observer");
|
|
69
70
|
const warnOnce_1 = __importDefault(require("./warnOnce"));
|
|
70
71
|
const event_builder_1 = require("./wrapper/engagement/ui-element/event-builder");
|
|
72
|
+
const types_1 = require("./wrapper/types");
|
|
71
73
|
const page_from_page_view_1 = require("./wrapper/utils/page-from-page-view");
|
|
72
74
|
const event_builder_2 = require("./wrapper/view/article/event-builder");
|
|
73
75
|
const event_builder_3 = require("./wrapper/view/frontpage/event-builder");
|
|
@@ -157,6 +159,27 @@ function unsubscribe(eventName, callback) {
|
|
|
157
159
|
* @class Tracker
|
|
158
160
|
*/
|
|
159
161
|
class Tracker {
|
|
162
|
+
async getCurrentTpaasPage() {
|
|
163
|
+
const { id, type, url } = await this.currentPage;
|
|
164
|
+
return {
|
|
165
|
+
// remove the SDRN prefix, it's not expected for TPaaS
|
|
166
|
+
pageId: id.startsWith('sdrn:') ? id.split(':').slice(-1)[0] : id,
|
|
167
|
+
// make sure the pageType is valid for TPaaS
|
|
168
|
+
pageType: (0, tpaas_event_builder_1.isPageType)(type) ? type : 'Page',
|
|
169
|
+
url,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
async getCurrentLegacyPage() {
|
|
173
|
+
const { id, type, url } = await this.currentPage;
|
|
174
|
+
// make sure the pageType is valid for legacy events
|
|
175
|
+
const validatedType = (0, types_1.isLegacyPageType)(type) ? type : 'Page';
|
|
176
|
+
return {
|
|
177
|
+
// add the SDRN prefix if it's not there, legacy events expect the full SDRN format
|
|
178
|
+
id: id.startsWith('sdrn:') ? id : `sdrn:${this.state.providerId}:${validatedType.toLowerCase()}:${id}`,
|
|
179
|
+
type: validatedType,
|
|
180
|
+
url,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
160
183
|
/**
|
|
161
184
|
* > [!WARNING]
|
|
162
185
|
* >
|
|
@@ -175,19 +198,30 @@ class Tracker {
|
|
|
175
198
|
// the tracking of the same element with both old and new events at the same time
|
|
176
199
|
this.legacyVisibilityObservers = new Map();
|
|
177
200
|
this.visibilityObservers = new Map();
|
|
178
|
-
|
|
179
|
-
|
|
201
|
+
/**
|
|
202
|
+
* @private
|
|
203
|
+
*
|
|
204
|
+
* This is used as the source of truth for the current page's information, which is updated based on the View Page-level event
|
|
205
|
+
* As a single source of truth for the current page, this needs to be compatible between legacy and TPaaS events, hence the need for a custom data type.
|
|
206
|
+
* Legacy events can provide an id with SDRN, while TPaaS events don't need it
|
|
207
|
+
*/
|
|
208
|
+
this.currentPage = {
|
|
209
|
+
id: 'unknown',
|
|
180
210
|
type: 'Page',
|
|
181
|
-
url:
|
|
211
|
+
url: pulse_utils_1.isBrowser ? window.location.href : undefined,
|
|
182
212
|
};
|
|
183
|
-
this.currentPage = undefined;
|
|
184
213
|
/**
|
|
185
214
|
* Promise that resolves when a session ID becomes available
|
|
186
215
|
* @private
|
|
187
216
|
*/
|
|
188
217
|
this.sessionIdPromise = null;
|
|
218
|
+
/**
|
|
219
|
+
* A simple flag used to prevent duplicate listeners being registered
|
|
220
|
+
* if `exposeToProxyClients` or `startProxyProviderListener` is called more than once.
|
|
221
|
+
*/
|
|
222
|
+
this.hasProxyListener = false;
|
|
189
223
|
this.setPageDefaults = (pageViewEvent) => {
|
|
190
|
-
this.
|
|
224
|
+
this.currentPage = (0, page_from_page_view_1.pageFromPageView)(pageViewEvent);
|
|
191
225
|
if (pageViewEvent.origin) {
|
|
192
226
|
const pageDefaults = { origin: pageViewEvent.origin };
|
|
193
227
|
this.update(pageDefaults, true);
|
|
@@ -195,8 +229,8 @@ class Tracker {
|
|
|
195
229
|
};
|
|
196
230
|
this.setCurrentPage = (id, type) => {
|
|
197
231
|
this.currentPage = {
|
|
198
|
-
|
|
199
|
-
|
|
232
|
+
id: id || 'unknown',
|
|
233
|
+
type: type || 'Page',
|
|
200
234
|
url: pulse_utils_1.isBrowser ? window.location.href : undefined,
|
|
201
235
|
};
|
|
202
236
|
};
|
|
@@ -205,6 +239,9 @@ class Tracker {
|
|
|
205
239
|
if (!providerId || !(typeof providerId === 'string')) {
|
|
206
240
|
throw new Error('Required parameter `providerId` missing');
|
|
207
241
|
}
|
|
242
|
+
if (config?.componentVersion !== undefined && config?.component === undefined) {
|
|
243
|
+
throw new Error('`componentVersion` cannot be provided without `component`');
|
|
244
|
+
}
|
|
208
245
|
let includeAdvertising;
|
|
209
246
|
if (pulse_utils_1.isBrowser && config?.autoCreateConsents) {
|
|
210
247
|
config.consents = (0, consent_manager_1.getConsentsWaitForAnalytics)((consents) => {
|
|
@@ -248,9 +285,11 @@ class Tracker {
|
|
|
248
285
|
this.builders = (0, pulse_utils_1.pulseMerge)({}, builders, {
|
|
249
286
|
provider: {
|
|
250
287
|
id: providerId,
|
|
288
|
+
...(config?.component !== undefined && { component: config.component }),
|
|
289
|
+
...(config?.componentVersion !== undefined && { componentVersion: config.componentVersion }),
|
|
251
290
|
},
|
|
252
291
|
tracker: {
|
|
253
|
-
version:
|
|
292
|
+
version: version_1.SDK_VERSION,
|
|
254
293
|
},
|
|
255
294
|
});
|
|
256
295
|
this.bookmark = new Map();
|
|
@@ -364,6 +403,11 @@ class Tracker {
|
|
|
364
403
|
return queuedEvent.then((result) => result);
|
|
365
404
|
});
|
|
366
405
|
};
|
|
406
|
+
/*
|
|
407
|
+
* Casting `input` as `Partial<Builders>` to formalise the intention of processing the event input in relation to the properties in
|
|
408
|
+
* the Builders type. It would justify changing the public api for `.track`, but as this deals with legacy code, we
|
|
409
|
+
* keep it internal, so dependencies from now on can count on objects being a Partial<Builder>
|
|
410
|
+
*/
|
|
367
411
|
return this.syncRemoteResources(input, currentBuilders).then(_track, _track);
|
|
368
412
|
}
|
|
369
413
|
/**
|
|
@@ -433,6 +477,11 @@ class Tracker {
|
|
|
433
477
|
return {
|
|
434
478
|
name: exp.name || exp.id,
|
|
435
479
|
variant: exp.variant || '',
|
|
480
|
+
// nobody should be sending experiment id with an sdrn format, but in case they do
|
|
481
|
+
// we want to be able to handle it and not generate an invalid sdrn by adding another layer to it
|
|
482
|
+
experimentSdrn: exp.id.startsWith('sdrn:') ? exp.id : (0, experiments_1.generateExperimentSDRN)(exp.id, exp.platform),
|
|
483
|
+
platform: exp.platform || '',
|
|
484
|
+
testId: exp.custom?.testId,
|
|
436
485
|
};
|
|
437
486
|
});
|
|
438
487
|
}
|
|
@@ -450,15 +499,16 @@ class Tracker {
|
|
|
450
499
|
}
|
|
451
500
|
return {
|
|
452
501
|
autoTrackerVersion: this.builders.tracker?.autoTrackerVersion,
|
|
453
|
-
version:
|
|
502
|
+
version: version_1.SDK_VERSION,
|
|
454
503
|
isHybrid: !!this.state.isHybrid,
|
|
455
504
|
pageviewId: this.state.pageViewId,
|
|
456
505
|
providerId: this.state.providerId,
|
|
506
|
+
component: this.state.component,
|
|
507
|
+
componentVersion: this.state.componentVersion,
|
|
457
508
|
experiments: await this.adaptExperiments(this.builders.experiments),
|
|
458
509
|
};
|
|
459
510
|
}
|
|
460
511
|
/**
|
|
461
|
-
*
|
|
462
512
|
* @private
|
|
463
513
|
* @category TPaaS Tracking
|
|
464
514
|
*/
|
|
@@ -518,42 +568,29 @@ class Tracker {
|
|
|
518
568
|
source: source || 'unknown',
|
|
519
569
|
};
|
|
520
570
|
}
|
|
521
|
-
const [actor, consents, experiments] = await Promise.all([
|
|
571
|
+
const [actor, consents, experiments, currentPage] = await Promise.all([
|
|
522
572
|
this.getActor(),
|
|
523
573
|
this.getConsents(),
|
|
524
574
|
this.adaptExperiments(this.builders.experiments),
|
|
575
|
+
this.getCurrentTpaasPage(),
|
|
525
576
|
]);
|
|
526
577
|
const { environmentId, jwe } = (0, pulse_cis_sync_1.parsePulseCookies)();
|
|
527
578
|
return {
|
|
528
579
|
autoTrackerVersion: this.builders.tracker?.autoTrackerVersion,
|
|
529
|
-
version:
|
|
580
|
+
version: version_1.SDK_VERSION,
|
|
530
581
|
isHybrid: !!this.state.isHybrid,
|
|
531
582
|
user: adaptActorToNewFormat(actor),
|
|
532
583
|
consents: adaptConsentsToNewFormat(consents),
|
|
533
584
|
providerId: this.state.providerId,
|
|
585
|
+
component: this.state.component,
|
|
586
|
+
componentVersion: this.state.componentVersion,
|
|
534
587
|
pageviewId: this.state.pageViewId,
|
|
535
|
-
currentPage
|
|
588
|
+
currentPage,
|
|
536
589
|
experiments,
|
|
537
590
|
environmentId,
|
|
538
591
|
jwe,
|
|
539
592
|
};
|
|
540
593
|
}
|
|
541
|
-
/**
|
|
542
|
-
* Generate a generic TPaaS event with common builders output
|
|
543
|
-
* The method should be used for experiments, not for real production work.
|
|
544
|
-
* It doesn't have any real TPaaS schema associated with it.
|
|
545
|
-
* The method doesn't queue or send the event, it just returns the merged object.
|
|
546
|
-
* The method can be removed at any time in the future, so use it with caution.
|
|
547
|
-
*
|
|
548
|
-
* @param input - The input object to merge with the common builders output
|
|
549
|
-
* @returns A promise that resolves to the merged object
|
|
550
|
-
* @private
|
|
551
|
-
* @category TPaaS Tracking
|
|
552
|
-
*/
|
|
553
|
-
async generateGenericTpaasEvent(input) {
|
|
554
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
555
|
-
return (0, pulse_utils_1.pulseMerge)({}, input, (0, tpaas_event_builder_1.getCommonBuildersOutput)(new Date(), dependencies));
|
|
556
|
-
}
|
|
557
594
|
/**
|
|
558
595
|
* This method extends the list of base experiments that will be automatically included in every event sent by the tracker.
|
|
559
596
|
*
|
|
@@ -575,6 +612,9 @@ class Tracker {
|
|
|
575
612
|
* @category Tracking
|
|
576
613
|
*/
|
|
577
614
|
addExperiments(experiments) {
|
|
615
|
+
if (experiments.some((experiment) => experiment.id.startsWith('sdrn:'))) {
|
|
616
|
+
loglevel_1.default.warn('Pulse - addExperiments received an experiment id starting with "sdrn:"; pass the raw experiment id instead. The SDK will generate the sdrn automatically.');
|
|
617
|
+
}
|
|
578
618
|
this.update({ experiments }, true);
|
|
579
619
|
}
|
|
580
620
|
/**
|
|
@@ -609,7 +649,7 @@ class Tracker {
|
|
|
609
649
|
const viewUIElementInputProperties = buildEventFromElement(element);
|
|
610
650
|
this.trackLegacyViewUIElement(viewUIElementInputProperties);
|
|
611
651
|
}));
|
|
612
|
-
this.legacyVisibilityObservers.get(selector)?.observe(selector);
|
|
652
|
+
this.legacyVisibilityObservers.get(selector)?.observe(selector, {});
|
|
613
653
|
}
|
|
614
654
|
/**
|
|
615
655
|
* The `addUIElementVisibilityTracking` function provides an interface for sending tracking events when specific UI elements become visible within the viewport.
|
|
@@ -641,7 +681,38 @@ class Tracker {
|
|
|
641
681
|
const eventInput = buildEventFromElement(element);
|
|
642
682
|
this.trackImpressionUIElement(eventInput);
|
|
643
683
|
}));
|
|
644
|
-
this.visibilityObservers.get(selector)?.observe(selector);
|
|
684
|
+
this.visibilityObservers.get(selector)?.observe(selector, {});
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* The `addElementVisibilityObserver` function provides an interface for executing arbitrary code when specific DOM Elements become visible within the viewport.
|
|
688
|
+
* It is built on the `VisibilityObserver` class, which efficiently detects visibility changes in DOM elements.
|
|
689
|
+
* When an element becomes at least 2/3 visible, a callback is triggered, with the Element that invoked the callback call as argument.
|
|
690
|
+
* It leverages the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) for viewport tracking
|
|
691
|
+
* and the [Mutation Observer API](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) to monitor lazy-loaded elements.
|
|
692
|
+
*
|
|
693
|
+
* Example usage:
|
|
694
|
+
*
|
|
695
|
+
* ```ts
|
|
696
|
+
* tracker.addElementVisibilityObserver('[data-pulse-entity-id]', (element) => {
|
|
697
|
+
* const eventInput = parseElementIntoEventInput(element); // user-defined function
|
|
698
|
+
* tracker.trackImpressionTeaser(eventInput); // can be anything actually, not necessarily a Teaser tracking call
|
|
699
|
+
* });
|
|
700
|
+
* ```
|
|
701
|
+
* @param selector
|
|
702
|
+
* @param callback
|
|
703
|
+
* @param options {ObserverOptions}
|
|
704
|
+
* @param options.threshold - A number between 0 and 1 indicating how much of the element should be visible to trigger
|
|
705
|
+
* the callback. Default is 0.67 (2/3 of the element).
|
|
706
|
+
*/
|
|
707
|
+
addElementVisibilityObserver(selector, callback, options = {}) {
|
|
708
|
+
if (this.visibilityObservers.has(selector)) {
|
|
709
|
+
console.warn(`Cannot add UI Element visibility tracking for selector "${selector}" as it is already being tracked.`);
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
this.visibilityObservers.set(selector, new visibility_observer_1.VisibilityObserver((element) => {
|
|
713
|
+
callback(element);
|
|
714
|
+
}));
|
|
715
|
+
this.visibilityObservers.get(selector)?.observe(selector, options);
|
|
645
716
|
}
|
|
646
717
|
/**
|
|
647
718
|
* The old trackViewArticle method from the Media Wrapper.
|
|
@@ -735,7 +806,7 @@ class Tracker {
|
|
|
735
806
|
* @category Legacy Tracking
|
|
736
807
|
*/
|
|
737
808
|
trackLegacyViewUIElement(inputProperties, trackOptions) {
|
|
738
|
-
const viewUIElementEventData = (0, event_builder_8.buildLegacyViewUIElementEvent)(inputProperties, this.
|
|
809
|
+
const viewUIElementEventData = (0, event_builder_8.buildLegacyViewUIElementEvent)(inputProperties, this.getCurrentLegacyPage());
|
|
739
810
|
return this.track('trackerEvent', viewUIElementEventData, trackOptions);
|
|
740
811
|
}
|
|
741
812
|
/**
|
|
@@ -746,7 +817,7 @@ class Tracker {
|
|
|
746
817
|
* @category Legacy Tracking
|
|
747
818
|
*/
|
|
748
819
|
trackLegacyClickUIElement(inputProperties, trackOptions) {
|
|
749
|
-
const clickUIElementEventData = (0, event_builder_1.buildClickUIElementEvent)(inputProperties, this.
|
|
820
|
+
const clickUIElementEventData = (0, event_builder_1.buildClickUIElementEvent)(inputProperties, this.getCurrentLegacyPage());
|
|
750
821
|
return this.track('trackerEvent', clickUIElementEventData, trackOptions);
|
|
751
822
|
}
|
|
752
823
|
/**
|
|
@@ -773,19 +844,18 @@ class Tracker {
|
|
|
773
844
|
}
|
|
774
845
|
async trackViewHealthPage(input, options) {
|
|
775
846
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
776
|
-
this.setCurrentPage(input.object.objectId,
|
|
847
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewHealthPage.object.objectType);
|
|
777
848
|
const dependencies = await this.prepareTpaasEvent();
|
|
778
849
|
const event = (0, tpaas_event_builder_1.buildViewHealthPageEvent)(input, dependencies);
|
|
779
850
|
const result = this.sendTpaasEvent(event);
|
|
780
851
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
this.trackLeavePage({
|
|
852
|
+
const leavePageCallback = async (leave) => {
|
|
853
|
+
// HealthView Page is a bit special, in the sense that in doesn't have a dedicated Leave event.
|
|
854
|
+
// Instead, we need to reuse the generic Leave Page event, but adapt the input accordingly.
|
|
855
|
+
// This means omitting some fields from HealthView Page that are not part of Leave Page schema.
|
|
856
|
+
const { experiments, metrics, object, origin, ...restInput } = input;
|
|
857
|
+
const { category, custom, intent, name, tags, ...restObject } = input.object;
|
|
858
|
+
await this.trackLeavePage({
|
|
789
859
|
leave,
|
|
790
860
|
...restInput,
|
|
791
861
|
object: {
|
|
@@ -795,10 +865,7 @@ class Tracker {
|
|
|
795
865
|
});
|
|
796
866
|
};
|
|
797
867
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
798
|
-
|
|
799
|
-
pageElement,
|
|
800
|
-
objectResizable,
|
|
801
|
-
heightBuilder,
|
|
868
|
+
...options.leaveTracking,
|
|
802
869
|
schema: tpaas_schemas_1.LeavePage.object.objectType,
|
|
803
870
|
trackMethod: leavePageCallback,
|
|
804
871
|
});
|
|
@@ -822,18 +889,14 @@ class Tracker {
|
|
|
822
889
|
const event = (0, tpaas_event_builder_1.buildViewPageEvent)(input, dependencies);
|
|
823
890
|
const result = this.sendTpaasEvent(event);
|
|
824
891
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
this.trackLeavePage({
|
|
892
|
+
const leavePageCallback = async (leave) => {
|
|
893
|
+
await this.trackLeavePage({
|
|
828
894
|
leave,
|
|
829
895
|
...input,
|
|
830
896
|
});
|
|
831
897
|
};
|
|
832
898
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
833
|
-
|
|
834
|
-
pageElement,
|
|
835
|
-
objectResizable,
|
|
836
|
-
heightBuilder,
|
|
899
|
+
...options.leaveTracking,
|
|
837
900
|
schema: tpaas_schemas_1.LeavePage.object.objectType,
|
|
838
901
|
trackMethod: leavePageCallback,
|
|
839
902
|
});
|
|
@@ -842,32 +905,49 @@ class Tracker {
|
|
|
842
905
|
}
|
|
843
906
|
/**
|
|
844
907
|
* @param input
|
|
908
|
+
* @param options
|
|
845
909
|
* @category TPaaS Tracking
|
|
846
910
|
*/
|
|
847
|
-
async
|
|
911
|
+
async trackViewSportsPage(input, options) {
|
|
848
912
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
849
|
-
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.
|
|
913
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewSportsPage.object.objectType);
|
|
850
914
|
const dependencies = await this.prepareTpaasEvent();
|
|
851
|
-
const event = (0, tpaas_event_builder_1.
|
|
852
|
-
|
|
853
|
-
|
|
915
|
+
const event = (0, tpaas_event_builder_1.buildViewSportsPageEvent)(input, dependencies);
|
|
916
|
+
const result = this.sendTpaasEvent(event);
|
|
917
|
+
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
918
|
+
const leaveSportsPageCallback = async (leave) => {
|
|
919
|
+
await this.trackLeaveSportsPage({
|
|
920
|
+
leave,
|
|
921
|
+
...input,
|
|
922
|
+
});
|
|
923
|
+
};
|
|
924
|
+
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
925
|
+
...options.leaveTracking,
|
|
926
|
+
schema: tpaas_schemas_1.LeaveSportsPage.object.objectType,
|
|
927
|
+
trackMethod: leaveSportsPageCallback,
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
return result;
|
|
854
931
|
}
|
|
855
932
|
/**
|
|
856
933
|
* @param input
|
|
857
934
|
* @category TPaaS Tracking
|
|
858
935
|
*/
|
|
859
|
-
async
|
|
936
|
+
async trackViewTitle(input) {
|
|
937
|
+
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
938
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewTitle.object.objectType);
|
|
860
939
|
const dependencies = await this.prepareTpaasEvent();
|
|
861
|
-
const event = (0, tpaas_event_builder_1.
|
|
940
|
+
const event = (0, tpaas_event_builder_1.buildViewTitleEvent)(input, dependencies);
|
|
862
941
|
return this.sendTpaasEvent(event);
|
|
942
|
+
// there's no Leave Title event
|
|
863
943
|
}
|
|
864
944
|
/**
|
|
865
945
|
* @param input
|
|
866
946
|
* @category TPaaS Tracking
|
|
867
947
|
*/
|
|
868
|
-
async
|
|
948
|
+
async trackImpressionWidget(input) {
|
|
869
949
|
const dependencies = await this.prepareTpaasEvent();
|
|
870
|
-
const event = (0, tpaas_event_builder_1.
|
|
950
|
+
const event = (0, tpaas_event_builder_1.buildImpressionWidgetEvent)(input, dependencies);
|
|
871
951
|
return this.sendTpaasEvent(event);
|
|
872
952
|
}
|
|
873
953
|
/**
|
|
@@ -882,36 +962,20 @@ class Tracker {
|
|
|
882
962
|
const event = (0, tpaas_event_builder_1.buildViewArticleEvent)(input, dependencies);
|
|
883
963
|
const result = this.sendTpaasEvent(event);
|
|
884
964
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
885
|
-
const
|
|
886
|
-
|
|
887
|
-
this.trackLeaveArticle({
|
|
965
|
+
const leaveArticleCallback = async (leave) => {
|
|
966
|
+
await this.trackLeaveArticle({
|
|
888
967
|
leave,
|
|
889
968
|
...input,
|
|
890
969
|
});
|
|
891
970
|
};
|
|
892
971
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
893
|
-
|
|
894
|
-
pageElement,
|
|
895
|
-
heightBuilder,
|
|
896
|
-
objectResizable,
|
|
972
|
+
...options.leaveTracking,
|
|
897
973
|
schema: tpaas_schemas_1.LeaveArticle.object.objectType,
|
|
898
974
|
trackMethod: leaveArticleCallback,
|
|
899
975
|
});
|
|
900
976
|
}
|
|
901
977
|
return result;
|
|
902
978
|
}
|
|
903
|
-
/**
|
|
904
|
-
* @param input
|
|
905
|
-
* @param options
|
|
906
|
-
* @category TPaaS Tracking
|
|
907
|
-
*/
|
|
908
|
-
async trackViewAudio(input) {
|
|
909
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
910
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
911
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
912
|
-
const event = (0, tpaas_event_builder_1.buildViewAudioEvent)(input, dependencies);
|
|
913
|
-
return this.sendTpaasEvent(event);
|
|
914
|
-
}
|
|
915
979
|
/**
|
|
916
980
|
* Tracks a View AudioPage event and automatically fires a Leave AudioPage event when the user
|
|
917
981
|
* navigates away.
|
|
@@ -954,20 +1018,20 @@ class Tracker {
|
|
|
954
1018
|
*/
|
|
955
1019
|
async trackViewAudioPage(input, options) {
|
|
956
1020
|
this.newPageView();
|
|
957
|
-
this.setCurrentPage(input.object.objectId,
|
|
1021
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewAudioPage.object.objectType);
|
|
958
1022
|
const dependencies = await this.prepareTpaasEvent();
|
|
959
1023
|
const event = (0, tpaas_event_builder_1.buildViewAudioPageEvent)(input, dependencies);
|
|
960
1024
|
const result = this.sendTpaasEvent(event);
|
|
961
1025
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
962
|
-
const {
|
|
963
|
-
const leaveAudioPageCallback = (leave) => {
|
|
1026
|
+
const { leaveAudioBuilder, ...restLeaveTrackingOptions } = options.leaveTracking;
|
|
1027
|
+
const leaveAudioPageCallback = async (leave) => {
|
|
964
1028
|
const leaveAudioInput = leaveAudioBuilder?.() ?? {
|
|
965
1029
|
audioCompleted: 0,
|
|
966
1030
|
audioStarted: 0,
|
|
967
1031
|
maxPlaylistPosition: 0,
|
|
968
1032
|
playlistPositionPercentage: 0,
|
|
969
1033
|
};
|
|
970
|
-
this.trackLeaveAudioPage({
|
|
1034
|
+
await this.trackLeaveAudioPage({
|
|
971
1035
|
leave,
|
|
972
1036
|
leaveAudio: {
|
|
973
1037
|
...leaveAudioInput,
|
|
@@ -978,10 +1042,7 @@ class Tracker {
|
|
|
978
1042
|
});
|
|
979
1043
|
};
|
|
980
1044
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
981
|
-
|
|
982
|
-
pageElement,
|
|
983
|
-
heightBuilder,
|
|
984
|
-
objectResizable,
|
|
1045
|
+
...restLeaveTrackingOptions,
|
|
985
1046
|
schema: tpaas_schemas_1.LeaveAudioPage.object.objectType,
|
|
986
1047
|
trackMethod: leaveAudioPageCallback,
|
|
987
1048
|
});
|
|
@@ -1000,24 +1061,29 @@ class Tracker {
|
|
|
1000
1061
|
const event = (0, tpaas_event_builder_1.buildViewErrorEvent)(input, dependencies);
|
|
1001
1062
|
const result = this.sendTpaasEvent(event);
|
|
1002
1063
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
this.trackLeaveError({
|
|
1064
|
+
const leaveErrorCallback = async (leave) => {
|
|
1065
|
+
await this.trackLeaveError({
|
|
1006
1066
|
leave,
|
|
1007
1067
|
...input,
|
|
1008
1068
|
});
|
|
1009
1069
|
};
|
|
1010
1070
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1011
|
-
|
|
1012
|
-
pageElement,
|
|
1013
|
-
heightBuilder,
|
|
1014
|
-
objectResizable,
|
|
1071
|
+
...options.leaveTracking,
|
|
1015
1072
|
schema: tpaas_schemas_1.LeaveError.object.objectType,
|
|
1016
1073
|
trackMethod: leaveErrorCallback,
|
|
1017
1074
|
});
|
|
1018
1075
|
}
|
|
1019
1076
|
return result;
|
|
1020
1077
|
}
|
|
1078
|
+
/**
|
|
1079
|
+
* @param input
|
|
1080
|
+
* @category TPaaS Tracking
|
|
1081
|
+
*/
|
|
1082
|
+
async trackImpressionAdSlot(input) {
|
|
1083
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1084
|
+
const event = (0, tpaas_event_builder_1.buildImpressionAdSlotEvent)(input, dependencies);
|
|
1085
|
+
return this.sendTpaasEvent(event);
|
|
1086
|
+
}
|
|
1021
1087
|
/**
|
|
1022
1088
|
* @param input
|
|
1023
1089
|
* @category TPaaS Tracking
|
|
@@ -1075,18 +1141,14 @@ class Tracker {
|
|
|
1075
1141
|
const event = (0, tpaas_event_builder_1.buildViewFrontpageEvent)(input, dependencies);
|
|
1076
1142
|
const result = this.sendTpaasEvent(event);
|
|
1077
1143
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1080
|
-
this.trackLeaveFrontpage({
|
|
1144
|
+
const leaveFrontpageCallback = async (leave) => {
|
|
1145
|
+
await this.trackLeaveFrontpage({
|
|
1081
1146
|
leave,
|
|
1082
1147
|
...input,
|
|
1083
1148
|
});
|
|
1084
1149
|
};
|
|
1085
1150
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1086
|
-
|
|
1087
|
-
pageElement,
|
|
1088
|
-
objectResizable,
|
|
1089
|
-
heightBuilder,
|
|
1151
|
+
...options.leaveTracking,
|
|
1090
1152
|
schema: tpaas_schemas_1.LeaveFrontpage.object.objectType,
|
|
1091
1153
|
trackMethod: leaveFrontpageCallback,
|
|
1092
1154
|
});
|
|
@@ -1100,23 +1162,19 @@ class Tracker {
|
|
|
1100
1162
|
*/
|
|
1101
1163
|
async trackViewLandingpage(input, options) {
|
|
1102
1164
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1103
|
-
this.setCurrentPage(input.object.objectId,
|
|
1165
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewLandingpage.object.objectType);
|
|
1104
1166
|
const dependencies = await this.prepareTpaasEvent();
|
|
1105
1167
|
const event = (0, tpaas_event_builder_1.buildViewLandingpageEvent)(input, dependencies);
|
|
1106
1168
|
const result = this.sendTpaasEvent(event);
|
|
1107
1169
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
this.trackLeaveLandingpage({
|
|
1170
|
+
const leaveLandingpageCallback = async (leave) => {
|
|
1171
|
+
await this.trackLeaveLandingpage({
|
|
1111
1172
|
leave,
|
|
1112
1173
|
...input,
|
|
1113
1174
|
});
|
|
1114
1175
|
};
|
|
1115
1176
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1116
|
-
|
|
1117
|
-
pageElement,
|
|
1118
|
-
heightBuilder,
|
|
1119
|
-
objectResizable,
|
|
1177
|
+
...options.leaveTracking,
|
|
1120
1178
|
schema: tpaas_schemas_1.LeaveLandingpage.object.objectType,
|
|
1121
1179
|
trackMethod: leaveLandingpageCallback,
|
|
1122
1180
|
});
|
|
@@ -1135,18 +1193,14 @@ class Tracker {
|
|
|
1135
1193
|
const event = (0, tpaas_event_builder_1.buildViewListingEvent)(input, dependencies);
|
|
1136
1194
|
const result = this.sendTpaasEvent(event);
|
|
1137
1195
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1138
|
-
const
|
|
1139
|
-
|
|
1140
|
-
this.trackLeaveListing({
|
|
1196
|
+
const leaveListingCallback = async (leave) => {
|
|
1197
|
+
await this.trackLeaveListing({
|
|
1141
1198
|
leave,
|
|
1142
1199
|
...input,
|
|
1143
1200
|
});
|
|
1144
1201
|
};
|
|
1145
1202
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1146
|
-
|
|
1147
|
-
pageElement,
|
|
1148
|
-
heightBuilder,
|
|
1149
|
-
objectResizable,
|
|
1203
|
+
...options.leaveTracking,
|
|
1150
1204
|
schema: tpaas_schemas_1.LeaveListing.object.objectType,
|
|
1151
1205
|
trackMethod: leaveListingCallback,
|
|
1152
1206
|
});
|
|
@@ -1165,36 +1219,20 @@ class Tracker {
|
|
|
1165
1219
|
const event = (0, tpaas_event_builder_1.buildViewLockedArticleEvent)(input, dependencies);
|
|
1166
1220
|
const result = this.sendTpaasEvent(event);
|
|
1167
1221
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
this.trackLeaveLockedArticle({
|
|
1222
|
+
const leaveLockedArticleCallback = async (leave) => {
|
|
1223
|
+
await this.trackLeaveLockedArticle({
|
|
1171
1224
|
leave,
|
|
1172
1225
|
...input,
|
|
1173
1226
|
});
|
|
1174
1227
|
};
|
|
1175
1228
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1176
|
-
|
|
1177
|
-
pageElement,
|
|
1178
|
-
objectResizable,
|
|
1179
|
-
heightBuilder,
|
|
1229
|
+
...options.leaveTracking,
|
|
1180
1230
|
schema: tpaas_schemas_1.LeaveLockedArticle.object.objectType,
|
|
1181
1231
|
trackMethod: leaveLockedArticleCallback,
|
|
1182
1232
|
});
|
|
1183
1233
|
}
|
|
1184
1234
|
return result;
|
|
1185
1235
|
}
|
|
1186
|
-
/**
|
|
1187
|
-
* @param input
|
|
1188
|
-
* @param options
|
|
1189
|
-
* @category TPaaS Tracking
|
|
1190
|
-
*/
|
|
1191
|
-
async trackViewLockedAudio(input) {
|
|
1192
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
1193
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
1194
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1195
|
-
const event = (0, tpaas_event_builder_1.buildViewLockedAudioEvent)(input, dependencies);
|
|
1196
|
-
return this.sendTpaasEvent(event);
|
|
1197
|
-
}
|
|
1198
1236
|
/**
|
|
1199
1237
|
* @param input
|
|
1200
1238
|
* @param options
|
|
@@ -1202,40 +1240,25 @@ class Tracker {
|
|
|
1202
1240
|
*/
|
|
1203
1241
|
async trackViewLockedAudioPage(input, options) {
|
|
1204
1242
|
this.newPageView();
|
|
1205
|
-
this.setCurrentPage(input.object.objectId,
|
|
1243
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewLockedAudioPage.object.objectType);
|
|
1206
1244
|
const dependencies = await this.prepareTpaasEvent();
|
|
1207
1245
|
const event = (0, tpaas_event_builder_1.buildViewLockedAudioPageEvent)(input, dependencies);
|
|
1208
1246
|
const result = this.sendTpaasEvent(event);
|
|
1209
1247
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1212
|
-
this.trackLeaveLockedAudioPage({
|
|
1248
|
+
const leaveLockedAudioPageCallback = async (leave) => {
|
|
1249
|
+
await this.trackLeaveLockedAudioPage({
|
|
1213
1250
|
leave,
|
|
1214
1251
|
...input,
|
|
1215
1252
|
});
|
|
1216
1253
|
};
|
|
1217
1254
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1218
|
-
|
|
1219
|
-
pageElement,
|
|
1220
|
-
heightBuilder,
|
|
1221
|
-
objectResizable,
|
|
1255
|
+
...options.leaveTracking,
|
|
1222
1256
|
schema: tpaas_schemas_1.LeaveLockedAudioPage.object.objectType,
|
|
1223
1257
|
trackMethod: leaveLockedAudioPageCallback,
|
|
1224
1258
|
});
|
|
1225
1259
|
}
|
|
1226
1260
|
return result;
|
|
1227
1261
|
}
|
|
1228
|
-
/**
|
|
1229
|
-
* @param input
|
|
1230
|
-
* @category TPaaS Tracking
|
|
1231
|
-
*/
|
|
1232
|
-
async trackViewLockedVideo(input) {
|
|
1233
|
-
// despite the name, this is not a page-level event. trackViewLockedVideoPage is a page-level event
|
|
1234
|
-
// as such, we don't support (yet) automatic leave event enabling
|
|
1235
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1236
|
-
const event = (0, tpaas_event_builder_1.buildViewLockedVideoEvent)(input, dependencies);
|
|
1237
|
-
return this.sendTpaasEvent(event);
|
|
1238
|
-
}
|
|
1239
1262
|
/**
|
|
1240
1263
|
* @param input
|
|
1241
1264
|
* @param options
|
|
@@ -1243,40 +1266,25 @@ class Tracker {
|
|
|
1243
1266
|
*/
|
|
1244
1267
|
async trackViewLockedVideoPage(input, options) {
|
|
1245
1268
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1246
|
-
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.
|
|
1269
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewLockedVideoPage.object.objectType);
|
|
1247
1270
|
const dependencies = await this.prepareTpaasEvent();
|
|
1248
1271
|
const event = (0, tpaas_event_builder_1.buildViewLockedVideoPageEvent)(input, dependencies);
|
|
1249
1272
|
const result = this.sendTpaasEvent(event);
|
|
1250
1273
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1251
|
-
const
|
|
1252
|
-
|
|
1253
|
-
this.trackLeaveLockedVideoPage({
|
|
1274
|
+
const leaveLockedVideoPageCallback = async (leave) => {
|
|
1275
|
+
await this.trackLeaveLockedVideoPage({
|
|
1254
1276
|
leave,
|
|
1255
1277
|
...input,
|
|
1256
1278
|
});
|
|
1257
1279
|
};
|
|
1258
1280
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1259
|
-
|
|
1260
|
-
pageElement,
|
|
1261
|
-
heightBuilder,
|
|
1262
|
-
objectResizable,
|
|
1281
|
+
...options.leaveTracking,
|
|
1263
1282
|
schema: tpaas_schemas_1.LeaveLockedVideoPage.object.objectType,
|
|
1264
1283
|
trackMethod: leaveLockedVideoPageCallback,
|
|
1265
1284
|
});
|
|
1266
1285
|
}
|
|
1267
1286
|
return result;
|
|
1268
1287
|
}
|
|
1269
|
-
/**
|
|
1270
|
-
* @param input
|
|
1271
|
-
* @category TPaaS Tracking
|
|
1272
|
-
*/
|
|
1273
|
-
async trackViewVideo(input) {
|
|
1274
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
1275
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
1276
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1277
|
-
const event = (0, tpaas_event_builder_1.buildViewVideoEvent)(input, dependencies);
|
|
1278
|
-
return this.sendTpaasEvent(event);
|
|
1279
|
-
}
|
|
1280
1288
|
/**
|
|
1281
1289
|
* Tracks a View VideoPage event and automatically fires a Leave VideoPage event when the user
|
|
1282
1290
|
* navigates away.
|
|
@@ -1321,15 +1329,15 @@ class Tracker {
|
|
|
1321
1329
|
*/
|
|
1322
1330
|
async trackViewVideoPage(input, options) {
|
|
1323
1331
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1324
|
-
this.setCurrentPage(input.object.objectId,
|
|
1332
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewVideoPage.object.objectType);
|
|
1325
1333
|
const dependencies = await this.prepareTpaasEvent();
|
|
1326
1334
|
const event = (0, tpaas_event_builder_1.buildViewVideoPageEvent)(input, dependencies);
|
|
1327
1335
|
const result = this.sendTpaasEvent(event);
|
|
1328
1336
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1329
|
-
const {
|
|
1330
|
-
const leaveVideoCallback = (leave) => {
|
|
1337
|
+
const { leaveStoriesBuilder, ...restLeaveTrackingOptions } = options.leaveTracking;
|
|
1338
|
+
const leaveVideoCallback = async (leave) => {
|
|
1331
1339
|
const leaveStoriesInput = leaveStoriesBuilder?.();
|
|
1332
|
-
this.trackLeaveVideoPage({
|
|
1340
|
+
await this.trackLeaveVideoPage({
|
|
1333
1341
|
leave,
|
|
1334
1342
|
leaveStories: leaveStoriesInput && {
|
|
1335
1343
|
...leaveStoriesInput,
|
|
@@ -1340,10 +1348,7 @@ class Tracker {
|
|
|
1340
1348
|
});
|
|
1341
1349
|
};
|
|
1342
1350
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1343
|
-
|
|
1344
|
-
pageElement,
|
|
1345
|
-
heightBuilder,
|
|
1346
|
-
objectResizable,
|
|
1351
|
+
...restLeaveTrackingOptions,
|
|
1347
1352
|
schema: tpaas_schemas_1.LeaveVideoPage.object.objectType,
|
|
1348
1353
|
trackMethod: leaveVideoCallback,
|
|
1349
1354
|
});
|
|
@@ -1357,23 +1362,19 @@ class Tracker {
|
|
|
1357
1362
|
*/
|
|
1358
1363
|
async trackViewWeather(input, options) {
|
|
1359
1364
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1360
|
-
this.setCurrentPage(input.object.objectId,
|
|
1365
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewWeather.object.objectType);
|
|
1361
1366
|
const dependencies = await this.prepareTpaasEvent();
|
|
1362
1367
|
const event = (0, tpaas_event_builder_1.buildViewWeatherEvent)(input, dependencies);
|
|
1363
1368
|
const result = this.sendTpaasEvent(event);
|
|
1364
1369
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
this.trackLeaveWeather({
|
|
1370
|
+
const leaveWeatherCallback = async (leave) => {
|
|
1371
|
+
await this.trackLeaveWeather({
|
|
1368
1372
|
leave,
|
|
1369
1373
|
...input,
|
|
1370
1374
|
});
|
|
1371
1375
|
};
|
|
1372
1376
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1373
|
-
|
|
1374
|
-
pageElement,
|
|
1375
|
-
heightBuilder,
|
|
1376
|
-
objectResizable,
|
|
1377
|
+
...options.leaveTracking,
|
|
1377
1378
|
schema: tpaas_schemas_1.LeaveWeather.object.objectType,
|
|
1378
1379
|
trackMethod: leaveWeatherCallback,
|
|
1379
1380
|
});
|
|
@@ -1443,15 +1444,6 @@ class Tracker {
|
|
|
1443
1444
|
const event = (0, tpaas_event_builder_1.buildLeaveLockedArticleEvent)(input, dependencies);
|
|
1444
1445
|
return this.sendTpaasEvent(event);
|
|
1445
1446
|
}
|
|
1446
|
-
/**
|
|
1447
|
-
* @param input
|
|
1448
|
-
* @category TPaaS Tracking
|
|
1449
|
-
*/
|
|
1450
|
-
async trackLeaveLockedAudio(input) {
|
|
1451
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1452
|
-
const event = (0, tpaas_event_builder_1.buildLeaveLockedAudioEvent)(input, dependencies);
|
|
1453
|
-
return this.sendTpaasEvent(event);
|
|
1454
|
-
}
|
|
1455
1447
|
/**
|
|
1456
1448
|
* @param input
|
|
1457
1449
|
* @category TPaaS Tracking
|
|
@@ -1465,27 +1457,27 @@ class Tracker {
|
|
|
1465
1457
|
* @param input
|
|
1466
1458
|
* @category TPaaS Tracking
|
|
1467
1459
|
*/
|
|
1468
|
-
async
|
|
1460
|
+
async trackLeaveLockedVideoPage(input) {
|
|
1469
1461
|
const dependencies = await this.prepareTpaasEvent();
|
|
1470
|
-
const event = (0, tpaas_event_builder_1.
|
|
1462
|
+
const event = (0, tpaas_event_builder_1.buildLeaveLockedVideoPageEvent)(input, dependencies);
|
|
1471
1463
|
return this.sendTpaasEvent(event);
|
|
1472
1464
|
}
|
|
1473
1465
|
/**
|
|
1474
1466
|
* @param input
|
|
1475
1467
|
* @category TPaaS Tracking
|
|
1476
1468
|
*/
|
|
1477
|
-
async
|
|
1469
|
+
async trackLeavePage(input) {
|
|
1478
1470
|
const dependencies = await this.prepareTpaasEvent();
|
|
1479
|
-
const event = (0, tpaas_event_builder_1.
|
|
1471
|
+
const event = (0, tpaas_event_builder_1.buildLeavePageEvent)(input, dependencies);
|
|
1480
1472
|
return this.sendTpaasEvent(event);
|
|
1481
1473
|
}
|
|
1482
1474
|
/**
|
|
1483
1475
|
* @param input
|
|
1484
1476
|
* @category TPaaS Tracking
|
|
1485
1477
|
*/
|
|
1486
|
-
async
|
|
1478
|
+
async trackLeaveSportsPage(input) {
|
|
1487
1479
|
const dependencies = await this.prepareTpaasEvent();
|
|
1488
|
-
const event = (0, tpaas_event_builder_1.
|
|
1480
|
+
const event = (0, tpaas_event_builder_1.buildLeaveSportsPageEvent)(input, dependencies);
|
|
1489
1481
|
return this.sendTpaasEvent(event);
|
|
1490
1482
|
}
|
|
1491
1483
|
/**
|
|
@@ -2221,8 +2213,8 @@ class Tracker {
|
|
|
2221
2213
|
* with the added guarantee that a second Leave event will not be triggered if one already has been sent.
|
|
2222
2214
|
* @category TPaaS Leave Tracking
|
|
2223
2215
|
*/
|
|
2224
|
-
trackTpaasActiveLeave() {
|
|
2225
|
-
(0, leaveTrackingTpaas_1.trackTpaasActiveLeave)();
|
|
2216
|
+
async trackTpaasActiveLeave() {
|
|
2217
|
+
await (0, leaveTrackingTpaas_1.trackTpaasActiveLeave)();
|
|
2226
2218
|
}
|
|
2227
2219
|
/**
|
|
2228
2220
|
* Check if leave tracking is enabled (if an event will be sent when the user leaves the page)
|