@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
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncWithCis = syncWithCis;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const pulse_cookie_1 = require("./pulse-cookie");
|
|
6
|
+
const { PULSE_COOKIE_KEY } = utils_1.cookieConfig;
|
|
7
|
+
const CIS_HOST = 'https://cis.schibsted.com';
|
|
8
|
+
const CIS_PATH = '/api/v2/identify';
|
|
9
|
+
let preferredCISHost = 'cis.schibsted.com';
|
|
10
|
+
/**
|
|
11
|
+
* CIS has two endpoints:
|
|
12
|
+
* - anonymous identifier keys (/identify/guest),
|
|
13
|
+
* - identifiable keys (/identify/user)
|
|
14
|
+
*/
|
|
15
|
+
const CISActorType = {
|
|
16
|
+
USER: 'user',
|
|
17
|
+
GUEST: 'guest',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolves CIS path param
|
|
21
|
+
* @param actorId
|
|
22
|
+
*/
|
|
23
|
+
const getActorPath = (actorId) => {
|
|
24
|
+
let endpoint = CISActorType.GUEST;
|
|
25
|
+
if (actorId) {
|
|
26
|
+
endpoint = CISActorType.USER;
|
|
27
|
+
}
|
|
28
|
+
return `${CIS_PATH}/${endpoint}`;
|
|
29
|
+
};
|
|
30
|
+
const cisFetchHeaders = new Headers({
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
});
|
|
33
|
+
const CIS_MAX_REDIRECT_ATTEMPTS = 2;
|
|
34
|
+
const CIS_DEFAULT_REALM = 'schibsted.com';
|
|
35
|
+
const cisRequestMap = new Map();
|
|
36
|
+
/**
|
|
37
|
+
* Call CIS with the current user information.
|
|
38
|
+
*
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
async function cisFetch({ adChoicesEnabled, cisLocation, clientId, includeAdvertising, resolvedJwe: jwe, trackerType, trackerVersion, userId, vendors, } = {}) {
|
|
42
|
+
const basePath = cisLocation?.endsWith('/') ? cisLocation.slice(0, -1) : cisLocation;
|
|
43
|
+
const path = `${basePath}${getActorPath(userId)}`;
|
|
44
|
+
const features = adChoicesEnabled === true ? ['COP'] : undefined;
|
|
45
|
+
// Using 'toString' here to make unit test mock comparisons easier
|
|
46
|
+
return fetch(new URL(path).toString(), {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
credentials: 'include',
|
|
49
|
+
headers: cisFetchHeaders,
|
|
50
|
+
body: JSON.stringify({
|
|
51
|
+
clientId,
|
|
52
|
+
features,
|
|
53
|
+
includeAdvertising,
|
|
54
|
+
jwe,
|
|
55
|
+
trackerType,
|
|
56
|
+
trackerVersion,
|
|
57
|
+
userId,
|
|
58
|
+
vendors,
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Identify recursively until no `redirectToHost` field */
|
|
63
|
+
async function cisFetchWithRedirect({ adChoicesEnabled, cisLocation, clientId, includeAdvertising, resolvedJwe, trackerType, trackerVersion, userId, vendors, }, redirectAttempts = 0) {
|
|
64
|
+
if (redirectAttempts > CIS_MAX_REDIRECT_ATTEMPTS) {
|
|
65
|
+
throw new Error('Too many CIS redirects');
|
|
66
|
+
}
|
|
67
|
+
const response = await cisFetch({
|
|
68
|
+
adChoicesEnabled,
|
|
69
|
+
cisLocation,
|
|
70
|
+
clientId,
|
|
71
|
+
includeAdvertising,
|
|
72
|
+
resolvedJwe,
|
|
73
|
+
trackerType,
|
|
74
|
+
trackerVersion,
|
|
75
|
+
userId,
|
|
76
|
+
vendors,
|
|
77
|
+
});
|
|
78
|
+
const { data: responseData } = await response.json();
|
|
79
|
+
if (responseData.redirectToHost) {
|
|
80
|
+
preferredCISHost = responseData.redirectToHost;
|
|
81
|
+
return cisFetchWithRedirect({
|
|
82
|
+
adChoicesEnabled,
|
|
83
|
+
resolvedJwe,
|
|
84
|
+
userId,
|
|
85
|
+
cisLocation: `https://${preferredCISHost}`,
|
|
86
|
+
clientId,
|
|
87
|
+
trackerType,
|
|
88
|
+
trackerVersion,
|
|
89
|
+
includeAdvertising,
|
|
90
|
+
vendors,
|
|
91
|
+
}, redirectAttempts + 1);
|
|
92
|
+
}
|
|
93
|
+
return responseData;
|
|
94
|
+
}
|
|
95
|
+
let currentCisRequest = Promise.resolve((0, pulse_cookie_1.parsePulseCookies)());
|
|
96
|
+
/**
|
|
97
|
+
* Call CIS serially if needed, 'needed' being evaluated when the call reaches the top of the queue.
|
|
98
|
+
*
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
async function serialSyncWithCis(shortUserId,
|
|
102
|
+
// biome-ignore lint/style/useDefaultParameterLast: -
|
|
103
|
+
forceSync = false, cisLocation, nativeJwe, realm, clientId, trackerType, trackerVersion, options) {
|
|
104
|
+
// Re-read our sync state as the previous cis request might have
|
|
105
|
+
// made this sync obsolete.
|
|
106
|
+
const cookie = (0, utils_1.readCookie)(PULSE_COOKIE_KEY);
|
|
107
|
+
const { syncWithCis: shouldSyncWithCIS, syncWithCisReason: requestReason } = (0, pulse_cookie_1.getSyncState)(shortUserId, {
|
|
108
|
+
cookie,
|
|
109
|
+
...options,
|
|
110
|
+
});
|
|
111
|
+
const { jwe, prevUserId } = (0, pulse_cookie_1.parsePulseCookies)(cookie);
|
|
112
|
+
const requestHandlerFn = async () => {
|
|
113
|
+
// For reason === login, we know shortUserId should be set and should be trusted.
|
|
114
|
+
// For reason === logout, we know shortUserId is unset, but should be trusted.
|
|
115
|
+
// For reason === initialise, we can't trust shortUserId and should use prevUserId instead.
|
|
116
|
+
// For reason === refresh, we could use either as they should be in sync, but using
|
|
117
|
+
// prevUserId makes it possible to do regular syncs without access to an event, so we use that.
|
|
118
|
+
const resolvedJwe = nativeJwe || jwe; // always send a nativeJwe when present. Hybrid app use case;
|
|
119
|
+
let prominentUserId = shortUserId;
|
|
120
|
+
if (requestReason !== pulse_cookie_1.CisSyncReason.Login && requestReason !== pulse_cookie_1.CisSyncReason.Logout) {
|
|
121
|
+
prominentUserId = prevUserId;
|
|
122
|
+
}
|
|
123
|
+
const userId = prominentUserId && `sdrn:${realm}:user:${prominentUserId}`;
|
|
124
|
+
if (shouldSyncWithCIS || forceSync) {
|
|
125
|
+
try {
|
|
126
|
+
const cisResponseData = await cisFetchWithRedirect({
|
|
127
|
+
resolvedJwe,
|
|
128
|
+
userId,
|
|
129
|
+
cisLocation,
|
|
130
|
+
clientId,
|
|
131
|
+
adChoicesEnabled: options?.adChoicesEnabled,
|
|
132
|
+
trackerType,
|
|
133
|
+
trackerVersion,
|
|
134
|
+
includeAdvertising: options?.includeAdvertising,
|
|
135
|
+
vendors: options?.vendors,
|
|
136
|
+
});
|
|
137
|
+
const refreshAfterTimestamp = cisResponseData.refreshAfter
|
|
138
|
+
? new Date(cisResponseData.refreshAfter).getTime()
|
|
139
|
+
: 0;
|
|
140
|
+
const storageData = {
|
|
141
|
+
ppId: {},
|
|
142
|
+
...cisResponseData,
|
|
143
|
+
prevUserId: shortUserId,
|
|
144
|
+
refreshAfterTimestamp,
|
|
145
|
+
includeAdvertising: options?.includeAdvertising,
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* AdChoices restricts the issuing of PPID.
|
|
149
|
+
* When the user has NOT consented to advertising purpose, and the application runs with AdChoices rules, the sdk
|
|
150
|
+
* cannot delegate or persist the PPID in localStorage.
|
|
151
|
+
* `adChoicesEnabled` must be explicitly set to `true`. No room for truthy values here.
|
|
152
|
+
*/
|
|
153
|
+
if (options?.adChoicesEnabled === true && options?.includeAdvertising !== true) {
|
|
154
|
+
storageData.ppId = {};
|
|
155
|
+
}
|
|
156
|
+
(0, pulse_cookie_1.serializePulseCookie)(storageData);
|
|
157
|
+
return storageData;
|
|
158
|
+
}
|
|
159
|
+
catch (_err) {
|
|
160
|
+
// silent error.
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
if (options?.trackerId) {
|
|
164
|
+
cisRequestMap.delete(options.trackerId);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return (0, pulse_cookie_1.parsePulseCookies)();
|
|
169
|
+
};
|
|
170
|
+
if (options?.trackerId) {
|
|
171
|
+
const { request, requestReason: onGoingRequestReason } = cisRequestMap.get(options.trackerId) || {};
|
|
172
|
+
let ongoingRequest = request;
|
|
173
|
+
if (!ongoingRequest || onGoingRequestReason !== requestReason || forceSync) {
|
|
174
|
+
ongoingRequest = requestHandlerFn();
|
|
175
|
+
cisRequestMap.set(options.trackerId, { request: ongoingRequest, requestReason });
|
|
176
|
+
}
|
|
177
|
+
return ongoingRequest;
|
|
178
|
+
}
|
|
179
|
+
// maintaining the old behaviour for when there is no "internalId" passed to the tracker.
|
|
180
|
+
currentCisRequest = currentCisRequest.then(requestHandlerFn);
|
|
181
|
+
return currentCisRequest;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Sync with CIS
|
|
185
|
+
*
|
|
186
|
+
* This method deals with all communication and communication with dependent systems (currently AppNexus and Norstat).
|
|
187
|
+
*
|
|
188
|
+
* An optional user id should be provided if a tracker have received a logged in state. Providing a new user id
|
|
189
|
+
* (different from a previous user id, serialized to the pulse cookie) will cause a "blocking call" to CIS (the
|
|
190
|
+
* returned promise will not resolve before the communication is done). This is done because CIS could provide new data
|
|
191
|
+
* regarding opt-out.
|
|
192
|
+
*
|
|
193
|
+
* The returned promise will also be blocking if no pulse cookie is found. Pulse requires environmentIds generated
|
|
194
|
+
* server side so one have to wait to be allocated to one.
|
|
195
|
+
*
|
|
196
|
+
* In other context CIS could or could not be called but the returned promise will resolve immediately. If CIS have
|
|
197
|
+
* been called recently there is no point in calling it again. In a different case, if a refresh call to CIS is required
|
|
198
|
+
* it doesn't mean that other systems have to wait of it. Both cases will return a promise that resolves more or less
|
|
199
|
+
* immediately.
|
|
200
|
+
*/
|
|
201
|
+
async function syncWithCis(shortUserId, nativeJwe, userServiceLocation, realm = CIS_DEFAULT_REALM, clientId, trackerType, trackerVersion, options) {
|
|
202
|
+
const { syncWithCis: shouldSyncWithCIS, waitForCis: shouldWaitForCIS } = (0, pulse_cookie_1.getSyncState)(shortUserId, options);
|
|
203
|
+
const storageData = (0, pulse_cookie_1.parsePulseCookies)();
|
|
204
|
+
const cisLocation = userServiceLocation || CIS_HOST;
|
|
205
|
+
let cisRequest = Promise.resolve(storageData);
|
|
206
|
+
if (shouldSyncWithCIS || options?.forceSync) {
|
|
207
|
+
cisRequest = serialSyncWithCis(shortUserId, Boolean(options?.forceSync), cisLocation, nativeJwe, realm, clientId || '', trackerType || '', trackerVersion || '', options);
|
|
208
|
+
}
|
|
209
|
+
// If `shouldWaitForCIS` is false the update with CIS is only a "soft sync" and
|
|
210
|
+
// shouldn't block other operations. This is the case when the browser has a
|
|
211
|
+
// _pulse2data cookie and the user haven't logged in or out. When the user do
|
|
212
|
+
// log in we have to wait to avoid sending events with user ids after logging
|
|
213
|
+
// out or without ids after logging in.
|
|
214
|
+
let ongoingCISRequest = Promise.resolve(storageData);
|
|
215
|
+
if (shouldWaitForCIS || options?.forceSync) {
|
|
216
|
+
ongoingCISRequest = cisRequest;
|
|
217
|
+
}
|
|
218
|
+
return ongoingCISRequest;
|
|
219
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class EventEmitter {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.events = {};
|
|
6
|
+
}
|
|
7
|
+
on(event, callback) {
|
|
8
|
+
if (typeof this.events[event] !== 'object') {
|
|
9
|
+
this.events[event] = [];
|
|
10
|
+
}
|
|
11
|
+
this.events[event].push(callback);
|
|
12
|
+
}
|
|
13
|
+
off(event, callback) {
|
|
14
|
+
this.removeListener(event, callback);
|
|
15
|
+
}
|
|
16
|
+
removeListener(event, callback) {
|
|
17
|
+
if (typeof this.events[event] === 'object') {
|
|
18
|
+
const index = this.events[event].indexOf(callback);
|
|
19
|
+
if (index !== -1) {
|
|
20
|
+
this.events[event].splice(index, 1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
removeAllListeners() {
|
|
25
|
+
this.events = {};
|
|
26
|
+
}
|
|
27
|
+
emit(event, value) {
|
|
28
|
+
if (typeof this.events[event] === 'object') {
|
|
29
|
+
this.events[event]
|
|
30
|
+
.filter((cb) => cb != null)
|
|
31
|
+
.forEach((cb) => {
|
|
32
|
+
cb(value);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = EventEmitter;
|
|
@@ -9,4 +9,3 @@ Object.defineProperty(exports, "clearCookieJweIfStale", { enumerable: true, get:
|
|
|
9
9
|
Object.defineProperty(exports, "eventEmitter", { enumerable: true, get: function () { return pulse_cookie_1.eventEmitter; } });
|
|
10
10
|
Object.defineProperty(exports, "parsePulseCookies", { enumerable: true, get: function () { return pulse_cookie_1.parsePulseCookies; } });
|
|
11
11
|
Object.defineProperty(exports, "resetRefreshAfter", { enumerable: true, get: function () { return pulse_cookie_1.resetRefreshAfter; } });
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
package/{node_modules/@schibsted/pulse-cis-sync/dist/cjs → dist/cjs/cis-sync}/pulse-cookie.js
RENAMED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -22,50 +11,46 @@ exports.clearCookieAdvertisingIds = clearCookieAdvertisingIds;
|
|
|
22
11
|
exports.clearCookieJweIfStale = clearCookieJweIfStale;
|
|
23
12
|
exports.resetRefreshAfter = resetRefreshAfter;
|
|
24
13
|
exports.getSyncState = getSyncState;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
const eventEmitter_1 = __importDefault(require("./eventEmitter"));
|
|
16
|
+
const pulseStorage_1 = __importDefault(require("./storage/pulseStorage"));
|
|
17
|
+
const { PULSE_COOKIE_KEY, ENV_COOKIE_KEY } = utils_1.cookieConfig;
|
|
18
|
+
const CIS_POLL_INTERVAL = 900000; // 15 minutes
|
|
30
19
|
/**
|
|
31
20
|
* Responsible for subscribing to, and emitting events.
|
|
32
21
|
*/
|
|
33
22
|
exports.eventEmitter = new eventEmitter_1.default();
|
|
34
23
|
function cacheOldEnvironmentId(id) {
|
|
35
24
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
let envCookie = '';
|
|
26
|
+
let oldIds = {};
|
|
38
27
|
try {
|
|
39
|
-
envCookie = (0,
|
|
28
|
+
envCookie = (0, utils_1.readCookie)(ENV_COOKIE_KEY);
|
|
40
29
|
}
|
|
41
30
|
catch (_e) { }
|
|
42
31
|
try {
|
|
43
|
-
|
|
32
|
+
oldIds = envCookie ? JSON.parse(envCookie) : [];
|
|
44
33
|
}
|
|
45
34
|
catch (_e) { }
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.map(
|
|
49
|
-
.sort(
|
|
35
|
+
oldIds[id] = Date.now();
|
|
36
|
+
const idsToCache = Object.keys(oldIds)
|
|
37
|
+
.map((envId) => ({ id: envId, date: oldIds[envId] }))
|
|
38
|
+
.sort((o) => o.date)
|
|
50
39
|
.slice(0, 5)
|
|
51
40
|
// biome-ignore lint/performance/noAccumulatingSpread: -
|
|
52
|
-
.reduce(
|
|
53
|
-
|
|
54
|
-
return (__assign(__assign({}, accl), (_a = {}, _a[o.id] = o.date, _a)));
|
|
55
|
-
}, {});
|
|
56
|
-
(0, pulse_utils_1.writeCookie)(ENV_COOKIE_KEY, JSON.stringify(idsToCache), (0, pulse_utils_1.getRootDomain)(), 365);
|
|
41
|
+
.reduce((accl, o) => ({ ...accl, [o.id]: o.date }), {});
|
|
42
|
+
(0, utils_1.writeCookie)(ENV_COOKIE_KEY, JSON.stringify(idsToCache), (0, utils_1.getRootDomain)(), 365);
|
|
57
43
|
}
|
|
58
44
|
catch (_e) { }
|
|
59
45
|
}
|
|
60
|
-
function parsePulseCookies(cookie) {
|
|
61
|
-
|
|
62
|
-
var values = decodeURIComponent(cookie).split(',');
|
|
46
|
+
function parsePulseCookies(cookie = (0, utils_1.readCookie)(PULSE_COOKIE_KEY)) {
|
|
47
|
+
let values = decodeURIComponent(cookie).split(',');
|
|
63
48
|
// Cookie is in an unknown, possibly old format. Will be ignored.
|
|
64
49
|
if (values.length !== 10) {
|
|
65
50
|
values = [];
|
|
66
51
|
}
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
const altEnvCookie = (0, utils_1.readCookie)(ENV_COOKIE_KEY);
|
|
53
|
+
let altEnvIds;
|
|
69
54
|
if (altEnvIds) {
|
|
70
55
|
try {
|
|
71
56
|
altEnvIds = JSON.parse(altEnvCookie);
|
|
@@ -74,8 +59,8 @@ function parsePulseCookies(cookie) {
|
|
|
74
59
|
altEnvIds = undefined;
|
|
75
60
|
}
|
|
76
61
|
}
|
|
77
|
-
|
|
78
|
-
|
|
62
|
+
const ppId = pulseStorage_1.default.getPPIDsFromStorage();
|
|
63
|
+
const cisCache = pulseStorage_1.default.getCisCacheFromStorage();
|
|
79
64
|
return {
|
|
80
65
|
environmentId: values[0],
|
|
81
66
|
prevUserId: values[2] ? values[2] : undefined,
|
|
@@ -86,17 +71,17 @@ function parsePulseCookies(cookie) {
|
|
|
86
71
|
doTracking: true,
|
|
87
72
|
pixelInjected: values[8] ? values[8] === 'true' : undefined,
|
|
88
73
|
adId: values[9],
|
|
89
|
-
altEnvIds
|
|
74
|
+
altEnvIds,
|
|
90
75
|
visitorIdPlaceholder: values[1],
|
|
91
|
-
ppId
|
|
92
|
-
includeAdvertising: cisCache
|
|
76
|
+
ppId,
|
|
77
|
+
includeAdvertising: cisCache?.includeAdvertising,
|
|
93
78
|
};
|
|
94
79
|
}
|
|
95
80
|
function serializePulseCookie(input) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
const { environmentId = '', prevUserId = '', jwe = '', pixelInjected = '', adId = '', visitorIdPlaceholder = 'v', ppId = {}, refreshAfterTimestamp, includeAdvertising, } = input || {};
|
|
82
|
+
const now = Date.now();
|
|
83
|
+
const refreshCisAfterTimestamp = refreshAfterTimestamp || new Date(now + CIS_POLL_INTERVAL).getTime();
|
|
84
|
+
const cookieString = [
|
|
100
85
|
environmentId,
|
|
101
86
|
visitorIdPlaceholder,
|
|
102
87
|
prevUserId,
|
|
@@ -109,8 +94,8 @@ function serializePulseCookie(input) {
|
|
|
109
94
|
adId,
|
|
110
95
|
].join(',');
|
|
111
96
|
pulseStorage_1.default.setPPIDsToStorage(ppId);
|
|
112
|
-
pulseStorage_1.default.setCisCacheToStorage({ includeAdvertising
|
|
113
|
-
(0,
|
|
97
|
+
pulseStorage_1.default.setCisCacheToStorage({ includeAdvertising });
|
|
98
|
+
(0, utils_1.writeCookie)(PULSE_COOKIE_KEY, cookieString, (0, utils_1.getRootDomain)(), 2 * 365);
|
|
114
99
|
exports.eventEmitter.emit('environmentIdSet', environmentId);
|
|
115
100
|
exports.eventEmitter.emit('jweSet', jwe);
|
|
116
101
|
}
|
|
@@ -128,7 +113,14 @@ var CisSyncReason;
|
|
|
128
113
|
* @deprecated Advertising Identifiers methods will be removed in the next major version.
|
|
129
114
|
*/
|
|
130
115
|
function clearCookieAdvertisingIds() {
|
|
131
|
-
|
|
116
|
+
const cookieValues = {
|
|
117
|
+
...parsePulseCookies(),
|
|
118
|
+
adId: '',
|
|
119
|
+
anId: '',
|
|
120
|
+
includeAdvertising: false,
|
|
121
|
+
jwe: '',
|
|
122
|
+
syncWithAppNexus: 0,
|
|
123
|
+
};
|
|
132
124
|
serializePulseCookie(cookieValues);
|
|
133
125
|
return cookieValues;
|
|
134
126
|
}
|
|
@@ -142,9 +134,8 @@ function clearCookieAdvertisingIds() {
|
|
|
142
134
|
* send any nativeJwe in config.
|
|
143
135
|
* @deprecated Advertising Identifiers methods will be removed in the next major version.
|
|
144
136
|
*/
|
|
145
|
-
function clearCookieJweIfStale(jwe) {
|
|
146
|
-
|
|
147
|
-
var currentJwe = parsePulseCookies().jwe;
|
|
137
|
+
function clearCookieJweIfStale(jwe = '') {
|
|
138
|
+
const { jwe: currentJwe } = parsePulseCookies();
|
|
148
139
|
if (jwe && currentJwe !== jwe) {
|
|
149
140
|
clearCookieAdvertisingIds();
|
|
150
141
|
}
|
|
@@ -154,7 +145,10 @@ function clearCookieJweIfStale(jwe) {
|
|
|
154
145
|
* @param refreshAfterDateTime
|
|
155
146
|
*/
|
|
156
147
|
function resetRefreshAfter(refreshAfterDateTime) {
|
|
157
|
-
|
|
148
|
+
const cookieValues = {
|
|
149
|
+
...parsePulseCookies(),
|
|
150
|
+
refreshAfterTimestamp: refreshAfterDateTime ? refreshAfterDateTime.getTime() : Date.now(),
|
|
151
|
+
};
|
|
158
152
|
serializePulseCookie(cookieValues);
|
|
159
153
|
return cookieValues;
|
|
160
154
|
}
|
|
@@ -164,7 +158,7 @@ function resetRefreshAfter(refreshAfterDateTime) {
|
|
|
164
158
|
* @param prevUserId previous user's id stored in the application
|
|
165
159
|
* @returns
|
|
166
160
|
*/
|
|
167
|
-
|
|
161
|
+
const shouldLogin = (userId, prevUserId) => {
|
|
168
162
|
return Boolean(userId) && String(userId) !== String(prevUserId);
|
|
169
163
|
};
|
|
170
164
|
/**
|
|
@@ -173,7 +167,7 @@ var shouldLogin = function (userId, prevUserId) {
|
|
|
173
167
|
* @param prevUserId previous user's id stored in the application
|
|
174
168
|
* @returns
|
|
175
169
|
*/
|
|
176
|
-
|
|
170
|
+
const shouldLogout = (userId, prevUserId) => {
|
|
177
171
|
return !userId && String(userId) !== String(prevUserId);
|
|
178
172
|
};
|
|
179
173
|
/**
|
|
@@ -181,7 +175,7 @@ var shouldLogout = function (userId, prevUserId) {
|
|
|
181
175
|
* @param currentTimestamp now, expressed as timestamp in ms
|
|
182
176
|
* @param refreshAfterTimestamp threshold, expressed as timestamp in ms
|
|
183
177
|
*/
|
|
184
|
-
|
|
178
|
+
const shouldRefresh = (currentTimestamp, refreshAfterTimestamp) => {
|
|
185
179
|
return refreshAfterTimestamp && currentTimestamp > refreshAfterTimestamp;
|
|
186
180
|
};
|
|
187
181
|
/**
|
|
@@ -190,7 +184,7 @@ var shouldRefresh = function (currentTimestamp, refreshAfterTimestamp) {
|
|
|
190
184
|
* @param updatedIncludeAdvertising newly processed value for includeAdvertising
|
|
191
185
|
* @deprecated Advertising Identifiers methods will be removed in the next major version.
|
|
192
186
|
*/
|
|
193
|
-
|
|
187
|
+
const shouldRefetchAdvertisingIdentifiers = (currentIncludeAdvertising, updatedIncludeAdvertising) => {
|
|
194
188
|
return currentIncludeAdvertising !== updatedIncludeAdvertising;
|
|
195
189
|
};
|
|
196
190
|
/**
|
|
@@ -200,9 +194,7 @@ var shouldRefetchAdvertisingIdentifiers = function (currentIncludeAdvertising, u
|
|
|
200
194
|
* @param includeAdvertising expresses whether advertising ids are expected in the stored state of the application
|
|
201
195
|
* @param vendors for which vendors the application is expecting advertising ids
|
|
202
196
|
*/
|
|
203
|
-
|
|
204
|
-
if (includeAdvertising === void 0) { includeAdvertising = false; }
|
|
205
|
-
if (vendors === void 0) { vendors = []; }
|
|
197
|
+
const shouldInitialise = (cookieInput, currentCookie, includeAdvertising = false, vendors = []) => {
|
|
206
198
|
return (!cookieInput ||
|
|
207
199
|
cookieInput.indexOf('undefined') !== -1 || // 'undefined' should not be a value in the raw cookie. Treat as invalid.
|
|
208
200
|
!currentCookie.environmentId ||
|
|
@@ -215,11 +207,10 @@ var shouldInitialise = function (cookieInput, currentCookie, includeAdvertising,
|
|
|
215
207
|
* @param options
|
|
216
208
|
* @returns {SyncState}
|
|
217
209
|
*/
|
|
218
|
-
function getSyncState(userId, options) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
var currentTimestamp = Date.now();
|
|
210
|
+
function getSyncState(userId, options = {}) {
|
|
211
|
+
const { cookie: cookieInput = (0, utils_1.readCookie)(PULSE_COOKIE_KEY), includeAdvertising, vendors } = options;
|
|
212
|
+
const currentCookie = parsePulseCookies(cookieInput);
|
|
213
|
+
const currentTimestamp = Date.now();
|
|
223
214
|
/*
|
|
224
215
|
* This case only handles login. For example when we don't necessarily have an event (tracker.update({actor: ...})
|
|
225
216
|
* might or might not have been called), then we only want to sync if we DO have a userId, and if that userId is not
|
|
@@ -273,4 +264,3 @@ function getSyncState(userId, options) {
|
|
|
273
264
|
syncWithCis: false,
|
|
274
265
|
};
|
|
275
266
|
}
|
|
276
|
-
//# sourceMappingURL=pulse-cookie.js.map
|
|
@@ -33,45 +33,53 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
exports.pulseStorageKeys = void 0;
|
|
37
|
+
const storage = __importStar(require("./storage"));
|
|
38
|
+
exports.pulseStorageKeys = {
|
|
38
39
|
PULSE_PPID_STORAGE_KEY: '_pulse.internal.identity.ppid',
|
|
39
40
|
PULSE_CIS_CACHE_STORAGE_KEY: '_pulse.internal.identity.cis',
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
-
var _a;
|
|
42
|
+
const getPPIDsFromStorage = () => {
|
|
43
43
|
try {
|
|
44
|
-
|
|
45
|
-
return JSON.parse(
|
|
44
|
+
const webStorage = storage.getStorage();
|
|
45
|
+
return JSON.parse(webStorage.getItem(exports.pulseStorageKeys.PULSE_PPID_STORAGE_KEY) ?? '{}');
|
|
46
46
|
}
|
|
47
47
|
catch (_err) {
|
|
48
48
|
return {};
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
const setPPIDsToStorage = (ppid) => {
|
|
52
52
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const webStorage = storage.getStorage();
|
|
54
|
+
/**
|
|
55
|
+
* we maintain the interface consistent with the ppId api, but there is no need to persist an empty object in
|
|
56
|
+
* localStorage. We normalise back when we read the value.
|
|
57
|
+
* @see getPPIDsFromStorage
|
|
58
|
+
*/
|
|
59
|
+
if (Object.keys(ppid).length === 0) {
|
|
60
|
+
webStorage.removeItem(exports.pulseStorageKeys.PULSE_PPID_STORAGE_KEY);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
webStorage.setItem(exports.pulseStorageKeys.PULSE_PPID_STORAGE_KEY, JSON.stringify(ppid));
|
|
55
64
|
return true;
|
|
56
65
|
}
|
|
57
66
|
catch (_err) {
|
|
58
67
|
return false;
|
|
59
68
|
}
|
|
60
69
|
};
|
|
61
|
-
|
|
62
|
-
var _a;
|
|
70
|
+
const getCisCacheFromStorage = () => {
|
|
63
71
|
try {
|
|
64
|
-
|
|
65
|
-
return JSON.parse(
|
|
72
|
+
const webStorage = storage.getStorage();
|
|
73
|
+
return JSON.parse(webStorage.getItem(exports.pulseStorageKeys.PULSE_CIS_CACHE_STORAGE_KEY) ?? '{}');
|
|
66
74
|
}
|
|
67
75
|
catch (_err) {
|
|
68
76
|
return {};
|
|
69
77
|
}
|
|
70
78
|
};
|
|
71
|
-
|
|
79
|
+
const setCisCacheToStorage = (cisPayload) => {
|
|
72
80
|
try {
|
|
73
|
-
|
|
74
|
-
webStorage.setItem(pulseStorageKeys.PULSE_CIS_CACHE_STORAGE_KEY, JSON.stringify(cisPayload));
|
|
81
|
+
const webStorage = storage.getStorage();
|
|
82
|
+
webStorage.setItem(exports.pulseStorageKeys.PULSE_CIS_CACHE_STORAGE_KEY, JSON.stringify(cisPayload));
|
|
75
83
|
return true;
|
|
76
84
|
}
|
|
77
85
|
catch (_err) {
|
|
@@ -79,9 +87,8 @@ var setCisCacheToStorage = function (cisPayload) {
|
|
|
79
87
|
}
|
|
80
88
|
};
|
|
81
89
|
exports.default = {
|
|
82
|
-
getCisCacheFromStorage
|
|
83
|
-
setCisCacheToStorage
|
|
84
|
-
getPPIDsFromStorage
|
|
85
|
-
setPPIDsToStorage
|
|
90
|
+
getCisCacheFromStorage,
|
|
91
|
+
setCisCacheToStorage,
|
|
92
|
+
getPPIDsFromStorage,
|
|
93
|
+
setPPIDsToStorage,
|
|
86
94
|
};
|
|
87
|
-
//# sourceMappingURL=pulseStorage.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStorage = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const getStorage = (storageType = 'localStorage') => {
|
|
6
|
+
const storage = utils_1.webApi[storageType];
|
|
7
|
+
const getItem = (key) => {
|
|
8
|
+
return utils_1.isBrowser && storage ? storage.getItem(key) : undefined;
|
|
9
|
+
};
|
|
10
|
+
const removeItem = (key) => {
|
|
11
|
+
if (utils_1.isBrowser && storage)
|
|
12
|
+
storage.removeItem(key);
|
|
13
|
+
};
|
|
14
|
+
const setItem = (key, value) => {
|
|
15
|
+
if (utils_1.isBrowser && storage)
|
|
16
|
+
storage.setItem(key, value);
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
getItem,
|
|
20
|
+
removeItem,
|
|
21
|
+
setItem,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.getStorage = getStorage;
|
|
@@ -10,20 +10,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createPulseTracker = createPulseTracker;
|
|
13
|
-
const pulse_utils_1 = require("@schibsted/pulse-utils/");
|
|
14
13
|
const Tracker_1 = __importDefault(require("./Tracker"));
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
15
|
/**
|
|
16
16
|
* Flags whether the Pulse Tracker creation process has been started.
|
|
17
17
|
*/
|
|
18
18
|
function isTrackerCreated() {
|
|
19
|
-
return
|
|
19
|
+
return utils_1.isBrowser && !!window.__pulseTracker;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Make the given tracker instance globally accessible
|
|
23
23
|
* @param singleton
|
|
24
24
|
*/
|
|
25
25
|
function attachTrackerToWindow(singleton) {
|
|
26
|
-
if (
|
|
26
|
+
if (utils_1.isBrowser) {
|
|
27
27
|
window.__pulseTracker = singleton;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -36,7 +36,7 @@ function attachTrackerToWindow(singleton) {
|
|
|
36
36
|
* @throws - If the Pulse Tracker has already been created (or creation is already in progress).
|
|
37
37
|
*/
|
|
38
38
|
async function createPulseTracker({ clientId, config, builders }) {
|
|
39
|
-
if (!
|
|
39
|
+
if (!utils_1.isBrowser) {
|
|
40
40
|
throw new Error('createPulseTracker is only available in browser environments');
|
|
41
41
|
}
|
|
42
42
|
if (isTrackerCreated()) {
|