@schibsted/pulse-sdk 8.0.0-rc.1 → 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 +169 -216
- 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-node.js +3 -3
- package/dist/cjs/builders/experiments.js +1 -0
- package/dist/cjs/identity/actor.js +18 -6
- package/dist/cjs/identity/cis.js +2 -1
- 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 +1 -1
- package/dist/cjs/visibility-observer/index.js +9 -7
- package/dist/cjs/wrapper/types/event.js +5 -0
- package/dist/ejs/Tracker.js +171 -218
- 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-node.js +3 -3
- package/dist/ejs/builders/experiments.js +1 -1
- package/dist/ejs/identity/actor.js +19 -7
- package/dist/ejs/identity/cis.js +2 -1
- 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 +1 -1
- package/dist/ejs/visibility-observer/index.js +9 -7
- package/dist/ejs/wrapper/types/event.js +4 -1
- package/dist/types/Tracker.d.ts +86 -92
- 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 -1
- package/dist/types/visibility-observer/index.d.ts +6 -1
- package/dist/types/wrapper/types/event.d.ts +3 -1
- 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 +69 -78
- 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 +70 -73
- 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 +1561 -1190
- package/node_modules/@schibsted/tpaas-event-builder/package.json +3 -2
- package/node_modules/@schibsted/tpaas-schemas/dist/cjs/constants.js +93 -107
- 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 +91 -105
- 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 +1654 -1288
- package/node_modules/@schibsted/tpaas-schemas/package.json +1 -1
- package/package.json +6 -6
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");
|
|
@@ -68,6 +69,7 @@ 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,6 +285,8 @@ 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
292
|
version: version_1.SDK_VERSION,
|
|
@@ -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
|
}
|
|
@@ -454,11 +503,12 @@ class Tracker {
|
|
|
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,10 +568,11 @@ 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 {
|
|
@@ -531,29 +582,15 @@ class Tracker {
|
|
|
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
|
});
|
|
@@ -847,23 +910,19 @@ class Tracker {
|
|
|
847
910
|
*/
|
|
848
911
|
async trackViewSportsPage(input, options) {
|
|
849
912
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
850
|
-
this.setCurrentPage(input.object.objectId,
|
|
913
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewSportsPage.object.objectType);
|
|
851
914
|
const dependencies = await this.prepareTpaasEvent();
|
|
852
915
|
const event = (0, tpaas_event_builder_1.buildViewSportsPageEvent)(input, dependencies);
|
|
853
916
|
const result = this.sendTpaasEvent(event);
|
|
854
917
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
this.trackLeaveSportsPage({
|
|
918
|
+
const leaveSportsPageCallback = async (leave) => {
|
|
919
|
+
await this.trackLeaveSportsPage({
|
|
858
920
|
leave,
|
|
859
921
|
...input,
|
|
860
922
|
});
|
|
861
923
|
};
|
|
862
924
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
863
|
-
|
|
864
|
-
pageElement,
|
|
865
|
-
objectResizable,
|
|
866
|
-
heightBuilder,
|
|
925
|
+
...options.leaveTracking,
|
|
867
926
|
schema: tpaas_schemas_1.LeaveSportsPage.object.objectType,
|
|
868
927
|
trackMethod: leaveSportsPageCallback,
|
|
869
928
|
});
|
|
@@ -891,15 +950,6 @@ class Tracker {
|
|
|
891
950
|
const event = (0, tpaas_event_builder_1.buildImpressionWidgetEvent)(input, dependencies);
|
|
892
951
|
return this.sendTpaasEvent(event);
|
|
893
952
|
}
|
|
894
|
-
/**
|
|
895
|
-
* @param input
|
|
896
|
-
* @category TPaaS Tracking
|
|
897
|
-
*/
|
|
898
|
-
async trackImpressionAdSlot(input) {
|
|
899
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
900
|
-
const event = (0, tpaas_event_builder_1.buildImpressionAdSlotEvent)(input, dependencies);
|
|
901
|
-
return this.sendTpaasEvent(event);
|
|
902
|
-
}
|
|
903
953
|
/**
|
|
904
954
|
* @param input
|
|
905
955
|
* @param options
|
|
@@ -912,36 +962,20 @@ class Tracker {
|
|
|
912
962
|
const event = (0, tpaas_event_builder_1.buildViewArticleEvent)(input, dependencies);
|
|
913
963
|
const result = this.sendTpaasEvent(event);
|
|
914
964
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
this.trackLeaveArticle({
|
|
965
|
+
const leaveArticleCallback = async (leave) => {
|
|
966
|
+
await this.trackLeaveArticle({
|
|
918
967
|
leave,
|
|
919
968
|
...input,
|
|
920
969
|
});
|
|
921
970
|
};
|
|
922
971
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
923
|
-
|
|
924
|
-
pageElement,
|
|
925
|
-
heightBuilder,
|
|
926
|
-
objectResizable,
|
|
972
|
+
...options.leaveTracking,
|
|
927
973
|
schema: tpaas_schemas_1.LeaveArticle.object.objectType,
|
|
928
974
|
trackMethod: leaveArticleCallback,
|
|
929
975
|
});
|
|
930
976
|
}
|
|
931
977
|
return result;
|
|
932
978
|
}
|
|
933
|
-
/**
|
|
934
|
-
* @param input
|
|
935
|
-
* @param options
|
|
936
|
-
* @category TPaaS Tracking
|
|
937
|
-
*/
|
|
938
|
-
async trackViewAudio(input) {
|
|
939
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
940
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
941
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
942
|
-
const event = (0, tpaas_event_builder_1.buildViewAudioEvent)(input, dependencies);
|
|
943
|
-
return this.sendTpaasEvent(event);
|
|
944
|
-
}
|
|
945
979
|
/**
|
|
946
980
|
* Tracks a View AudioPage event and automatically fires a Leave AudioPage event when the user
|
|
947
981
|
* navigates away.
|
|
@@ -984,20 +1018,20 @@ class Tracker {
|
|
|
984
1018
|
*/
|
|
985
1019
|
async trackViewAudioPage(input, options) {
|
|
986
1020
|
this.newPageView();
|
|
987
|
-
this.setCurrentPage(input.object.objectId,
|
|
1021
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewAudioPage.object.objectType);
|
|
988
1022
|
const dependencies = await this.prepareTpaasEvent();
|
|
989
1023
|
const event = (0, tpaas_event_builder_1.buildViewAudioPageEvent)(input, dependencies);
|
|
990
1024
|
const result = this.sendTpaasEvent(event);
|
|
991
1025
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
992
|
-
const {
|
|
993
|
-
const leaveAudioPageCallback = (leave) => {
|
|
1026
|
+
const { leaveAudioBuilder, ...restLeaveTrackingOptions } = options.leaveTracking;
|
|
1027
|
+
const leaveAudioPageCallback = async (leave) => {
|
|
994
1028
|
const leaveAudioInput = leaveAudioBuilder?.() ?? {
|
|
995
1029
|
audioCompleted: 0,
|
|
996
1030
|
audioStarted: 0,
|
|
997
1031
|
maxPlaylistPosition: 0,
|
|
998
1032
|
playlistPositionPercentage: 0,
|
|
999
1033
|
};
|
|
1000
|
-
this.trackLeaveAudioPage({
|
|
1034
|
+
await this.trackLeaveAudioPage({
|
|
1001
1035
|
leave,
|
|
1002
1036
|
leaveAudio: {
|
|
1003
1037
|
...leaveAudioInput,
|
|
@@ -1008,10 +1042,7 @@ class Tracker {
|
|
|
1008
1042
|
});
|
|
1009
1043
|
};
|
|
1010
1044
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1011
|
-
|
|
1012
|
-
pageElement,
|
|
1013
|
-
heightBuilder,
|
|
1014
|
-
objectResizable,
|
|
1045
|
+
...restLeaveTrackingOptions,
|
|
1015
1046
|
schema: tpaas_schemas_1.LeaveAudioPage.object.objectType,
|
|
1016
1047
|
trackMethod: leaveAudioPageCallback,
|
|
1017
1048
|
});
|
|
@@ -1030,24 +1061,29 @@ class Tracker {
|
|
|
1030
1061
|
const event = (0, tpaas_event_builder_1.buildViewErrorEvent)(input, dependencies);
|
|
1031
1062
|
const result = this.sendTpaasEvent(event);
|
|
1032
1063
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1035
|
-
this.trackLeaveError({
|
|
1064
|
+
const leaveErrorCallback = async (leave) => {
|
|
1065
|
+
await this.trackLeaveError({
|
|
1036
1066
|
leave,
|
|
1037
1067
|
...input,
|
|
1038
1068
|
});
|
|
1039
1069
|
};
|
|
1040
1070
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1041
|
-
|
|
1042
|
-
pageElement,
|
|
1043
|
-
heightBuilder,
|
|
1044
|
-
objectResizable,
|
|
1071
|
+
...options.leaveTracking,
|
|
1045
1072
|
schema: tpaas_schemas_1.LeaveError.object.objectType,
|
|
1046
1073
|
trackMethod: leaveErrorCallback,
|
|
1047
1074
|
});
|
|
1048
1075
|
}
|
|
1049
1076
|
return result;
|
|
1050
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
|
+
}
|
|
1051
1087
|
/**
|
|
1052
1088
|
* @param input
|
|
1053
1089
|
* @category TPaaS Tracking
|
|
@@ -1105,18 +1141,14 @@ class Tracker {
|
|
|
1105
1141
|
const event = (0, tpaas_event_builder_1.buildViewFrontpageEvent)(input, dependencies);
|
|
1106
1142
|
const result = this.sendTpaasEvent(event);
|
|
1107
1143
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
this.trackLeaveFrontpage({
|
|
1144
|
+
const leaveFrontpageCallback = async (leave) => {
|
|
1145
|
+
await this.trackLeaveFrontpage({
|
|
1111
1146
|
leave,
|
|
1112
1147
|
...input,
|
|
1113
1148
|
});
|
|
1114
1149
|
};
|
|
1115
1150
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1116
|
-
|
|
1117
|
-
pageElement,
|
|
1118
|
-
objectResizable,
|
|
1119
|
-
heightBuilder,
|
|
1151
|
+
...options.leaveTracking,
|
|
1120
1152
|
schema: tpaas_schemas_1.LeaveFrontpage.object.objectType,
|
|
1121
1153
|
trackMethod: leaveFrontpageCallback,
|
|
1122
1154
|
});
|
|
@@ -1130,23 +1162,19 @@ class Tracker {
|
|
|
1130
1162
|
*/
|
|
1131
1163
|
async trackViewLandingpage(input, options) {
|
|
1132
1164
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1133
|
-
this.setCurrentPage(input.object.objectId,
|
|
1165
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewLandingpage.object.objectType);
|
|
1134
1166
|
const dependencies = await this.prepareTpaasEvent();
|
|
1135
1167
|
const event = (0, tpaas_event_builder_1.buildViewLandingpageEvent)(input, dependencies);
|
|
1136
1168
|
const result = this.sendTpaasEvent(event);
|
|
1137
1169
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1138
|
-
const
|
|
1139
|
-
|
|
1140
|
-
this.trackLeaveLandingpage({
|
|
1170
|
+
const leaveLandingpageCallback = async (leave) => {
|
|
1171
|
+
await this.trackLeaveLandingpage({
|
|
1141
1172
|
leave,
|
|
1142
1173
|
...input,
|
|
1143
1174
|
});
|
|
1144
1175
|
};
|
|
1145
1176
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1146
|
-
|
|
1147
|
-
pageElement,
|
|
1148
|
-
heightBuilder,
|
|
1149
|
-
objectResizable,
|
|
1177
|
+
...options.leaveTracking,
|
|
1150
1178
|
schema: tpaas_schemas_1.LeaveLandingpage.object.objectType,
|
|
1151
1179
|
trackMethod: leaveLandingpageCallback,
|
|
1152
1180
|
});
|
|
@@ -1165,18 +1193,14 @@ class Tracker {
|
|
|
1165
1193
|
const event = (0, tpaas_event_builder_1.buildViewListingEvent)(input, dependencies);
|
|
1166
1194
|
const result = this.sendTpaasEvent(event);
|
|
1167
1195
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
this.trackLeaveListing({
|
|
1196
|
+
const leaveListingCallback = async (leave) => {
|
|
1197
|
+
await this.trackLeaveListing({
|
|
1171
1198
|
leave,
|
|
1172
1199
|
...input,
|
|
1173
1200
|
});
|
|
1174
1201
|
};
|
|
1175
1202
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1176
|
-
|
|
1177
|
-
pageElement,
|
|
1178
|
-
heightBuilder,
|
|
1179
|
-
objectResizable,
|
|
1203
|
+
...options.leaveTracking,
|
|
1180
1204
|
schema: tpaas_schemas_1.LeaveListing.object.objectType,
|
|
1181
1205
|
trackMethod: leaveListingCallback,
|
|
1182
1206
|
});
|
|
@@ -1195,36 +1219,20 @@ class Tracker {
|
|
|
1195
1219
|
const event = (0, tpaas_event_builder_1.buildViewLockedArticleEvent)(input, dependencies);
|
|
1196
1220
|
const result = this.sendTpaasEvent(event);
|
|
1197
1221
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
this.trackLeaveLockedArticle({
|
|
1222
|
+
const leaveLockedArticleCallback = async (leave) => {
|
|
1223
|
+
await this.trackLeaveLockedArticle({
|
|
1201
1224
|
leave,
|
|
1202
1225
|
...input,
|
|
1203
1226
|
});
|
|
1204
1227
|
};
|
|
1205
1228
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1206
|
-
|
|
1207
|
-
pageElement,
|
|
1208
|
-
objectResizable,
|
|
1209
|
-
heightBuilder,
|
|
1229
|
+
...options.leaveTracking,
|
|
1210
1230
|
schema: tpaas_schemas_1.LeaveLockedArticle.object.objectType,
|
|
1211
1231
|
trackMethod: leaveLockedArticleCallback,
|
|
1212
1232
|
});
|
|
1213
1233
|
}
|
|
1214
1234
|
return result;
|
|
1215
1235
|
}
|
|
1216
|
-
/**
|
|
1217
|
-
* @param input
|
|
1218
|
-
* @param options
|
|
1219
|
-
* @category TPaaS Tracking
|
|
1220
|
-
*/
|
|
1221
|
-
async trackViewLockedAudio(input) {
|
|
1222
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
1223
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
1224
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1225
|
-
const event = (0, tpaas_event_builder_1.buildViewLockedAudioEvent)(input, dependencies);
|
|
1226
|
-
return this.sendTpaasEvent(event);
|
|
1227
|
-
}
|
|
1228
1236
|
/**
|
|
1229
1237
|
* @param input
|
|
1230
1238
|
* @param options
|
|
@@ -1232,40 +1240,25 @@ class Tracker {
|
|
|
1232
1240
|
*/
|
|
1233
1241
|
async trackViewLockedAudioPage(input, options) {
|
|
1234
1242
|
this.newPageView();
|
|
1235
|
-
this.setCurrentPage(input.object.objectId,
|
|
1243
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewLockedAudioPage.object.objectType);
|
|
1236
1244
|
const dependencies = await this.prepareTpaasEvent();
|
|
1237
1245
|
const event = (0, tpaas_event_builder_1.buildViewLockedAudioPageEvent)(input, dependencies);
|
|
1238
1246
|
const result = this.sendTpaasEvent(event);
|
|
1239
1247
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
this.trackLeaveLockedAudioPage({
|
|
1248
|
+
const leaveLockedAudioPageCallback = async (leave) => {
|
|
1249
|
+
await this.trackLeaveLockedAudioPage({
|
|
1243
1250
|
leave,
|
|
1244
1251
|
...input,
|
|
1245
1252
|
});
|
|
1246
1253
|
};
|
|
1247
1254
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1248
|
-
|
|
1249
|
-
pageElement,
|
|
1250
|
-
heightBuilder,
|
|
1251
|
-
objectResizable,
|
|
1255
|
+
...options.leaveTracking,
|
|
1252
1256
|
schema: tpaas_schemas_1.LeaveLockedAudioPage.object.objectType,
|
|
1253
1257
|
trackMethod: leaveLockedAudioPageCallback,
|
|
1254
1258
|
});
|
|
1255
1259
|
}
|
|
1256
1260
|
return result;
|
|
1257
1261
|
}
|
|
1258
|
-
/**
|
|
1259
|
-
* @param input
|
|
1260
|
-
* @category TPaaS Tracking
|
|
1261
|
-
*/
|
|
1262
|
-
async trackViewLockedVideo(input) {
|
|
1263
|
-
// despite the name, this is not a page-level event. trackViewLockedVideoPage is a page-level event
|
|
1264
|
-
// as such, we don't support (yet) automatic leave event enabling
|
|
1265
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1266
|
-
const event = (0, tpaas_event_builder_1.buildViewLockedVideoEvent)(input, dependencies);
|
|
1267
|
-
return this.sendTpaasEvent(event);
|
|
1268
|
-
}
|
|
1269
1262
|
/**
|
|
1270
1263
|
* @param input
|
|
1271
1264
|
* @param options
|
|
@@ -1273,40 +1266,25 @@ class Tracker {
|
|
|
1273
1266
|
*/
|
|
1274
1267
|
async trackViewLockedVideoPage(input, options) {
|
|
1275
1268
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1276
|
-
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.
|
|
1269
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewLockedVideoPage.object.objectType);
|
|
1277
1270
|
const dependencies = await this.prepareTpaasEvent();
|
|
1278
1271
|
const event = (0, tpaas_event_builder_1.buildViewLockedVideoPageEvent)(input, dependencies);
|
|
1279
1272
|
const result = this.sendTpaasEvent(event);
|
|
1280
1273
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1281
|
-
const
|
|
1282
|
-
|
|
1283
|
-
this.trackLeaveLockedVideoPage({
|
|
1274
|
+
const leaveLockedVideoPageCallback = async (leave) => {
|
|
1275
|
+
await this.trackLeaveLockedVideoPage({
|
|
1284
1276
|
leave,
|
|
1285
1277
|
...input,
|
|
1286
1278
|
});
|
|
1287
1279
|
};
|
|
1288
1280
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1289
|
-
|
|
1290
|
-
pageElement,
|
|
1291
|
-
heightBuilder,
|
|
1292
|
-
objectResizable,
|
|
1281
|
+
...options.leaveTracking,
|
|
1293
1282
|
schema: tpaas_schemas_1.LeaveLockedVideoPage.object.objectType,
|
|
1294
1283
|
trackMethod: leaveLockedVideoPageCallback,
|
|
1295
1284
|
});
|
|
1296
1285
|
}
|
|
1297
1286
|
return result;
|
|
1298
1287
|
}
|
|
1299
|
-
/**
|
|
1300
|
-
* @param input
|
|
1301
|
-
* @category TPaaS Tracking
|
|
1302
|
-
*/
|
|
1303
|
-
async trackViewVideo(input) {
|
|
1304
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
1305
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
1306
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1307
|
-
const event = (0, tpaas_event_builder_1.buildViewVideoEvent)(input, dependencies);
|
|
1308
|
-
return this.sendTpaasEvent(event);
|
|
1309
|
-
}
|
|
1310
1288
|
/**
|
|
1311
1289
|
* Tracks a View VideoPage event and automatically fires a Leave VideoPage event when the user
|
|
1312
1290
|
* navigates away.
|
|
@@ -1351,15 +1329,15 @@ class Tracker {
|
|
|
1351
1329
|
*/
|
|
1352
1330
|
async trackViewVideoPage(input, options) {
|
|
1353
1331
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1354
|
-
this.setCurrentPage(input.object.objectId,
|
|
1332
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewVideoPage.object.objectType);
|
|
1355
1333
|
const dependencies = await this.prepareTpaasEvent();
|
|
1356
1334
|
const event = (0, tpaas_event_builder_1.buildViewVideoPageEvent)(input, dependencies);
|
|
1357
1335
|
const result = this.sendTpaasEvent(event);
|
|
1358
1336
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1359
|
-
const {
|
|
1360
|
-
const leaveVideoCallback = (leave) => {
|
|
1337
|
+
const { leaveStoriesBuilder, ...restLeaveTrackingOptions } = options.leaveTracking;
|
|
1338
|
+
const leaveVideoCallback = async (leave) => {
|
|
1361
1339
|
const leaveStoriesInput = leaveStoriesBuilder?.();
|
|
1362
|
-
this.trackLeaveVideoPage({
|
|
1340
|
+
await this.trackLeaveVideoPage({
|
|
1363
1341
|
leave,
|
|
1364
1342
|
leaveStories: leaveStoriesInput && {
|
|
1365
1343
|
...leaveStoriesInput,
|
|
@@ -1370,10 +1348,7 @@ class Tracker {
|
|
|
1370
1348
|
});
|
|
1371
1349
|
};
|
|
1372
1350
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1373
|
-
|
|
1374
|
-
pageElement,
|
|
1375
|
-
heightBuilder,
|
|
1376
|
-
objectResizable,
|
|
1351
|
+
...restLeaveTrackingOptions,
|
|
1377
1352
|
schema: tpaas_schemas_1.LeaveVideoPage.object.objectType,
|
|
1378
1353
|
trackMethod: leaveVideoCallback,
|
|
1379
1354
|
});
|
|
@@ -1387,23 +1362,19 @@ class Tracker {
|
|
|
1387
1362
|
*/
|
|
1388
1363
|
async trackViewWeather(input, options) {
|
|
1389
1364
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1390
|
-
this.setCurrentPage(input.object.objectId,
|
|
1365
|
+
this.setCurrentPage(input.object.objectId, tpaas_schemas_1.ViewWeather.object.objectType);
|
|
1391
1366
|
const dependencies = await this.prepareTpaasEvent();
|
|
1392
1367
|
const event = (0, tpaas_event_builder_1.buildViewWeatherEvent)(input, dependencies);
|
|
1393
1368
|
const result = this.sendTpaasEvent(event);
|
|
1394
1369
|
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1397
|
-
this.trackLeaveWeather({
|
|
1370
|
+
const leaveWeatherCallback = async (leave) => {
|
|
1371
|
+
await this.trackLeaveWeather({
|
|
1398
1372
|
leave,
|
|
1399
1373
|
...input,
|
|
1400
1374
|
});
|
|
1401
1375
|
};
|
|
1402
1376
|
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1403
|
-
|
|
1404
|
-
pageElement,
|
|
1405
|
-
heightBuilder,
|
|
1406
|
-
objectResizable,
|
|
1377
|
+
...options.leaveTracking,
|
|
1407
1378
|
schema: tpaas_schemas_1.LeaveWeather.object.objectType,
|
|
1408
1379
|
trackMethod: leaveWeatherCallback,
|
|
1409
1380
|
});
|
|
@@ -1473,15 +1444,6 @@ class Tracker {
|
|
|
1473
1444
|
const event = (0, tpaas_event_builder_1.buildLeaveLockedArticleEvent)(input, dependencies);
|
|
1474
1445
|
return this.sendTpaasEvent(event);
|
|
1475
1446
|
}
|
|
1476
|
-
/**
|
|
1477
|
-
* @param input
|
|
1478
|
-
* @category TPaaS Tracking
|
|
1479
|
-
*/
|
|
1480
|
-
async trackLeaveLockedAudio(input) {
|
|
1481
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1482
|
-
const event = (0, tpaas_event_builder_1.buildLeaveLockedAudioEvent)(input, dependencies);
|
|
1483
|
-
return this.sendTpaasEvent(event);
|
|
1484
|
-
}
|
|
1485
1447
|
/**
|
|
1486
1448
|
* @param input
|
|
1487
1449
|
* @category TPaaS Tracking
|
|
@@ -1491,15 +1453,6 @@ class Tracker {
|
|
|
1491
1453
|
const event = (0, tpaas_event_builder_1.buildLeaveLockedAudioPageEvent)(input, dependencies);
|
|
1492
1454
|
return this.sendTpaasEvent(event);
|
|
1493
1455
|
}
|
|
1494
|
-
/**
|
|
1495
|
-
* @param input
|
|
1496
|
-
* @category TPaaS Tracking
|
|
1497
|
-
*/
|
|
1498
|
-
async trackLeaveLockedVideo(input) {
|
|
1499
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1500
|
-
const event = (0, tpaas_event_builder_1.buildLeaveLockedVideoEvent)(input, dependencies);
|
|
1501
|
-
return this.sendTpaasEvent(event);
|
|
1502
|
-
}
|
|
1503
1456
|
/**
|
|
1504
1457
|
* @param input
|
|
1505
1458
|
* @category TPaaS Tracking
|
|
@@ -2260,8 +2213,8 @@ class Tracker {
|
|
|
2260
2213
|
* with the added guarantee that a second Leave event will not be triggered if one already has been sent.
|
|
2261
2214
|
* @category TPaaS Leave Tracking
|
|
2262
2215
|
*/
|
|
2263
|
-
trackTpaasActiveLeave() {
|
|
2264
|
-
(0, leaveTrackingTpaas_1.trackTpaasActiveLeave)();
|
|
2216
|
+
async trackTpaasActiveLeave() {
|
|
2217
|
+
await (0, leaveTrackingTpaas_1.trackTpaasActiveLeave)();
|
|
2265
2218
|
}
|
|
2266
2219
|
/**
|
|
2267
2220
|
* Check if leave tracking is enabled (if an event will be sent when the user leaves the page)
|