@schibsted/pulse-sdk 8.0.0-rc.17 → 8.0.0-rc.19
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 +280 -80
- package/dist/cjs/tpaas-builders/builders/pageContent.js +7 -0
- package/dist/cjs/tpaas-builders/builders/pageSports.js +7 -0
- package/dist/cjs/tpaas-builders/builders/provider.js +4 -1
- package/dist/cjs/tpaas-builders/builders/trackerBuilder.js +1 -3
- package/dist/cjs/tpaas-builders/builders.js +63 -27
- package/dist/cjs/tpaas-schemas/constants.js +115 -95
- package/dist/cjs/tracker-proxy/consts.js +8 -0
- package/dist/cjs/version.js +1 -1
- package/dist/ejs/Tracker.js +282 -82
- package/dist/ejs/tpaas-builders/builders/pageContent.js +3 -0
- package/dist/ejs/tpaas-builders/builders/pageSports.js +3 -0
- package/dist/ejs/tpaas-builders/builders/provider.js +4 -1
- package/dist/ejs/tpaas-builders/builders/trackerBuilder.js +1 -3
- package/dist/ejs/tpaas-builders/builders.js +56 -28
- package/dist/ejs/tpaas-schemas/constants.js +113 -93
- package/dist/ejs/tracker-proxy/consts.js +8 -0
- package/dist/ejs/version.js +1 -1
- package/dist/types/Tracker.d.ts +62 -17
- package/dist/types/createPulseTracker.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/pageContent.d.ts +6 -0
- package/dist/types/tpaas-builders/builders/pageSports.d.ts +6 -0
- package/dist/types/tpaas-builders/builders/provider.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/trackerBuilder.d.ts +1 -1
- package/dist/types/tpaas-builders/builders.d.ts +13 -4
- package/dist/types/tpaas-builders/types.d.ts +7 -3
- package/dist/types/tpaas-schemas/constants.d.ts +113 -59
- package/dist/types/tpaas-schemas/types/ITpaasEvent.d.ts +16 -0
- package/dist/types/tpaas-schemas/types/schemas/ICompletedHealthAction.d.ts +0 -5
- package/dist/types/tpaas-schemas/types/schemas/IEngagementAffiliate.d.ts +5 -1
- package/dist/types/tpaas-schemas/types/schemas/IEngagementAudio.d.ts +0 -4
- package/dist/types/tpaas-schemas/types/schemas/IEngagementHealthUIElement.d.ts +0 -5
- package/dist/types/tpaas-schemas/types/schemas/IEngagementSchoolUIElement.d.ts +107 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementSportsUIElement.d.ts +157 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementVideo.d.ts +2 -9
- package/dist/types/tpaas-schemas/types/schemas/IImpressionAffiliate.d.ts +5 -1
- package/dist/types/tpaas-schemas/types/schemas/IImpressionHealthUIElement.d.ts +0 -5
- package/dist/types/tpaas-schemas/types/schemas/IImpressionPlayer.d.ts +5 -1
- package/dist/types/tpaas-schemas/types/schemas/IImpressionSchoolUIElement.d.ts +109 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionSportsUIElement.d.ts +159 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveListing.d.ts +1 -1
- package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedPage.d.ts +90 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveSchoolPage.d.ts +84 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveSportsPage.d.ts +47 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewHealthPage.d.ts +0 -5
- package/dist/types/tpaas-schemas/types/schemas/IViewListing.d.ts +1 -1
- package/dist/types/tpaas-schemas/types/schemas/IViewLockedPage.d.ts +94 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewSchoolPage.d.ts +88 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewSportsPage.d.ts +47 -0
- package/dist/types/tpaas-schemas/types/schemas/index.d.ts +8 -0
- package/dist/types/tpaas-schemas/types/templates/ILeaveStories.d.ts +0 -10
- package/dist/types/tpaas-schemas/types/templates/IPageRef.d.ts +1 -0
- package/dist/types/tpaas-schemas/types/templates/ISchool.d.ts +73 -0
- package/dist/types/tpaas-schemas/types/templates/ISession.d.ts +1 -1
- package/dist/types/tpaas-schemas/types/templates/ISports.d.ts +0 -61
- package/dist/types/tpaas-schemas/types/templates/ISportsUserFeatures.d.ts +28 -0
- package/dist/types/tpaas-schemas/types/templates/ITracker.d.ts +0 -10
- package/dist/types/tpaas-schemas/types/templates/index.d.ts +2 -0
- package/dist/types/tpaas-schemas/types.d.ts +3 -3
- package/dist/types/tracker-proxy/consts.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/Tracker.js
CHANGED
|
@@ -172,12 +172,12 @@ function unsubscribe(eventName, callback) {
|
|
|
172
172
|
* @class Tracker
|
|
173
173
|
*/
|
|
174
174
|
class Tracker {
|
|
175
|
-
async getCurrentTpaasPage() {
|
|
176
|
-
const { id, type, url } = await
|
|
175
|
+
async getCurrentTpaasPage(currentPageInfo = this.currentPageContext.info) {
|
|
176
|
+
const { id, type, url } = await currentPageInfo;
|
|
177
177
|
return (0, map_page_to_page_ref_1.mapPageToPageRef)(id, type, url);
|
|
178
178
|
}
|
|
179
179
|
async getCurrentLegacyPage() {
|
|
180
|
-
const { id, type, url } = await this.
|
|
180
|
+
const { id, type, url } = await this.currentPageContext.info;
|
|
181
181
|
// make sure the pageType is valid for legacy events
|
|
182
182
|
const validatedType = (0, types_1.isLegacyPageType)(type) ? type : 'Page';
|
|
183
183
|
return {
|
|
@@ -206,37 +206,33 @@ class Tracker {
|
|
|
206
206
|
this.legacyVisibilityObservers = new Map();
|
|
207
207
|
this.visibilityObservers = new Map();
|
|
208
208
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* This is used as the source of truth for the current page's information, which is updated based on the View Page-level event
|
|
212
|
-
* 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.
|
|
213
|
-
* Legacy events can provide an id with SDRN, while TPaaS events don't need it
|
|
214
|
-
*/
|
|
215
|
-
this.currentPageInfo = {
|
|
216
|
-
id: 'unknown',
|
|
217
|
-
type: 'Page',
|
|
218
|
-
url: utils_1.isBrowser ? window.location.href : undefined,
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* @private
|
|
222
|
-
*
|
|
223
|
-
* This is used as the source of truth for the current page's referrer information, which is updated based on the View Page-level event
|
|
224
|
-
* !! This is only used in TPaaS events and contexts, as we don't want to risk changing the behaviour of legacy events
|
|
225
|
-
* This is also the reason this is being kept as a separate variable from the currentPageInfo property,
|
|
226
|
-
* which is used for both legacy and TPaaS events
|
|
209
|
+
* Current page state shared by legacy and TPaaS tracking. See CurrentPageContext for
|
|
210
|
+
* which properties are shared and which are exclusively TPaaS metadata.
|
|
227
211
|
*/
|
|
228
|
-
this.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
this.currentPageInfo = {
|
|
233
|
-
id: id || 'unknown',
|
|
234
|
-
type: type || 'Page',
|
|
212
|
+
this.currentPageContext = {
|
|
213
|
+
info: {
|
|
214
|
+
id: 'unknown',
|
|
215
|
+
type: 'Page',
|
|
235
216
|
url: utils_1.isBrowser ? window.location.href : undefined,
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
217
|
+
},
|
|
218
|
+
referrer: {
|
|
219
|
+
url: utils_1.isBrowser ? document.referrer || undefined : undefined,
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
this.setCurrentTpaasPageData = ({ id, type, referrer, content, sports, }) => {
|
|
223
|
+
// TPaaS Views replace the context, intentionally resetting omitted content and sports.
|
|
224
|
+
this.currentPageContext = {
|
|
225
|
+
info: {
|
|
226
|
+
id: id || 'unknown',
|
|
227
|
+
type: type || 'Page',
|
|
228
|
+
url: utils_1.isBrowser ? window.location.href : undefined,
|
|
229
|
+
},
|
|
230
|
+
referrer: {
|
|
231
|
+
...referrer,
|
|
232
|
+
url: referrer?.url ?? (utils_1.isBrowser ? document.referrer || undefined : undefined),
|
|
233
|
+
},
|
|
234
|
+
content,
|
|
235
|
+
sports,
|
|
240
236
|
};
|
|
241
237
|
};
|
|
242
238
|
/**
|
|
@@ -250,8 +246,9 @@ class Tracker {
|
|
|
250
246
|
*/
|
|
251
247
|
this.hasProxyListener = false;
|
|
252
248
|
this.setPageDefaults = (pageViewEvent) => {
|
|
253
|
-
|
|
254
|
-
this.
|
|
249
|
+
// Legacy Views update only the shared properties, preserving TPaaS-only content and sports.
|
|
250
|
+
this.currentPageContext.info = (0, page_from_page_view_1.pageFromPageView)(pageViewEvent);
|
|
251
|
+
this.currentPageContext.referrer = Promise.resolve(pageViewEvent.origin).then((originProperties) => (0, map_page_to_page_ref_1.mapPageToPageRef)(originProperties?.id, originProperties?.type, originProperties?.url));
|
|
255
252
|
if (pageViewEvent.origin) {
|
|
256
253
|
const pageDefaults = { origin: pageViewEvent.origin };
|
|
257
254
|
this.update(pageDefaults, true);
|
|
@@ -517,6 +514,11 @@ class Tracker {
|
|
|
517
514
|
* @category TPaaS Tracking
|
|
518
515
|
*/
|
|
519
516
|
async prepareAnonymousTpaasEvent() {
|
|
517
|
+
const { isHybrid, pageViewId, providerId, component, componentVersion, stage: providerStage, product: providerProduct, version: providerVersion, deployStageTpaas, } = this.state;
|
|
518
|
+
const providerName = this.state.provider?.name;
|
|
519
|
+
const providerGroup = this.state.provider?.group;
|
|
520
|
+
const experimentsInput = this.builders.experiments;
|
|
521
|
+
const currentPageReferrerInput = this.currentPageContext.referrer;
|
|
520
522
|
try {
|
|
521
523
|
await this._applyRemoteConfigEndpoints();
|
|
522
524
|
}
|
|
@@ -524,20 +526,22 @@ class Tracker {
|
|
|
524
526
|
loglevel_1.default.trace('Failed to sync remote config', ex);
|
|
525
527
|
}
|
|
526
528
|
const [experiments, currentPageReferrer] = await Promise.all([
|
|
527
|
-
this.adaptExperiments(
|
|
528
|
-
|
|
529
|
+
this.adaptExperiments(experimentsInput),
|
|
530
|
+
currentPageReferrerInput,
|
|
529
531
|
]);
|
|
530
532
|
return {
|
|
531
|
-
autoTrackerVersion: this.builders.tracker?.autoTrackerVersion,
|
|
532
533
|
version: version_1.SDK_VERSION,
|
|
533
|
-
isHybrid: !!
|
|
534
|
-
pageviewId:
|
|
535
|
-
providerId
|
|
536
|
-
providerName
|
|
537
|
-
providerGroup
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
534
|
+
isHybrid: !!isHybrid,
|
|
535
|
+
pageviewId: pageViewId,
|
|
536
|
+
providerId,
|
|
537
|
+
providerName,
|
|
538
|
+
providerGroup,
|
|
539
|
+
providerStage,
|
|
540
|
+
providerProduct,
|
|
541
|
+
providerVersion,
|
|
542
|
+
component,
|
|
543
|
+
componentVersion,
|
|
544
|
+
routingStage: mapDeployStageToTpaasStage(deployStageTpaas),
|
|
541
545
|
experiments,
|
|
542
546
|
currentPageReferrer,
|
|
543
547
|
};
|
|
@@ -547,8 +551,15 @@ class Tracker {
|
|
|
547
551
|
* @category TPaaS Tracking
|
|
548
552
|
*/
|
|
549
553
|
async prepareTpaasEvent() {
|
|
554
|
+
// Capture event context before any asynchronous work so a concurrent update or View
|
|
555
|
+
// event cannot change the dependencies used to finish building this event.
|
|
556
|
+
const builders = { ...this.builders };
|
|
557
|
+
const { isHybrid, providerId, component, componentVersion, stage: providerStage, product: providerProduct, version: providerVersion, pageViewId, deployStageTpaas, } = this.state;
|
|
558
|
+
const providerName = this.state.provider?.name;
|
|
559
|
+
const providerGroup = this.state.provider?.group;
|
|
560
|
+
const { info: currentPageInfoInput, content: currentPageContent, sports: currentPageSports, referrer: currentPageReferrerInput, } = this.currentPageContext;
|
|
550
561
|
try {
|
|
551
|
-
await this.syncRemoteResources(undefined,
|
|
562
|
+
await this.syncRemoteResources(undefined, builders);
|
|
552
563
|
}
|
|
553
564
|
catch (ex) {
|
|
554
565
|
loglevel_1.default.trace('Failed to sync remote resources', ex);
|
|
@@ -602,28 +613,34 @@ class Tracker {
|
|
|
602
613
|
source: source || 'unknown',
|
|
603
614
|
};
|
|
604
615
|
}
|
|
616
|
+
// Consents are intentionally not part of the event-context snapshot. Read them after
|
|
617
|
+
// remote synchronization so a blocking tracking call can use newly resolved consents.
|
|
605
618
|
const [actor, consents, experiments, currentPage, currentPageReferrer] = await Promise.all([
|
|
606
|
-
|
|
619
|
+
identity.getActor(builders),
|
|
607
620
|
this.getConsents(),
|
|
608
|
-
this.adaptExperiments(
|
|
609
|
-
this.getCurrentTpaasPage(),
|
|
610
|
-
|
|
621
|
+
this.adaptExperiments(builders.experiments),
|
|
622
|
+
this.getCurrentTpaasPage(currentPageInfoInput),
|
|
623
|
+
currentPageReferrerInput,
|
|
611
624
|
]);
|
|
612
625
|
const { environmentId, jwe } = (0, cis_sync_1.parsePulseCookies)();
|
|
613
626
|
return {
|
|
614
|
-
autoTrackerVersion: this.builders.tracker?.autoTrackerVersion,
|
|
615
627
|
version: version_1.SDK_VERSION,
|
|
616
|
-
isHybrid: !!
|
|
628
|
+
isHybrid: !!isHybrid,
|
|
617
629
|
user: adaptActorToNewFormat(actor),
|
|
618
630
|
consents: adaptConsentsToNewFormat(consents),
|
|
619
|
-
providerId
|
|
620
|
-
providerName
|
|
621
|
-
providerGroup
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
631
|
+
providerId,
|
|
632
|
+
providerName,
|
|
633
|
+
providerGroup,
|
|
634
|
+
providerStage,
|
|
635
|
+
providerProduct,
|
|
636
|
+
providerVersion,
|
|
637
|
+
component,
|
|
638
|
+
componentVersion,
|
|
639
|
+
pageviewId: pageViewId,
|
|
640
|
+
routingStage: mapDeployStageToTpaasStage(deployStageTpaas),
|
|
626
641
|
currentPage,
|
|
642
|
+
currentPageContent,
|
|
643
|
+
currentPageSports,
|
|
627
644
|
currentPageReferrer,
|
|
628
645
|
experiments,
|
|
629
646
|
environmentId,
|
|
@@ -883,7 +900,11 @@ class Tracker {
|
|
|
883
900
|
}
|
|
884
901
|
async trackViewHealthPage(input, options) {
|
|
885
902
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
886
|
-
this.setCurrentTpaasPageData(
|
|
903
|
+
this.setCurrentTpaasPageData({
|
|
904
|
+
id: input.object.objectId,
|
|
905
|
+
type: tpaas_schemas_1.ViewHealthPage.object.objectType,
|
|
906
|
+
referrer: input.page?.referrer,
|
|
907
|
+
});
|
|
887
908
|
const dependencies = await this.prepareTpaasEvent();
|
|
888
909
|
const event = (0, tpaas_builders_1.buildViewHealthPageEvent)(input, dependencies);
|
|
889
910
|
const result = this.sendTpaasEvent(event);
|
|
@@ -893,7 +914,7 @@ class Tracker {
|
|
|
893
914
|
// Instead, we need to reuse the generic Leave Page event, but adapt the input accordingly.
|
|
894
915
|
// This means omitting some fields from HealthView Page that are not part of Leave Page schema.
|
|
895
916
|
const { experiments, metrics, object, origin, userHealthData, ...restInput } = input;
|
|
896
|
-
const { category, custom,
|
|
917
|
+
const { category, custom, name, tags, food, physicalActivity, training, ...restObject } = input.object;
|
|
897
918
|
await this.trackLeavePage({
|
|
898
919
|
leave,
|
|
899
920
|
...restInput,
|
|
@@ -923,7 +944,11 @@ class Tracker {
|
|
|
923
944
|
*/
|
|
924
945
|
async trackViewPage(input, options) {
|
|
925
946
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
926
|
-
this.setCurrentTpaasPageData(
|
|
947
|
+
this.setCurrentTpaasPageData({
|
|
948
|
+
id: input.object.objectId,
|
|
949
|
+
type: tpaas_schemas_1.ViewPage.object.objectType,
|
|
950
|
+
referrer: input.page?.referrer,
|
|
951
|
+
});
|
|
927
952
|
const dependencies = await this.prepareTpaasEvent();
|
|
928
953
|
const event = (0, tpaas_builders_1.buildViewPageEvent)(input, dependencies);
|
|
929
954
|
const result = this.sendTpaasEvent(event);
|
|
@@ -949,7 +974,17 @@ class Tracker {
|
|
|
949
974
|
*/
|
|
950
975
|
async trackViewSportsPage(input, options) {
|
|
951
976
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
952
|
-
this.setCurrentTpaasPageData(
|
|
977
|
+
this.setCurrentTpaasPageData({
|
|
978
|
+
id: input.object.objectId,
|
|
979
|
+
type: tpaas_schemas_1.ViewSportsPage.object.objectType,
|
|
980
|
+
referrer: input.page?.referrer,
|
|
981
|
+
sports: {
|
|
982
|
+
sportName: input.object.sportName,
|
|
983
|
+
sportSubview: input.object.sportSubview,
|
|
984
|
+
sportView: input.object.sportView,
|
|
985
|
+
sports: input.object.sports,
|
|
986
|
+
},
|
|
987
|
+
});
|
|
953
988
|
const dependencies = await this.prepareTpaasEvent();
|
|
954
989
|
const event = (0, tpaas_builders_1.buildViewSportsPageEvent)(input, dependencies);
|
|
955
990
|
const result = this.sendTpaasEvent(event);
|
|
@@ -968,13 +1003,48 @@ class Tracker {
|
|
|
968
1003
|
}
|
|
969
1004
|
return result;
|
|
970
1005
|
}
|
|
1006
|
+
/**
|
|
1007
|
+
* @param input
|
|
1008
|
+
* @param options
|
|
1009
|
+
* @category TPaaS Tracking
|
|
1010
|
+
*/
|
|
1011
|
+
async trackViewSchoolPage(input, options) {
|
|
1012
|
+
this.newPageView();
|
|
1013
|
+
// TODO: SchoolPage is not currently part of the catalog's PageRef.pageType enum.
|
|
1014
|
+
this.setCurrentTpaasPageData({
|
|
1015
|
+
id: input.object.objectId,
|
|
1016
|
+
type: 'Page',
|
|
1017
|
+
referrer: input.page?.referrer,
|
|
1018
|
+
});
|
|
1019
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1020
|
+
const event = (0, tpaas_builders_1.buildViewSchoolPageEvent)(input, dependencies);
|
|
1021
|
+
const result = this.sendTpaasEvent(event);
|
|
1022
|
+
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1023
|
+
const leaveSchoolPageCallback = async (leave) => {
|
|
1024
|
+
await this.trackLeaveSchoolPage({
|
|
1025
|
+
leave,
|
|
1026
|
+
...input,
|
|
1027
|
+
});
|
|
1028
|
+
};
|
|
1029
|
+
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1030
|
+
...options.leaveTracking,
|
|
1031
|
+
schema: tpaas_schemas_1.LeaveSchoolPage.object.objectType,
|
|
1032
|
+
trackMethod: leaveSchoolPageCallback,
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
return result;
|
|
1036
|
+
}
|
|
971
1037
|
/**
|
|
972
1038
|
* @param input
|
|
973
1039
|
* @category TPaaS Tracking
|
|
974
1040
|
*/
|
|
975
1041
|
async trackViewTitle(input) {
|
|
976
1042
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
977
|
-
this.setCurrentTpaasPageData(
|
|
1043
|
+
this.setCurrentTpaasPageData({
|
|
1044
|
+
id: input.object.objectId,
|
|
1045
|
+
type: tpaas_schemas_1.ViewTitle.object.objectType,
|
|
1046
|
+
referrer: input.page?.referrer,
|
|
1047
|
+
});
|
|
978
1048
|
const dependencies = await this.prepareTpaasEvent();
|
|
979
1049
|
const event = (0, tpaas_builders_1.buildViewTitleEvent)(input, dependencies);
|
|
980
1050
|
return this.sendTpaasEvent(event);
|
|
@@ -1014,7 +1084,12 @@ class Tracker {
|
|
|
1014
1084
|
*/
|
|
1015
1085
|
async trackViewArticle(input, options) {
|
|
1016
1086
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1017
|
-
this.setCurrentTpaasPageData(
|
|
1087
|
+
this.setCurrentTpaasPageData({
|
|
1088
|
+
id: input.object.objectId,
|
|
1089
|
+
type: tpaas_schemas_1.ViewArticle.object.objectType,
|
|
1090
|
+
referrer: input.page?.referrer,
|
|
1091
|
+
content: input.page?.content,
|
|
1092
|
+
});
|
|
1018
1093
|
const dependencies = await this.prepareTpaasEvent();
|
|
1019
1094
|
const event = (0, tpaas_builders_1.buildViewArticleEvent)(input, dependencies);
|
|
1020
1095
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1075,7 +1150,12 @@ class Tracker {
|
|
|
1075
1150
|
*/
|
|
1076
1151
|
async trackViewAudioPage(input, options) {
|
|
1077
1152
|
this.newPageView();
|
|
1078
|
-
this.setCurrentTpaasPageData(
|
|
1153
|
+
this.setCurrentTpaasPageData({
|
|
1154
|
+
id: input.object.objectId,
|
|
1155
|
+
type: tpaas_schemas_1.ViewAudioPage.object.objectType,
|
|
1156
|
+
referrer: input.page?.referrer,
|
|
1157
|
+
content: input.page?.content,
|
|
1158
|
+
});
|
|
1079
1159
|
const dependencies = await this.prepareTpaasEvent();
|
|
1080
1160
|
const event = (0, tpaas_builders_1.buildViewAudioPageEvent)(input, dependencies);
|
|
1081
1161
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1113,7 +1193,11 @@ class Tracker {
|
|
|
1113
1193
|
*/
|
|
1114
1194
|
async trackViewError(input, options) {
|
|
1115
1195
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1116
|
-
this.setCurrentTpaasPageData(
|
|
1196
|
+
this.setCurrentTpaasPageData({
|
|
1197
|
+
id: input.object.objectId,
|
|
1198
|
+
type: tpaas_schemas_1.ViewError.object.objectType,
|
|
1199
|
+
referrer: input.page?.referrer,
|
|
1200
|
+
});
|
|
1117
1201
|
const dependencies = await this.prepareTpaasEvent();
|
|
1118
1202
|
const event = (0, tpaas_builders_1.buildViewErrorEvent)(input, dependencies);
|
|
1119
1203
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1186,6 +1270,24 @@ class Tracker {
|
|
|
1186
1270
|
const event = (0, tpaas_builders_1.buildImpressionPlayerEvent)(input, dependencies);
|
|
1187
1271
|
return this.sendTpaasEvent(event);
|
|
1188
1272
|
}
|
|
1273
|
+
/**
|
|
1274
|
+
* @param input
|
|
1275
|
+
* @category TPaaS Tracking
|
|
1276
|
+
*/
|
|
1277
|
+
async trackImpressionSportsUIElement(input) {
|
|
1278
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1279
|
+
const event = (0, tpaas_builders_1.buildImpressionSportsUIElementEvent)(input, dependencies);
|
|
1280
|
+
return this.sendTpaasEvent(event);
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* @param input
|
|
1284
|
+
* @category TPaaS Tracking
|
|
1285
|
+
*/
|
|
1286
|
+
async trackImpressionSchoolUIElement(input) {
|
|
1287
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1288
|
+
const event = (0, tpaas_builders_1.buildImpressionSchoolUIElementEvent)(input, dependencies);
|
|
1289
|
+
return this.sendTpaasEvent(event);
|
|
1290
|
+
}
|
|
1189
1291
|
/**
|
|
1190
1292
|
* @param input
|
|
1191
1293
|
* @category TPaaS Tracking
|
|
@@ -1211,7 +1313,11 @@ class Tracker {
|
|
|
1211
1313
|
*/
|
|
1212
1314
|
async trackViewFrontpage(input, options) {
|
|
1213
1315
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1214
|
-
this.setCurrentTpaasPageData(
|
|
1316
|
+
this.setCurrentTpaasPageData({
|
|
1317
|
+
id: input.object.objectId,
|
|
1318
|
+
type: tpaas_schemas_1.ViewFrontpage.object.objectType,
|
|
1319
|
+
referrer: input.page?.referrer,
|
|
1320
|
+
});
|
|
1215
1321
|
const dependencies = await this.prepareTpaasEvent();
|
|
1216
1322
|
const event = (0, tpaas_builders_1.buildViewFrontpageEvent)(input, dependencies);
|
|
1217
1323
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1237,7 +1343,11 @@ class Tracker {
|
|
|
1237
1343
|
*/
|
|
1238
1344
|
async trackViewLandingpage(input, options) {
|
|
1239
1345
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1240
|
-
this.setCurrentTpaasPageData(
|
|
1346
|
+
this.setCurrentTpaasPageData({
|
|
1347
|
+
id: input.object.objectId,
|
|
1348
|
+
type: tpaas_schemas_1.ViewLandingpage.object.objectType,
|
|
1349
|
+
referrer: input.page?.referrer,
|
|
1350
|
+
});
|
|
1241
1351
|
const dependencies = await this.prepareTpaasEvent();
|
|
1242
1352
|
const event = (0, tpaas_builders_1.buildViewLandingpageEvent)(input, dependencies);
|
|
1243
1353
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1263,7 +1373,11 @@ class Tracker {
|
|
|
1263
1373
|
*/
|
|
1264
1374
|
async trackViewListing(input, options) {
|
|
1265
1375
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1266
|
-
this.setCurrentTpaasPageData(
|
|
1376
|
+
this.setCurrentTpaasPageData({
|
|
1377
|
+
id: input.object.objectId,
|
|
1378
|
+
type: tpaas_schemas_1.ViewListing.object.objectType,
|
|
1379
|
+
referrer: input.page?.referrer,
|
|
1380
|
+
});
|
|
1267
1381
|
const dependencies = await this.prepareTpaasEvent();
|
|
1268
1382
|
const event = (0, tpaas_builders_1.buildViewListingEvent)(input, dependencies);
|
|
1269
1383
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1289,7 +1403,12 @@ class Tracker {
|
|
|
1289
1403
|
*/
|
|
1290
1404
|
async trackViewLockedArticle(input, options) {
|
|
1291
1405
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1292
|
-
this.setCurrentTpaasPageData(
|
|
1406
|
+
this.setCurrentTpaasPageData({
|
|
1407
|
+
id: input.object.objectId,
|
|
1408
|
+
type: tpaas_schemas_1.ViewLockedArticle.object.objectType,
|
|
1409
|
+
referrer: input.page?.referrer,
|
|
1410
|
+
content: input.page?.content,
|
|
1411
|
+
});
|
|
1293
1412
|
const dependencies = await this.prepareTpaasEvent();
|
|
1294
1413
|
const event = (0, tpaas_builders_1.buildViewLockedArticleEvent)(input, dependencies);
|
|
1295
1414
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1315,7 +1434,12 @@ class Tracker {
|
|
|
1315
1434
|
*/
|
|
1316
1435
|
async trackViewLockedAudioPage(input, options) {
|
|
1317
1436
|
this.newPageView();
|
|
1318
|
-
this.setCurrentTpaasPageData(
|
|
1437
|
+
this.setCurrentTpaasPageData({
|
|
1438
|
+
id: input.object.objectId,
|
|
1439
|
+
type: tpaas_schemas_1.ViewLockedAudioPage.object.objectType,
|
|
1440
|
+
referrer: input.page?.referrer,
|
|
1441
|
+
content: input.page?.content,
|
|
1442
|
+
});
|
|
1319
1443
|
const dependencies = await this.prepareTpaasEvent();
|
|
1320
1444
|
const event = (0, tpaas_builders_1.buildViewLockedAudioPageEvent)(input, dependencies);
|
|
1321
1445
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1334,6 +1458,36 @@ class Tracker {
|
|
|
1334
1458
|
}
|
|
1335
1459
|
return result;
|
|
1336
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* @param input
|
|
1463
|
+
* @param options
|
|
1464
|
+
* @category TPaaS Tracking
|
|
1465
|
+
*/
|
|
1466
|
+
async trackViewLockedPage(input, options) {
|
|
1467
|
+
this.newPageView();
|
|
1468
|
+
this.setCurrentTpaasPageData({
|
|
1469
|
+
id: input.object.objectId,
|
|
1470
|
+
type: tpaas_schemas_1.ViewLockedPage.object.objectType,
|
|
1471
|
+
referrer: input.page?.referrer,
|
|
1472
|
+
});
|
|
1473
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1474
|
+
const event = (0, tpaas_builders_1.buildViewLockedPageEvent)(input, dependencies);
|
|
1475
|
+
const result = this.sendTpaasEvent(event);
|
|
1476
|
+
if ((0, leaveTrackingTpaas_1.shouldEnableLeaveTracking)(options.leaveTracking)) {
|
|
1477
|
+
const leaveLockedPageCallback = async (leave) => {
|
|
1478
|
+
await this.trackLeaveLockedPage({
|
|
1479
|
+
leave,
|
|
1480
|
+
...input,
|
|
1481
|
+
});
|
|
1482
|
+
};
|
|
1483
|
+
(0, leaveTrackingTpaas_1.addTpaasLeaveTracking)({
|
|
1484
|
+
...options.leaveTracking,
|
|
1485
|
+
schema: tpaas_schemas_1.LeaveLockedPage.object.objectType,
|
|
1486
|
+
trackMethod: leaveLockedPageCallback,
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
return result;
|
|
1490
|
+
}
|
|
1337
1491
|
/**
|
|
1338
1492
|
* @param input
|
|
1339
1493
|
* @param options
|
|
@@ -1341,7 +1495,12 @@ class Tracker {
|
|
|
1341
1495
|
*/
|
|
1342
1496
|
async trackViewLockedVideoPage(input, options) {
|
|
1343
1497
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1344
|
-
this.setCurrentTpaasPageData(
|
|
1498
|
+
this.setCurrentTpaasPageData({
|
|
1499
|
+
id: input.object.objectId,
|
|
1500
|
+
type: tpaas_schemas_1.ViewLockedVideoPage.object.objectType,
|
|
1501
|
+
referrer: input.page?.referrer,
|
|
1502
|
+
content: input.page?.content,
|
|
1503
|
+
});
|
|
1345
1504
|
const dependencies = await this.prepareTpaasEvent();
|
|
1346
1505
|
const event = (0, tpaas_builders_1.buildViewLockedVideoPageEvent)(input, dependencies);
|
|
1347
1506
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1404,7 +1563,12 @@ class Tracker {
|
|
|
1404
1563
|
*/
|
|
1405
1564
|
async trackViewVideoPage(input, options) {
|
|
1406
1565
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1407
|
-
this.setCurrentTpaasPageData(
|
|
1566
|
+
this.setCurrentTpaasPageData({
|
|
1567
|
+
id: input.object.objectId,
|
|
1568
|
+
type: tpaas_schemas_1.ViewVideoPage.object.objectType,
|
|
1569
|
+
referrer: input.page?.referrer,
|
|
1570
|
+
content: input.page?.content,
|
|
1571
|
+
});
|
|
1408
1572
|
const dependencies = await this.prepareTpaasEvent();
|
|
1409
1573
|
const event = (0, tpaas_builders_1.buildViewVideoPageEvent)(input, dependencies);
|
|
1410
1574
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1414,11 +1578,7 @@ class Tracker {
|
|
|
1414
1578
|
const leaveStoriesInput = leaveStoriesBuilder?.();
|
|
1415
1579
|
await this.trackLeaveVideoPage({
|
|
1416
1580
|
leave,
|
|
1417
|
-
leaveStories: leaveStoriesInput
|
|
1418
|
-
...leaveStoriesInput,
|
|
1419
|
-
activityDurationMs: leave.activityDurationMs,
|
|
1420
|
-
durationMs: leave.durationMs,
|
|
1421
|
-
},
|
|
1581
|
+
leaveStories: leaveStoriesInput,
|
|
1422
1582
|
...input,
|
|
1423
1583
|
});
|
|
1424
1584
|
};
|
|
@@ -1437,7 +1597,11 @@ class Tracker {
|
|
|
1437
1597
|
*/
|
|
1438
1598
|
async trackViewWeather(input, options) {
|
|
1439
1599
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1440
|
-
this.setCurrentTpaasPageData(
|
|
1600
|
+
this.setCurrentTpaasPageData({
|
|
1601
|
+
id: input.object.objectId,
|
|
1602
|
+
type: tpaas_schemas_1.ViewWeather.object.objectType,
|
|
1603
|
+
referrer: input.page?.referrer,
|
|
1604
|
+
});
|
|
1441
1605
|
const dependencies = await this.prepareTpaasEvent();
|
|
1442
1606
|
const event = (0, tpaas_builders_1.buildViewWeatherEvent)(input, dependencies);
|
|
1443
1607
|
const result = this.sendTpaasEvent(event);
|
|
@@ -1528,6 +1692,15 @@ class Tracker {
|
|
|
1528
1692
|
const event = (0, tpaas_builders_1.buildLeaveLockedAudioPageEvent)(input, dependencies);
|
|
1529
1693
|
return this.sendTpaasEvent(event);
|
|
1530
1694
|
}
|
|
1695
|
+
/**
|
|
1696
|
+
* @param input
|
|
1697
|
+
* @category TPaaS Tracking
|
|
1698
|
+
*/
|
|
1699
|
+
async trackLeaveLockedPage(input) {
|
|
1700
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1701
|
+
const event = (0, tpaas_builders_1.buildLeaveLockedPageEvent)(input, dependencies);
|
|
1702
|
+
return this.sendTpaasEvent(event);
|
|
1703
|
+
}
|
|
1531
1704
|
/**
|
|
1532
1705
|
* @param input
|
|
1533
1706
|
* @category TPaaS Tracking
|
|
@@ -1555,6 +1728,15 @@ class Tracker {
|
|
|
1555
1728
|
const event = (0, tpaas_builders_1.buildLeaveSportsPageEvent)(input, dependencies);
|
|
1556
1729
|
return this.sendTpaasEvent(event);
|
|
1557
1730
|
}
|
|
1731
|
+
/**
|
|
1732
|
+
* @param input
|
|
1733
|
+
* @category TPaaS Tracking
|
|
1734
|
+
*/
|
|
1735
|
+
async trackLeaveSchoolPage(input) {
|
|
1736
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1737
|
+
const event = (0, tpaas_builders_1.buildLeaveSchoolPageEvent)(input, dependencies);
|
|
1738
|
+
return this.sendTpaasEvent(event);
|
|
1739
|
+
}
|
|
1558
1740
|
/**
|
|
1559
1741
|
* @param input
|
|
1560
1742
|
* @category TPaaS Tracking
|
|
@@ -1618,6 +1800,24 @@ class Tracker {
|
|
|
1618
1800
|
const event = (0, tpaas_builders_1.buildEngagementOfferEvent)(input, dependencies);
|
|
1619
1801
|
return this.sendTpaasEvent(event);
|
|
1620
1802
|
}
|
|
1803
|
+
/**
|
|
1804
|
+
* @param input
|
|
1805
|
+
* @category TPaaS Tracking
|
|
1806
|
+
*/
|
|
1807
|
+
async trackEngagementSportsUIElement(input) {
|
|
1808
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1809
|
+
const event = (0, tpaas_builders_1.buildEngagementSportsUIElementEvent)(input, dependencies);
|
|
1810
|
+
return this.sendTpaasEvent(event);
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* @param input
|
|
1814
|
+
* @category TPaaS Tracking
|
|
1815
|
+
*/
|
|
1816
|
+
async trackEngagementSchoolUIElement(input) {
|
|
1817
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1818
|
+
const event = (0, tpaas_builders_1.buildEngagementSchoolUIElementEvent)(input, dependencies);
|
|
1819
|
+
return this.sendTpaasEvent(event);
|
|
1820
|
+
}
|
|
1621
1821
|
/**
|
|
1622
1822
|
* @param input
|
|
1623
1823
|
* @category TPaaS Tracking
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.builder = builder;
|
|
4
4
|
const generateProviderSDRN = (providerId) => `sdrn:schibsted:client:${providerId}`;
|
|
5
|
-
function builder(providerId, component, componentVersion, providerName, providerGroup) {
|
|
5
|
+
function builder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup) {
|
|
6
6
|
return {
|
|
7
7
|
provider: {
|
|
8
8
|
providerId,
|
|
@@ -11,6 +11,9 @@ function builder(providerId, component, componentVersion, providerName, provider
|
|
|
11
11
|
...(componentVersion !== undefined && { componentVersion }),
|
|
12
12
|
...(providerGroup !== undefined && { group: providerGroup }),
|
|
13
13
|
...(providerName !== undefined && { name: providerName }),
|
|
14
|
+
stage: providerStage,
|
|
15
|
+
product: providerProduct,
|
|
16
|
+
version: providerVersion,
|
|
14
17
|
},
|
|
15
18
|
};
|
|
16
19
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.builder = void 0;
|
|
4
|
-
const builder = ({
|
|
4
|
+
const builder = ({ isHybrid, routingStage, version, }) => {
|
|
5
5
|
return {
|
|
6
6
|
tracker: {
|
|
7
|
-
autoTrackerVersion,
|
|
8
|
-
isAutoTracker: !!autoTrackerVersion,
|
|
9
7
|
isHybrid,
|
|
10
8
|
routingStage,
|
|
11
9
|
trackerType: 'JS',
|