@schibsted/pulse-sdk 8.0.0-rc.2 → 8.0.0-rc.20
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 +578 -303
- package/dist/cjs/app-integration.js +3 -3
- package/dist/cjs/builders/actor.js +6 -6
- package/dist/cjs/builders/consents.js +8 -8
- package/dist/cjs/builders/device-browser.js +8 -8
- package/dist/cjs/builders/device-node.js +3 -3
- package/dist/cjs/builders/events-anonymous-node.js +3 -3
- package/dist/cjs/builders/events-node.js +7 -7
- package/dist/cjs/builders/experimentMetadata.js +2 -2
- package/dist/cjs/builders/experiments.js +1 -0
- package/dist/cjs/builders/objects/objects-anonymous-browser.js +2 -2
- package/dist/cjs/builders/objects/objects-anonymous-node.js +9 -9
- package/dist/cjs/builders/objects/objects-browser.js +2 -2
- package/dist/cjs/builders/objects/objects-node.js +10 -10
- package/dist/cjs/builders/objects/utils.js +3 -3
- package/dist/cjs/builders/origin-browser.js +2 -2
- package/dist/cjs/builders/origin-node.js +4 -4
- package/dist/cjs/builders/session-browser.js +6 -5
- package/dist/cjs/cis-sync/cis-browser.js +219 -0
- package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/cis.js +0 -1
- package/dist/cjs/cis-sync/eventEmitter.js +37 -0
- package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/index.js +0 -1
- package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/pulse-cookie.js +53 -63
- package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/storage/pulseStorage.js +28 -21
- package/dist/cjs/cis-sync/storage/storage.js +24 -0
- package/dist/cjs/createPulseTracker.js +4 -4
- package/dist/cjs/identity/actor.js +20 -8
- package/dist/cjs/identity/advertising.js +1 -1
- package/dist/cjs/identity/cis.js +7 -6
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/leaveTracking/index.js +10 -10
- package/dist/cjs/leaveTrackingTpaas/constants.js +2 -7
- package/dist/cjs/leaveTrackingTpaas/index.js +70 -46
- package/dist/cjs/network-browser.js +3 -3
- package/dist/cjs/remoteConfig/index.js +5 -5
- package/dist/cjs/tpaas-builders/builders/catalogVersion.js +9 -0
- package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/device.js +11 -5
- package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/navigationType.js +2 -3
- package/dist/cjs/tpaas-builders/builders/pageContent.js +7 -0
- package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/pageInfo.js +2 -2
- package/dist/cjs/tpaas-builders/builders/pageSports.js +7 -0
- package/dist/cjs/tpaas-builders/builders/provider.js +19 -0
- package/dist/cjs/tpaas-builders/builders/referrer.js +17 -0
- package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/session.js +23 -20
- package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/trackerBuilder.js +2 -3
- package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/user.js +1 -1
- package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/utm.js +3 -3
- package/dist/cjs/tpaas-builders/builders.js +339 -0
- package/dist/cjs/tpaas-builders/guards.js +7 -0
- package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/index.js +3 -0
- package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/tpaas-builders}/types.js +0 -1
- package/{node_modules/@schibsted/tpaas-schemas/dist/cjs → dist/cjs/tpaas-schemas}/constants.js +193 -155
- package/{node_modules/@schibsted/tpaas-schemas/dist/cjs → dist/cjs/tpaas-schemas}/index.js +1 -0
- package/dist/cjs/tpaas-schemas/types.js +2 -0
- package/dist/cjs/tracker-proxy/consts.js +29 -6
- package/dist/cjs/tracker-proxy/proxy-provider.js +2 -2
- package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/index.js +4 -1
- package/dist/cjs/utils/xDomainId.js +15 -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/cjs/wrapper/utils/map-page-to-page-ref.js +13 -0
- package/dist/ejs/Tracker.js +510 -235
- package/dist/ejs/app-integration.js +1 -1
- package/dist/ejs/builders/actor.js +3 -3
- package/dist/ejs/builders/consents.js +4 -4
- package/dist/ejs/builders/device-browser.js +2 -2
- package/dist/ejs/builders/device-node.js +1 -1
- package/dist/ejs/builders/events-anonymous-node.js +1 -1
- package/dist/ejs/builders/events-node.js +4 -4
- package/dist/ejs/builders/experimentMetadata.js +1 -1
- package/dist/ejs/builders/experiments.js +1 -1
- package/dist/ejs/builders/objects/objects-anonymous-browser.js +1 -1
- package/dist/ejs/builders/objects/objects-anonymous-node.js +1 -1
- package/dist/ejs/builders/objects/objects-browser.js +1 -1
- package/dist/ejs/builders/objects/objects-node.js +1 -1
- package/dist/ejs/builders/objects/utils.js +1 -1
- package/dist/ejs/builders/origin-browser.js +1 -1
- package/dist/ejs/builders/origin-node.js +1 -1
- package/dist/ejs/builders/session-browser.js +2 -1
- package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/cis-browser.js +17 -4
- package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/cis.js +0 -1
- package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/eventEmitter.js +0 -1
- package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/index.js +0 -1
- package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/pulse-cookie.js +1 -2
- package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/storage/pulseStorage.js +12 -4
- package/{node_modules/@schibsted/pulse-cis-sync/dist/ejs → dist/ejs/cis-sync}/storage/storage.js +6 -2
- package/dist/ejs/createPulseTracker.js +1 -1
- package/dist/ejs/identity/actor.js +21 -9
- package/dist/ejs/identity/advertising.js +1 -1
- package/dist/ejs/identity/cis.js +4 -3
- package/dist/ejs/index.js +4 -3
- package/dist/ejs/leaveTracking/index.js +1 -1
- package/dist/ejs/leaveTrackingTpaas/constants.js +1 -5
- package/dist/ejs/leaveTrackingTpaas/index.js +65 -41
- package/dist/ejs/network-browser.js +1 -1
- package/dist/ejs/remoteConfig/index.js +1 -1
- package/dist/ejs/tpaas-builders/builders/catalogVersion.js +6 -0
- package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/device.js +10 -4
- package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/navigationType.js +2 -3
- package/dist/ejs/tpaas-builders/builders/pageContent.js +3 -0
- package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/pageInfo.js +1 -1
- package/dist/ejs/tpaas-builders/builders/pageSports.js +3 -0
- package/dist/ejs/tpaas-builders/builders/provider.js +16 -0
- package/dist/ejs/tpaas-builders/builders/referrer.js +13 -0
- package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/session.js +18 -15
- package/dist/ejs/tpaas-builders/builders/trackerBuilder.js +10 -0
- package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/user.js +1 -1
- package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/utm.js +2 -2
- package/dist/ejs/tpaas-builders/builders.js +271 -0
- package/dist/ejs/tpaas-builders/guards.js +4 -0
- package/dist/ejs/tpaas-builders/index.js +2 -0
- package/{node_modules/@schibsted/tpaas-schemas/dist/ejs → dist/ejs/tpaas-schemas}/constants.js +191 -153
- package/{node_modules/@schibsted/tpaas-schemas/dist/ejs → dist/ejs/tpaas-schemas}/index.js +1 -0
- package/dist/ejs/tpaas-schemas/types.js +1 -0
- package/dist/ejs/tracker-proxy/consts.js +29 -6
- package/dist/ejs/tracker-proxy/proxy-provider.js +1 -1
- package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/index.js +1 -0
- package/dist/ejs/utils/xDomainId.js +11 -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/ejs/wrapper/utils/map-page-to-page-ref.js +10 -0
- package/dist/types/Tracker.d.ts +178 -77
- package/dist/types/builders/actor.d.ts +3 -2
- package/dist/types/builders/consents.d.ts +3 -3
- package/dist/types/builders/device-node.d.ts +2 -2
- package/dist/types/builders/events-anonymous-node.d.ts +4 -4
- package/dist/types/builders/events-node.d.ts +5 -5
- package/dist/types/builders/experiments.d.ts +1 -0
- package/dist/types/builders/index.d.ts +1 -1
- package/dist/types/builders/objects/objects-anonymous-node.d.ts +1 -1
- package/dist/types/builders/objects/objects-node.d.ts +1 -1
- package/dist/types/builders/origin-node.d.ts +1 -1
- package/dist/types/builders/session-browser.d.ts +1 -0
- package/{node_modules/@schibsted/pulse-cis-sync/dist/types → dist/types/cis-sync}/cis-browser.d.ts +1 -0
- package/{node_modules/@schibsted/pulse-cis-sync/dist/types → dist/types/cis-sync}/storage/pulseStorage.d.ts +12 -4
- package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/storage/storage.d.ts +2 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/createPulseTracker.d.ts +1 -1
- package/dist/types/identity/actor.d.ts +3 -3
- package/dist/types/identity/advertising.d.ts +2 -2
- package/dist/types/identity/cis.d.ts +4 -4
- package/dist/types/index.d.ts +7 -8
- 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 +2 -10
- package/dist/types/tpaas-builders/builders/anonymous.d.ts +3 -0
- package/dist/types/tpaas-builders/builders/baseEvent.d.ts +3 -0
- package/dist/types/tpaas-builders/builders/catalogVersion.d.ts +3 -0
- package/dist/types/tpaas-builders/builders/consents.d.ts +5 -0
- package/dist/types/tpaas-builders/builders/device.d.ts +5 -0
- package/dist/types/tpaas-builders/builders/experiments.d.ts +9 -0
- package/dist/types/tpaas-builders/builders/navigationType.d.ts +6 -0
- package/dist/types/tpaas-builders/builders/pageContent.d.ts +6 -0
- package/dist/types/tpaas-builders/builders/pageInfo.d.ts +6 -0
- package/dist/types/tpaas-builders/builders/pageSports.d.ts +6 -0
- package/dist/types/tpaas-builders/builders/pageviewId.d.ts +6 -0
- package/dist/types/tpaas-builders/builders/provider.d.ts +5 -0
- package/dist/types/tpaas-builders/builders/referrer.d.ts +6 -0
- package/dist/types/tpaas-builders/builders/session.d.ts +15 -0
- package/dist/types/tpaas-builders/builders/time.d.ts +4 -0
- package/dist/types/tpaas-builders/builders/trackerBuilder.d.ts +5 -0
- package/dist/types/tpaas-builders/builders/user.d.ts +5 -0
- package/dist/types/tpaas-builders/builders/utm.d.ts +6 -0
- package/dist/types/tpaas-builders/builders.d.ts +141 -0
- package/dist/types/tpaas-builders/guards.d.ts +2 -0
- package/dist/types/tpaas-builders/index.d.ts +3 -0
- package/dist/types/tpaas-builders/types.d.ts +36 -0
- package/dist/types/tpaas-schemas/constants.d.ts +478 -0
- package/dist/types/tpaas-schemas/index.d.ts +5 -0
- package/dist/types/tpaas-schemas/types/ITpaasEvent.d.ts +132 -0
- package/dist/types/tpaas-schemas/types/schemas/IAnonymousViewUIElement.d.ts +58 -0
- package/dist/types/tpaas-schemas/types/schemas/ICompletedHealthAction.d.ts +139 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementAd.d.ts +117 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementAffiliate.d.ts +144 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementAudio.d.ts +209 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementForm.d.ts +111 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementHealthUIElement.d.ts +133 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementOffer.d.ts +107 -0
- 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/IEngagementTeaser.d.ts +114 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementTvModule.d.ts +130 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementTvSearch.d.ts +142 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementUIElement.d.ts +105 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementVideo.d.ts +234 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementVideoAd.d.ts +145 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementWidget.d.ts +91 -0
- package/dist/types/tpaas-schemas/types/schemas/IHeartbeatCommercialArticle.d.ts +96 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionAd.d.ts +115 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionAdSlot.d.ts +89 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionAffiliate.d.ts +142 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionForm.d.ts +113 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionHealthUIElement.d.ts +138 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionOffer.d.ts +109 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionPlayer.d.ts +108 -0
- 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/IImpressionTeaser.d.ts +112 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionUIElement.d.ts +107 -0
- package/dist/types/tpaas-schemas/types/schemas/IImpressionWidget.d.ts +89 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveArticle.d.ts +133 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveAudioPage.d.ts +88 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveError.d.ts +95 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveFrontpage.d.ts +83 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveLandingpage.d.ts +90 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveListing.d.ts +123 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedArticle.d.ts +139 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedAudioPage.d.ts +97 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedPage.d.ts +90 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveLockedVideoPage.d.ts +97 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeavePage.d.ts +82 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveSchoolPage.d.ts +84 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveSportsPage.d.ts +137 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveVideoPage.d.ts +91 -0
- package/dist/types/tpaas-schemas/types/schemas/ILeaveWeather.d.ts +94 -0
- package/dist/types/tpaas-schemas/types/schemas/ILoadAd.d.ts +119 -0
- package/dist/types/tpaas-schemas/types/schemas/IRequestAd.d.ts +95 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewArticle.d.ts +133 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewAudioPage.d.ts +87 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewError.d.ts +90 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewFrontpage.d.ts +80 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewHealthPage.d.ts +119 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewLandingpage.d.ts +76 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewListing.d.ts +118 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewLockedArticle.d.ts +139 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewLockedAudioPage.d.ts +95 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewLockedPage.d.ts +94 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewLockedVideoPage.d.ts +95 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewPage.d.ts +86 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewSchoolPage.d.ts +88 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewSportsPage.d.ts +135 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewTitle.d.ts +92 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewVideoPage.d.ts +87 -0
- package/dist/types/tpaas-schemas/types/schemas/IViewWeather.d.ts +94 -0
- package/dist/types/tpaas-schemas/types/schemas/index.d.ts +64 -0
- package/dist/types/tpaas-schemas/types/templates/IBranded.d.ts +42 -0
- package/dist/types/tpaas-schemas/types/templates/IConsents.d.ts +34 -0
- package/dist/types/tpaas-schemas/types/templates/IContent.d.ts +56 -0
- package/dist/types/tpaas-schemas/types/templates/IDevice.d.ts +62 -0
- package/dist/types/tpaas-schemas/types/templates/IEngagement.d.ts +21 -0
- package/dist/types/tpaas-schemas/types/templates/IExperiments.d.ts +35 -0
- package/dist/types/tpaas-schemas/types/templates/IHealthFood.d.ts +55 -0
- package/dist/types/tpaas-schemas/types/templates/IHealthOrigin.d.ts +27 -0
- package/dist/types/tpaas-schemas/types/templates/IHealthPhysicalActivity.d.ts +36 -0
- package/dist/types/tpaas-schemas/types/templates/IHealthTraining.d.ts +74 -0
- package/dist/types/tpaas-schemas/types/templates/IHealthUserData.d.ts +25 -0
- package/dist/types/tpaas-schemas/types/templates/ILeave.d.ts +54 -0
- package/dist/types/tpaas-schemas/types/templates/ILeaveAudio.d.ts +37 -0
- package/dist/types/tpaas-schemas/types/templates/ILeaveStories.d.ts +34 -0
- package/dist/types/tpaas-schemas/types/templates/ILocation.d.ts +21 -0
- package/dist/types/tpaas-schemas/types/templates/IMetrics.d.ts +32 -0
- package/dist/types/tpaas-schemas/types/templates/IPageRef.d.ts +46 -0
- package/dist/types/tpaas-schemas/types/templates/IPlacement.d.ts +45 -0
- package/dist/types/tpaas-schemas/types/templates/IProvider.d.ts +73 -0
- package/dist/types/tpaas-schemas/types/templates/ISchool.d.ts +74 -0
- package/dist/types/tpaas-schemas/types/templates/ISession.d.ts +33 -0
- package/dist/types/tpaas-schemas/types/templates/ISports.d.ts +98 -0
- package/dist/types/tpaas-schemas/types/templates/ISportsUserFeatures.d.ts +28 -0
- package/dist/types/tpaas-schemas/types/templates/ITime.d.ts +32 -0
- package/dist/types/tpaas-schemas/types/templates/ITracker.d.ts +37 -0
- package/dist/types/tpaas-schemas/types/templates/IUser.d.ts +34 -0
- package/dist/types/tpaas-schemas/types/templates/IUtmTags.d.ts +38 -0
- package/dist/types/tpaas-schemas/types/templates/index.d.ts +27 -0
- package/dist/types/tpaas-schemas/types.d.ts +42 -0
- package/dist/types/tracker-proxy/consts.d.ts +2 -2
- package/dist/types/types.d.ts +19 -13
- package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/index.d.ts +1 -0
- package/dist/types/utils/xDomainId.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/visibility-observer/index.d.ts +6 -1
- package/dist/types/wrapper/engagement/ui-element/types.d.ts +1 -1
- package/dist/types/wrapper/types/base-event.d.ts +1 -1
- package/dist/types/wrapper/types/event.d.ts +4 -2
- package/dist/types/wrapper/types/utils.d.ts +1 -1
- package/dist/types/wrapper/utils/map-page-to-page-ref.d.ts +3 -0
- package/dist/types/wrapper/view/article/types.d.ts +1 -1
- package/dist/types/wrapper/view/frontpage/types.d.ts +1 -1
- package/dist/types/wrapper/view/listing/types.d.ts +1 -1
- package/dist/types/wrapper/view/loginposter/types.d.ts +1 -1
- package/dist/types/wrapper/view/page/types.d.ts +1 -1
- package/dist/types/wrapper/view/salesposter/types.d.ts +1 -1
- package/dist/types/wrapper/view/ui-element/types.d.ts +1 -1
- package/package.json +21 -20
- package/dist/cjs/Tracker.test-d.js +0 -76
- package/dist/ejs/Tracker.test-d.js +0 -71
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.d.ts +0 -26
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js +0 -273
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.js +0 -39
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/index.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/pulse-cookie.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.d.ts +0 -36
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js +0 -21
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/types.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.d.ts +0 -26
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.d.ts +0 -10
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.d.ts +0 -14
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.d.ts +0 -4
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.d.ts +0 -55
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.d.ts +0 -36
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.d.ts +0 -6
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.d.ts +0 -24
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.js +0 -2
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.js.map +0 -1
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/cis.d.ts +0 -10
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/eventEmitter.d.ts +0 -14
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/index.d.ts +0 -4
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/pulse-cookie.d.ts +0 -55
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/storage/storage.d.ts +0 -6
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/types.d.ts +0 -24
- package/node_modules/@schibsted/pulse-cis-sync/package.json +0 -44
- package/node_modules/@schibsted/pulse-utils/package.json +0 -36
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/provider.js +0 -12
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/referrer.js +0 -19
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders.js +0 -272
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/provider.js +0 -9
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/referrer.js +0 -15
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/trackerBuilder.js +0 -11
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders.js +0 -215
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/index.js +0 -1
- package/node_modules/@schibsted/tpaas-event-builder/dist/index.d.ts +0 -5403
- package/node_modules/@schibsted/tpaas-event-builder/package.json +0 -40
- package/node_modules/@schibsted/tpaas-schemas/dist/index.d.ts +0 -6176
- package/node_modules/@schibsted/tpaas-schemas/package.json +0 -35
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/cis-sync}/types.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/anonymous.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/baseEvent.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/consents.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/experiments.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/pageviewId.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/cjs → dist/cjs/tpaas-builders}/builders/time.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/cookie-config.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/cookie.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/events.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/get.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/getRootDomain.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/merge.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/objects.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/omit.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/randomString.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/throttle.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/cjs → dist/cjs/utils}/webApi.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/cis-sync}/types.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/anonymous.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/baseEvent.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/consents.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/experiments.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/pageviewId.js +0 -0
- /package/{node_modules/@schibsted/tpaas-event-builder/dist/ejs → dist/ejs/tpaas-builders}/builders/time.js +0 -0
- /package/dist/{types/Tracker.test-d.d.ts → ejs/tpaas-builders/types.js} +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/cookie-config.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/cookie.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/events.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/get.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/getRootDomain.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/merge.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/objects.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/omit.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/randomString.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/throttle.js +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/ejs → dist/ejs/utils}/webApi.js +0 -0
- /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/cis.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/eventEmitter.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/index.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/pulse-cookie.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/types/cis-sync}/types.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/cookie-config.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/cookie.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/events.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/get.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/getRootDomain.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/merge.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/objects.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/omit.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/randomString.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/throttle.d.ts +0 -0
- /package/{node_modules/@schibsted/pulse-utils/dist/types → dist/types/utils}/webApi.d.ts +0 -0
package/dist/ejs/Tracker.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { parsePulseCookies } from '@schibsted/pulse-cis-sync';
|
|
2
|
-
import { evaluateAndFlatten, isBrowser, isFunction, isPromise, isString, pulseMerge, throttle, } from '@schibsted/pulse-utils';
|
|
3
|
-
import { buildAnonymousViewUIElementEvent, buildCompletedHealthActionEvent, buildEngagementAudioEvent, buildEngagementFormEvent, buildEngagementHealthUIElementEvent, buildEngagementOfferEvent, buildEngagementTeaserEvent, buildEngagementUIElementEvent, buildEngagementVideoAdEvent, buildEngagementVideoEvent, buildEngagementWidgetEvent, buildImpressionAdSlotEvent, buildImpressionFormEvent, buildImpressionHealthUIElementEvent, buildImpressionOfferEvent, buildImpressionPlayerEvent, buildImpressionTeaserEvent, buildImpressionUIElementEvent, buildImpressionWidgetEvent, buildLeaveArticleEvent, buildLeaveAudioPageEvent, buildLeaveErrorEvent, buildLeaveFrontpageEvent, buildLeaveLandingpageEvent, buildLeaveListingEvent, buildLeaveLockedArticleEvent, buildLeaveLockedAudioEvent, buildLeaveLockedAudioPageEvent, buildLeaveLockedVideoEvent, buildLeaveLockedVideoPageEvent, buildLeavePageEvent, buildLeaveSportsPageEvent, buildLeaveVideoPageEvent, buildLeaveWeatherEvent, buildViewArticleEvent, buildViewAudioEvent, buildViewAudioPageEvent, buildViewErrorEvent, buildViewFrontpageEvent, buildViewHealthPageEvent, buildViewLandingpageEvent, buildViewListingEvent, buildViewLockedArticleEvent, buildViewLockedAudioEvent, buildViewLockedAudioPageEvent, buildViewLockedVideoEvent, buildViewLockedVideoPageEvent, buildViewPageEvent, buildViewSportsPageEvent, buildViewTitleEvent, buildViewVideoEvent, buildViewVideoPageEvent, buildViewWeatherEvent, getCommonBuildersOutput, } from '@schibsted/tpaas-event-builder';
|
|
4
|
-
import { LeaveArticle, LeaveAudioPage, LeaveError, LeaveFrontpage, LeaveLandingpage, LeaveListing, LeaveLockedArticle, LeaveLockedAudioPage, LeaveLockedVideoPage, LeavePage, LeaveSportsPage, LeaveVideoPage, LeaveWeather, ViewArticle, ViewError, ViewFrontpage, ViewListing, ViewLockedArticle, ViewLockedVideo, ViewPage, ViewTitle, } from '@schibsted/tpaas-schemas';
|
|
5
1
|
import logger from 'loglevel';
|
|
6
2
|
import { v4 } from 'uuid';
|
|
7
3
|
import { getDefaultAltHandler, getDefaultNativeJwe } from './app-integration';
|
|
@@ -10,7 +6,9 @@ import { getConsentsWaitForAnalytics, getFallbackConsents } from './builders/con
|
|
|
10
6
|
import { applyAdvertisingConsent, applyAdvertisingConsentSync, } from './builders/consents';
|
|
11
7
|
import { engagementEvent, identityEvent, routableEvent, trackerEvent } from './builders/events';
|
|
12
8
|
import { anonymousEngagementEvent, anonymousTrackerEvent } from './builders/events-anonymous-node';
|
|
9
|
+
import { generateExperimentSDRN } from './builders/experiments';
|
|
13
10
|
import { readSession } from './builders/session-browser';
|
|
11
|
+
import { parsePulseCookies } from './cis-sync';
|
|
14
12
|
import { baseConfig as defaultConfig } from './config';
|
|
15
13
|
import { CISEndpoints, collectorEndpoints, remoteConfig } from './config-browser';
|
|
16
14
|
import defer from './defer';
|
|
@@ -20,11 +18,16 @@ import { addPageLeaveTracking, leaveTrackingIsActive, removePageLeaveTracking, r
|
|
|
20
18
|
import { addTpaasLeaveTracking, getTpaasLeaveObject, leaveTpaasTrackingIsActive, resetTpaasViewedContent, shouldEnableLeaveTracking, trackTpaasActiveLeave, updateTpaasLeaveTracking, updateTpaasViewedContent, } from './leaveTrackingTpaas';
|
|
21
19
|
import send from './network';
|
|
22
20
|
import * as config from './remoteConfig';
|
|
21
|
+
import { buildAnonymousViewUIElementEvent, buildCompletedHealthActionEvent, buildEngagementAdEvent, buildEngagementAffiliateEvent, buildEngagementAudioEvent, buildEngagementFormEvent, buildEngagementHealthUIElementEvent, buildEngagementOfferEvent, buildEngagementSchoolUIElementEvent, buildEngagementSportsUIElementEvent, buildEngagementTeaserEvent, buildEngagementTvModuleEvent, buildEngagementTvSearchEvent, buildEngagementUIElementEvent, buildEngagementVideoAdEvent, buildEngagementVideoEvent, buildEngagementWidgetEvent, buildHeartbeatCommercialArticleEvent, buildImpressionAdEvent, buildImpressionAdSlotEvent, buildImpressionAffiliateEvent, buildImpressionFormEvent, buildImpressionHealthUIElementEvent, buildImpressionOfferEvent, buildImpressionPlayerEvent, buildImpressionSchoolUIElementEvent, buildImpressionSportsUIElementEvent, buildImpressionTeaserEvent, buildImpressionUIElementEvent, buildImpressionWidgetEvent, buildLeaveArticleEvent, buildLeaveAudioPageEvent, buildLeaveErrorEvent, buildLeaveFrontpageEvent, buildLeaveLandingpageEvent, buildLeaveListingEvent, buildLeaveLockedArticleEvent, buildLeaveLockedAudioPageEvent, buildLeaveLockedPageEvent, buildLeaveLockedVideoPageEvent, buildLeavePageEvent, buildLeaveSchoolPageEvent, buildLeaveSportsPageEvent, buildLeaveVideoPageEvent, buildLeaveWeatherEvent, buildLoadAdEvent, buildRequestAdEvent, buildViewArticleEvent, buildViewAudioPageEvent, buildViewErrorEvent, buildViewFrontpageEvent, buildViewHealthPageEvent, buildViewLandingpageEvent, buildViewListingEvent, buildViewLockedArticleEvent, buildViewLockedAudioPageEvent, buildViewLockedPageEvent, buildViewLockedVideoPageEvent, buildViewPageEvent, buildViewSchoolPageEvent, buildViewSportsPageEvent, buildViewTitleEvent, buildViewVideoPageEvent, buildViewWeatherEvent, } from './tpaas-builders';
|
|
22
|
+
import { LeaveArticle, LeaveAudioPage, LeaveError, LeaveFrontpage, LeaveLandingpage, LeaveListing, LeaveLockedArticle, LeaveLockedAudioPage, LeaveLockedPage, LeaveLockedVideoPage, LeavePage, LeaveSchoolPage, LeaveSportsPage, LeaveVideoPage, LeaveWeather, ViewArticle, ViewAudioPage, ViewError, ViewFrontpage, ViewHealthPage, ViewLandingpage, ViewListing, ViewLockedArticle, ViewLockedAudioPage, ViewLockedPage, ViewLockedVideoPage, ViewPage, ViewSportsPage, ViewTitle, ViewVideoPage, ViewWeather, } from './tpaas-schemas';
|
|
23
23
|
import { startProxyProviderListener } from './tracker-proxy/proxy-provider';
|
|
24
|
+
import { evaluateAndFlatten, isBrowser, isFunction, isPromise, isString, omit, pulseMerge, throttle } from './utils';
|
|
24
25
|
import { SDK_VERSION } from './version';
|
|
25
26
|
import { VisibilityObserver } from './visibility-observer';
|
|
26
27
|
import warnOnce from './warnOnce';
|
|
27
28
|
import { buildClickUIElementEvent } from './wrapper/engagement/ui-element/event-builder';
|
|
29
|
+
import { isLegacyPageType } from './wrapper/types';
|
|
30
|
+
import { mapPageToPageRef } from './wrapper/utils/map-page-to-page-ref';
|
|
28
31
|
import { pageFromPageView } from './wrapper/utils/page-from-page-view';
|
|
29
32
|
import { buildLegacyViewArticleEvent } from './wrapper/view/article/event-builder';
|
|
30
33
|
import { buildLegacyViewFrontpageEvent } from './wrapper/view/frontpage/event-builder';
|
|
@@ -60,6 +63,7 @@ const anonymousEvents = {
|
|
|
60
63
|
trackerEvent: anonymousTrackerEvent,
|
|
61
64
|
engagementEvent: anonymousEngagementEvent,
|
|
62
65
|
};
|
|
66
|
+
const ANONYMOUS_EVENT_FORBIDDEN_FIELDS = ['session', 'actor', 'device', 'location', 'pageViewId'];
|
|
63
67
|
/**
|
|
64
68
|
* @typeParam T Type of event to track
|
|
65
69
|
* @param name
|
|
@@ -68,6 +72,17 @@ const anonymousEvents = {
|
|
|
68
72
|
function getAnonymousEventBuilder(name) {
|
|
69
73
|
return name in anonymousEvents ? anonymousEvents[name] : anonymousEvents.trackerEvent;
|
|
70
74
|
}
|
|
75
|
+
// This looks overkill, but a mapping feels safer than doing string operations (capitalize) with javascript
|
|
76
|
+
const mapDeployStageToTpaasStage = (deployStage) => {
|
|
77
|
+
switch (deployStage) {
|
|
78
|
+
case 'dev':
|
|
79
|
+
return 'Dev';
|
|
80
|
+
case 'pre':
|
|
81
|
+
return 'Pre';
|
|
82
|
+
case 'pro':
|
|
83
|
+
return 'Pro';
|
|
84
|
+
}
|
|
85
|
+
};
|
|
71
86
|
/**
|
|
72
87
|
* Determines if the SDK is running in a Hybrid (WebView) environment.
|
|
73
88
|
*
|
|
@@ -114,6 +129,21 @@ export function unsubscribe(eventName, callback) {
|
|
|
114
129
|
* @class Tracker
|
|
115
130
|
*/
|
|
116
131
|
export default class Tracker {
|
|
132
|
+
async getCurrentTpaasPage(currentPageInfo = this.currentPageContext.info) {
|
|
133
|
+
const { id, type, url } = await currentPageInfo;
|
|
134
|
+
return mapPageToPageRef(id, type, url);
|
|
135
|
+
}
|
|
136
|
+
async getCurrentLegacyPage() {
|
|
137
|
+
const { id, type, url } = await this.currentPageContext.info;
|
|
138
|
+
// make sure the pageType is valid for legacy events
|
|
139
|
+
const validatedType = isLegacyPageType(type) ? type : 'Page';
|
|
140
|
+
return {
|
|
141
|
+
// add the SDRN prefix if it's not there, legacy events expect the full SDRN format
|
|
142
|
+
id: id.startsWith('sdrn:') ? id : `sdrn:${this.state.providerId}:${validatedType.toLowerCase()}:${id}`,
|
|
143
|
+
type: validatedType,
|
|
144
|
+
url,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
117
147
|
/**
|
|
118
148
|
* > [!WARNING]
|
|
119
149
|
* >
|
|
@@ -132,12 +162,36 @@ export default class Tracker {
|
|
|
132
162
|
// the tracking of the same element with both old and new events at the same time
|
|
133
163
|
this.legacyVisibilityObservers = new Map();
|
|
134
164
|
this.visibilityObservers = new Map();
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Current page state shared by legacy and TPaaS tracking. See CurrentPageContext for
|
|
167
|
+
* which properties are shared and which are exclusively TPaaS metadata.
|
|
168
|
+
*/
|
|
169
|
+
this.currentPageContext = {
|
|
170
|
+
info: {
|
|
171
|
+
id: 'unknown',
|
|
172
|
+
type: 'Page',
|
|
173
|
+
url: isBrowser ? window.location.href : undefined,
|
|
174
|
+
},
|
|
175
|
+
referrer: {
|
|
176
|
+
url: isBrowser ? document.referrer || undefined : undefined,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
this.setCurrentTpaasPageData = ({ id, type, referrer, content, sports, }) => {
|
|
180
|
+
// TPaaS Views replace the context, intentionally resetting omitted content and sports.
|
|
181
|
+
this.currentPageContext = {
|
|
182
|
+
info: {
|
|
183
|
+
id: id || 'unknown',
|
|
184
|
+
type: type || 'Page',
|
|
185
|
+
url: isBrowser ? window.location.href : undefined,
|
|
186
|
+
},
|
|
187
|
+
referrer: {
|
|
188
|
+
...referrer,
|
|
189
|
+
url: referrer?.url ?? (isBrowser ? document.referrer || undefined : undefined),
|
|
190
|
+
},
|
|
191
|
+
content,
|
|
192
|
+
sports,
|
|
193
|
+
};
|
|
139
194
|
};
|
|
140
|
-
this.currentPage = undefined;
|
|
141
195
|
/**
|
|
142
196
|
* Promise that resolves when a session ID becomes available
|
|
143
197
|
* @private
|
|
@@ -149,24 +203,22 @@ export default class Tracker {
|
|
|
149
203
|
*/
|
|
150
204
|
this.hasProxyListener = false;
|
|
151
205
|
this.setPageDefaults = (pageViewEvent) => {
|
|
152
|
-
|
|
206
|
+
// Legacy Views update only the shared properties, preserving TPaaS-only content and sports.
|
|
207
|
+
this.currentPageContext.info = pageFromPageView(pageViewEvent);
|
|
208
|
+
this.currentPageContext.referrer = Promise.resolve(pageViewEvent.origin).then((originProperties) => mapPageToPageRef(originProperties?.id, originProperties?.type, originProperties?.url));
|
|
153
209
|
if (pageViewEvent.origin) {
|
|
154
210
|
const pageDefaults = { origin: pageViewEvent.origin };
|
|
155
211
|
this.update(pageDefaults, true);
|
|
156
212
|
}
|
|
157
213
|
};
|
|
158
|
-
this.setCurrentPage = (id, type) => {
|
|
159
|
-
this.currentPage = {
|
|
160
|
-
pageId: id,
|
|
161
|
-
pageType: type,
|
|
162
|
-
url: isBrowser ? window.location.href : undefined,
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
214
|
logger.setLevel(config?.logLevel ?? logger.levels.ERROR);
|
|
166
215
|
// runtime check for providerId inconsistency
|
|
167
216
|
if (!providerId || !(typeof providerId === 'string')) {
|
|
168
217
|
throw new Error('Required parameter `providerId` missing');
|
|
169
218
|
}
|
|
219
|
+
if (config?.componentVersion !== undefined && config?.component === undefined) {
|
|
220
|
+
throw new Error('`componentVersion` cannot be provided without `component`');
|
|
221
|
+
}
|
|
170
222
|
let includeAdvertising;
|
|
171
223
|
if (isBrowser && config?.autoCreateConsents) {
|
|
172
224
|
config.consents = getConsentsWaitForAnalytics((consents) => {
|
|
@@ -205,11 +257,15 @@ export default class Tracker {
|
|
|
205
257
|
tpaasCollectorBaseUrl: collectorEndpoints[deployStageTpaas],
|
|
206
258
|
trackerId: v4(),
|
|
207
259
|
vendors: config?.vendors?.length ? [] : ['xandr'],
|
|
260
|
+
useBeacon: true,
|
|
261
|
+
useBeaconWhenAvailable: true,
|
|
208
262
|
}, config);
|
|
209
263
|
// Move to default config?
|
|
210
264
|
this.builders = pulseMerge({}, builders, {
|
|
211
265
|
provider: {
|
|
212
266
|
id: providerId,
|
|
267
|
+
...(config?.component !== undefined && { component: config.component }),
|
|
268
|
+
...(config?.componentVersion !== undefined && { componentVersion: config.componentVersion }),
|
|
213
269
|
},
|
|
214
270
|
tracker: {
|
|
215
271
|
version: SDK_VERSION,
|
|
@@ -326,6 +382,11 @@ export default class Tracker {
|
|
|
326
382
|
return queuedEvent.then((result) => result);
|
|
327
383
|
});
|
|
328
384
|
};
|
|
385
|
+
/*
|
|
386
|
+
* Casting `input` as `Partial<Builders>` to formalise the intention of processing the event input in relation to the properties in
|
|
387
|
+
* the Builders type. It would justify changing the public api for `.track`, but as this deals with legacy code, we
|
|
388
|
+
* keep it internal, so dependencies from now on can count on objects being a Partial<Builder>
|
|
389
|
+
*/
|
|
329
390
|
return this.syncRemoteResources(input, currentBuilders).then(_track, _track);
|
|
330
391
|
}
|
|
331
392
|
/**
|
|
@@ -358,11 +419,11 @@ export default class Tracker {
|
|
|
358
419
|
*/
|
|
359
420
|
async trackAnonymous(eventType, input, options) {
|
|
360
421
|
// We must create the event as soon as possible, as it defines the creationDate.
|
|
361
|
-
const newEvent = this.createAnonymousEvent(input);
|
|
422
|
+
const newEvent = omit(this.createAnonymousEvent(input), ANONYMOUS_EVENT_FORBIDDEN_FIELDS);
|
|
362
423
|
// Remote config values ----------------
|
|
363
424
|
await this._applyRemoteConfigEndpoints();
|
|
364
425
|
// Resolve all available properties ----------------
|
|
365
|
-
const resolvedOutput = await Promise.all([this.resolveTrackInput(newEvent), this.
|
|
426
|
+
const resolvedOutput = await Promise.all([this.resolveTrackInput(newEvent), this.resolveAnonymousTrackGlobals()]);
|
|
366
427
|
let eventOutput = resolvedOutput.reduce((acc, p) => pulseMerge(acc, p), {});
|
|
367
428
|
eventOutput = this.applyAnonymousEventTypeDefaults(eventOutput, eventType);
|
|
368
429
|
// Leave Events ----------------
|
|
@@ -376,6 +437,7 @@ export default class Tracker {
|
|
|
376
437
|
eventInput: eventOutput,
|
|
377
438
|
sdkConfig: this.state,
|
|
378
439
|
});
|
|
440
|
+
eventOutput = omit(eventOutput, ANONYMOUS_EVENT_FORBIDDEN_FIELDS);
|
|
379
441
|
if (options?.bookmarkKey) {
|
|
380
442
|
this.bookmark.set(options.bookmarkKey, eventOutput);
|
|
381
443
|
}
|
|
@@ -395,6 +457,11 @@ export default class Tracker {
|
|
|
395
457
|
return {
|
|
396
458
|
name: exp.name || exp.id,
|
|
397
459
|
variant: exp.variant || '',
|
|
460
|
+
// nobody should be sending experiment id with an sdrn format, but in case they do
|
|
461
|
+
// we want to be able to handle it and not generate an invalid sdrn by adding another layer to it
|
|
462
|
+
experimentSdrn: exp.id.startsWith('sdrn:') ? exp.id : generateExperimentSDRN(exp.id, exp.platform),
|
|
463
|
+
platform: exp.platform || '',
|
|
464
|
+
testId: exp.custom?.testId,
|
|
398
465
|
};
|
|
399
466
|
});
|
|
400
467
|
}
|
|
@@ -404,29 +471,52 @@ export default class Tracker {
|
|
|
404
471
|
* @category TPaaS Tracking
|
|
405
472
|
*/
|
|
406
473
|
async prepareAnonymousTpaasEvent() {
|
|
474
|
+
const { isHybrid, pageViewId, providerId, component, componentVersion, stage: providerStage, product: providerProduct, version: providerVersion, deployStageTpaas, } = this.state;
|
|
475
|
+
const providerName = this.state.provider?.name;
|
|
476
|
+
const providerGroup = this.state.provider?.group;
|
|
477
|
+
const experimentsInput = this.builders.experiments;
|
|
478
|
+
const currentPageReferrerInput = this.currentPageContext.referrer;
|
|
407
479
|
try {
|
|
408
480
|
await this._applyRemoteConfigEndpoints();
|
|
409
481
|
}
|
|
410
482
|
catch (ex) {
|
|
411
483
|
logger.trace('Failed to sync remote config', ex);
|
|
412
484
|
}
|
|
485
|
+
const [experiments, currentPageReferrer] = await Promise.all([
|
|
486
|
+
this.adaptExperiments(experimentsInput),
|
|
487
|
+
currentPageReferrerInput,
|
|
488
|
+
]);
|
|
413
489
|
return {
|
|
414
|
-
autoTrackerVersion: this.builders.tracker?.autoTrackerVersion,
|
|
415
490
|
version: SDK_VERSION,
|
|
416
|
-
isHybrid: !!
|
|
417
|
-
pageviewId:
|
|
418
|
-
providerId
|
|
419
|
-
|
|
491
|
+
isHybrid: !!isHybrid,
|
|
492
|
+
pageviewId: pageViewId,
|
|
493
|
+
providerId,
|
|
494
|
+
providerName,
|
|
495
|
+
providerGroup,
|
|
496
|
+
providerStage,
|
|
497
|
+
providerProduct,
|
|
498
|
+
providerVersion,
|
|
499
|
+
component,
|
|
500
|
+
componentVersion,
|
|
501
|
+
routingStage: mapDeployStageToTpaasStage(deployStageTpaas),
|
|
502
|
+
experiments,
|
|
503
|
+
currentPageReferrer,
|
|
420
504
|
};
|
|
421
505
|
}
|
|
422
506
|
/**
|
|
423
|
-
*
|
|
424
507
|
* @private
|
|
425
508
|
* @category TPaaS Tracking
|
|
426
509
|
*/
|
|
427
510
|
async prepareTpaasEvent() {
|
|
511
|
+
// Capture event context before any asynchronous work so a concurrent update or View
|
|
512
|
+
// event cannot change the dependencies used to finish building this event.
|
|
513
|
+
const builders = { ...this.builders };
|
|
514
|
+
const { isHybrid, providerId, component, componentVersion, stage: providerStage, product: providerProduct, version: providerVersion, pageViewId, deployStageTpaas, } = this.state;
|
|
515
|
+
const providerName = this.state.provider?.name;
|
|
516
|
+
const providerGroup = this.state.provider?.group;
|
|
517
|
+
const { info: currentPageInfoInput, content: currentPageContent, sports: currentPageSports, referrer: currentPageReferrerInput, } = this.currentPageContext;
|
|
428
518
|
try {
|
|
429
|
-
await this.syncRemoteResources(undefined,
|
|
519
|
+
await this.syncRemoteResources(undefined, builders);
|
|
430
520
|
}
|
|
431
521
|
catch (ex) {
|
|
432
522
|
logger.trace('Failed to sync remote resources', ex);
|
|
@@ -480,42 +570,40 @@ export default class Tracker {
|
|
|
480
570
|
source: source || 'unknown',
|
|
481
571
|
};
|
|
482
572
|
}
|
|
483
|
-
|
|
484
|
-
|
|
573
|
+
// Consents are intentionally not part of the event-context snapshot. Read them after
|
|
574
|
+
// remote synchronization so a blocking tracking call can use newly resolved consents.
|
|
575
|
+
const [actor, consents, experiments, currentPage, currentPageReferrer] = await Promise.all([
|
|
576
|
+
identity.getActor(builders),
|
|
485
577
|
this.getConsents(),
|
|
486
|
-
this.adaptExperiments(
|
|
578
|
+
this.adaptExperiments(builders.experiments),
|
|
579
|
+
this.getCurrentTpaasPage(currentPageInfoInput),
|
|
580
|
+
currentPageReferrerInput,
|
|
487
581
|
]);
|
|
488
582
|
const { environmentId, jwe } = parsePulseCookies();
|
|
489
583
|
return {
|
|
490
|
-
autoTrackerVersion: this.builders.tracker?.autoTrackerVersion,
|
|
491
584
|
version: SDK_VERSION,
|
|
492
|
-
isHybrid: !!
|
|
585
|
+
isHybrid: !!isHybrid,
|
|
493
586
|
user: adaptActorToNewFormat(actor),
|
|
494
587
|
consents: adaptConsentsToNewFormat(consents),
|
|
495
|
-
providerId
|
|
496
|
-
|
|
497
|
-
|
|
588
|
+
providerId,
|
|
589
|
+
providerName,
|
|
590
|
+
providerGroup,
|
|
591
|
+
providerStage,
|
|
592
|
+
providerProduct,
|
|
593
|
+
providerVersion,
|
|
594
|
+
component,
|
|
595
|
+
componentVersion,
|
|
596
|
+
pageviewId: pageViewId,
|
|
597
|
+
routingStage: mapDeployStageToTpaasStage(deployStageTpaas),
|
|
598
|
+
currentPage,
|
|
599
|
+
currentPageContent,
|
|
600
|
+
currentPageSports,
|
|
601
|
+
currentPageReferrer,
|
|
498
602
|
experiments,
|
|
499
603
|
environmentId,
|
|
500
604
|
jwe,
|
|
501
605
|
};
|
|
502
606
|
}
|
|
503
|
-
/**
|
|
504
|
-
* Generate a generic TPaaS event with common builders output
|
|
505
|
-
* The method should be used for experiments, not for real production work.
|
|
506
|
-
* It doesn't have any real TPaaS schema associated with it.
|
|
507
|
-
* The method doesn't queue or send the event, it just returns the merged object.
|
|
508
|
-
* The method can be removed at any time in the future, so use it with caution.
|
|
509
|
-
*
|
|
510
|
-
* @param input - The input object to merge with the common builders output
|
|
511
|
-
* @returns A promise that resolves to the merged object
|
|
512
|
-
* @private
|
|
513
|
-
* @category TPaaS Tracking
|
|
514
|
-
*/
|
|
515
|
-
async generateGenericTpaasEvent(input) {
|
|
516
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
517
|
-
return pulseMerge({}, input, getCommonBuildersOutput(new Date(), dependencies));
|
|
518
|
-
}
|
|
519
607
|
/**
|
|
520
608
|
* This method extends the list of base experiments that will be automatically included in every event sent by the tracker.
|
|
521
609
|
*
|
|
@@ -537,6 +625,9 @@ export default class Tracker {
|
|
|
537
625
|
* @category Tracking
|
|
538
626
|
*/
|
|
539
627
|
addExperiments(experiments) {
|
|
628
|
+
if (experiments.some((experiment) => experiment.id.startsWith('sdrn:'))) {
|
|
629
|
+
logger.warn('Pulse - addExperiments received an experiment id starting with "sdrn:"; pass the raw experiment id instead. The SDK will generate the sdrn automatically.');
|
|
630
|
+
}
|
|
540
631
|
this.update({ experiments }, true);
|
|
541
632
|
}
|
|
542
633
|
/**
|
|
@@ -571,7 +662,7 @@ export default class Tracker {
|
|
|
571
662
|
const viewUIElementInputProperties = buildEventFromElement(element);
|
|
572
663
|
this.trackLegacyViewUIElement(viewUIElementInputProperties);
|
|
573
664
|
}));
|
|
574
|
-
this.legacyVisibilityObservers.get(selector)?.observe(selector);
|
|
665
|
+
this.legacyVisibilityObservers.get(selector)?.observe(selector, {});
|
|
575
666
|
}
|
|
576
667
|
/**
|
|
577
668
|
* The `addUIElementVisibilityTracking` function provides an interface for sending tracking events when specific UI elements become visible within the viewport.
|
|
@@ -603,7 +694,38 @@ export default class Tracker {
|
|
|
603
694
|
const eventInput = buildEventFromElement(element);
|
|
604
695
|
this.trackImpressionUIElement(eventInput);
|
|
605
696
|
}));
|
|
606
|
-
this.visibilityObservers.get(selector)?.observe(selector);
|
|
697
|
+
this.visibilityObservers.get(selector)?.observe(selector, {});
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* The `addElementVisibilityObserver` function provides an interface for executing arbitrary code when specific DOM Elements become visible within the viewport.
|
|
701
|
+
* It is built on the `VisibilityObserver` class, which efficiently detects visibility changes in DOM elements.
|
|
702
|
+
* When an element becomes at least 2/3 visible, a callback is triggered, with the Element that invoked the callback call as argument.
|
|
703
|
+
* It leverages the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) for viewport tracking
|
|
704
|
+
* and the [Mutation Observer API](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) to monitor lazy-loaded elements.
|
|
705
|
+
*
|
|
706
|
+
* Example usage:
|
|
707
|
+
*
|
|
708
|
+
* ```ts
|
|
709
|
+
* tracker.addElementVisibilityObserver('[data-pulse-entity-id]', (element) => {
|
|
710
|
+
* const eventInput = parseElementIntoEventInput(element); // user-defined function
|
|
711
|
+
* tracker.trackImpressionTeaser(eventInput); // can be anything actually, not necessarily a Teaser tracking call
|
|
712
|
+
* });
|
|
713
|
+
* ```
|
|
714
|
+
* @param selector
|
|
715
|
+
* @param callback
|
|
716
|
+
* @param options {ObserverOptions}
|
|
717
|
+
* @param options.threshold - A number between 0 and 1 indicating how much of the element should be visible to trigger
|
|
718
|
+
* the callback. Default is 0.67 (2/3 of the element).
|
|
719
|
+
*/
|
|
720
|
+
addElementVisibilityObserver(selector, callback, options = {}) {
|
|
721
|
+
if (this.visibilityObservers.has(selector)) {
|
|
722
|
+
console.warn(`Cannot add UI Element visibility tracking for selector "${selector}" as it is already being tracked.`);
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
this.visibilityObservers.set(selector, new VisibilityObserver((element) => {
|
|
726
|
+
callback(element);
|
|
727
|
+
}));
|
|
728
|
+
this.visibilityObservers.get(selector)?.observe(selector, options);
|
|
607
729
|
}
|
|
608
730
|
/**
|
|
609
731
|
* The old trackViewArticle method from the Media Wrapper.
|
|
@@ -697,7 +819,7 @@ export default class Tracker {
|
|
|
697
819
|
* @category Legacy Tracking
|
|
698
820
|
*/
|
|
699
821
|
trackLegacyViewUIElement(inputProperties, trackOptions) {
|
|
700
|
-
const viewUIElementEventData = buildLegacyViewUIElementEvent(inputProperties, this.
|
|
822
|
+
const viewUIElementEventData = buildLegacyViewUIElementEvent(inputProperties, this.getCurrentLegacyPage());
|
|
701
823
|
return this.track('trackerEvent', viewUIElementEventData, trackOptions);
|
|
702
824
|
}
|
|
703
825
|
/**
|
|
@@ -708,7 +830,7 @@ export default class Tracker {
|
|
|
708
830
|
* @category Legacy Tracking
|
|
709
831
|
*/
|
|
710
832
|
trackLegacyClickUIElement(inputProperties, trackOptions) {
|
|
711
|
-
const clickUIElementEventData = buildClickUIElementEvent(inputProperties, this.
|
|
833
|
+
const clickUIElementEventData = buildClickUIElementEvent(inputProperties, this.getCurrentLegacyPage());
|
|
712
834
|
return this.track('trackerEvent', clickUIElementEventData, trackOptions);
|
|
713
835
|
}
|
|
714
836
|
/**
|
|
@@ -735,19 +857,22 @@ export default class Tracker {
|
|
|
735
857
|
}
|
|
736
858
|
async trackViewHealthPage(input, options) {
|
|
737
859
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
738
|
-
this.
|
|
860
|
+
this.setCurrentTpaasPageData({
|
|
861
|
+
id: input.object.objectId,
|
|
862
|
+
type: ViewHealthPage.object.objectType,
|
|
863
|
+
referrer: input.page?.referrer,
|
|
864
|
+
});
|
|
739
865
|
const dependencies = await this.prepareTpaasEvent();
|
|
740
866
|
const event = buildViewHealthPageEvent(input, dependencies);
|
|
741
867
|
const result = this.sendTpaasEvent(event);
|
|
742
868
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
this.trackLeavePage({
|
|
869
|
+
const leavePageCallback = async (leave) => {
|
|
870
|
+
// HealthView Page is a bit special, in the sense that in doesn't have a dedicated Leave event.
|
|
871
|
+
// Instead, we need to reuse the generic Leave Page event, but adapt the input accordingly.
|
|
872
|
+
// This means omitting some fields from HealthView Page that are not part of Leave Page schema.
|
|
873
|
+
const { experiments, metrics, object, origin, userHealthData, ...restInput } = input;
|
|
874
|
+
const { category, custom, name, tags, food, physicalActivity, training, ...restObject } = input.object;
|
|
875
|
+
await this.trackLeavePage({
|
|
751
876
|
leave,
|
|
752
877
|
...restInput,
|
|
753
878
|
object: {
|
|
@@ -757,10 +882,7 @@ export default class Tracker {
|
|
|
757
882
|
});
|
|
758
883
|
};
|
|
759
884
|
addTpaasLeaveTracking({
|
|
760
|
-
|
|
761
|
-
pageElement,
|
|
762
|
-
objectResizable,
|
|
763
|
-
heightBuilder,
|
|
885
|
+
...options.leaveTracking,
|
|
764
886
|
schema: LeavePage.object.objectType,
|
|
765
887
|
trackMethod: leavePageCallback,
|
|
766
888
|
});
|
|
@@ -779,23 +901,23 @@ export default class Tracker {
|
|
|
779
901
|
*/
|
|
780
902
|
async trackViewPage(input, options) {
|
|
781
903
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
782
|
-
this.
|
|
904
|
+
this.setCurrentTpaasPageData({
|
|
905
|
+
id: input.object.objectId,
|
|
906
|
+
type: ViewPage.object.objectType,
|
|
907
|
+
referrer: input.page?.referrer,
|
|
908
|
+
});
|
|
783
909
|
const dependencies = await this.prepareTpaasEvent();
|
|
784
910
|
const event = buildViewPageEvent(input, dependencies);
|
|
785
911
|
const result = this.sendTpaasEvent(event);
|
|
786
912
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
this.trackLeavePage({
|
|
913
|
+
const leavePageCallback = async (leave) => {
|
|
914
|
+
await this.trackLeavePage({
|
|
790
915
|
leave,
|
|
791
916
|
...input,
|
|
792
917
|
});
|
|
793
918
|
};
|
|
794
919
|
addTpaasLeaveTracking({
|
|
795
|
-
|
|
796
|
-
pageElement,
|
|
797
|
-
objectResizable,
|
|
798
|
-
heightBuilder,
|
|
920
|
+
...options.leaveTracking,
|
|
799
921
|
schema: LeavePage.object.objectType,
|
|
800
922
|
trackMethod: leavePageCallback,
|
|
801
923
|
});
|
|
@@ -809,36 +931,77 @@ export default class Tracker {
|
|
|
809
931
|
*/
|
|
810
932
|
async trackViewSportsPage(input, options) {
|
|
811
933
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
812
|
-
this.
|
|
934
|
+
this.setCurrentTpaasPageData({
|
|
935
|
+
id: input.object.objectId,
|
|
936
|
+
type: ViewSportsPage.object.objectType,
|
|
937
|
+
referrer: input.page?.referrer,
|
|
938
|
+
sports: {
|
|
939
|
+
sportName: input.object.sportName,
|
|
940
|
+
sportSubview: input.object.sportSubview,
|
|
941
|
+
sportView: input.object.sportView,
|
|
942
|
+
sports: input.object.sports,
|
|
943
|
+
},
|
|
944
|
+
});
|
|
813
945
|
const dependencies = await this.prepareTpaasEvent();
|
|
814
946
|
const event = buildViewSportsPageEvent(input, dependencies);
|
|
815
947
|
const result = this.sendTpaasEvent(event);
|
|
816
948
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
this.trackLeaveSportsPage({
|
|
949
|
+
const leaveSportsPageCallback = async (leave) => {
|
|
950
|
+
await this.trackLeaveSportsPage({
|
|
820
951
|
leave,
|
|
821
952
|
...input,
|
|
822
953
|
});
|
|
823
954
|
};
|
|
824
955
|
addTpaasLeaveTracking({
|
|
825
|
-
|
|
826
|
-
pageElement,
|
|
827
|
-
objectResizable,
|
|
828
|
-
heightBuilder,
|
|
956
|
+
...options.leaveTracking,
|
|
829
957
|
schema: LeaveSportsPage.object.objectType,
|
|
830
958
|
trackMethod: leaveSportsPageCallback,
|
|
831
959
|
});
|
|
832
960
|
}
|
|
833
961
|
return result;
|
|
834
962
|
}
|
|
963
|
+
/**
|
|
964
|
+
* @param input
|
|
965
|
+
* @param options
|
|
966
|
+
* @category TPaaS Tracking
|
|
967
|
+
*/
|
|
968
|
+
async trackViewSchoolPage(input, options) {
|
|
969
|
+
this.newPageView();
|
|
970
|
+
// TODO: SchoolPage is not currently part of the catalog's PageRef.pageType enum.
|
|
971
|
+
this.setCurrentTpaasPageData({
|
|
972
|
+
id: input.object.objectId,
|
|
973
|
+
type: 'Page',
|
|
974
|
+
referrer: input.page?.referrer,
|
|
975
|
+
});
|
|
976
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
977
|
+
const event = buildViewSchoolPageEvent(input, dependencies);
|
|
978
|
+
const result = this.sendTpaasEvent(event);
|
|
979
|
+
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
980
|
+
const leaveSchoolPageCallback = async (leave) => {
|
|
981
|
+
await this.trackLeaveSchoolPage({
|
|
982
|
+
leave,
|
|
983
|
+
...input,
|
|
984
|
+
});
|
|
985
|
+
};
|
|
986
|
+
addTpaasLeaveTracking({
|
|
987
|
+
...options.leaveTracking,
|
|
988
|
+
schema: LeaveSchoolPage.object.objectType,
|
|
989
|
+
trackMethod: leaveSchoolPageCallback,
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
return result;
|
|
993
|
+
}
|
|
835
994
|
/**
|
|
836
995
|
* @param input
|
|
837
996
|
* @category TPaaS Tracking
|
|
838
997
|
*/
|
|
839
998
|
async trackViewTitle(input) {
|
|
840
999
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
841
|
-
this.
|
|
1000
|
+
this.setCurrentTpaasPageData({
|
|
1001
|
+
id: input.object.objectId,
|
|
1002
|
+
type: ViewTitle.object.objectType,
|
|
1003
|
+
referrer: input.page?.referrer,
|
|
1004
|
+
});
|
|
842
1005
|
const dependencies = await this.prepareTpaasEvent();
|
|
843
1006
|
const event = buildViewTitleEvent(input, dependencies);
|
|
844
1007
|
return this.sendTpaasEvent(event);
|
|
@@ -857,9 +1020,18 @@ export default class Tracker {
|
|
|
857
1020
|
* @param input
|
|
858
1021
|
* @category TPaaS Tracking
|
|
859
1022
|
*/
|
|
860
|
-
async
|
|
1023
|
+
async trackLoadAd(input) {
|
|
861
1024
|
const dependencies = await this.prepareTpaasEvent();
|
|
862
|
-
const event =
|
|
1025
|
+
const event = buildLoadAdEvent(input, dependencies);
|
|
1026
|
+
return this.sendTpaasEvent(event);
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* @param input
|
|
1030
|
+
* @category TPaaS Tracking
|
|
1031
|
+
*/
|
|
1032
|
+
async trackRequestAd(input) {
|
|
1033
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1034
|
+
const event = buildRequestAdEvent(input, dependencies);
|
|
863
1035
|
return this.sendTpaasEvent(event);
|
|
864
1036
|
}
|
|
865
1037
|
/**
|
|
@@ -869,41 +1041,30 @@ export default class Tracker {
|
|
|
869
1041
|
*/
|
|
870
1042
|
async trackViewArticle(input, options) {
|
|
871
1043
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
872
|
-
this.
|
|
1044
|
+
this.setCurrentTpaasPageData({
|
|
1045
|
+
id: input.object.objectId,
|
|
1046
|
+
type: ViewArticle.object.objectType,
|
|
1047
|
+
referrer: input.page?.referrer,
|
|
1048
|
+
content: input.page?.content,
|
|
1049
|
+
});
|
|
873
1050
|
const dependencies = await this.prepareTpaasEvent();
|
|
874
1051
|
const event = buildViewArticleEvent(input, dependencies);
|
|
875
1052
|
const result = this.sendTpaasEvent(event);
|
|
876
1053
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
this.trackLeaveArticle({
|
|
1054
|
+
const leaveArticleCallback = async (leave) => {
|
|
1055
|
+
await this.trackLeaveArticle({
|
|
880
1056
|
leave,
|
|
881
1057
|
...input,
|
|
882
1058
|
});
|
|
883
1059
|
};
|
|
884
1060
|
addTpaasLeaveTracking({
|
|
885
|
-
|
|
886
|
-
pageElement,
|
|
887
|
-
heightBuilder,
|
|
888
|
-
objectResizable,
|
|
1061
|
+
...options.leaveTracking,
|
|
889
1062
|
schema: LeaveArticle.object.objectType,
|
|
890
1063
|
trackMethod: leaveArticleCallback,
|
|
891
1064
|
});
|
|
892
1065
|
}
|
|
893
1066
|
return result;
|
|
894
1067
|
}
|
|
895
|
-
/**
|
|
896
|
-
* @param input
|
|
897
|
-
* @param options
|
|
898
|
-
* @category TPaaS Tracking
|
|
899
|
-
*/
|
|
900
|
-
async trackViewAudio(input) {
|
|
901
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
902
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
903
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
904
|
-
const event = buildViewAudioEvent(input, dependencies);
|
|
905
|
-
return this.sendTpaasEvent(event);
|
|
906
|
-
}
|
|
907
1068
|
/**
|
|
908
1069
|
* Tracks a View AudioPage event and automatically fires a Leave AudioPage event when the user
|
|
909
1070
|
* navigates away.
|
|
@@ -946,20 +1107,25 @@ export default class Tracker {
|
|
|
946
1107
|
*/
|
|
947
1108
|
async trackViewAudioPage(input, options) {
|
|
948
1109
|
this.newPageView();
|
|
949
|
-
this.
|
|
1110
|
+
this.setCurrentTpaasPageData({
|
|
1111
|
+
id: input.object.objectId,
|
|
1112
|
+
type: ViewAudioPage.object.objectType,
|
|
1113
|
+
referrer: input.page?.referrer,
|
|
1114
|
+
content: input.page?.content,
|
|
1115
|
+
});
|
|
950
1116
|
const dependencies = await this.prepareTpaasEvent();
|
|
951
1117
|
const event = buildViewAudioPageEvent(input, dependencies);
|
|
952
1118
|
const result = this.sendTpaasEvent(event);
|
|
953
1119
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
954
|
-
const {
|
|
955
|
-
const leaveAudioPageCallback = (leave) => {
|
|
1120
|
+
const { leaveAudioBuilder, ...restLeaveTrackingOptions } = options.leaveTracking;
|
|
1121
|
+
const leaveAudioPageCallback = async (leave) => {
|
|
956
1122
|
const leaveAudioInput = leaveAudioBuilder?.() ?? {
|
|
957
1123
|
audioCompleted: 0,
|
|
958
1124
|
audioStarted: 0,
|
|
959
1125
|
maxPlaylistPosition: 0,
|
|
960
1126
|
playlistPositionPercentage: 0,
|
|
961
1127
|
};
|
|
962
|
-
this.trackLeaveAudioPage({
|
|
1128
|
+
await this.trackLeaveAudioPage({
|
|
963
1129
|
leave,
|
|
964
1130
|
leaveAudio: {
|
|
965
1131
|
...leaveAudioInput,
|
|
@@ -970,10 +1136,7 @@ export default class Tracker {
|
|
|
970
1136
|
});
|
|
971
1137
|
};
|
|
972
1138
|
addTpaasLeaveTracking({
|
|
973
|
-
|
|
974
|
-
pageElement,
|
|
975
|
-
heightBuilder,
|
|
976
|
-
objectResizable,
|
|
1139
|
+
...restLeaveTrackingOptions,
|
|
977
1140
|
schema: LeaveAudioPage.object.objectType,
|
|
978
1141
|
trackMethod: leaveAudioPageCallback,
|
|
979
1142
|
});
|
|
@@ -987,29 +1150,56 @@ export default class Tracker {
|
|
|
987
1150
|
*/
|
|
988
1151
|
async trackViewError(input, options) {
|
|
989
1152
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
990
|
-
this.
|
|
1153
|
+
this.setCurrentTpaasPageData({
|
|
1154
|
+
id: input.object.objectId,
|
|
1155
|
+
type: ViewError.object.objectType,
|
|
1156
|
+
referrer: input.page?.referrer,
|
|
1157
|
+
});
|
|
991
1158
|
const dependencies = await this.prepareTpaasEvent();
|
|
992
1159
|
const event = buildViewErrorEvent(input, dependencies);
|
|
993
1160
|
const result = this.sendTpaasEvent(event);
|
|
994
1161
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
this.trackLeaveError({
|
|
1162
|
+
const leaveErrorCallback = async (leave) => {
|
|
1163
|
+
await this.trackLeaveError({
|
|
998
1164
|
leave,
|
|
999
1165
|
...input,
|
|
1000
1166
|
});
|
|
1001
1167
|
};
|
|
1002
1168
|
addTpaasLeaveTracking({
|
|
1003
|
-
|
|
1004
|
-
pageElement,
|
|
1005
|
-
heightBuilder,
|
|
1006
|
-
objectResizable,
|
|
1169
|
+
...options.leaveTracking,
|
|
1007
1170
|
schema: LeaveError.object.objectType,
|
|
1008
1171
|
trackMethod: leaveErrorCallback,
|
|
1009
1172
|
});
|
|
1010
1173
|
}
|
|
1011
1174
|
return result;
|
|
1012
1175
|
}
|
|
1176
|
+
/**
|
|
1177
|
+
* @param input
|
|
1178
|
+
* @category TPaaS Tracking
|
|
1179
|
+
*/
|
|
1180
|
+
async trackImpressionAd(input) {
|
|
1181
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1182
|
+
const event = buildImpressionAdEvent(input, dependencies);
|
|
1183
|
+
return this.sendTpaasEvent(event);
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* @param input
|
|
1187
|
+
* @category TPaaS Tracking
|
|
1188
|
+
*/
|
|
1189
|
+
async trackImpressionAdSlot(input) {
|
|
1190
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1191
|
+
const event = buildImpressionAdSlotEvent(input, dependencies);
|
|
1192
|
+
return this.sendTpaasEvent(event);
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* @param input
|
|
1196
|
+
* @category TPaaS Tracking
|
|
1197
|
+
*/
|
|
1198
|
+
async trackImpressionAffiliate(input) {
|
|
1199
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1200
|
+
const event = buildImpressionAffiliateEvent(input, dependencies);
|
|
1201
|
+
return this.sendTpaasEvent(event);
|
|
1202
|
+
}
|
|
1013
1203
|
/**
|
|
1014
1204
|
* @param input
|
|
1015
1205
|
* @category TPaaS Tracking
|
|
@@ -1037,6 +1227,24 @@ export default class Tracker {
|
|
|
1037
1227
|
const event = buildImpressionPlayerEvent(input, dependencies);
|
|
1038
1228
|
return this.sendTpaasEvent(event);
|
|
1039
1229
|
}
|
|
1230
|
+
/**
|
|
1231
|
+
* @param input
|
|
1232
|
+
* @category TPaaS Tracking
|
|
1233
|
+
*/
|
|
1234
|
+
async trackImpressionSportsUIElement(input) {
|
|
1235
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1236
|
+
const event = buildImpressionSportsUIElementEvent(input, dependencies);
|
|
1237
|
+
return this.sendTpaasEvent(event);
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* @param input
|
|
1241
|
+
* @category TPaaS Tracking
|
|
1242
|
+
*/
|
|
1243
|
+
async trackImpressionSchoolUIElement(input) {
|
|
1244
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1245
|
+
const event = buildImpressionSchoolUIElementEvent(input, dependencies);
|
|
1246
|
+
return this.sendTpaasEvent(event);
|
|
1247
|
+
}
|
|
1040
1248
|
/**
|
|
1041
1249
|
* @param input
|
|
1042
1250
|
* @category TPaaS Tracking
|
|
@@ -1062,23 +1270,23 @@ export default class Tracker {
|
|
|
1062
1270
|
*/
|
|
1063
1271
|
async trackViewFrontpage(input, options) {
|
|
1064
1272
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1065
|
-
this.
|
|
1273
|
+
this.setCurrentTpaasPageData({
|
|
1274
|
+
id: input.object.objectId,
|
|
1275
|
+
type: ViewFrontpage.object.objectType,
|
|
1276
|
+
referrer: input.page?.referrer,
|
|
1277
|
+
});
|
|
1066
1278
|
const dependencies = await this.prepareTpaasEvent();
|
|
1067
1279
|
const event = buildViewFrontpageEvent(input, dependencies);
|
|
1068
1280
|
const result = this.sendTpaasEvent(event);
|
|
1069
1281
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
this.trackLeaveFrontpage({
|
|
1282
|
+
const leaveFrontpageCallback = async (leave) => {
|
|
1283
|
+
await this.trackLeaveFrontpage({
|
|
1073
1284
|
leave,
|
|
1074
1285
|
...input,
|
|
1075
1286
|
});
|
|
1076
1287
|
};
|
|
1077
1288
|
addTpaasLeaveTracking({
|
|
1078
|
-
|
|
1079
|
-
pageElement,
|
|
1080
|
-
objectResizable,
|
|
1081
|
-
heightBuilder,
|
|
1289
|
+
...options.leaveTracking,
|
|
1082
1290
|
schema: LeaveFrontpage.object.objectType,
|
|
1083
1291
|
trackMethod: leaveFrontpageCallback,
|
|
1084
1292
|
});
|
|
@@ -1092,23 +1300,23 @@ export default class Tracker {
|
|
|
1092
1300
|
*/
|
|
1093
1301
|
async trackViewLandingpage(input, options) {
|
|
1094
1302
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1095
|
-
this.
|
|
1303
|
+
this.setCurrentTpaasPageData({
|
|
1304
|
+
id: input.object.objectId,
|
|
1305
|
+
type: ViewLandingpage.object.objectType,
|
|
1306
|
+
referrer: input.page?.referrer,
|
|
1307
|
+
});
|
|
1096
1308
|
const dependencies = await this.prepareTpaasEvent();
|
|
1097
1309
|
const event = buildViewLandingpageEvent(input, dependencies);
|
|
1098
1310
|
const result = this.sendTpaasEvent(event);
|
|
1099
1311
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
this.trackLeaveLandingpage({
|
|
1312
|
+
const leaveLandingpageCallback = async (leave) => {
|
|
1313
|
+
await this.trackLeaveLandingpage({
|
|
1103
1314
|
leave,
|
|
1104
1315
|
...input,
|
|
1105
1316
|
});
|
|
1106
1317
|
};
|
|
1107
1318
|
addTpaasLeaveTracking({
|
|
1108
|
-
|
|
1109
|
-
pageElement,
|
|
1110
|
-
heightBuilder,
|
|
1111
|
-
objectResizable,
|
|
1319
|
+
...options.leaveTracking,
|
|
1112
1320
|
schema: LeaveLandingpage.object.objectType,
|
|
1113
1321
|
trackMethod: leaveLandingpageCallback,
|
|
1114
1322
|
});
|
|
@@ -1122,23 +1330,23 @@ export default class Tracker {
|
|
|
1122
1330
|
*/
|
|
1123
1331
|
async trackViewListing(input, options) {
|
|
1124
1332
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1125
|
-
this.
|
|
1333
|
+
this.setCurrentTpaasPageData({
|
|
1334
|
+
id: input.object.objectId,
|
|
1335
|
+
type: ViewListing.object.objectType,
|
|
1336
|
+
referrer: input.page?.referrer,
|
|
1337
|
+
});
|
|
1126
1338
|
const dependencies = await this.prepareTpaasEvent();
|
|
1127
1339
|
const event = buildViewListingEvent(input, dependencies);
|
|
1128
1340
|
const result = this.sendTpaasEvent(event);
|
|
1129
1341
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
this.trackLeaveListing({
|
|
1342
|
+
const leaveListingCallback = async (leave) => {
|
|
1343
|
+
await this.trackLeaveListing({
|
|
1133
1344
|
leave,
|
|
1134
1345
|
...input,
|
|
1135
1346
|
});
|
|
1136
1347
|
};
|
|
1137
1348
|
addTpaasLeaveTracking({
|
|
1138
|
-
|
|
1139
|
-
pageElement,
|
|
1140
|
-
heightBuilder,
|
|
1141
|
-
objectResizable,
|
|
1349
|
+
...options.leaveTracking,
|
|
1142
1350
|
schema: LeaveListing.object.objectType,
|
|
1143
1351
|
trackMethod: leaveListingCallback,
|
|
1144
1352
|
});
|
|
@@ -1152,41 +1360,30 @@ export default class Tracker {
|
|
|
1152
1360
|
*/
|
|
1153
1361
|
async trackViewLockedArticle(input, options) {
|
|
1154
1362
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1155
|
-
this.
|
|
1363
|
+
this.setCurrentTpaasPageData({
|
|
1364
|
+
id: input.object.objectId,
|
|
1365
|
+
type: ViewLockedArticle.object.objectType,
|
|
1366
|
+
referrer: input.page?.referrer,
|
|
1367
|
+
content: input.page?.content,
|
|
1368
|
+
});
|
|
1156
1369
|
const dependencies = await this.prepareTpaasEvent();
|
|
1157
1370
|
const event = buildViewLockedArticleEvent(input, dependencies);
|
|
1158
1371
|
const result = this.sendTpaasEvent(event);
|
|
1159
1372
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
this.trackLeaveLockedArticle({
|
|
1373
|
+
const leaveLockedArticleCallback = async (leave) => {
|
|
1374
|
+
await this.trackLeaveLockedArticle({
|
|
1163
1375
|
leave,
|
|
1164
1376
|
...input,
|
|
1165
1377
|
});
|
|
1166
1378
|
};
|
|
1167
1379
|
addTpaasLeaveTracking({
|
|
1168
|
-
|
|
1169
|
-
pageElement,
|
|
1170
|
-
objectResizable,
|
|
1171
|
-
heightBuilder,
|
|
1380
|
+
...options.leaveTracking,
|
|
1172
1381
|
schema: LeaveLockedArticle.object.objectType,
|
|
1173
1382
|
trackMethod: leaveLockedArticleCallback,
|
|
1174
1383
|
});
|
|
1175
1384
|
}
|
|
1176
1385
|
return result;
|
|
1177
1386
|
}
|
|
1178
|
-
/**
|
|
1179
|
-
* @param input
|
|
1180
|
-
* @param options
|
|
1181
|
-
* @category TPaaS Tracking
|
|
1182
|
-
*/
|
|
1183
|
-
async trackViewLockedAudio(input) {
|
|
1184
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
1185
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
1186
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1187
|
-
const event = buildViewLockedAudioEvent(input, dependencies);
|
|
1188
|
-
return this.sendTpaasEvent(event);
|
|
1189
|
-
}
|
|
1190
1387
|
/**
|
|
1191
1388
|
* @param input
|
|
1192
1389
|
* @param options
|
|
@@ -1194,23 +1391,24 @@ export default class Tracker {
|
|
|
1194
1391
|
*/
|
|
1195
1392
|
async trackViewLockedAudioPage(input, options) {
|
|
1196
1393
|
this.newPageView();
|
|
1197
|
-
this.
|
|
1394
|
+
this.setCurrentTpaasPageData({
|
|
1395
|
+
id: input.object.objectId,
|
|
1396
|
+
type: ViewLockedAudioPage.object.objectType,
|
|
1397
|
+
referrer: input.page?.referrer,
|
|
1398
|
+
content: input.page?.content,
|
|
1399
|
+
});
|
|
1198
1400
|
const dependencies = await this.prepareTpaasEvent();
|
|
1199
1401
|
const event = buildViewLockedAudioPageEvent(input, dependencies);
|
|
1200
1402
|
const result = this.sendTpaasEvent(event);
|
|
1201
1403
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
this.trackLeaveLockedAudioPage({
|
|
1404
|
+
const leaveLockedAudioPageCallback = async (leave) => {
|
|
1405
|
+
await this.trackLeaveLockedAudioPage({
|
|
1205
1406
|
leave,
|
|
1206
1407
|
...input,
|
|
1207
1408
|
});
|
|
1208
1409
|
};
|
|
1209
1410
|
addTpaasLeaveTracking({
|
|
1210
|
-
|
|
1211
|
-
pageElement,
|
|
1212
|
-
heightBuilder,
|
|
1213
|
-
objectResizable,
|
|
1411
|
+
...options.leaveTracking,
|
|
1214
1412
|
schema: LeaveLockedAudioPage.object.objectType,
|
|
1215
1413
|
trackMethod: leaveLockedAudioPageCallback,
|
|
1216
1414
|
});
|
|
@@ -1219,14 +1417,33 @@ export default class Tracker {
|
|
|
1219
1417
|
}
|
|
1220
1418
|
/**
|
|
1221
1419
|
* @param input
|
|
1420
|
+
* @param options
|
|
1222
1421
|
* @category TPaaS Tracking
|
|
1223
1422
|
*/
|
|
1224
|
-
async
|
|
1225
|
-
|
|
1226
|
-
|
|
1423
|
+
async trackViewLockedPage(input, options) {
|
|
1424
|
+
this.newPageView();
|
|
1425
|
+
this.setCurrentTpaasPageData({
|
|
1426
|
+
id: input.object.objectId,
|
|
1427
|
+
type: ViewLockedPage.object.objectType,
|
|
1428
|
+
referrer: input.page?.referrer,
|
|
1429
|
+
});
|
|
1227
1430
|
const dependencies = await this.prepareTpaasEvent();
|
|
1228
|
-
const event =
|
|
1229
|
-
|
|
1431
|
+
const event = buildViewLockedPageEvent(input, dependencies);
|
|
1432
|
+
const result = this.sendTpaasEvent(event);
|
|
1433
|
+
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1434
|
+
const leaveLockedPageCallback = async (leave) => {
|
|
1435
|
+
await this.trackLeaveLockedPage({
|
|
1436
|
+
leave,
|
|
1437
|
+
...input,
|
|
1438
|
+
});
|
|
1439
|
+
};
|
|
1440
|
+
addTpaasLeaveTracking({
|
|
1441
|
+
...options.leaveTracking,
|
|
1442
|
+
schema: LeaveLockedPage.object.objectType,
|
|
1443
|
+
trackMethod: leaveLockedPageCallback,
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
return result;
|
|
1230
1447
|
}
|
|
1231
1448
|
/**
|
|
1232
1449
|
* @param input
|
|
@@ -1235,40 +1452,30 @@ export default class Tracker {
|
|
|
1235
1452
|
*/
|
|
1236
1453
|
async trackViewLockedVideoPage(input, options) {
|
|
1237
1454
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1238
|
-
this.
|
|
1455
|
+
this.setCurrentTpaasPageData({
|
|
1456
|
+
id: input.object.objectId,
|
|
1457
|
+
type: ViewLockedVideoPage.object.objectType,
|
|
1458
|
+
referrer: input.page?.referrer,
|
|
1459
|
+
content: input.page?.content,
|
|
1460
|
+
});
|
|
1239
1461
|
const dependencies = await this.prepareTpaasEvent();
|
|
1240
1462
|
const event = buildViewLockedVideoPageEvent(input, dependencies);
|
|
1241
1463
|
const result = this.sendTpaasEvent(event);
|
|
1242
1464
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1243
|
-
const
|
|
1244
|
-
|
|
1245
|
-
this.trackLeaveLockedVideoPage({
|
|
1465
|
+
const leaveLockedVideoPageCallback = async (leave) => {
|
|
1466
|
+
await this.trackLeaveLockedVideoPage({
|
|
1246
1467
|
leave,
|
|
1247
1468
|
...input,
|
|
1248
1469
|
});
|
|
1249
1470
|
};
|
|
1250
1471
|
addTpaasLeaveTracking({
|
|
1251
|
-
|
|
1252
|
-
pageElement,
|
|
1253
|
-
heightBuilder,
|
|
1254
|
-
objectResizable,
|
|
1472
|
+
...options.leaveTracking,
|
|
1255
1473
|
schema: LeaveLockedVideoPage.object.objectType,
|
|
1256
1474
|
trackMethod: leaveLockedVideoPageCallback,
|
|
1257
1475
|
});
|
|
1258
1476
|
}
|
|
1259
1477
|
return result;
|
|
1260
1478
|
}
|
|
1261
|
-
/**
|
|
1262
|
-
* @param input
|
|
1263
|
-
* @category TPaaS Tracking
|
|
1264
|
-
*/
|
|
1265
|
-
async trackViewVideo(input) {
|
|
1266
|
-
// despite the View event type, this is not a page view event, but rather a media object view event
|
|
1267
|
-
// so we shouldn't reset the page view ID here or enable leave tracking
|
|
1268
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1269
|
-
const event = buildViewVideoEvent(input, dependencies);
|
|
1270
|
-
return this.sendTpaasEvent(event);
|
|
1271
|
-
}
|
|
1272
1479
|
/**
|
|
1273
1480
|
* Tracks a View VideoPage event and automatically fires a Leave VideoPage event when the user
|
|
1274
1481
|
* navigates away.
|
|
@@ -1313,29 +1520,27 @@ export default class Tracker {
|
|
|
1313
1520
|
*/
|
|
1314
1521
|
async trackViewVideoPage(input, options) {
|
|
1315
1522
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1316
|
-
this.
|
|
1523
|
+
this.setCurrentTpaasPageData({
|
|
1524
|
+
id: input.object.objectId,
|
|
1525
|
+
type: ViewVideoPage.object.objectType,
|
|
1526
|
+
referrer: input.page?.referrer,
|
|
1527
|
+
content: input.page?.content,
|
|
1528
|
+
});
|
|
1317
1529
|
const dependencies = await this.prepareTpaasEvent();
|
|
1318
1530
|
const event = buildViewVideoPageEvent(input, dependencies);
|
|
1319
1531
|
const result = this.sendTpaasEvent(event);
|
|
1320
1532
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1321
|
-
const {
|
|
1322
|
-
const leaveVideoCallback = (leave) => {
|
|
1533
|
+
const { leaveStoriesBuilder, ...restLeaveTrackingOptions } = options.leaveTracking;
|
|
1534
|
+
const leaveVideoCallback = async (leave) => {
|
|
1323
1535
|
const leaveStoriesInput = leaveStoriesBuilder?.();
|
|
1324
|
-
this.trackLeaveVideoPage({
|
|
1536
|
+
await this.trackLeaveVideoPage({
|
|
1325
1537
|
leave,
|
|
1326
|
-
leaveStories: leaveStoriesInput
|
|
1327
|
-
...leaveStoriesInput,
|
|
1328
|
-
activityDurationMs: leave.activityDurationMs,
|
|
1329
|
-
durationMs: leave.durationMs,
|
|
1330
|
-
},
|
|
1538
|
+
leaveStories: leaveStoriesInput,
|
|
1331
1539
|
...input,
|
|
1332
1540
|
});
|
|
1333
1541
|
};
|
|
1334
1542
|
addTpaasLeaveTracking({
|
|
1335
|
-
|
|
1336
|
-
pageElement,
|
|
1337
|
-
heightBuilder,
|
|
1338
|
-
objectResizable,
|
|
1543
|
+
...restLeaveTrackingOptions,
|
|
1339
1544
|
schema: LeaveVideoPage.object.objectType,
|
|
1340
1545
|
trackMethod: leaveVideoCallback,
|
|
1341
1546
|
});
|
|
@@ -1349,23 +1554,23 @@ export default class Tracker {
|
|
|
1349
1554
|
*/
|
|
1350
1555
|
async trackViewWeather(input, options) {
|
|
1351
1556
|
this.newPageView(); // Reset the page view ID if it is not set, to ensure a new page view is tracked
|
|
1352
|
-
this.
|
|
1557
|
+
this.setCurrentTpaasPageData({
|
|
1558
|
+
id: input.object.objectId,
|
|
1559
|
+
type: ViewWeather.object.objectType,
|
|
1560
|
+
referrer: input.page?.referrer,
|
|
1561
|
+
});
|
|
1353
1562
|
const dependencies = await this.prepareTpaasEvent();
|
|
1354
1563
|
const event = buildViewWeatherEvent(input, dependencies);
|
|
1355
1564
|
const result = this.sendTpaasEvent(event);
|
|
1356
1565
|
if (shouldEnableLeaveTracking(options.leaveTracking)) {
|
|
1357
|
-
const
|
|
1358
|
-
|
|
1359
|
-
this.trackLeaveWeather({
|
|
1566
|
+
const leaveWeatherCallback = async (leave) => {
|
|
1567
|
+
await this.trackLeaveWeather({
|
|
1360
1568
|
leave,
|
|
1361
1569
|
...input,
|
|
1362
1570
|
});
|
|
1363
1571
|
};
|
|
1364
1572
|
addTpaasLeaveTracking({
|
|
1365
|
-
|
|
1366
|
-
pageElement,
|
|
1367
|
-
heightBuilder,
|
|
1368
|
-
objectResizable,
|
|
1573
|
+
...options.leaveTracking,
|
|
1369
1574
|
schema: LeaveWeather.object.objectType,
|
|
1370
1575
|
trackMethod: leaveWeatherCallback,
|
|
1371
1576
|
});
|
|
@@ -1435,15 +1640,6 @@ export default class Tracker {
|
|
|
1435
1640
|
const event = buildLeaveLockedArticleEvent(input, dependencies);
|
|
1436
1641
|
return this.sendTpaasEvent(event);
|
|
1437
1642
|
}
|
|
1438
|
-
/**
|
|
1439
|
-
* @param input
|
|
1440
|
-
* @category TPaaS Tracking
|
|
1441
|
-
*/
|
|
1442
|
-
async trackLeaveLockedAudio(input) {
|
|
1443
|
-
const dependencies = await this.prepareTpaasEvent();
|
|
1444
|
-
const event = buildLeaveLockedAudioEvent(input, dependencies);
|
|
1445
|
-
return this.sendTpaasEvent(event);
|
|
1446
|
-
}
|
|
1447
1643
|
/**
|
|
1448
1644
|
* @param input
|
|
1449
1645
|
* @category TPaaS Tracking
|
|
@@ -1457,9 +1653,9 @@ export default class Tracker {
|
|
|
1457
1653
|
* @param input
|
|
1458
1654
|
* @category TPaaS Tracking
|
|
1459
1655
|
*/
|
|
1460
|
-
async
|
|
1656
|
+
async trackLeaveLockedPage(input) {
|
|
1461
1657
|
const dependencies = await this.prepareTpaasEvent();
|
|
1462
|
-
const event =
|
|
1658
|
+
const event = buildLeaveLockedPageEvent(input, dependencies);
|
|
1463
1659
|
return this.sendTpaasEvent(event);
|
|
1464
1660
|
}
|
|
1465
1661
|
/**
|
|
@@ -1489,6 +1685,15 @@ export default class Tracker {
|
|
|
1489
1685
|
const event = buildLeaveSportsPageEvent(input, dependencies);
|
|
1490
1686
|
return this.sendTpaasEvent(event);
|
|
1491
1687
|
}
|
|
1688
|
+
/**
|
|
1689
|
+
* @param input
|
|
1690
|
+
* @category TPaaS Tracking
|
|
1691
|
+
*/
|
|
1692
|
+
async trackLeaveSchoolPage(input) {
|
|
1693
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1694
|
+
const event = buildLeaveSchoolPageEvent(input, dependencies);
|
|
1695
|
+
return this.sendTpaasEvent(event);
|
|
1696
|
+
}
|
|
1492
1697
|
/**
|
|
1493
1698
|
* @param input
|
|
1494
1699
|
* @category TPaaS Tracking
|
|
@@ -1507,6 +1712,24 @@ export default class Tracker {
|
|
|
1507
1712
|
const event = buildLeaveWeatherEvent(input, dependencies);
|
|
1508
1713
|
return this.sendTpaasEvent(event);
|
|
1509
1714
|
}
|
|
1715
|
+
/**
|
|
1716
|
+
* @param input
|
|
1717
|
+
* @category TPaaS Tracking
|
|
1718
|
+
*/
|
|
1719
|
+
async trackEngagementAd(input) {
|
|
1720
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1721
|
+
const event = buildEngagementAdEvent(input, dependencies);
|
|
1722
|
+
return this.sendTpaasEvent(event);
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* @param input
|
|
1726
|
+
* @category TPaaS Tracking
|
|
1727
|
+
*/
|
|
1728
|
+
async trackEngagementAffiliate(input) {
|
|
1729
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1730
|
+
const event = buildEngagementAffiliateEvent(input, dependencies);
|
|
1731
|
+
return this.sendTpaasEvent(event);
|
|
1732
|
+
}
|
|
1510
1733
|
/**
|
|
1511
1734
|
* @param input
|
|
1512
1735
|
* @category TPaaS Tracking
|
|
@@ -1534,6 +1757,24 @@ export default class Tracker {
|
|
|
1534
1757
|
const event = buildEngagementOfferEvent(input, dependencies);
|
|
1535
1758
|
return this.sendTpaasEvent(event);
|
|
1536
1759
|
}
|
|
1760
|
+
/**
|
|
1761
|
+
* @param input
|
|
1762
|
+
* @category TPaaS Tracking
|
|
1763
|
+
*/
|
|
1764
|
+
async trackEngagementSportsUIElement(input) {
|
|
1765
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1766
|
+
const event = buildEngagementSportsUIElementEvent(input, dependencies);
|
|
1767
|
+
return this.sendTpaasEvent(event);
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
* @param input
|
|
1771
|
+
* @category TPaaS Tracking
|
|
1772
|
+
*/
|
|
1773
|
+
async trackEngagementSchoolUIElement(input) {
|
|
1774
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1775
|
+
const event = buildEngagementSchoolUIElementEvent(input, dependencies);
|
|
1776
|
+
return this.sendTpaasEvent(event);
|
|
1777
|
+
}
|
|
1537
1778
|
/**
|
|
1538
1779
|
* @param input
|
|
1539
1780
|
* @category TPaaS Tracking
|
|
@@ -1543,6 +1784,24 @@ export default class Tracker {
|
|
|
1543
1784
|
const event = buildEngagementTeaserEvent(input, dependencies);
|
|
1544
1785
|
return this.sendTpaasEvent(event);
|
|
1545
1786
|
}
|
|
1787
|
+
/**
|
|
1788
|
+
* @param input
|
|
1789
|
+
* @category TPaaS Tracking
|
|
1790
|
+
*/
|
|
1791
|
+
async trackEngagementTvModule(input) {
|
|
1792
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1793
|
+
const event = buildEngagementTvModuleEvent(input, dependencies);
|
|
1794
|
+
return this.sendTpaasEvent(event);
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* @param input
|
|
1798
|
+
* @category TPaaS Tracking
|
|
1799
|
+
*/
|
|
1800
|
+
async trackEngagementTvSearch(input) {
|
|
1801
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1802
|
+
const event = buildEngagementTvSearchEvent(input, dependencies);
|
|
1803
|
+
return this.sendTpaasEvent(event);
|
|
1804
|
+
}
|
|
1546
1805
|
/**
|
|
1547
1806
|
* @param input
|
|
1548
1807
|
* @category TPaaS Tracking
|
|
@@ -1579,6 +1838,15 @@ export default class Tracker {
|
|
|
1579
1838
|
const event = buildEngagementWidgetEvent(input, dependencies);
|
|
1580
1839
|
return this.sendTpaasEvent(event);
|
|
1581
1840
|
}
|
|
1841
|
+
/**
|
|
1842
|
+
* @param input
|
|
1843
|
+
* @category TPaaS Tracking
|
|
1844
|
+
*/
|
|
1845
|
+
async trackHeartbeatCommercialArticle(input) {
|
|
1846
|
+
const dependencies = await this.prepareTpaasEvent();
|
|
1847
|
+
const event = buildHeartbeatCommercialArticleEvent(input, dependencies);
|
|
1848
|
+
return this.sendTpaasEvent(event);
|
|
1849
|
+
}
|
|
1582
1850
|
/**
|
|
1583
1851
|
* this is the method that actually sends the event to the server
|
|
1584
1852
|
* @private
|
|
@@ -2222,8 +2490,8 @@ export default class Tracker {
|
|
|
2222
2490
|
* with the added guarantee that a second Leave event will not be triggered if one already has been sent.
|
|
2223
2491
|
* @category TPaaS Leave Tracking
|
|
2224
2492
|
*/
|
|
2225
|
-
trackTpaasActiveLeave() {
|
|
2226
|
-
trackTpaasActiveLeave();
|
|
2493
|
+
async trackTpaasActiveLeave() {
|
|
2494
|
+
await trackTpaasActiveLeave();
|
|
2227
2495
|
}
|
|
2228
2496
|
/**
|
|
2229
2497
|
* Check if leave tracking is enabled (if an event will be sent when the user leaves the page)
|
|
@@ -2252,8 +2520,9 @@ export default class Tracker {
|
|
|
2252
2520
|
/**
|
|
2253
2521
|
* @private
|
|
2254
2522
|
*/
|
|
2255
|
-
async
|
|
2256
|
-
|
|
2523
|
+
async resolveAnonymousTrackGlobals() {
|
|
2524
|
+
// Omit before evaluation so forbidden promise/function builders cannot delay or fail anonymous tracking.
|
|
2525
|
+
return evaluateAndFlatten(omit(this.builders, ANONYMOUS_EVENT_FORBIDDEN_FIELDS));
|
|
2257
2526
|
}
|
|
2258
2527
|
/**
|
|
2259
2528
|
* Send all anonymous events that are in the internal anonymous event queue.
|
|
@@ -2317,12 +2586,18 @@ export default class Tracker {
|
|
|
2317
2586
|
async prepareQueuesAndSend(eventQueue, retryEventQueue) {
|
|
2318
2587
|
const promisesToBeSent = eventQueue.splice(0);
|
|
2319
2588
|
const eventsToBeSent = promisesToBeSent.map((p) => p.inputValue);
|
|
2320
|
-
const eventsToRetry = retryEventQueue;
|
|
2589
|
+
const eventsToRetry = retryEventQueue.splice(0);
|
|
2321
2590
|
eventQueue.length = 0;
|
|
2322
2591
|
retryEventQueue.length = 0;
|
|
2323
2592
|
const evaluatedEvents = await Promise.all(eventsToBeSent);
|
|
2324
2593
|
const url = this._getCollectorPath();
|
|
2325
2594
|
const data = [...evaluatedEvents, ...eventsToRetry];
|
|
2595
|
+
// in some cases, _sendImmediately executes an asynchronous operation (cisSync) after checking for empty array
|
|
2596
|
+
// due to that, it's still possible for this function to be called with an empty array, so we need to check for that again before sending
|
|
2597
|
+
// in order to avoid making an empty request to collector
|
|
2598
|
+
if (data.length === 0) {
|
|
2599
|
+
return [];
|
|
2600
|
+
}
|
|
2326
2601
|
// biome-ignore lint/suspicious/noExplicitAny: -
|
|
2327
2602
|
async function onFailedSend(response) {
|
|
2328
2603
|
// We retry an event once, but discard already retried events
|