@schibsted/pulse-sdk 8.0.0-rc.2 → 8.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Tracker.js +582 -471
- 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 -80
- 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/session/store.js +96 -0
- 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 +50 -72
- 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 -3
- 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/dist/cjs/tpaas-builders/builders/session.js +5 -0
- 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 -9
- package/dist/cjs/tpaas-builders/builders.js +326 -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/dist/cjs/tpaas-context/adapters.js +85 -0
- package/dist/cjs/tpaas-context/browser.js +51 -0
- package/dist/cjs/tpaas-context/index.js +6 -0
- package/dist/cjs/tpaas-context/prepare.js +177 -0
- package/dist/cjs/tpaas-context/session.js +23 -0
- package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/tpaas-context}/types.js +0 -1
- package/{node_modules/@schibsted/tpaas-schemas/dist/cjs → dist/cjs/tpaas-schemas}/constants.js +189 -158
- 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 -7
- 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 +558 -447
- 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 +5 -77
- 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/session/store.js +90 -0
- 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 +50 -72
- 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 +2 -3
- 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/dist/ejs/tpaas-builders/builders/session.js +1 -0
- 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 +3 -9
- package/dist/ejs/tpaas-builders/builders.js +259 -0
- package/dist/ejs/tpaas-builders/guards.js +4 -0
- package/dist/ejs/tpaas-builders/index.js +2 -0
- package/dist/ejs/tpaas-context/adapters.js +80 -0
- package/dist/ejs/tpaas-context/browser.js +47 -0
- package/dist/ejs/tpaas-context/index.js +1 -0
- package/dist/ejs/tpaas-context/prepare.js +137 -0
- package/dist/ejs/tpaas-context/session.js +19 -0
- package/{node_modules/@schibsted/tpaas-schemas/dist/ejs → dist/ejs/tpaas-schemas}/constants.js +187 -156
- 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 -7
- 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 +198 -93
- 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 -13
- 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/session/store.d.ts +34 -0
- 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 +7 -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 +4 -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 +7 -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 +2 -0
- package/dist/types/tpaas-context/adapters.d.ts +26 -0
- package/dist/types/tpaas-context/browser.d.ts +8 -0
- package/dist/types/tpaas-context/index.d.ts +2 -0
- package/dist/types/tpaas-context/prepare.d.ts +38 -0
- package/dist/types/tpaas-context/session.d.ts +10 -0
- package/dist/types/tpaas-context/types.d.ts +66 -0
- package/dist/types/tpaas-schemas/constants.d.ts +471 -0
- package/dist/types/tpaas-schemas/index.d.ts +5 -0
- package/dist/types/tpaas-schemas/types/ITpaasEvent.d.ts +130 -0
- package/dist/types/tpaas-schemas/types/schemas/IAnonymousImpressionUIElement.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 +213 -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 +133 -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 +238 -0
- package/dist/types/tpaas-schemas/types/schemas/IEngagementVideoAd.d.ts +147 -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 +96 -0
- package/dist/types/tpaas-schemas/types/schemas/ILoadAd.d.ts +119 -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 +63 -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 +21 -17
- 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/session.js +0 -114
- 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/session.js +0 -108
- 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-context/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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isBrowser, isFunction, throttle } from '@schibsted/pulse-utils';
|
|
2
1
|
import * as logger from 'loglevel';
|
|
3
|
-
import {
|
|
2
|
+
import { isBrowser, isFunction, throttle } from '../utils';
|
|
3
|
+
import { ACTIVITY_DURATION_LIMIT_MS, DEFAULT_PAGE_LEAVE_EVENT } from './constants';
|
|
4
4
|
import { BrowserEvents } from './types';
|
|
5
5
|
let currentLeaveSchema;
|
|
6
6
|
let currentTrackMethod;
|
|
@@ -9,19 +9,44 @@ let updateViewedContentListeners = [];
|
|
|
9
9
|
let activityListeners = [];
|
|
10
10
|
let resizeObserver = null;
|
|
11
11
|
let throttledUpdateFn = throttle(() => undefined, 0);
|
|
12
|
-
let
|
|
13
|
-
let
|
|
12
|
+
let durationStartTime = 0;
|
|
13
|
+
let previousActivityTime = 0;
|
|
14
|
+
let activityDurationMs = 0;
|
|
14
15
|
let currentLeaveEvent = DEFAULT_PAGE_LEAVE_EVENT();
|
|
15
16
|
let additionalHeightBuilder;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a DOM element from either a CSS selector string or an Element instance.
|
|
19
|
+
*/
|
|
20
|
+
function resolveDomElement(element) {
|
|
21
|
+
try {
|
|
22
|
+
return typeof element === 'string' ? document.querySelector(element) : element || null;
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
logger.error('Error while resolving DOM element', e);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
16
29
|
/*
|
|
17
30
|
Add leave tracking
|
|
18
31
|
*/
|
|
19
32
|
export function addTpaasLeaveTracking({ objectElement, pageElement, schema, objectResizable, heightBuilder, trackMethod, }) {
|
|
20
33
|
function _addLeaveTracking() {
|
|
34
|
+
const objectDomElement = resolveDomElement(objectElement);
|
|
35
|
+
if (objectDomElement == null) {
|
|
36
|
+
logger.error('Could not find object element for leave tracking');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let pageDomElement = resolveDomElement(pageElement);
|
|
40
|
+
if (pageDomElement == null) {
|
|
41
|
+
logger.warn('Could not find page element for leave tracking, defaulting to document.body');
|
|
42
|
+
pageDomElement = document.body;
|
|
43
|
+
}
|
|
21
44
|
additionalHeightBuilder = heightBuilder;
|
|
22
45
|
addTpaasLeaveListeners();
|
|
23
|
-
addUpdateEventListeners(
|
|
24
|
-
|
|
46
|
+
addUpdateEventListeners(objectDomElement, pageDomElement, objectResizable);
|
|
47
|
+
previousActivityTime = resetTime();
|
|
48
|
+
durationStartTime = resetTime();
|
|
49
|
+
activityDurationMs = 0;
|
|
25
50
|
currentLeaveSchema = schema;
|
|
26
51
|
currentTrackMethod = trackMethod;
|
|
27
52
|
logger.debug('addLeaveTracking:after:state', currentLeaveEvent);
|
|
@@ -113,12 +138,9 @@ function removeUpdateEventListeners() {
|
|
|
113
138
|
*/
|
|
114
139
|
const resetEventDefaults = () => {
|
|
115
140
|
currentLeaveEvent = DEFAULT_PAGE_LEAVE_EVENT();
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const resetActivityDuration = () => {
|
|
120
|
-
clearInterval(activityDuration.interval);
|
|
121
|
-
return DEFAULT_ACTIVITY_DURATION();
|
|
141
|
+
durationStartTime = resetTime();
|
|
142
|
+
previousActivityTime = resetTime();
|
|
143
|
+
activityDurationMs = 0;
|
|
122
144
|
};
|
|
123
145
|
export const resetTpaasViewedContent = () => {
|
|
124
146
|
currentLeaveEvent = DEFAULT_PAGE_LEAVE_EVENT();
|
|
@@ -126,34 +148,43 @@ export const resetTpaasViewedContent = () => {
|
|
|
126
148
|
const resetTime = () => Date.now();
|
|
127
149
|
/*
|
|
128
150
|
Send a Leave event only if Page Leave tracking is active in the SDK
|
|
129
|
-
The event that is ultimately sent is
|
|
130
|
-
|
|
131
|
-
to the brand event. After the event has been sent, leave page tracking is removed
|
|
151
|
+
The event that is ultimately sent is the View event saved in the currentTrackMethod callback.
|
|
152
|
+
After the event has been sent, leave page tracking is removed
|
|
132
153
|
and must be explicitly re-added if needed.
|
|
133
154
|
*/
|
|
134
|
-
export function trackTpaasActiveLeave() {
|
|
155
|
+
export async function trackTpaasActiveLeave() {
|
|
135
156
|
if (leaveTpaasTrackingIsActive()) {
|
|
136
|
-
trackTpaasLeave();
|
|
157
|
+
await trackTpaasLeave();
|
|
137
158
|
}
|
|
138
159
|
}
|
|
139
160
|
/*
|
|
140
161
|
Send a Leave event regardless of whether Page Leave tracking is active in the SDK
|
|
141
|
-
The event that is ultimately sent is
|
|
142
|
-
|
|
143
|
-
to the brand event. After the event has been sent, leave page tracking is removed
|
|
162
|
+
The event that is ultimately sent is the View event saved in the currentTrackMethod callback.
|
|
163
|
+
After the event has been sent, leave page tracking is removed
|
|
144
164
|
and must be explicitly re-added if needed.
|
|
145
165
|
*/
|
|
146
|
-
export function trackTpaasLeave() {
|
|
166
|
+
export async function trackTpaasLeave() {
|
|
147
167
|
const leave = getTpaasLeaveObject();
|
|
148
|
-
currentTrackMethod
|
|
168
|
+
// Capture currentTrackMethod and remove tracking synchronously before awaiting.
|
|
169
|
+
// If removal happened after the await, a new trackView* call arriving during the async
|
|
170
|
+
// gap would see tracking still active with the same schema and silently discard its
|
|
171
|
+
// new callback (e.g. a fresh leaveAudioBuilder), causing the next leave event to
|
|
172
|
+
// never fire or to use the wrong builder.
|
|
173
|
+
const trackMethod = currentTrackMethod;
|
|
149
174
|
removeTpaasLeaveTracking();
|
|
175
|
+
await trackMethod(leave);
|
|
150
176
|
}
|
|
151
177
|
export function getTpaasLeaveObject() {
|
|
152
178
|
const endTime = Date.now();
|
|
153
|
-
|
|
179
|
+
// TPaaS leave event requires duration/activity to be at least 1ms, otherwise the event is rejected
|
|
180
|
+
// also, in practice, it's almost impossible to have an activity or duration of 0ms
|
|
181
|
+
// We don't call increaseActivityDuration here because it's possible to call getTpaasLeaveObject multiple times
|
|
182
|
+
// without any activity events in between, which would incorrectly increase the activity duration.
|
|
183
|
+
const durationMs = Math.max(endTime - durationStartTime, 1);
|
|
184
|
+
const lastActivityDuration = calculateActivityGap(endTime);
|
|
154
185
|
const leave = {
|
|
155
|
-
durationMs
|
|
156
|
-
activityDurationMs:
|
|
186
|
+
durationMs,
|
|
187
|
+
activityDurationMs: Math.max(activityDurationMs + lastActivityDuration, 1),
|
|
157
188
|
...currentLeaveEvent,
|
|
158
189
|
};
|
|
159
190
|
logger.debug('trackTpaasLeave: event', leave);
|
|
@@ -226,18 +257,10 @@ export const calculateScrollPosition = (element) => Math.abs(Math.min(element.ge
|
|
|
226
257
|
'mousedown', 'mousemove', 'keydown', 'scroll' and/or 'touchstart' browser events.
|
|
227
258
|
*/
|
|
228
259
|
function addUpdateActivityDurationListeners() {
|
|
229
|
-
if
|
|
230
|
-
|
|
260
|
+
// if there are already listeners for activity, do not add more
|
|
261
|
+
if (activityListeners.length > 0) {
|
|
231
262
|
return;
|
|
232
263
|
}
|
|
233
|
-
const interval = 1000;
|
|
234
|
-
const activityTimeout = 30 * 1000;
|
|
235
|
-
activityDuration.interval = window.setInterval(() => {
|
|
236
|
-
activityDuration.timeSinceLastActivity += interval;
|
|
237
|
-
if (activityDuration.timeSinceLastActivity < activityTimeout) {
|
|
238
|
-
activityDuration.value += interval;
|
|
239
|
-
}
|
|
240
|
-
}, interval);
|
|
241
264
|
const activityEvents = [
|
|
242
265
|
BrowserEvents.SCROLL,
|
|
243
266
|
BrowserEvents.MOUSEDOWN,
|
|
@@ -246,14 +269,15 @@ function addUpdateActivityDurationListeners() {
|
|
|
246
269
|
BrowserEvents.TOUCHSTART,
|
|
247
270
|
];
|
|
248
271
|
activityListeners = addEventListeners(activityEvents, () => {
|
|
249
|
-
|
|
272
|
+
increaseActivityDuration(Date.now());
|
|
250
273
|
}, { passive: true });
|
|
251
274
|
}
|
|
252
|
-
function
|
|
253
|
-
return
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
275
|
+
function calculateActivityGap(activityEndTime) {
|
|
276
|
+
return Math.min(activityEndTime - previousActivityTime, ACTIVITY_DURATION_LIMIT_MS);
|
|
277
|
+
}
|
|
278
|
+
function increaseActivityDuration(activityEndTime) {
|
|
279
|
+
activityDurationMs += calculateActivityGap(activityEndTime);
|
|
280
|
+
previousActivityTime = resetTime();
|
|
257
281
|
}
|
|
258
282
|
/*
|
|
259
283
|
Add listeners to a set of browser events.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBrowser } from '
|
|
1
|
+
import { isBrowser } from './utils';
|
|
2
2
|
const supportsBeacon = () => isBrowser && Boolean(window.navigator.sendBeacon);
|
|
3
3
|
export default function send(url, data, sdkConfig) {
|
|
4
4
|
// if there is as large number of events, only send 10 in each request
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { v4 as uuid } from 'uuid';
|
|
2
|
+
import { cookieConfig, getRootDomain, readCookie, SESSION_SDRN_PREFIX, webApi, writeCookie } from '../utils';
|
|
3
|
+
const { USE_LOCALSTORAGE } = cookieConfig;
|
|
4
|
+
const SESSION_STORAGE_KEY = '_pulsesession';
|
|
5
|
+
const SESSION_MAX_INTERVAL_MS = 30 * 60 * 1000; // 30 minutes
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
export const generateSessionSDRN = (sessionId) => `${SESSION_SDRN_PREFIX}${sessionId}`;
|
|
10
|
+
// Return parsed json from cookie (or localStorage if enabled), or undefined.
|
|
11
|
+
const readAndParse = () => {
|
|
12
|
+
try {
|
|
13
|
+
const storedSession = readCookie(SESSION_STORAGE_KEY);
|
|
14
|
+
if (storedSession) {
|
|
15
|
+
return JSON.parse(storedSession);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch (_e) {
|
|
19
|
+
// If localStorage/cookie is not available, we treat it as if
|
|
20
|
+
// the value is undefined.
|
|
21
|
+
// If data is unparseable, we also ignore it.
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Reads the stored session. Any invalid or unreadable data is ignored.
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
export const readSession = () => {
|
|
31
|
+
const storedSession = readAndParse();
|
|
32
|
+
if (storedSession) {
|
|
33
|
+
const [sessionSdrn, startTimeMs, lastEventTimeMs] = storedSession;
|
|
34
|
+
const startTime = new Date(startTimeMs);
|
|
35
|
+
const lastEventTime = new Date(lastEventTimeMs);
|
|
36
|
+
if (sessionSdrn && !Number.isNaN(startTime.getTime()) && !Number.isNaN(lastEventTime.getTime())) {
|
|
37
|
+
return {
|
|
38
|
+
// the session is stored as an SDRN, for compatibility with legacy events and older SDK versions
|
|
39
|
+
sessionId: sessionSdrn.replace(SESSION_SDRN_PREFIX, ''),
|
|
40
|
+
startTime,
|
|
41
|
+
lastEventTime,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
47
|
+
const writeSession = ({ sessionId, startTime, lastEventTime }) => {
|
|
48
|
+
try {
|
|
49
|
+
// SDK v8 (supporting TPaaS events) needs to be compatible with legacy events AND older SDK versions
|
|
50
|
+
// as a result, we can't store just the sessionId, we need the full SDRN in there
|
|
51
|
+
const sessionToStore = [
|
|
52
|
+
generateSessionSDRN(sessionId),
|
|
53
|
+
startTime.getTime(),
|
|
54
|
+
lastEventTime.getTime(),
|
|
55
|
+
];
|
|
56
|
+
const halfHourInDays = 1.0 / (24 * 2);
|
|
57
|
+
writeCookie(SESSION_STORAGE_KEY, JSON.stringify(sessionToStore), getRootDomain(), halfHourInDays);
|
|
58
|
+
// Delete old localStorage-based session if needed
|
|
59
|
+
if (!USE_LOCALSTORAGE) {
|
|
60
|
+
// removeItem will do nothing to a non-existing item.
|
|
61
|
+
webApi.localStorage?.removeItem(SESSION_STORAGE_KEY);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (_e) {
|
|
65
|
+
// If we can't write the session, we just move on in life
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const updateSession = (createdAt, session) => {
|
|
69
|
+
if (!session || session.lastEventTime.getTime() < createdAt.getTime() - SESSION_MAX_INTERVAL_MS) {
|
|
70
|
+
return { sessionId: uuid(), startTime: createdAt, lastEventTime: createdAt, isFirstEvent: true };
|
|
71
|
+
}
|
|
72
|
+
// Never move lastEventTime backwards, or the session would expire early.
|
|
73
|
+
// In case the order of events is not strictly chronological, this ensures the session remains valid.
|
|
74
|
+
const lastEventTime = createdAt.getTime() > session.lastEventTime.getTime() ? createdAt : session.lastEventTime;
|
|
75
|
+
return { ...session, lastEventTime, isFirstEvent: false };
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Registers an event created at `createdAt` in the stored session: extends the current session,
|
|
79
|
+
* or starts a new one when it expired, and stores the result.
|
|
80
|
+
*
|
|
81
|
+
* Call it synchronously, together with capturing `createdAt`, before any asynchronous work,
|
|
82
|
+
* so sessions are updated in the order events are tracked.
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
export const touchSession = (createdAt) => {
|
|
87
|
+
const session = updateSession(createdAt, readSession());
|
|
88
|
+
writeSession(session);
|
|
89
|
+
return session;
|
|
90
|
+
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { isBrowser } from '@schibsted/pulse-utils';
|
|
2
1
|
import * as logger from 'loglevel';
|
|
3
2
|
import { UAParser } from 'ua-parser-js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
cachedUAParser = UAParser();
|
|
3
|
+
let cachedUserAgentResult;
|
|
4
|
+
function getUserAgentResult(userAgent) {
|
|
5
|
+
if (cachedUserAgentResult?.ua !== userAgent) {
|
|
6
|
+
cachedUserAgentResult = UAParser(userAgent);
|
|
9
7
|
}
|
|
10
|
-
return
|
|
8
|
+
return cachedUserAgentResult;
|
|
11
9
|
}
|
|
12
|
-
export const builder = (environmentId, jwe) => {
|
|
13
|
-
if (
|
|
10
|
+
export const builder = (environmentId, jwe, browser) => {
|
|
11
|
+
if (browser.userAgent === undefined) {
|
|
14
12
|
return {
|
|
15
13
|
device: {
|
|
16
14
|
// TODO: server side rendering (or nodejs). do we need to set all the following fields?
|
|
@@ -25,7 +23,7 @@ export const builder = (environmentId, jwe) => {
|
|
|
25
23
|
},
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
|
-
const uaParser =
|
|
26
|
+
const uaParser = getUserAgentResult(browser.userAgent);
|
|
29
27
|
return {
|
|
30
28
|
device: {
|
|
31
29
|
clientType: getClientType(uaParser),
|
|
@@ -36,12 +34,42 @@ export const builder = (environmentId, jwe) => {
|
|
|
36
34
|
mobileBrand: uaParser.device.vendor,
|
|
37
35
|
mobileModel: uaParser.device.model,
|
|
38
36
|
operatingSystem: getOperatingSystem(uaParser),
|
|
39
|
-
screenOrientation: getScreenOrientation(),
|
|
40
|
-
userAgent:
|
|
41
|
-
viewportSize: getViewportSize(),
|
|
37
|
+
screenOrientation: getScreenOrientation(browser.screenOrientationType),
|
|
38
|
+
userAgent: browser.userAgent,
|
|
39
|
+
viewportSize: getViewportSize(browser.viewportWidth, browser.viewportHeight),
|
|
42
40
|
},
|
|
43
41
|
};
|
|
44
42
|
};
|
|
43
|
+
function getScreenOrientation(orientationType) {
|
|
44
|
+
if (orientationType === 'landscape-primary' || orientationType === 'landscape-secondary') {
|
|
45
|
+
return 'Landscape';
|
|
46
|
+
}
|
|
47
|
+
return 'Portrait';
|
|
48
|
+
}
|
|
49
|
+
function getSizeFromPixels(pixels) {
|
|
50
|
+
if (pixels < 360) {
|
|
51
|
+
return 'XS';
|
|
52
|
+
}
|
|
53
|
+
if (pixels < 480) {
|
|
54
|
+
return 'S';
|
|
55
|
+
}
|
|
56
|
+
if (pixels < 768) {
|
|
57
|
+
return 'M';
|
|
58
|
+
}
|
|
59
|
+
if (pixels < 1024) {
|
|
60
|
+
return 'L';
|
|
61
|
+
}
|
|
62
|
+
if (pixels >= 1024) {
|
|
63
|
+
return 'XL';
|
|
64
|
+
}
|
|
65
|
+
logger.error('Could not determine viewport size, defaulting to M');
|
|
66
|
+
return 'M';
|
|
67
|
+
}
|
|
68
|
+
function getViewportSize(viewportWidth, viewportHeight) {
|
|
69
|
+
const size = getSizeFromPixels(Math.min(viewportWidth, viewportHeight));
|
|
70
|
+
logger.debug(`Viewport size: ${viewportWidth}x${viewportHeight}, mapped to ${size}`);
|
|
71
|
+
return size;
|
|
72
|
+
}
|
|
45
73
|
function getClientType(uaParser) {
|
|
46
74
|
const { browser } = uaParser;
|
|
47
75
|
const browserName = browser.name?.toLocaleLowerCase() || '';
|
|
@@ -102,73 +130,23 @@ function getOperatingSystem(uaParser) {
|
|
|
102
130
|
if (osName.includes('windows')) {
|
|
103
131
|
return 'Windows';
|
|
104
132
|
}
|
|
105
|
-
if (osName.includes('macos')) {
|
|
133
|
+
if (osName.includes('macos') || osName.includes('mac os')) {
|
|
106
134
|
return 'Mac';
|
|
107
135
|
}
|
|
108
|
-
|
|
136
|
+
if (osName.includes('android')) {
|
|
137
|
+
return 'Android';
|
|
138
|
+
}
|
|
139
|
+
if (osName.includes('ios')) {
|
|
140
|
+
return 'iOS';
|
|
141
|
+
}
|
|
142
|
+
// some flavours of Linux might not be captured by this
|
|
109
143
|
// do we need a better detection, based on a list?
|
|
110
144
|
// for example (Gentoo - https://docs.uaparser.dev/info/os/name.html)
|
|
111
145
|
if (osName.includes('linux')) {
|
|
112
146
|
return 'Linux';
|
|
113
147
|
}
|
|
114
|
-
// the TPaaS `device` template is missing
|
|
148
|
+
// the TPaaS `device` template is missing iPadOS and maybe others?
|
|
115
149
|
logger.log(`Unknown operating system: ${osName}. Defaulting to 'other'.`);
|
|
116
150
|
// default value
|
|
117
151
|
return 'Other';
|
|
118
152
|
}
|
|
119
|
-
function getScreenOrientation() {
|
|
120
|
-
const orientationType = window.screen.orientation?.type;
|
|
121
|
-
const portraitOrientations = ['portrait-primary', 'portrait-secondary'];
|
|
122
|
-
const landscapeOrientations = ['landscape-primary', 'landscape-secondary'];
|
|
123
|
-
// the ifs might be a bit overkill, but it helps with separating the default value from the logic
|
|
124
|
-
if (portraitOrientations.includes(orientationType)) {
|
|
125
|
-
return 'Portrait';
|
|
126
|
-
}
|
|
127
|
-
if (landscapeOrientations.includes(orientationType)) {
|
|
128
|
-
return 'Landscape';
|
|
129
|
-
}
|
|
130
|
-
// default value
|
|
131
|
-
return 'Portrait';
|
|
132
|
-
}
|
|
133
|
-
function getSizeFromPixels(pixels) {
|
|
134
|
-
if (pixels < 360) {
|
|
135
|
-
return 'XS';
|
|
136
|
-
}
|
|
137
|
-
if (pixels < 480) {
|
|
138
|
-
return 'S';
|
|
139
|
-
}
|
|
140
|
-
if (pixels < 768) {
|
|
141
|
-
return 'M';
|
|
142
|
-
}
|
|
143
|
-
if (pixels < 1024) {
|
|
144
|
-
return 'L';
|
|
145
|
-
}
|
|
146
|
-
if (pixels >= 1024) {
|
|
147
|
-
return 'XL';
|
|
148
|
-
}
|
|
149
|
-
// default value
|
|
150
|
-
logger.error('Could not determine viewport size, defaulting to M');
|
|
151
|
-
return 'M';
|
|
152
|
-
}
|
|
153
|
-
function getViewportSize() {
|
|
154
|
-
let viewportWidth;
|
|
155
|
-
let viewportHeight;
|
|
156
|
-
const { document } = window;
|
|
157
|
-
if (typeof window.innerWidth !== 'undefined') {
|
|
158
|
-
viewportWidth = window.innerWidth;
|
|
159
|
-
viewportHeight = window.innerHeight;
|
|
160
|
-
}
|
|
161
|
-
else if (typeof document.documentElement.clientWidth !== 'undefined' &&
|
|
162
|
-
document.documentElement.clientWidth !== 0) {
|
|
163
|
-
viewportWidth = document.documentElement.clientWidth;
|
|
164
|
-
viewportHeight = document.documentElement.clientHeight;
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
viewportWidth = document.getElementsByTagName('body')[0].clientWidth;
|
|
168
|
-
viewportHeight = document.getElementsByTagName('body')[0].clientHeight;
|
|
169
|
-
}
|
|
170
|
-
const shortestDimension = Math.min(viewportWidth, viewportHeight);
|
|
171
|
-
const size = getSizeFromPixels(shortestDimension);
|
|
172
|
-
logger.debug(`Viewport size: ${viewportWidth}x${viewportHeight}, mapped to ${size}`);
|
|
173
|
-
return size;
|
|
174
|
-
}
|
|
@@ -12,12 +12,11 @@ export const builder = (eventNavigationType) => {
|
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
// In practice they use the same values, but for future proofing we keep them separate and mapped
|
|
15
|
+
// In practice, they use the same values, but for future proofing we keep them separate and mapped
|
|
16
16
|
const modernNavigationMap = {
|
|
17
17
|
navigate: 'Navigate',
|
|
18
18
|
reload: 'Reload',
|
|
19
19
|
back_forward: 'BackForward',
|
|
20
|
-
prerender: 'Prerender',
|
|
21
20
|
};
|
|
22
21
|
const legacyNavigationMap = {
|
|
23
22
|
0: 'Navigate',
|
|
@@ -25,7 +24,7 @@ const legacyNavigationMap = {
|
|
|
25
24
|
2: 'BackForward',
|
|
26
25
|
};
|
|
27
26
|
const getModernNavigationType = (entryType) => {
|
|
28
|
-
return modernNavigationMap[entryType];
|
|
27
|
+
return modernNavigationMap[entryType] || 'Navigate';
|
|
29
28
|
};
|
|
30
29
|
const getLegacyNavigationType = (entryType) => {
|
|
31
30
|
return legacyNavigationMap[entryType] || 'Navigate';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export const builder = (currentPage) => {
|
|
1
|
+
export const builder = (currentPage, url) => {
|
|
3
2
|
// if something happens and there was no View Page type of event sent before, we need a fallback
|
|
4
3
|
if (!currentPage) {
|
|
5
4
|
return {
|
|
@@ -7,7 +6,7 @@ export const builder = (currentPage) => {
|
|
|
7
6
|
info: {
|
|
8
7
|
pageId: 'unknown',
|
|
9
8
|
pageType: 'Page',
|
|
10
|
-
url
|
|
9
|
+
url,
|
|
11
10
|
},
|
|
12
11
|
},
|
|
13
12
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const generateProviderSDRN = (providerId) => `sdrn:schibsted:client:${providerId}`;
|
|
2
|
+
export function builder(providerId, providerStage, providerProduct, providerVersion, component, componentVersion, providerName, providerGroup) {
|
|
3
|
+
return {
|
|
4
|
+
provider: {
|
|
5
|
+
providerId,
|
|
6
|
+
providerSdrn: generateProviderSDRN(providerId),
|
|
7
|
+
...(component !== undefined && { component }),
|
|
8
|
+
...(componentVersion !== undefined && { componentVersion }),
|
|
9
|
+
...(providerGroup !== undefined && { group: providerGroup }),
|
|
10
|
+
...(providerName !== undefined && { name: providerName }),
|
|
11
|
+
stage: providerStage,
|
|
12
|
+
product: providerProduct,
|
|
13
|
+
version: providerVersion,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const hasReferrerData = (referrer) => Boolean(referrer.pageId || referrer.url || referrer.pageType);
|
|
2
|
+
export const builder = (referrer) => {
|
|
3
|
+
if (!hasReferrerData(referrer)) {
|
|
4
|
+
return {
|
|
5
|
+
page: {},
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
page: {
|
|
10
|
+
referrer,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const builder = (session) => ({ session });
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (!isBrowser) {
|
|
5
|
-
return {
|
|
6
|
-
page: {},
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
const urlParams = new URLSearchParams(window?.location?.search ?? '');
|
|
1
|
+
import { UTM_MEDIUM_VALUES } from '../../tpaas-schemas';
|
|
2
|
+
export const builder = (search) => {
|
|
3
|
+
const urlParams = new URLSearchParams(search);
|
|
10
4
|
const utmCampaign = urlParams.get('utm_campaign');
|
|
11
5
|
const utmContent = urlParams.get('utm_content');
|
|
12
6
|
const utmMediumRaw = urlParams.get('utm_medium');
|