@schibsted/pulse-sdk 8.0.0-alpha.16 → 8.0.0-alpha.18
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/EventBus/EventBus.js +146 -0
- package/dist/cjs/Tracker.js +2499 -0
- package/dist/cjs/Tracker.test-d.js +76 -0
- package/dist/cjs/app-integration.js +40 -0
- package/dist/cjs/builders/actor.js +60 -0
- package/dist/cjs/builders/consent-manager.js +134 -0
- package/dist/cjs/builders/consents.js +149 -0
- package/dist/cjs/builders/device-browser.js +89 -0
- package/dist/cjs/builders/device-node.js +63 -0
- package/dist/cjs/builders/device.js +23 -0
- package/dist/cjs/builders/events-anonymous-browser.js +6 -0
- package/dist/cjs/builders/events-anonymous-node.js +88 -0
- package/dist/cjs/builders/events-anonymous.js +17 -0
- package/dist/cjs/builders/events-browser.js +8 -0
- package/dist/cjs/builders/events-node.js +127 -0
- package/dist/cjs/builders/events.js +17 -0
- package/dist/cjs/builders/experimentMetadata.js +25 -0
- package/dist/cjs/builders/experiments.js +32 -0
- package/dist/cjs/builders/index.js +52 -0
- package/dist/cjs/builders/location.js +38 -0
- package/dist/cjs/builders/objects/objects-anonymous-browser.js +36 -0
- package/dist/cjs/builders/objects/objects-anonymous-node.js +95 -0
- package/dist/cjs/builders/objects/objects-anonymous.js +23 -0
- package/dist/cjs/builders/objects/objects-browser.js +36 -0
- package/dist/cjs/builders/objects/objects-node.js +126 -0
- package/dist/cjs/builders/objects/objects.js +23 -0
- package/dist/cjs/builders/objects/utils.js +23 -0
- package/dist/cjs/builders/origin-browser.js +28 -0
- package/dist/cjs/builders/origin-node.js +29 -0
- package/dist/cjs/builders/origin.js +23 -0
- package/dist/cjs/builders/provider.js +24 -0
- package/dist/cjs/builders/session-browser.js +97 -0
- package/dist/cjs/builders/session-node.js +9 -0
- package/dist/cjs/builders/session.js +23 -0
- package/dist/cjs/builders/tracker-browser.js +34 -0
- package/dist/cjs/builders/tracker-node.js +22 -0
- package/dist/cjs/builders/trackerBuilder.js +23 -0
- package/dist/cjs/config-browser.js +26 -0
- package/dist/cjs/config.js +9 -0
- package/dist/cjs/createPulseTracker.js +50 -0
- package/dist/cjs/defer.js +20 -0
- package/dist/cjs/getPulseTracker.js +74 -0
- package/dist/cjs/identity/actor.js +60 -0
- package/dist/cjs/identity/advertising.js +62 -0
- package/dist/cjs/identity/cis.js +66 -0
- package/dist/cjs/identity/device.js +20 -0
- package/dist/cjs/identity/index.js +20 -0
- package/dist/cjs/index.js +57 -0
- package/dist/cjs/leaveTracking/constants.js +26 -0
- package/dist/cjs/leaveTracking/index.js +368 -0
- package/dist/cjs/leaveTracking/types.js +19 -0
- package/dist/cjs/leaveTrackingTpaas/constants.js +18 -0
- package/dist/cjs/leaveTrackingTpaas/index.js +341 -0
- package/dist/cjs/leaveTrackingTpaas/types.js +19 -0
- package/dist/cjs/network-browser.js +35 -0
- package/dist/cjs/network.js +15 -0
- package/dist/cjs/remoteConfig/index.js +124 -0
- package/dist/cjs/tracker-proxy/consts.js +72 -0
- package/dist/cjs/tracker-proxy/proxy-provider.js +68 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/version.json +1 -0
- package/dist/cjs/visibility-observer/index.js +101 -0
- package/dist/cjs/warnOnce.js +11 -0
- package/dist/cjs/wrapper/engagement/ui-element/event-builder.js +21 -0
- package/dist/cjs/wrapper/engagement/ui-element/types.js +2 -0
- package/dist/cjs/wrapper/types/base-event.js +2 -0
- package/dist/cjs/wrapper/types/engagement-event.js +2 -0
- package/dist/cjs/wrapper/types/event.js +2 -0
- package/dist/cjs/wrapper/types/index.js +19 -0
- package/dist/cjs/wrapper/types/utils.js +2 -0
- package/dist/cjs/wrapper/utils/get-navigation-type.js +32 -0
- package/dist/cjs/wrapper/utils/page-from-page-view.js +9 -0
- package/dist/cjs/wrapper/view/article/event-builder.js +19 -0
- package/dist/cjs/wrapper/view/article/types.js +2 -0
- package/dist/cjs/wrapper/view/frontpage/event-builder.js +16 -0
- package/dist/cjs/wrapper/view/frontpage/types.js +2 -0
- package/dist/cjs/wrapper/view/listing/event-builder.js +14 -0
- package/dist/cjs/wrapper/view/listing/types.js +2 -0
- package/dist/cjs/wrapper/view/loginposter/event-builder.js +11 -0
- package/dist/cjs/wrapper/view/loginposter/types.js +2 -0
- package/dist/cjs/wrapper/view/page/event-builder.js +18 -0
- package/dist/cjs/wrapper/view/page/types.js +2 -0
- package/dist/cjs/wrapper/view/salesposter/event-builder.js +18 -0
- package/dist/cjs/wrapper/view/salesposter/types.js +2 -0
- package/dist/cjs/wrapper/view/ui-element/event-builder.js +15 -0
- package/dist/cjs/wrapper/view/ui-element/types.js +2 -0
- package/dist/ejs/EventBus/EventBus.js +140 -0
- package/dist/ejs/Tracker.js +2455 -0
- package/dist/ejs/Tracker.test-d.js +71 -0
- package/dist/ejs/app-integration.js +33 -0
- package/dist/ejs/builders/actor.js +53 -0
- package/dist/ejs/builders/consent-manager.js +125 -0
- package/dist/ejs/builders/consents.js +138 -0
- package/dist/ejs/builders/device-browser.js +69 -0
- package/dist/ejs/builders/device-node.js +57 -0
- package/dist/ejs/builders/device.js +2 -0
- package/dist/ejs/builders/events-anonymous-browser.js +1 -0
- package/dist/ejs/builders/events-anonymous-node.js +48 -0
- package/dist/ejs/builders/events-anonymous.js +1 -0
- package/dist/ejs/builders/events-browser.js +1 -0
- package/dist/ejs/builders/events-node.js +84 -0
- package/dist/ejs/builders/events.js +1 -0
- package/dist/ejs/builders/experimentMetadata.js +21 -0
- package/dist/ejs/builders/experiments.js +27 -0
- package/dist/ejs/builders/index.js +12 -0
- package/dist/ejs/builders/location.js +34 -0
- package/dist/ejs/builders/objects/objects-anonymous-browser.js +14 -0
- package/dist/ejs/builders/objects/objects-anonymous-node.js +90 -0
- package/dist/ejs/builders/objects/objects-anonymous.js +2 -0
- package/dist/ejs/builders/objects/objects-browser.js +14 -0
- package/dist/ejs/builders/objects/objects-node.js +121 -0
- package/dist/ejs/builders/objects/objects.js +2 -0
- package/dist/ejs/builders/objects/utils.js +20 -0
- package/dist/ejs/builders/origin-browser.js +6 -0
- package/dist/ejs/builders/origin-node.js +24 -0
- package/dist/ejs/builders/origin.js +2 -0
- package/dist/ejs/builders/provider.js +18 -0
- package/dist/ejs/builders/session-browser.js +90 -0
- package/dist/ejs/builders/session-node.js +4 -0
- package/dist/ejs/builders/session.js +2 -0
- package/dist/ejs/builders/tracker-browser.js +13 -0
- package/dist/ejs/builders/tracker-node.js +14 -0
- package/dist/ejs/builders/trackerBuilder.js +2 -0
- package/dist/ejs/config-browser.js +23 -0
- package/dist/ejs/config.js +6 -0
- package/dist/ejs/createPulseTracker.js +44 -0
- package/dist/ejs/defer.js +17 -0
- package/dist/ejs/getPulseTracker.js +71 -0
- package/dist/ejs/identity/actor.js +51 -0
- package/dist/ejs/identity/advertising.js +57 -0
- package/dist/ejs/identity/cis.js +58 -0
- package/dist/ejs/identity/device.js +17 -0
- package/dist/ejs/identity/index.js +4 -0
- package/dist/ejs/index.js +9 -0
- package/dist/ejs/leaveTracking/constants.js +19 -0
- package/dist/ejs/leaveTracking/index.js +319 -0
- package/dist/ejs/leaveTracking/types.js +16 -0
- package/dist/ejs/leaveTrackingTpaas/constants.js +13 -0
- package/dist/ejs/leaveTrackingTpaas/index.js +291 -0
- package/dist/ejs/leaveTrackingTpaas/types.js +16 -0
- package/dist/ejs/network-browser.js +32 -0
- package/dist/ejs/network.js +12 -0
- package/dist/ejs/remoteConfig/index.js +111 -0
- package/dist/ejs/tracker-proxy/consts.js +68 -0
- package/dist/ejs/tracker-proxy/proxy-provider.js +62 -0
- package/dist/ejs/types.js +1 -0
- package/dist/ejs/version.json +1 -0
- package/dist/ejs/visibility-observer/index.js +97 -0
- package/dist/ejs/warnOnce.js +9 -0
- package/dist/ejs/wrapper/engagement/ui-element/event-builder.js +17 -0
- package/dist/ejs/wrapper/engagement/ui-element/types.js +1 -0
- package/dist/ejs/wrapper/types/base-event.js +1 -0
- package/dist/ejs/wrapper/types/engagement-event.js +1 -0
- package/dist/ejs/wrapper/types/event.js +1 -0
- package/dist/ejs/wrapper/types/index.js +3 -0
- package/dist/ejs/wrapper/types/utils.js +1 -0
- package/dist/ejs/wrapper/utils/get-navigation-type.js +29 -0
- package/dist/ejs/wrapper/utils/page-from-page-view.js +6 -0
- package/dist/ejs/wrapper/view/article/event-builder.js +15 -0
- package/dist/ejs/wrapper/view/article/types.js +1 -0
- package/dist/ejs/wrapper/view/frontpage/event-builder.js +12 -0
- package/dist/ejs/wrapper/view/frontpage/types.js +1 -0
- package/dist/ejs/wrapper/view/listing/event-builder.js +10 -0
- package/dist/ejs/wrapper/view/listing/types.js +1 -0
- package/dist/ejs/wrapper/view/loginposter/event-builder.js +7 -0
- package/dist/ejs/wrapper/view/loginposter/types.js +1 -0
- package/dist/ejs/wrapper/view/page/event-builder.js +14 -0
- package/dist/ejs/wrapper/view/page/types.js +1 -0
- package/dist/ejs/wrapper/view/salesposter/event-builder.js +14 -0
- package/dist/ejs/wrapper/view/salesposter/types.js +1 -0
- package/dist/ejs/wrapper/view/ui-element/event-builder.js +11 -0
- package/dist/ejs/wrapper/view/ui-element/types.js +1 -0
- package/dist/types/EventBus/EventBus.d.ts +106 -0
- package/dist/types/Tracker.d.ts +1418 -0
- package/dist/types/Tracker.test-d.d.ts +1 -0
- package/dist/types/app-integration.d.ts +10 -0
- package/dist/types/builders/actor.d.ts +39 -0
- package/dist/types/builders/consent-manager.d.ts +49 -0
- package/dist/types/builders/consents.d.ts +107 -0
- package/dist/types/builders/device-browser.d.ts +6 -0
- package/dist/types/builders/device-node.d.ts +65 -0
- package/dist/types/builders/device.d.ts +2 -0
- package/dist/types/builders/events-anonymous-browser.d.ts +1 -0
- package/dist/types/builders/events-anonymous-node.d.ts +82 -0
- package/dist/types/builders/events-anonymous.d.ts +1 -0
- package/dist/types/builders/events-browser.d.ts +1 -0
- package/dist/types/builders/events-node.d.ts +130 -0
- package/dist/types/builders/events.d.ts +1 -0
- package/dist/types/builders/experimentMetadata.d.ts +25 -0
- package/dist/types/builders/experiments.d.ts +24 -0
- package/dist/types/builders/index.d.ts +23 -0
- package/dist/types/builders/location.d.ts +34 -0
- package/dist/types/builders/objects/objects-anonymous-browser.d.ts +11 -0
- package/dist/types/builders/objects/objects-anonymous-node.d.ts +52 -0
- package/dist/types/builders/objects/objects-anonymous.d.ts +2 -0
- package/dist/types/builders/objects/objects-browser.d.ts +11 -0
- package/dist/types/builders/objects/objects-node.d.ts +60 -0
- package/dist/types/builders/objects/objects.d.ts +2 -0
- package/dist/types/builders/objects/utils.d.ts +1 -0
- package/dist/types/builders/origin-browser.d.ts +5 -0
- package/dist/types/builders/origin-node.d.ts +18 -0
- package/dist/types/builders/origin.d.ts +2 -0
- package/dist/types/builders/provider.d.ts +14 -0
- package/dist/types/builders/session-browser.d.ts +20 -0
- package/dist/types/builders/session-node.d.ts +3 -0
- package/dist/types/builders/session.d.ts +2 -0
- package/dist/types/builders/tracker-browser.d.ts +2 -0
- package/dist/types/builders/tracker-node.d.ts +14 -0
- package/dist/types/builders/trackerBuilder.d.ts +2 -0
- package/dist/types/config-browser.d.ts +23 -0
- package/dist/types/config.d.ts +6 -0
- package/dist/types/createPulseTracker.d.ts +21 -0
- package/dist/types/defer.d.ts +28 -0
- package/dist/types/getPulseTracker.d.ts +59 -0
- package/dist/types/identity/actor.d.ts +28 -0
- package/dist/types/identity/advertising.d.ts +30 -0
- package/dist/types/identity/cis.d.ts +21 -0
- package/dist/types/identity/device.d.ts +12 -0
- package/dist/types/identity/index.d.ts +4 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/leaveTracking/constants.d.ts +26 -0
- package/dist/types/leaveTracking/index.d.ts +23 -0
- package/dist/types/leaveTracking/types.d.ts +78 -0
- package/dist/types/leaveTrackingTpaas/constants.d.ts +13 -0
- package/dist/types/leaveTrackingTpaas/index.d.ts +28 -0
- package/dist/types/leaveTrackingTpaas/types.d.ts +45 -0
- package/dist/types/network-browser.d.ts +5 -0
- package/dist/types/network.d.ts +4 -0
- package/dist/types/remoteConfig/index.d.ts +32 -0
- package/dist/types/tracker-proxy/consts.d.ts +45 -0
- package/dist/types/tracker-proxy/proxy-provider.d.ts +2 -0
- package/dist/types/types.d.ts +93 -0
- package/dist/types/visibility-observer/index.d.ts +38 -0
- package/dist/types/warnOnce.d.ts +2 -0
- package/dist/types/wrapper/engagement/ui-element/event-builder.d.ts +3 -0
- package/dist/types/wrapper/engagement/ui-element/types.d.ts +29 -0
- package/dist/types/wrapper/types/base-event.d.ts +74 -0
- package/dist/types/wrapper/types/engagement-event.d.ts +5 -0
- package/dist/types/wrapper/types/event.d.ts +41 -0
- package/dist/types/wrapper/types/index.d.ts +3 -0
- package/dist/types/wrapper/types/utils.d.ts +5 -0
- package/dist/types/wrapper/utils/get-navigation-type.d.ts +3 -0
- package/dist/types/wrapper/utils/page-from-page-view.d.ts +3 -0
- package/dist/types/wrapper/view/article/event-builder.d.ts +2 -0
- package/dist/types/wrapper/view/article/types.d.ts +27 -0
- package/dist/types/wrapper/view/frontpage/event-builder.d.ts +2 -0
- package/dist/types/wrapper/view/frontpage/types.d.ts +18 -0
- package/dist/types/wrapper/view/listing/event-builder.d.ts +2 -0
- package/dist/types/wrapper/view/listing/types.d.ts +27 -0
- package/dist/types/wrapper/view/loginposter/event-builder.d.ts +2 -0
- package/dist/types/wrapper/view/loginposter/types.d.ts +14 -0
- package/dist/types/wrapper/view/page/event-builder.d.ts +2 -0
- package/dist/types/wrapper/view/page/types.d.ts +16 -0
- package/dist/types/wrapper/view/salesposter/event-builder.d.ts +2 -0
- package/dist/types/wrapper/view/salesposter/types.d.ts +15 -0
- package/dist/types/wrapper/view/ui-element/event-builder.d.ts +3 -0
- package/dist/types/wrapper/view/ui-element/types.d.ts +28 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.d.ts +26 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js +273 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis-browser.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis.d.ts +10 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis.js +7 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/cis.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.d.ts +14 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.js +39 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/eventEmitter.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/index.d.ts +4 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/index.js +12 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/index.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/pulse-cookie.d.ts +55 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/pulse-cookie.js +276 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/pulse-cookie.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.d.ts +36 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.js +87 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/pulseStorage.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.d.ts +6 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js +21 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/storage/storage.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/types.d.ts +24 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/types.js +3 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/cjs/types.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.d.ts +26 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.js +203 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis-browser.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.d.ts +10 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.js +4 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/cis.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.d.ts +14 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.js +35 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/eventEmitter.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.d.ts +4 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.js +3 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/index.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.d.ts +55 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.js +254 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/pulse-cookie.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.d.ts +36 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.js +50 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/pulseStorage.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.d.ts +6 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.js +17 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/storage/storage.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.d.ts +24 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.js +2 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/ejs/types.js.map +1 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/cis-browser.d.ts +26 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/cis.d.ts +10 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/eventEmitter.d.ts +14 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/index.d.ts +4 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/pulse-cookie.d.ts +55 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/storage/pulseStorage.d.ts +36 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/storage/storage.d.ts +6 -0
- package/node_modules/@schibsted/pulse-cis-sync/dist/types/types.d.ts +24 -0
- package/node_modules/@schibsted/pulse-cis-sync/package.json +44 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/cookie-config.js +10 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/cookie.js +86 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/events.js +109 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/get.js +18 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/getRootDomain.js +54 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/index.js +38 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/merge.js +38 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/objects.js +34 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/omit.js +9 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/randomString.js +18 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/throttle.js +34 -0
- package/node_modules/@schibsted/pulse-utils/dist/cjs/webApi.js +21 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/cookie-config.js +7 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/cookie.js +81 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/events.js +103 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/get.js +15 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/getRootDomain.js +49 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/index.js +11 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/merge.js +35 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/objects.js +26 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/omit.js +6 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/randomString.js +15 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/throttle.js +31 -0
- package/node_modules/@schibsted/pulse-utils/dist/ejs/webApi.js +17 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/cookie-config.d.ts +7 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/cookie.d.ts +23 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/events.d.ts +17 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/get.d.ts +1 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/getRootDomain.d.ts +13 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/index.d.ts +11 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/merge.d.ts +4 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/objects.d.ts +6 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/omit.d.ts +3 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/randomString.d.ts +1 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/throttle.d.ts +3 -0
- package/node_modules/@schibsted/pulse-utils/dist/types/webApi.d.ts +10 -0
- package/node_modules/@schibsted/pulse-utils/package.json +36 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/anonymous.js +8 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/baseEvent.js +9 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/consents.js +15 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/device.js +211 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/experiments.js +11 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/navigationType.js +52 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/pageInfo.js +24 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/pageviewId.js +11 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/provider.js +12 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/referrer.js +19 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/session.js +114 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/time.js +15 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/trackerBuilder.js +15 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/user.js +26 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders/utm.js +35 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/builders.js +264 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/index.js +17 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/cjs/types.js +2 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/anonymous.js +5 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/baseEvent.js +6 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/consents.js +12 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/device.js +174 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/experiments.js +7 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/navigationType.js +48 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/pageInfo.js +20 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/pageviewId.js +7 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/provider.js +9 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/referrer.js +15 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/session.js +108 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/time.js +11 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/trackerBuilder.js +11 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/user.js +22 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders/utm.js +31 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/builders.js +209 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/index.js +1 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/ejs/types.js +1 -0
- package/node_modules/@schibsted/tpaas-event-builder/dist/index.d.ts +5171 -0
- package/node_modules/@schibsted/tpaas-event-builder/package.json +40 -0
- package/node_modules/@schibsted/tpaas-schemas/dist/cjs/constants.js +62 -1
- package/node_modules/@schibsted/tpaas-schemas/dist/ejs/constants.js +61 -0
- package/node_modules/@schibsted/tpaas-schemas/dist/index.d.ts +128 -0
- package/package.json +58 -13
- package/CHANGELOG.md +0 -1035
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -47
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { omit, pulseMerge } from '@schibsted/pulse-utils';
|
|
2
|
+
import actorBuilder, { defaultValue as actorDefaultValue } from './actor';
|
|
3
|
+
import consentsBuilder from './consents';
|
|
4
|
+
import deviceBuilder, { defaultValue as deviceDefaultValue } from './device';
|
|
5
|
+
import experimentMetadataBuilder, { defaultValue as experimentMetadataDefaultValue } from './experimentMetadata';
|
|
6
|
+
import experimentsBuilder, { defaultValue as experimentsDefaultValue } from './experiments';
|
|
7
|
+
import locationBuilder, { defaultValue as locationDefaultValue } from './location';
|
|
8
|
+
import objectBuilder, { defaultValue as objectDefaultValue } from './objects/objects';
|
|
9
|
+
import originBuilder, { defaultValue as originDefaultValue } from './origin';
|
|
10
|
+
import providerBuilder, { defaultValue as providerDefaultValue } from './provider';
|
|
11
|
+
import trackerBuilder, { defaultValue as trackerDefaultValue } from './trackerBuilder';
|
|
12
|
+
export const DEFAULT_SCHEMA_LOCATION = 'schema.schibsted.com';
|
|
13
|
+
function routableEventDefaults(eventInput) {
|
|
14
|
+
return pulseMerge({
|
|
15
|
+
actor: actorDefaultValue(),
|
|
16
|
+
provider: providerDefaultValue(),
|
|
17
|
+
}, eventInput);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Implements https://schibsted.ghe.com/data-platform/event-formats/blob/master/schema/master/events/base-routable-event.json
|
|
21
|
+
*/
|
|
22
|
+
export function routableEvent({ eventInput, sdkConfig } = {}) {
|
|
23
|
+
return Object.assign({}, eventInput, {
|
|
24
|
+
schema: eventInput?.schema ||
|
|
25
|
+
`http://${sdkConfig?.schemaLocation || DEFAULT_SCHEMA_LOCATION}/events/base-routable-event.json/246.json#`,
|
|
26
|
+
provider: providerBuilder(eventInput),
|
|
27
|
+
actor: actorBuilder(eventInput),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
routableEvent.defaults = routableEventDefaults;
|
|
31
|
+
/**
|
|
32
|
+
* Add default value to TrackerEventInput.
|
|
33
|
+
*/
|
|
34
|
+
function trackerEventInput(eventInput) {
|
|
35
|
+
return pulseMerge({
|
|
36
|
+
actor: actorDefaultValue(),
|
|
37
|
+
experiments: experimentsDefaultValue(),
|
|
38
|
+
experimentMetadata: experimentMetadataDefaultValue(),
|
|
39
|
+
device: deviceDefaultValue(),
|
|
40
|
+
location: locationDefaultValue(),
|
|
41
|
+
object: objectDefaultValue(),
|
|
42
|
+
origin: originDefaultValue(),
|
|
43
|
+
provider: providerDefaultValue(),
|
|
44
|
+
tracker: trackerDefaultValue(),
|
|
45
|
+
}, eventInput);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Implements https://schibsted.ghe.com/data-platform/event-formats/blob/master/schema/master/events/tracker-event.json
|
|
49
|
+
*/
|
|
50
|
+
export function trackerEvent({ eventInput, sdkConfig } = {}) {
|
|
51
|
+
const parentInput = trackerEventInput(eventInput);
|
|
52
|
+
const pageViewIdInput = eventInput?.pageViewId;
|
|
53
|
+
const pageViewIdSdk = sdkConfig?.pageViewId;
|
|
54
|
+
return Object.assign({}, omit(eventInput, ['type']), {
|
|
55
|
+
'@type': eventInput?.type || 'View',
|
|
56
|
+
pageViewId: pageViewIdInput || pageViewIdSdk,
|
|
57
|
+
schema: eventInput?.schema ||
|
|
58
|
+
`http://${sdkConfig?.schemaLocation || DEFAULT_SCHEMA_LOCATION}/events/tracker-event.json/359.json`,
|
|
59
|
+
actor: actorBuilder(parentInput),
|
|
60
|
+
consents: consentsBuilder(parentInput),
|
|
61
|
+
experiments: experimentsBuilder(parentInput),
|
|
62
|
+
experimentMetadata: experimentMetadataBuilder(parentInput),
|
|
63
|
+
device: deviceBuilder(parentInput),
|
|
64
|
+
location: locationBuilder(parentInput),
|
|
65
|
+
object: objectBuilder(parentInput),
|
|
66
|
+
origin: originBuilder(parentInput),
|
|
67
|
+
provider: providerBuilder(parentInput),
|
|
68
|
+
target: parentInput.target && objectBuilder(Object.assign({}, parentInput, { object: parentInput.target })),
|
|
69
|
+
tracker: trackerBuilder(parentInput),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
trackerEvent.defaults = trackerEventInput;
|
|
73
|
+
export function engagementEvent({ eventInput, sdkConfig } = {}) {
|
|
74
|
+
return Object.assign(trackerEvent({ eventInput, sdkConfig }), {
|
|
75
|
+
schema: eventInput?.schema ||
|
|
76
|
+
`http://${sdkConfig?.schemaLocation || DEFAULT_SCHEMA_LOCATION}/events/engagement-event.json/386.json`,
|
|
77
|
+
'@type': 'Engagement',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
engagementEvent.defaults = trackerEventInput;
|
|
81
|
+
export function identityEvent({ eventInput = {} } = {}) {
|
|
82
|
+
return eventInput;
|
|
83
|
+
}
|
|
84
|
+
identityEvent.defaults = () => ({});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './events-node';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isObjectEmpty } from '@schibsted/pulse-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Format experiment metadata
|
|
4
|
+
*/
|
|
5
|
+
export default function experimentMetadata(input) {
|
|
6
|
+
const { errors, assignmentId, requestTimestamp } = input?.experimentMetadata || {};
|
|
7
|
+
const formattedExperimentMetadata = {};
|
|
8
|
+
if (errors?.length) {
|
|
9
|
+
formattedExperimentMetadata.errors = errors;
|
|
10
|
+
}
|
|
11
|
+
if (assignmentId) {
|
|
12
|
+
formattedExperimentMetadata.assignmentId = assignmentId;
|
|
13
|
+
}
|
|
14
|
+
if (requestTimestamp) {
|
|
15
|
+
formattedExperimentMetadata.requestTimestamp = requestTimestamp;
|
|
16
|
+
}
|
|
17
|
+
return isObjectEmpty(formattedExperimentMetadata) ? undefined : formattedExperimentMetadata;
|
|
18
|
+
}
|
|
19
|
+
export function defaultValue() {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function generateExperimentSDRN(id, experimentationPlatform) {
|
|
2
|
+
return `sdrn:${experimentationPlatform}:experiment:${id}`;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Attempts to format a correct "@id" given the input.
|
|
6
|
+
* Allows for the "@id" property to be completely overridden by the dev's input
|
|
7
|
+
* @param experiment
|
|
8
|
+
*/
|
|
9
|
+
function formatExperiment(experiment) {
|
|
10
|
+
const { id, platform, ...rest } = experiment || {};
|
|
11
|
+
return {
|
|
12
|
+
'@id': generateExperimentSDRN(id, platform),
|
|
13
|
+
...(platform && { platform }),
|
|
14
|
+
...rest,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Experiments builder
|
|
19
|
+
* @param input A full Pulse Event, from where the "experiments" property is parsed.
|
|
20
|
+
*/
|
|
21
|
+
export default function experiments(input) {
|
|
22
|
+
const experimentList = input?.experiments || [];
|
|
23
|
+
if (experimentList.length > 0) {
|
|
24
|
+
return experimentList.map(formatExperiment);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export const defaultValue = () => undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * as actor from './actor';
|
|
2
|
+
export * as consents from './consents';
|
|
3
|
+
export * as device from './device';
|
|
4
|
+
export * as events from './events';
|
|
5
|
+
export * as experimentMetadata from './experimentMetadata';
|
|
6
|
+
export * as experiments from './experiments';
|
|
7
|
+
export * as location from './location';
|
|
8
|
+
export * as objects from './objects/objects';
|
|
9
|
+
export * as origin from './origin';
|
|
10
|
+
export * as provider from './provider';
|
|
11
|
+
export { default as session } from './session';
|
|
12
|
+
export * as tracker from './trackerBuilder';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const LOCATION_TYPE = 'GeoCoordinates';
|
|
2
|
+
function geoToFixed(pos) {
|
|
3
|
+
if (pos !== null && pos !== undefined && pos !== '' && !Number.isNaN(pos)) {
|
|
4
|
+
return (Math.round(Number(pos) * 1000) / 1000.0).toFixed(3);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a valid Location object according to schema. Will create the
|
|
9
|
+
* required '@type' field, and reduce `latitude` and `longitude` accuracy
|
|
10
|
+
* to 3 decimal places.
|
|
11
|
+
*
|
|
12
|
+
* "altitude" is dropped from the result.
|
|
13
|
+
*
|
|
14
|
+
* Other input will be merged with the object as is.
|
|
15
|
+
*
|
|
16
|
+
* @see https://schibsted.ghe.com/data-platform/event-formats/blob/master/schema/master/objects/GeoCoordinates.json
|
|
17
|
+
*/
|
|
18
|
+
export default function location(input) {
|
|
19
|
+
const { location: locationInput } = input || {};
|
|
20
|
+
const { latitude: lat, longitude: long, altitude: _, ...rest } = locationInput || {}; // "altitude" is dropped
|
|
21
|
+
const latitude = geoToFixed(lat);
|
|
22
|
+
const longitude = geoToFixed(long);
|
|
23
|
+
if (latitude || longitude) {
|
|
24
|
+
return {
|
|
25
|
+
'@type': LOCATION_TYPE,
|
|
26
|
+
...rest,
|
|
27
|
+
latitude,
|
|
28
|
+
longitude,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function defaultValue() {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isBrowser } from '@schibsted/pulse-utils';
|
|
2
|
+
export * from './objects-anonymous-node';
|
|
3
|
+
export { default } from './objects-anonymous-node';
|
|
4
|
+
export const defaultValue = () => {
|
|
5
|
+
if (!isBrowser) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
const { location = { href: undefined } } = window;
|
|
9
|
+
return {
|
|
10
|
+
name: document.title,
|
|
11
|
+
url: location.href,
|
|
12
|
+
id: location.href,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { isObject, isPlainObject, pulseMerge } from '@schibsted/pulse-utils';
|
|
2
|
+
import { generateObjectSDRN } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Format UIElement.
|
|
5
|
+
*
|
|
6
|
+
* This will transform the object to a valid UIElement.
|
|
7
|
+
* When building the id of the UIElement it will primarily
|
|
8
|
+
* try to use 'page.id' and 'page.type' (if available).
|
|
9
|
+
* If page is not available it will fall back to use
|
|
10
|
+
* 'target.id' and 'target.type' when calling sdrn().
|
|
11
|
+
* If neither page nor target is available it will
|
|
12
|
+
* use default type from the object.
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
* @param data object and provider is mandatory, rest is optional.
|
|
16
|
+
*/
|
|
17
|
+
function formatUIElement({ object, provider, page, target }) {
|
|
18
|
+
const { id, type, custom, 'spt:custom': _, ...rest } = object || {};
|
|
19
|
+
const { id: pageId, type: pageType } = page || {};
|
|
20
|
+
const { id: targetId, type: targetType } = target || {};
|
|
21
|
+
const { id: providerId } = provider || {};
|
|
22
|
+
const uiElementId = pageType || targetType
|
|
23
|
+
? `${generateObjectSDRN(pageId || targetId, providerId, pageType || targetType) || ''}:element:${id}`
|
|
24
|
+
: generateObjectSDRN(id, providerId, type);
|
|
25
|
+
const baseObject = {
|
|
26
|
+
'@id': uiElementId,
|
|
27
|
+
'@type': type,
|
|
28
|
+
};
|
|
29
|
+
return pulseMerge({}, baseObject, rest);
|
|
30
|
+
}
|
|
31
|
+
function formatDefaultObject({ object, provider }) {
|
|
32
|
+
const { id, type = 'Content', custom, 'spt:custom': _, ...rest } = object || {};
|
|
33
|
+
const { id: providerId } = provider || {};
|
|
34
|
+
const objectId = generateObjectSDRN(id, providerId, type);
|
|
35
|
+
let baseObject = {};
|
|
36
|
+
if (objectId) {
|
|
37
|
+
baseObject = {
|
|
38
|
+
'@id': objectId,
|
|
39
|
+
'@type': type,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return pulseMerge({}, baseObject, rest);
|
|
43
|
+
}
|
|
44
|
+
function getObjectFormatter(type) {
|
|
45
|
+
return type === 'UIElement' ? formatUIElement : formatDefaultObject;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Format object.
|
|
49
|
+
*
|
|
50
|
+
* This function will recursively format itself and all nested object.
|
|
51
|
+
* The initialPage parameter is optional and will be used in the recursive
|
|
52
|
+
* nature to always pass in the root object page to each formatting.
|
|
53
|
+
*
|
|
54
|
+
* @private
|
|
55
|
+
* @param {object} input
|
|
56
|
+
* @param {object|undefined} pageInput Optional
|
|
57
|
+
*/
|
|
58
|
+
export const formatObject = (input, pageInput) => {
|
|
59
|
+
const { object: objectInput = {} } = input || {};
|
|
60
|
+
const { page: pageInObject } = objectInput;
|
|
61
|
+
const page = pageInput || pageInObject;
|
|
62
|
+
const evaluatedObjectInput = Object.keys(objectInput).reduce((accl, key) => {
|
|
63
|
+
const prop = objectInput[key];
|
|
64
|
+
if (Array.isArray(prop)) {
|
|
65
|
+
return {
|
|
66
|
+
// biome-ignore lint/performance/noAccumulatingSpread: -
|
|
67
|
+
...accl,
|
|
68
|
+
[key]: prop.map((o) => {
|
|
69
|
+
if (isPlainObject(o)) {
|
|
70
|
+
return formatObject(Object.assign({}, input, { object: o }), page);
|
|
71
|
+
}
|
|
72
|
+
return o;
|
|
73
|
+
}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (isObject(prop)) {
|
|
77
|
+
return {
|
|
78
|
+
// biome-ignore lint/performance/noAccumulatingSpread: -
|
|
79
|
+
...accl,
|
|
80
|
+
[key]: formatObject(Object.assign({}, input, { object: prop }), page),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// biome-ignore lint/performance/noAccumulatingSpread: -
|
|
84
|
+
return { ...accl, [key]: prop };
|
|
85
|
+
}, {});
|
|
86
|
+
const output = Object.assign({}, input, { page, object: evaluatedObjectInput });
|
|
87
|
+
return getObjectFormatter(objectInput.type)(output);
|
|
88
|
+
};
|
|
89
|
+
export default formatObject;
|
|
90
|
+
export const defaultValue = () => undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isBrowser } from '@schibsted/pulse-utils';
|
|
2
|
+
export * from './objects-node';
|
|
3
|
+
export { default } from './objects-node';
|
|
4
|
+
export const defaultValue = () => {
|
|
5
|
+
if (!isBrowser) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
const { location = { href: undefined } } = window;
|
|
9
|
+
return {
|
|
10
|
+
name: document.title,
|
|
11
|
+
url: location.href,
|
|
12
|
+
id: location.href,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { isObject, isPlainObject, pulseMerge } from '@schibsted/pulse-utils';
|
|
2
|
+
import { generateObjectSDRN } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Format UIElement.
|
|
5
|
+
*
|
|
6
|
+
* This will transform the object to a valid UIElement.
|
|
7
|
+
* When building the id of the UIElement it will primarily
|
|
8
|
+
* try to use 'page.id' and 'page.type' (if available).
|
|
9
|
+
* If page is not available it will fall back to use
|
|
10
|
+
* 'target.id' and 'target.type' when calling sdrn().
|
|
11
|
+
* If neither page nor target is available it will
|
|
12
|
+
* use default type from the object.
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
* @param data object and provider is mandatory, rest is optional.
|
|
16
|
+
*/
|
|
17
|
+
function formatUIElement({ object, provider, page, target }) {
|
|
18
|
+
const { id, type, custom, ...rest } = object || {};
|
|
19
|
+
const { id: pageId, type: pageType } = page || {};
|
|
20
|
+
const { id: targetId, type: targetType } = target || {};
|
|
21
|
+
const { id: providerId } = provider || {};
|
|
22
|
+
const uiElementId = pageType || targetType
|
|
23
|
+
? `${generateObjectSDRN(pageId || targetId, providerId, pageType || targetType) || ''}:element:${id}`
|
|
24
|
+
: generateObjectSDRN(id, providerId, type);
|
|
25
|
+
const baseObject = {
|
|
26
|
+
'@id': uiElementId,
|
|
27
|
+
'@type': type,
|
|
28
|
+
};
|
|
29
|
+
if (custom) {
|
|
30
|
+
baseObject['spt:custom'] = custom;
|
|
31
|
+
}
|
|
32
|
+
return pulseMerge({}, baseObject, rest);
|
|
33
|
+
}
|
|
34
|
+
function formatDefaultObject({ object, provider }) {
|
|
35
|
+
const { id, type = 'Content', custom, ...rest } = object || {};
|
|
36
|
+
const { id: providerId } = provider || {};
|
|
37
|
+
const objectId = generateObjectSDRN(id, providerId, type);
|
|
38
|
+
let baseObject = {};
|
|
39
|
+
if (objectId) {
|
|
40
|
+
baseObject = {
|
|
41
|
+
'@id': objectId,
|
|
42
|
+
'@type': type,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (custom) {
|
|
46
|
+
baseObject['spt:custom'] = custom;
|
|
47
|
+
}
|
|
48
|
+
return pulseMerge({}, baseObject, rest);
|
|
49
|
+
}
|
|
50
|
+
function formatAccount({ object }) {
|
|
51
|
+
const { id, realm = 'schibsted.com', type: _, custom, ...rest } = object || {}; // type is dropped
|
|
52
|
+
if (!id) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const baseObject = {
|
|
56
|
+
'@id': `sdrn:${realm}:user:${id}`,
|
|
57
|
+
'@type': 'Account',
|
|
58
|
+
accountId: id,
|
|
59
|
+
};
|
|
60
|
+
if (custom) {
|
|
61
|
+
baseObject['spt:custom'] = custom;
|
|
62
|
+
}
|
|
63
|
+
return pulseMerge({}, baseObject, rest);
|
|
64
|
+
}
|
|
65
|
+
const objectFormatterMapping = {
|
|
66
|
+
UIElement: formatUIElement,
|
|
67
|
+
Account: formatAccount,
|
|
68
|
+
};
|
|
69
|
+
function getObjectFormatter(type) {
|
|
70
|
+
return objectFormatterMapping[type] || formatDefaultObject;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Format object.
|
|
74
|
+
*
|
|
75
|
+
* This function will recursively format itself and all nested object.
|
|
76
|
+
* The initialPage parameter is optional and will be used in the recursive
|
|
77
|
+
* nature to always pass in the root object page to each formatting.
|
|
78
|
+
*
|
|
79
|
+
* @param input
|
|
80
|
+
* @param pageInput
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
export const formatObject = (input, pageInput) => {
|
|
84
|
+
const { object: objectInput = {} } = input || {};
|
|
85
|
+
const { page: pageInObject } = objectInput;
|
|
86
|
+
const page = pageInput || pageInObject;
|
|
87
|
+
const evaluatedObjectInput = Object.keys(objectInput).reduce((accl, key) => {
|
|
88
|
+
const prop = objectInput[key];
|
|
89
|
+
if (Array.isArray(prop)) {
|
|
90
|
+
return {
|
|
91
|
+
// biome-ignore lint/performance/noAccumulatingSpread: -
|
|
92
|
+
...accl,
|
|
93
|
+
[key]: prop.map((o) => {
|
|
94
|
+
if (isPlainObject(o)) {
|
|
95
|
+
return formatObject(Object.assign({}, input, { object: o }), page);
|
|
96
|
+
}
|
|
97
|
+
return o;
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (isObject(prop)) {
|
|
102
|
+
return {
|
|
103
|
+
// biome-ignore lint/performance/noAccumulatingSpread: -
|
|
104
|
+
...accl,
|
|
105
|
+
[key]: formatObject(Object.assign({}, input, { object: prop }), page),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// biome-ignore lint/performance/noAccumulatingSpread: -
|
|
109
|
+
return { ...accl, [key]: prop };
|
|
110
|
+
}, {});
|
|
111
|
+
const output = Object.assign({}, input, { page, object: evaluatedObjectInput });
|
|
112
|
+
return getObjectFormatter(objectInput.type)(output);
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
export default formatObject;
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
export const defaultValue = () => undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isString } from '@schibsted/pulse-utils';
|
|
2
|
+
const objectTypeContentMapping = {
|
|
3
|
+
classifiedad: 'classified',
|
|
4
|
+
notificationcontent: 'notification',
|
|
5
|
+
businesstransaction: 'transaction',
|
|
6
|
+
uielement: 'element',
|
|
7
|
+
};
|
|
8
|
+
const getObjectContentByType = (type = '') => objectTypeContentMapping[type.toLowerCase()] ?? type.toLowerCase();
|
|
9
|
+
function idIsFormatted(id) {
|
|
10
|
+
return isString(id) && id?.startsWith('sdrn:');
|
|
11
|
+
}
|
|
12
|
+
export function generateObjectSDRN(id, providerId, type) {
|
|
13
|
+
if (idIsFormatted(id)) {
|
|
14
|
+
return id;
|
|
15
|
+
}
|
|
16
|
+
if ((isString(id) || Number.isFinite(id)) && isString(providerId) && isString(type)) {
|
|
17
|
+
const contentType = getObjectContentByType(type);
|
|
18
|
+
return `sdrn:${providerId}:${contentType}:${id}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isString } from '@schibsted/pulse-utils';
|
|
2
|
+
import { generateObjectSDRN } from './objects/utils';
|
|
3
|
+
// https://schibsted.ghe.com/data-platform/event-formats/blob/master/schema/master/common-definitions.json
|
|
4
|
+
const originIdRegex = /^unknown$|^sdrn:(.*)$/;
|
|
5
|
+
function isOriginSDRN(originId) {
|
|
6
|
+
return isString(originId) && originIdRegex.test(originId);
|
|
7
|
+
}
|
|
8
|
+
export default function origin(input) {
|
|
9
|
+
const { origin: originInput, provider } = input || {};
|
|
10
|
+
const { id: originInputId, type: originInputType, ...rest } = originInput || {};
|
|
11
|
+
const { id: providerId } = provider || {};
|
|
12
|
+
// If the id of origin has already been formatted upstream, we don't want to do it again
|
|
13
|
+
// This can happen, since previously we allowed the id through without any formatting and
|
|
14
|
+
// brands had to do it on their end to get it correctly.
|
|
15
|
+
const formattedOriginId = isOriginSDRN(originInputId)
|
|
16
|
+
? originInputId
|
|
17
|
+
: generateObjectSDRN(originInputId, providerId, originInputType);
|
|
18
|
+
const base = {
|
|
19
|
+
...(formattedOriginId && { '@id': formattedOriginId }),
|
|
20
|
+
...(originInputType && { '@type': originInputType }),
|
|
21
|
+
};
|
|
22
|
+
return Object.assign({}, base, rest);
|
|
23
|
+
}
|
|
24
|
+
export const defaultValue = () => undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const PROVIDER_ID_UNDEFINED = '--PROVIDER-ID-NOT-DEFINED--';
|
|
2
|
+
const DEFAULT_PROVIDER_TYPE = 'Organization';
|
|
3
|
+
export function generateProviderSDRN(providerId) {
|
|
4
|
+
if (providerId) {
|
|
5
|
+
return `sdrn:schibsted:client:${providerId}`;
|
|
6
|
+
}
|
|
7
|
+
return PROVIDER_ID_UNDEFINED;
|
|
8
|
+
}
|
|
9
|
+
export default function provider(input) {
|
|
10
|
+
const { provider: providerInput } = input || {};
|
|
11
|
+
const { id, type = DEFAULT_PROVIDER_TYPE, ...rest } = providerInput || {};
|
|
12
|
+
const base = {
|
|
13
|
+
'@type': type,
|
|
14
|
+
'@id': generateProviderSDRN(id),
|
|
15
|
+
};
|
|
16
|
+
return Object.assign({}, base, rest);
|
|
17
|
+
}
|
|
18
|
+
export const defaultValue = () => undefined;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { cookieConfig, getRootDomain, isBrowser, readCookie, writeCookie } from '@schibsted/pulse-utils';
|
|
2
|
+
import { v4 as uuid } from 'uuid';
|
|
3
|
+
const { USE_LOCALSTORAGE } = cookieConfig;
|
|
4
|
+
const SESSION_STORAGE_KEY = '_pulsesession';
|
|
5
|
+
const generateSessionSDRN = (sessionId) => `sdrn:schibsted:session:${sessionId}`;
|
|
6
|
+
// Return parsed json from cookie (or localStorage if enabled), or undefined.
|
|
7
|
+
export const readAndParse = (storageKey) => {
|
|
8
|
+
try {
|
|
9
|
+
const storedSession = readCookie(storageKey);
|
|
10
|
+
if (storedSession) {
|
|
11
|
+
return JSON.parse(storedSession);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch (_e) {
|
|
15
|
+
// If localStorage/cookie is not available, we treat it as if
|
|
16
|
+
// the value is undefined.
|
|
17
|
+
// If data is unparseable, we also ignore it.
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
};
|
|
22
|
+
// Read and parse session data from localStorage.
|
|
23
|
+
// Any invalid or unreadable data is ignored.
|
|
24
|
+
export const readSession = () => {
|
|
25
|
+
const storedSession = readAndParse(SESSION_STORAGE_KEY);
|
|
26
|
+
if (storedSession) {
|
|
27
|
+
const [id, startTimeMs, lastEventTimeMs] = storedSession;
|
|
28
|
+
const startTime = new Date(startTimeMs);
|
|
29
|
+
const lastEventTime = new Date(lastEventTimeMs);
|
|
30
|
+
if (id &&
|
|
31
|
+
startTime &&
|
|
32
|
+
lastEventTime &&
|
|
33
|
+
!Number.isNaN(startTime.getTime()) &&
|
|
34
|
+
!Number.isNaN(lastEventTime.getTime())) {
|
|
35
|
+
return { id, startTime, lastEventTime };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
};
|
|
40
|
+
// Write session data to localStorage
|
|
41
|
+
const writeSession = (session) => {
|
|
42
|
+
const { id, startTime, lastEventTime } = session;
|
|
43
|
+
try {
|
|
44
|
+
const sessionToStore = [id, startTime.getTime(), lastEventTime.getTime()];
|
|
45
|
+
const halfHourInDays = 1.0 / (24 * 2);
|
|
46
|
+
writeCookie(SESSION_STORAGE_KEY, JSON.stringify(sessionToStore), getRootDomain(), halfHourInDays);
|
|
47
|
+
// Delete old localStorage-based session if needed
|
|
48
|
+
if (!USE_LOCALSTORAGE && isBrowser && window.localStorage) {
|
|
49
|
+
// removeItem will do nothing to a non-existing item.
|
|
50
|
+
window.localStorage.removeItem(SESSION_STORAGE_KEY);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (_e) {
|
|
54
|
+
// If we can't write the session, we just move on in life
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const createSession = (eventCreationDate) => {
|
|
58
|
+
const now = eventCreationDate ?? new Date();
|
|
59
|
+
return {
|
|
60
|
+
id: generateSessionSDRN(uuid()),
|
|
61
|
+
startTime: now,
|
|
62
|
+
lastEventTime: now,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const updateSession = (session, eventCreationDate) => {
|
|
66
|
+
const now = eventCreationDate ?? new Date();
|
|
67
|
+
const sessionMaxInterval = 30 * 60 * 1000; // 30 minutes in milliseconds
|
|
68
|
+
if (!session || session.lastEventTime.getTime() < now.getTime() - sessionMaxInterval) {
|
|
69
|
+
return createSession(now);
|
|
70
|
+
}
|
|
71
|
+
return { ...session, lastEventTime: now };
|
|
72
|
+
};
|
|
73
|
+
export const defaultValue = () => undefined;
|
|
74
|
+
// Add session information to an event
|
|
75
|
+
// {
|
|
76
|
+
// "session": {
|
|
77
|
+
// "id": "sdrn:schibsted:session:123e4567-e89b-12d3-a456-426655440000",
|
|
78
|
+
// "startTime": "2020-01-21T12:29:00.999Z"
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
export default function session(_input, eventCreationDate) {
|
|
82
|
+
const oldSession = readSession();
|
|
83
|
+
const newSession = updateSession(oldSession, eventCreationDate);
|
|
84
|
+
writeSession(newSession);
|
|
85
|
+
const { id, startTime } = newSession;
|
|
86
|
+
return {
|
|
87
|
+
'@id': id,
|
|
88
|
+
startTime: startTime.toISOString(),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './tracker-node';
|
|
2
|
+
export { default } from './tracker-node';
|
|
3
|
+
/*
|
|
4
|
+
* this use case has not surfaced in any implementation:
|
|
5
|
+
*/
|
|
6
|
+
// export const defaultValue = () => {
|
|
7
|
+
// const { timing } = (window.performance || {});
|
|
8
|
+
// return {
|
|
9
|
+
// performance: {
|
|
10
|
+
// browser: timing ? timing.toJSON() : undefined,
|
|
11
|
+
// },
|
|
12
|
+
// };
|
|
13
|
+
// };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import version from '../version.json';
|
|
2
|
+
/**
|
|
3
|
+
* Format tracker objects
|
|
4
|
+
*/
|
|
5
|
+
export default function tracker(input) {
|
|
6
|
+
const { tracker: trackerInput } = input || {};
|
|
7
|
+
const base = {
|
|
8
|
+
name: 'Pulse Node.js SDK',
|
|
9
|
+
type: 'JS',
|
|
10
|
+
version: version.SDK_VERSION,
|
|
11
|
+
};
|
|
12
|
+
return Object.assign({}, base, trackerInput);
|
|
13
|
+
}
|
|
14
|
+
export const defaultValue = () => undefined;
|