@schibsted/pulse-sdk 8.0.0-rc.20 → 8.0.0-rc.21
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 +170 -334
- package/dist/cjs/builders/session-browser.js +4 -79
- package/dist/cjs/session/store.js +96 -0
- package/dist/cjs/tpaas-builders/builders/device.js +42 -70
- package/dist/cjs/tpaas-builders/builders/pageInfo.js +2 -3
- package/dist/cjs/tpaas-builders/builders/session.js +2 -114
- package/dist/cjs/tpaas-builders/builders/utm.js +2 -8
- package/dist/cjs/tpaas-builders/builders.js +135 -148
- package/dist/cjs/tpaas-context/adapters.js +85 -0
- package/dist/cjs/tpaas-context/browser.js +51 -0
- package/dist/cjs/tpaas-context/index.js +6 -0
- package/dist/cjs/tpaas-context/prepare.js +177 -0
- package/dist/cjs/tpaas-context/session.js +23 -0
- package/dist/cjs/tpaas-schemas/constants.js +68 -75
- package/dist/cjs/tracker-proxy/consts.js +1 -2
- package/dist/cjs/version.js +1 -1
- package/dist/ejs/Tracker.js +171 -335
- package/dist/ejs/builders/session-browser.js +4 -77
- package/dist/ejs/session/store.js +90 -0
- package/dist/ejs/tpaas-builders/builders/device.js +42 -70
- package/dist/ejs/tpaas-builders/builders/pageInfo.js +2 -3
- package/dist/ejs/tpaas-builders/builders/session.js +1 -111
- package/dist/ejs/tpaas-builders/builders/utm.js +2 -8
- package/dist/ejs/tpaas-builders/builders.js +135 -147
- package/dist/ejs/tpaas-context/adapters.js +80 -0
- package/dist/ejs/tpaas-context/browser.js +47 -0
- package/dist/ejs/tpaas-context/index.js +1 -0
- package/dist/ejs/tpaas-context/prepare.js +137 -0
- package/dist/ejs/tpaas-context/session.js +19 -0
- package/dist/ejs/tpaas-schemas/constants.js +66 -73
- package/dist/ejs/tracker-proxy/consts.js +1 -2
- package/dist/ejs/version.js +1 -1
- package/dist/types/Tracker.d.ts +27 -23
- package/dist/types/builders/session-browser.d.ts +0 -13
- package/dist/types/session/store.d.ts +34 -0
- package/dist/types/tpaas-builders/builders/consents.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/device.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/experiments.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/pageInfo.d.ts +2 -1
- package/dist/types/tpaas-builders/builders/pageviewId.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/provider.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/session.d.ts +1 -12
- package/dist/types/tpaas-builders/builders/trackerBuilder.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/user.d.ts +2 -2
- package/dist/types/tpaas-builders/builders/utm.d.ts +2 -1
- package/dist/types/tpaas-builders/builders.d.ts +70 -70
- package/dist/types/tpaas-builders/index.d.ts +0 -1
- package/dist/types/tpaas-context/adapters.d.ts +26 -0
- package/dist/types/tpaas-context/browser.d.ts +8 -0
- package/dist/types/tpaas-context/index.d.ts +2 -0
- package/dist/types/tpaas-context/prepare.d.ts +38 -0
- package/dist/types/tpaas-context/session.d.ts +10 -0
- package/dist/types/tpaas-context/types.d.ts +66 -0
- package/dist/types/tpaas-schemas/constants.d.ts +66 -73
- package/dist/types/tpaas-schemas/types/ITpaasEvent.d.ts +2 -4
- package/dist/types/tpaas-schemas/types/schemas/{IAnonymousViewUIElement.d.ts → IAnonymousImpressionUIElement.d.ts} +2 -2
- package/dist/types/tpaas-schemas/types/schemas/IEngagementAudio.d.ts +6 -2
- package/dist/types/tpaas-schemas/types/schemas/IEngagementTeaser.d.ts +2 -2
- package/dist/types/tpaas-schemas/types/schemas/IEngagementTvModule.d.ts +4 -1
- package/dist/types/tpaas-schemas/types/schemas/IEngagementTvSearch.d.ts +4 -4
- package/dist/types/tpaas-schemas/types/schemas/IEngagementVideo.d.ts +6 -2
- package/dist/types/tpaas-schemas/types/schemas/IEngagementVideoAd.d.ts +10 -8
- package/dist/types/tpaas-schemas/types/schemas/IImpressionTeaser.d.ts +2 -2
- package/dist/types/tpaas-schemas/types/schemas/ILeaveWeather.d.ts +2 -0
- package/dist/types/tpaas-schemas/types/schemas/index.d.ts +1 -2
- package/dist/types/tpaas-schemas/types.d.ts +2 -2
- package/dist/types/tracker-proxy/consts.d.ts +1 -1
- package/dist/types/types.d.ts +2 -4
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/types/tpaas-builders/types.d.ts +0 -36
- package/dist/types/tpaas-schemas/types/schemas/IRequestAd.d.ts +0 -95
- /package/dist/cjs/{tpaas-builders → tpaas-context}/types.js +0 -0
- /package/dist/ejs/{tpaas-builders → tpaas-context}/types.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { merge } from 'ts-deepmerge';
|
|
2
|
-
import {
|
|
2
|
+
import { AnonymousImpressionUIElement, CompletedHealthAction, EngagementAd, EngagementAffiliate, EngagementAudio, EngagementForm, EngagementHealthUIElement, EngagementOffer, EngagementSchoolUIElement, EngagementSportsUIElement, EngagementTeaser, EngagementTvModule, EngagementTvSearch, EngagementUIElement, EngagementVideo, EngagementVideoAd, EngagementWidget, HeartbeatCommercialArticle, ImpressionAd, ImpressionAdSlot, ImpressionAffiliate, ImpressionForm, ImpressionHealthUIElement, ImpressionOffer, ImpressionPlayer, ImpressionSchoolUIElement, ImpressionSportsUIElement, ImpressionTeaser, ImpressionUIElement, ImpressionWidget, LeaveArticle, LeaveAudioPage, LeaveError, LeaveFrontpage, LeaveLandingpage, LeaveListing, LeaveLockedArticle, LeaveLockedAudioPage, LeaveLockedPage, LeaveLockedVideoPage, LeavePage, LeaveSchoolPage, LeaveSportsPage, LeaveVideoPage, LeaveWeather, LoadAd, ViewArticle, ViewAudioPage, ViewError, ViewFrontpage, ViewHealthPage, ViewLandingpage, ViewListing, ViewLockedArticle, ViewLockedAudioPage, ViewLockedPage, ViewLockedVideoPage, ViewPage, ViewSchoolPage, ViewSportsPage, ViewTitle, ViewVideoPage, ViewWeather, } from '../tpaas-schemas';
|
|
3
3
|
import { builder as anonymousBuilder } from './builders/anonymous';
|
|
4
4
|
import { builder as baseEventBuilder } from './builders/baseEvent';
|
|
5
5
|
import { builder as catalogVersionBuilder } from './builders/catalogVersion';
|
|
@@ -18,19 +18,13 @@ import { builder as timeBuilder } from './builders/time';
|
|
|
18
18
|
import { builder as trackerBuilder } from './builders/trackerBuilder';
|
|
19
19
|
import { builder as userBuilder } from './builders/user';
|
|
20
20
|
import { builder as utmBuilder } from './builders/utm';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
export const getCommonBuildersOutput = (createdAt, dependencies, input) => {
|
|
28
|
-
const { isHybrid, version, environmentId, jwe, user, consents, providerId, providerName, providerGroup, providerStage, providerProduct, providerVersion, component, componentVersion, pageviewId, currentPage, currentPageReferrer, routingStage, } = dependencies;
|
|
29
|
-
const { experiments } = input;
|
|
30
|
-
return merge(trackerBuilder({ isHybrid, version, routingStage }), timeBuilder(createdAt), sessionBuilder(createdAt), deviceBuilder(environmentId, jwe), userBuilder(user), baseEventBuilder(), consentsBuilder(consents), providerBuilder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup), pageInfoBuilder(currentPage), pageviewIdBuilder(pageviewId), utmBuilder(), referrerBuilder(currentPageReferrer), catalogVersionBuilder(), experimentsBuilder(dependencies.experiments, experiments));
|
|
21
|
+
export const getCommonBuildersOutput = (context) => {
|
|
22
|
+
const { createdAt, session, isHybrid, version, environmentId, jwe, user, consents, providerId, providerName, providerGroup, providerStage, providerProduct, providerVersion, component, componentVersion, pageviewId, currentPage, currentPageReferrer, routingStage, browser, } = context;
|
|
23
|
+
const { experiments } = context.input;
|
|
24
|
+
return merge(trackerBuilder({ isHybrid, version, routingStage }), timeBuilder(createdAt), sessionBuilder(session), deviceBuilder(environmentId, jwe, browser), userBuilder(user), baseEventBuilder(), consentsBuilder(consents), providerBuilder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup), pageInfoBuilder(currentPage, browser.url), pageviewIdBuilder(pageviewId), utmBuilder(browser.search), referrerBuilder(currentPageReferrer), catalogVersionBuilder(), experimentsBuilder(context.experiments, experiments));
|
|
31
25
|
};
|
|
32
|
-
const getElementEventBuildersOutput = (
|
|
33
|
-
const getSportsElementEventBuildersOutput = (
|
|
26
|
+
const getElementEventBuildersOutput = (context) => merge(getCommonBuildersOutput(context), pageContentBuilder(context.currentPageContent));
|
|
27
|
+
const getSportsElementEventBuildersOutput = (context) => merge(getElementEventBuildersOutput(context), pageSportsBuilder(context.currentPageSports));
|
|
34
28
|
// there's a bug in the ts-deepmerge library that doesn't properly resolve merging optionals with required properties
|
|
35
29
|
// due to this, we need to do 2 things:
|
|
36
30
|
// (1) manually omit navigationType from the input before merging.
|
|
@@ -57,215 +51,209 @@ const normalizePageInput = (input) => {
|
|
|
57
51
|
},
|
|
58
52
|
};
|
|
59
53
|
};
|
|
60
|
-
// #region
|
|
61
|
-
export function
|
|
62
|
-
const createdAt =
|
|
63
|
-
|
|
64
|
-
return merge(AnonymousViewUIElement, baseEventBuilder(), trackerBuilder({ isHybrid, version, routingStage }), timeBuilder(createdAt), pageviewIdBuilder(pageviewId), utmBuilder(), anonymousBuilder(), providerBuilder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup), referrerBuilder(currentPageReferrer), experimentsBuilder(dependencies.experiments, input.experiments), catalogVersionBuilder(), normalizePageInput(input));
|
|
54
|
+
// #region AnonymousImpression Event Builders
|
|
55
|
+
export function buildAnonymousImpressionUIElementEvent(context) {
|
|
56
|
+
const { createdAt, isHybrid, version, pageviewId, providerId, providerName, providerGroup, providerStage, providerProduct, providerVersion, component, componentVersion, currentPageReferrer, routingStage, } = context;
|
|
57
|
+
return merge(AnonymousImpressionUIElement, baseEventBuilder(), trackerBuilder({ isHybrid, version, routingStage }), timeBuilder(createdAt), pageviewIdBuilder(pageviewId), utmBuilder(context.browser.search), anonymousBuilder(), providerBuilder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup), referrerBuilder(currentPageReferrer), experimentsBuilder(context.experiments, context.input.experiments), catalogVersionBuilder(), normalizePageInput(context.input));
|
|
65
58
|
}
|
|
66
59
|
// #endregion
|
|
67
60
|
// #region View Event Builders
|
|
68
|
-
export function buildViewArticleEvent(
|
|
69
|
-
return merge(ViewArticle, getCommonBuildersOutput(
|
|
61
|
+
export function buildViewArticleEvent(context) {
|
|
62
|
+
return merge(ViewArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
70
63
|
}
|
|
71
|
-
export function buildViewAudioPageEvent(
|
|
72
|
-
return merge(ViewAudioPage, getCommonBuildersOutput(
|
|
64
|
+
export function buildViewAudioPageEvent(context) {
|
|
65
|
+
return merge(ViewAudioPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
73
66
|
}
|
|
74
|
-
export function buildViewErrorEvent(
|
|
75
|
-
return merge(ViewError, getCommonBuildersOutput(
|
|
67
|
+
export function buildViewErrorEvent(context) {
|
|
68
|
+
return merge(ViewError, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
76
69
|
}
|
|
77
|
-
export function buildViewFrontpageEvent(
|
|
78
|
-
return merge(ViewFrontpage, getCommonBuildersOutput(
|
|
70
|
+
export function buildViewFrontpageEvent(context) {
|
|
71
|
+
return merge(ViewFrontpage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
79
72
|
}
|
|
80
|
-
export function buildViewLandingpageEvent(
|
|
81
|
-
return merge(ViewLandingpage, getCommonBuildersOutput(
|
|
73
|
+
export function buildViewLandingpageEvent(context) {
|
|
74
|
+
return merge(ViewLandingpage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
82
75
|
}
|
|
83
|
-
export function buildViewListingEvent(
|
|
84
|
-
return merge(ViewListing, getCommonBuildersOutput(
|
|
76
|
+
export function buildViewListingEvent(context) {
|
|
77
|
+
return merge(ViewListing, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
85
78
|
}
|
|
86
|
-
export function buildViewLockedArticleEvent(
|
|
87
|
-
return merge(ViewLockedArticle, getCommonBuildersOutput(
|
|
79
|
+
export function buildViewLockedArticleEvent(context) {
|
|
80
|
+
return merge(ViewLockedArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
88
81
|
}
|
|
89
|
-
export function buildViewLockedAudioPageEvent(
|
|
90
|
-
return merge(ViewLockedAudioPage, getCommonBuildersOutput(
|
|
82
|
+
export function buildViewLockedAudioPageEvent(context) {
|
|
83
|
+
return merge(ViewLockedAudioPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
91
84
|
}
|
|
92
|
-
export function buildViewLockedPageEvent(
|
|
93
|
-
return merge(ViewLockedPage, getCommonBuildersOutput(
|
|
85
|
+
export function buildViewLockedPageEvent(context) {
|
|
86
|
+
return merge(ViewLockedPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
94
87
|
}
|
|
95
|
-
export function buildViewLockedVideoPageEvent(
|
|
96
|
-
return merge(ViewLockedVideoPage, getCommonBuildersOutput(
|
|
88
|
+
export function buildViewLockedVideoPageEvent(context) {
|
|
89
|
+
return merge(ViewLockedVideoPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
97
90
|
}
|
|
98
|
-
export function buildLeaveLockedVideoPageEvent(
|
|
99
|
-
return merge(LeaveLockedVideoPage, getCommonBuildersOutput(
|
|
91
|
+
export function buildLeaveLockedVideoPageEvent(context) {
|
|
92
|
+
return merge(LeaveLockedVideoPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
100
93
|
}
|
|
101
|
-
export function buildViewPageEvent(
|
|
102
|
-
return merge(ViewPage, getCommonBuildersOutput(
|
|
94
|
+
export function buildViewPageEvent(context) {
|
|
95
|
+
return merge(ViewPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
103
96
|
}
|
|
104
|
-
export function buildViewSportsPageEvent(
|
|
105
|
-
return merge(ViewSportsPage, getCommonBuildersOutput(
|
|
97
|
+
export function buildViewSportsPageEvent(context) {
|
|
98
|
+
return merge(ViewSportsPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
106
99
|
}
|
|
107
|
-
export function buildViewSchoolPageEvent(
|
|
108
|
-
return merge(ViewSchoolPage, getCommonBuildersOutput(
|
|
100
|
+
export function buildViewSchoolPageEvent(context) {
|
|
101
|
+
return merge(ViewSchoolPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
109
102
|
}
|
|
110
|
-
export function buildViewTitleEvent(
|
|
111
|
-
return merge(ViewTitle, getCommonBuildersOutput(
|
|
103
|
+
export function buildViewTitleEvent(context) {
|
|
104
|
+
return merge(ViewTitle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
112
105
|
}
|
|
113
|
-
export function buildViewVideoPageEvent(
|
|
114
|
-
return merge(ViewVideoPage, getCommonBuildersOutput(
|
|
106
|
+
export function buildViewVideoPageEvent(context) {
|
|
107
|
+
return merge(ViewVideoPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
115
108
|
}
|
|
116
|
-
export function buildViewWeatherEvent(
|
|
117
|
-
return merge(ViewWeather, getCommonBuildersOutput(
|
|
109
|
+
export function buildViewWeatherEvent(context) {
|
|
110
|
+
return merge(ViewWeather, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
118
111
|
}
|
|
119
112
|
// #endregion
|
|
120
113
|
// #region Leave Event Builders
|
|
121
|
-
export function buildLeaveArticleEvent(
|
|
122
|
-
return merge(LeaveArticle, getCommonBuildersOutput(
|
|
114
|
+
export function buildLeaveArticleEvent(context) {
|
|
115
|
+
return merge(LeaveArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
123
116
|
}
|
|
124
|
-
export function buildLeaveAudioPageEvent(
|
|
125
|
-
return merge(LeaveAudioPage, getCommonBuildersOutput(
|
|
117
|
+
export function buildLeaveAudioPageEvent(context) {
|
|
118
|
+
return merge(LeaveAudioPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
126
119
|
}
|
|
127
|
-
export function buildLeaveErrorEvent(
|
|
128
|
-
return merge(LeaveError, getCommonBuildersOutput(
|
|
120
|
+
export function buildLeaveErrorEvent(context) {
|
|
121
|
+
return merge(LeaveError, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
129
122
|
}
|
|
130
|
-
export function buildLeaveFrontpageEvent(
|
|
131
|
-
return merge(LeaveFrontpage, getCommonBuildersOutput(
|
|
123
|
+
export function buildLeaveFrontpageEvent(context) {
|
|
124
|
+
return merge(LeaveFrontpage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
132
125
|
}
|
|
133
|
-
export function buildLeaveLandingpageEvent(
|
|
134
|
-
return merge(LeaveLandingpage, getCommonBuildersOutput(
|
|
126
|
+
export function buildLeaveLandingpageEvent(context) {
|
|
127
|
+
return merge(LeaveLandingpage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
135
128
|
}
|
|
136
|
-
export function buildLeaveListingEvent(
|
|
137
|
-
return merge(LeaveListing, getCommonBuildersOutput(
|
|
129
|
+
export function buildLeaveListingEvent(context) {
|
|
130
|
+
return merge(LeaveListing, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
138
131
|
}
|
|
139
|
-
export function buildLeaveLockedArticleEvent(
|
|
140
|
-
return merge(LeaveLockedArticle, getCommonBuildersOutput(
|
|
132
|
+
export function buildLeaveLockedArticleEvent(context) {
|
|
133
|
+
return merge(LeaveLockedArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
141
134
|
}
|
|
142
|
-
export function buildLeaveLockedAudioPageEvent(
|
|
143
|
-
return merge(LeaveLockedAudioPage, getCommonBuildersOutput(
|
|
135
|
+
export function buildLeaveLockedAudioPageEvent(context) {
|
|
136
|
+
return merge(LeaveLockedAudioPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
144
137
|
}
|
|
145
|
-
export function buildLeaveLockedPageEvent(
|
|
146
|
-
return merge(LeaveLockedPage, getCommonBuildersOutput(
|
|
138
|
+
export function buildLeaveLockedPageEvent(context) {
|
|
139
|
+
return merge(LeaveLockedPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
147
140
|
}
|
|
148
|
-
export function buildLeavePageEvent(
|
|
149
|
-
return merge(LeavePage, getCommonBuildersOutput(
|
|
141
|
+
export function buildLeavePageEvent(context) {
|
|
142
|
+
return merge(LeavePage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
150
143
|
}
|
|
151
|
-
export function buildLeaveSportsPageEvent(
|
|
152
|
-
return merge(LeaveSportsPage, getCommonBuildersOutput(
|
|
144
|
+
export function buildLeaveSportsPageEvent(context) {
|
|
145
|
+
return merge(LeaveSportsPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
153
146
|
}
|
|
154
|
-
export function buildLeaveSchoolPageEvent(
|
|
155
|
-
return merge(LeaveSchoolPage, getCommonBuildersOutput(
|
|
147
|
+
export function buildLeaveSchoolPageEvent(context) {
|
|
148
|
+
return merge(LeaveSchoolPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
156
149
|
}
|
|
157
|
-
export function buildLeaveVideoPageEvent(
|
|
158
|
-
return merge(LeaveVideoPage, getCommonBuildersOutput(
|
|
150
|
+
export function buildLeaveVideoPageEvent(context) {
|
|
151
|
+
return merge(LeaveVideoPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
159
152
|
}
|
|
160
|
-
export function buildLeaveWeatherEvent(
|
|
161
|
-
|
|
162
|
-
const { isHybrid, version, providerId, providerName, providerGroup, providerStage, providerProduct, providerVersion, component, componentVersion, user, experiments, routingStage, } = dependencies;
|
|
163
|
-
return merge(normalizePageInput(input), LeaveWeather, timeBuilder(createdAt), trackerBuilder({ isHybrid, version, routingStage }), baseEventBuilder(), providerBuilder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup), userBuilder(user), experimentsBuilder(experiments, input.experiments), consentsBuilder(dependencies.consents), deviceBuilder(dependencies.environmentId, dependencies.jwe), catalogVersionBuilder(), navigationTypeBuilder(input.page?.navigationType), pageviewIdBuilder(dependencies.pageviewId), pageInfoBuilder(dependencies.currentPage), referrerBuilder(dependencies.currentPageReferrer));
|
|
153
|
+
export function buildLeaveWeatherEvent(context) {
|
|
154
|
+
return merge(LeaveWeather, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
164
155
|
}
|
|
165
156
|
// #endregion
|
|
166
157
|
// #region Engagement Event Builders
|
|
167
|
-
export function buildEngagementAdEvent(
|
|
168
|
-
return merge(EngagementAd, getElementEventBuildersOutput(
|
|
158
|
+
export function buildEngagementAdEvent(context) {
|
|
159
|
+
return merge(EngagementAd, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
169
160
|
}
|
|
170
|
-
export function buildEngagementAffiliateEvent(
|
|
171
|
-
return merge(EngagementAffiliate, getElementEventBuildersOutput(
|
|
161
|
+
export function buildEngagementAffiliateEvent(context) {
|
|
162
|
+
return merge(EngagementAffiliate, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
172
163
|
}
|
|
173
|
-
export function buildEngagementAudioEvent(
|
|
174
|
-
return merge(EngagementAudio, getElementEventBuildersOutput(
|
|
164
|
+
export function buildEngagementAudioEvent(context) {
|
|
165
|
+
return merge(EngagementAudio, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
175
166
|
}
|
|
176
|
-
export function buildEngagementFormEvent(
|
|
177
|
-
return merge(EngagementForm, getElementEventBuildersOutput(
|
|
167
|
+
export function buildEngagementFormEvent(context) {
|
|
168
|
+
return merge(EngagementForm, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
178
169
|
}
|
|
179
|
-
export function buildEngagementOfferEvent(
|
|
180
|
-
return merge(EngagementOffer, getElementEventBuildersOutput(
|
|
170
|
+
export function buildEngagementOfferEvent(context) {
|
|
171
|
+
return merge(EngagementOffer, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
181
172
|
}
|
|
182
|
-
export function buildEngagementSportsUIElementEvent(
|
|
183
|
-
return merge(EngagementSportsUIElement, getSportsElementEventBuildersOutput(
|
|
173
|
+
export function buildEngagementSportsUIElementEvent(context) {
|
|
174
|
+
return merge(EngagementSportsUIElement, getSportsElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
184
175
|
}
|
|
185
|
-
export function buildEngagementSchoolUIElementEvent(
|
|
186
|
-
return merge(EngagementSchoolUIElement, getElementEventBuildersOutput(
|
|
176
|
+
export function buildEngagementSchoolUIElementEvent(context) {
|
|
177
|
+
return merge(EngagementSchoolUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
187
178
|
}
|
|
188
|
-
export function buildEngagementTeaserEvent(
|
|
189
|
-
return merge(EngagementTeaser, getElementEventBuildersOutput(
|
|
179
|
+
export function buildEngagementTeaserEvent(context) {
|
|
180
|
+
return merge(EngagementTeaser, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
190
181
|
}
|
|
191
|
-
export function buildEngagementTvModuleEvent(
|
|
192
|
-
return merge(EngagementTvModule, getElementEventBuildersOutput(
|
|
182
|
+
export function buildEngagementTvModuleEvent(context) {
|
|
183
|
+
return merge(EngagementTvModule, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
193
184
|
}
|
|
194
|
-
export function buildEngagementTvSearchEvent(
|
|
195
|
-
return merge(EngagementTvSearch, getElementEventBuildersOutput(
|
|
185
|
+
export function buildEngagementTvSearchEvent(context) {
|
|
186
|
+
return merge(EngagementTvSearch, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
196
187
|
}
|
|
197
|
-
export function buildEngagementUIElementEvent(
|
|
198
|
-
return merge(EngagementUIElement, getElementEventBuildersOutput(
|
|
188
|
+
export function buildEngagementUIElementEvent(context) {
|
|
189
|
+
return merge(EngagementUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
199
190
|
}
|
|
200
|
-
export function buildEngagementVideoEvent(
|
|
201
|
-
return merge(EngagementVideo, getElementEventBuildersOutput(
|
|
191
|
+
export function buildEngagementVideoEvent(context) {
|
|
192
|
+
return merge(EngagementVideo, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
202
193
|
}
|
|
203
|
-
export function buildEngagementVideoAdEvent(
|
|
204
|
-
return merge(EngagementVideoAd, getElementEventBuildersOutput(
|
|
194
|
+
export function buildEngagementVideoAdEvent(context) {
|
|
195
|
+
return merge(EngagementVideoAd, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
205
196
|
}
|
|
206
|
-
export function buildEngagementWidgetEvent(
|
|
207
|
-
return merge(EngagementWidget, getElementEventBuildersOutput(
|
|
197
|
+
export function buildEngagementWidgetEvent(context) {
|
|
198
|
+
return merge(EngagementWidget, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
208
199
|
}
|
|
209
200
|
// #endregion
|
|
210
201
|
// #region Heartbeat Event Builders
|
|
211
|
-
export function buildHeartbeatCommercialArticleEvent(
|
|
212
|
-
return merge(HeartbeatCommercialArticle, getCommonBuildersOutput(
|
|
202
|
+
export function buildHeartbeatCommercialArticleEvent(context) {
|
|
203
|
+
return merge(HeartbeatCommercialArticle, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
213
204
|
}
|
|
214
205
|
// #endregion
|
|
215
206
|
// #region Health Event Builders
|
|
216
|
-
export function buildCompletedHealthActionEvent(
|
|
217
|
-
return merge(CompletedHealthAction, getCommonBuildersOutput(
|
|
207
|
+
export function buildCompletedHealthActionEvent(context) {
|
|
208
|
+
return merge(CompletedHealthAction, getCommonBuildersOutput(context), normalizePageInput(context.input));
|
|
218
209
|
}
|
|
219
|
-
export function buildEngagementHealthUIElementEvent(
|
|
220
|
-
return merge(EngagementHealthUIElement, getElementEventBuildersOutput(
|
|
210
|
+
export function buildEngagementHealthUIElementEvent(context) {
|
|
211
|
+
return merge(EngagementHealthUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
221
212
|
}
|
|
222
|
-
export function buildViewHealthPageEvent(
|
|
223
|
-
return merge(ViewHealthPage, getCommonBuildersOutput(
|
|
213
|
+
export function buildViewHealthPageEvent(context) {
|
|
214
|
+
return merge(ViewHealthPage, getCommonBuildersOutput(context), normalizePageInput(context.input), navigationTypeBuilder(context.input.page?.navigationType));
|
|
224
215
|
}
|
|
225
|
-
export function buildImpressionHealthUIElementEvent(
|
|
226
|
-
return merge(ImpressionHealthUIElement, getCommonBuildersOutput(
|
|
216
|
+
export function buildImpressionHealthUIElementEvent(context) {
|
|
217
|
+
return merge(ImpressionHealthUIElement, getCommonBuildersOutput(context), normalizePageInput(context.input));
|
|
227
218
|
}
|
|
228
219
|
// #endregion
|
|
229
220
|
// #region Impression Event Builders
|
|
230
|
-
export function buildImpressionAdEvent(
|
|
231
|
-
return merge(ImpressionAd, getElementEventBuildersOutput(
|
|
221
|
+
export function buildImpressionAdEvent(context) {
|
|
222
|
+
return merge(ImpressionAd, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
232
223
|
}
|
|
233
|
-
export function buildImpressionAdSlotEvent(
|
|
234
|
-
return merge(ImpressionAdSlot, getElementEventBuildersOutput(
|
|
224
|
+
export function buildImpressionAdSlotEvent(context) {
|
|
225
|
+
return merge(ImpressionAdSlot, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
235
226
|
}
|
|
236
|
-
export function buildImpressionAffiliateEvent(
|
|
237
|
-
return merge(ImpressionAffiliate, getElementEventBuildersOutput(
|
|
227
|
+
export function buildImpressionAffiliateEvent(context) {
|
|
228
|
+
return merge(ImpressionAffiliate, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
238
229
|
}
|
|
239
|
-
export function buildImpressionFormEvent(
|
|
240
|
-
return merge(ImpressionForm, getElementEventBuildersOutput(
|
|
230
|
+
export function buildImpressionFormEvent(context) {
|
|
231
|
+
return merge(ImpressionForm, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
241
232
|
}
|
|
242
|
-
export function buildImpressionOfferEvent(
|
|
243
|
-
return merge(ImpressionOffer, getElementEventBuildersOutput(
|
|
233
|
+
export function buildImpressionOfferEvent(context) {
|
|
234
|
+
return merge(ImpressionOffer, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
244
235
|
}
|
|
245
|
-
export function buildImpressionPlayerEvent(
|
|
246
|
-
return merge(ImpressionPlayer, getElementEventBuildersOutput(
|
|
236
|
+
export function buildImpressionPlayerEvent(context) {
|
|
237
|
+
return merge(ImpressionPlayer, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
247
238
|
}
|
|
248
|
-
export function buildImpressionSportsUIElementEvent(
|
|
249
|
-
return merge(ImpressionSportsUIElement, getSportsElementEventBuildersOutput(
|
|
239
|
+
export function buildImpressionSportsUIElementEvent(context) {
|
|
240
|
+
return merge(ImpressionSportsUIElement, getSportsElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
250
241
|
}
|
|
251
|
-
export function buildImpressionSchoolUIElementEvent(
|
|
252
|
-
return merge(ImpressionSchoolUIElement, getElementEventBuildersOutput(
|
|
242
|
+
export function buildImpressionSchoolUIElementEvent(context) {
|
|
243
|
+
return merge(ImpressionSchoolUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
253
244
|
}
|
|
254
|
-
export function buildImpressionTeaserEvent(
|
|
255
|
-
return merge(ImpressionTeaser, getElementEventBuildersOutput(
|
|
245
|
+
export function buildImpressionTeaserEvent(context) {
|
|
246
|
+
return merge(ImpressionTeaser, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
256
247
|
}
|
|
257
|
-
export function buildImpressionUIElementEvent(
|
|
258
|
-
return merge(ImpressionUIElement, getElementEventBuildersOutput(
|
|
248
|
+
export function buildImpressionUIElementEvent(context) {
|
|
249
|
+
return merge(ImpressionUIElement, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
259
250
|
}
|
|
260
|
-
export function buildImpressionWidgetEvent(
|
|
261
|
-
return merge(ImpressionWidget, getElementEventBuildersOutput(
|
|
251
|
+
export function buildImpressionWidgetEvent(context) {
|
|
252
|
+
return merge(ImpressionWidget, getElementEventBuildersOutput(context), normalizePageInput(context.input));
|
|
262
253
|
}
|
|
263
254
|
// #endregion
|
|
264
255
|
// #region Ad Lifecycle Event Builders
|
|
265
|
-
export function buildLoadAdEvent(
|
|
266
|
-
return merge(LoadAd, getCommonBuildersOutput(
|
|
267
|
-
}
|
|
268
|
-
export function buildRequestAdEvent(input, dependencies) {
|
|
269
|
-
return merge(RequestAd, getCommonBuildersOutput(new Date(), dependencies, input), normalizePageInput(input));
|
|
256
|
+
export function buildLoadAdEvent(context) {
|
|
257
|
+
return merge(LoadAd, getCommonBuildersOutput(context), normalizePageInput(context.input));
|
|
270
258
|
}
|
|
271
259
|
// #endregion
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { generateExperimentSDRN } from '../builders/experiments';
|
|
2
|
+
import { isString } from '../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Adapts the legacy actor input to the TPaaS user format.
|
|
5
|
+
*
|
|
6
|
+
* @privateRemarks
|
|
7
|
+
* This is a temporary solution to adapt the actor to the new format.
|
|
8
|
+
* It should be removed once we have new methods in place to get the actor.
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export function adaptActorToNewFormat(actor) {
|
|
13
|
+
if (!actor) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
id: actor.id?.toString() || '',
|
|
18
|
+
realm: actor.realm || '',
|
|
19
|
+
hasAnySubscription: !!actor.hasAnySubscription,
|
|
20
|
+
region: isString(actor.region) ? actor.region : undefined,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function adaptStatusOrOptIn({ status, optIn }) {
|
|
24
|
+
// doing an unnecessary check for status here
|
|
25
|
+
// because otherwise the code after the switch will be marked as unreachable in the IDE
|
|
26
|
+
if (status) {
|
|
27
|
+
switch (status) {
|
|
28
|
+
case 'accepted':
|
|
29
|
+
return 'Accepted';
|
|
30
|
+
case 'rejected':
|
|
31
|
+
return 'Rejected';
|
|
32
|
+
case 'unknown':
|
|
33
|
+
return 'Unknown';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (optIn === true) {
|
|
37
|
+
return 'Accepted';
|
|
38
|
+
}
|
|
39
|
+
if (optIn === false) {
|
|
40
|
+
return 'Rejected';
|
|
41
|
+
}
|
|
42
|
+
return 'Unknown';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Adapts the legacy consents to the TPaaS consents format.
|
|
46
|
+
*
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
export function adaptConsentsToNewFormat(consents) {
|
|
50
|
+
if (!consents) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const { purposes, source } = consents;
|
|
54
|
+
const { CMP_ADVERTISING, CMP_ANALYTICS, CMP_MARKETING, CMP_PERSONALIZATION } = purposes;
|
|
55
|
+
return {
|
|
56
|
+
advertising: adaptStatusOrOptIn(CMP_ADVERTISING),
|
|
57
|
+
analytics: adaptStatusOrOptIn(CMP_ANALYTICS),
|
|
58
|
+
marketing: adaptStatusOrOptIn(CMP_MARKETING),
|
|
59
|
+
personalization: adaptStatusOrOptIn(CMP_PERSONALIZATION),
|
|
60
|
+
source: source || 'unknown',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Adapts the base experiments stored in the tracker to the TPaaS experiments format.
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
export function adaptExperiments(baseExperiments = []) {
|
|
69
|
+
return baseExperiments.map((exp) => {
|
|
70
|
+
return {
|
|
71
|
+
name: exp.name || exp.id,
|
|
72
|
+
variant: exp.variant || '',
|
|
73
|
+
// nobody should be sending experiment id with an sdrn format, but in case they do
|
|
74
|
+
// we want to be able to handle it and not generate an invalid sdrn by adding another layer to it
|
|
75
|
+
experimentSdrn: exp.id.startsWith('sdrn:') ? exp.id : generateExperimentSDRN(exp.id, exp.platform),
|
|
76
|
+
platform: exp.platform || '',
|
|
77
|
+
testId: exp.custom?.testId,
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isBrowser } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the browser state that can change between events, such as the URL after an SPA navigation
|
|
4
|
+
* or the viewport after a resize. Call it synchronously, when the event is tracked.
|
|
5
|
+
*
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
export const captureBrowserContext = () => {
|
|
9
|
+
if (!isBrowser) {
|
|
10
|
+
return {
|
|
11
|
+
url: undefined,
|
|
12
|
+
search: '',
|
|
13
|
+
screenOrientationType: undefined,
|
|
14
|
+
viewportWidth: 0,
|
|
15
|
+
viewportHeight: 0,
|
|
16
|
+
userAgent: undefined,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const { viewportWidth, viewportHeight } = getViewportDimensions();
|
|
20
|
+
return {
|
|
21
|
+
url: window.location.href,
|
|
22
|
+
search: window.location.search ?? '',
|
|
23
|
+
screenOrientationType: window.screen.orientation?.type,
|
|
24
|
+
viewportWidth,
|
|
25
|
+
viewportHeight,
|
|
26
|
+
userAgent: window.navigator.userAgent,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
function getViewportDimensions() {
|
|
30
|
+
let viewportWidth;
|
|
31
|
+
let viewportHeight;
|
|
32
|
+
const { document } = window;
|
|
33
|
+
if (typeof window.innerWidth !== 'undefined') {
|
|
34
|
+
viewportWidth = window.innerWidth;
|
|
35
|
+
viewportHeight = window.innerHeight;
|
|
36
|
+
}
|
|
37
|
+
else if (typeof document.documentElement.clientWidth !== 'undefined' &&
|
|
38
|
+
document.documentElement.clientWidth !== 0) {
|
|
39
|
+
viewportWidth = document.documentElement.clientWidth;
|
|
40
|
+
viewportHeight = document.documentElement.clientHeight;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
viewportWidth = document.getElementsByTagName('body')[0].clientWidth;
|
|
44
|
+
viewportHeight = document.getElementsByTagName('body')[0].clientHeight;
|
|
45
|
+
}
|
|
46
|
+
return { viewportWidth, viewportHeight };
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { prepareAnonymousTpaasEventContext, prepareTpaasEventContext } from './prepare';
|