@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,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webApi = exports.isBrowser = exports.initializeStorage = exports.throttle = exports.randomString = exports.omit = exports.isString = exports.isPromise = exports.isPlainObject = exports.isObjectEmpty = exports.isObject = exports.isFunction = exports.pulseMerge = exports.resetGetRootDomain = exports.getRootDomain = exports.get = exports.evaluateEventInput = exports.evaluateAndFlatten = exports.deviceType = exports.dateTime = exports.cookieConfig = exports.writeCookie = exports.readCookie = exports.deleteCookie = void 0;
|
|
4
|
+
var cookie_1 = require("./cookie");
|
|
5
|
+
Object.defineProperty(exports, "deleteCookie", { enumerable: true, get: function () { return cookie_1.deleteCookie; } });
|
|
6
|
+
Object.defineProperty(exports, "readCookie", { enumerable: true, get: function () { return cookie_1.readCookie; } });
|
|
7
|
+
Object.defineProperty(exports, "writeCookie", { enumerable: true, get: function () { return cookie_1.writeCookie; } });
|
|
8
|
+
var cookie_config_1 = require("./cookie-config");
|
|
9
|
+
Object.defineProperty(exports, "cookieConfig", { enumerable: true, get: function () { return cookie_config_1.cookieConfig; } });
|
|
10
|
+
var events_1 = require("./events");
|
|
11
|
+
Object.defineProperty(exports, "dateTime", { enumerable: true, get: function () { return events_1.dateTime; } });
|
|
12
|
+
Object.defineProperty(exports, "deviceType", { enumerable: true, get: function () { return events_1.deviceType; } });
|
|
13
|
+
Object.defineProperty(exports, "evaluateAndFlatten", { enumerable: true, get: function () { return events_1.evaluateAndFlatten; } });
|
|
14
|
+
Object.defineProperty(exports, "evaluateEventInput", { enumerable: true, get: function () { return events_1.evaluateEventInput; } });
|
|
15
|
+
var get_1 = require("./get");
|
|
16
|
+
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return get_1.get; } });
|
|
17
|
+
var getRootDomain_1 = require("./getRootDomain");
|
|
18
|
+
Object.defineProperty(exports, "getRootDomain", { enumerable: true, get: function () { return getRootDomain_1.getRootDomain; } });
|
|
19
|
+
Object.defineProperty(exports, "resetGetRootDomain", { enumerable: true, get: function () { return getRootDomain_1.resetGetRootDomain; } });
|
|
20
|
+
var merge_1 = require("./merge");
|
|
21
|
+
Object.defineProperty(exports, "pulseMerge", { enumerable: true, get: function () { return merge_1.pulseMerge; } });
|
|
22
|
+
var objects_1 = require("./objects");
|
|
23
|
+
Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return objects_1.isFunction; } });
|
|
24
|
+
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return objects_1.isObject; } });
|
|
25
|
+
Object.defineProperty(exports, "isObjectEmpty", { enumerable: true, get: function () { return objects_1.isObjectEmpty; } });
|
|
26
|
+
Object.defineProperty(exports, "isPlainObject", { enumerable: true, get: function () { return objects_1.isPlainObject; } });
|
|
27
|
+
Object.defineProperty(exports, "isPromise", { enumerable: true, get: function () { return objects_1.isPromise; } });
|
|
28
|
+
Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return objects_1.isString; } });
|
|
29
|
+
var omit_1 = require("./omit");
|
|
30
|
+
Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return omit_1.omit; } });
|
|
31
|
+
var randomString_1 = require("./randomString");
|
|
32
|
+
Object.defineProperty(exports, "randomString", { enumerable: true, get: function () { return randomString_1.randomString; } });
|
|
33
|
+
var throttle_1 = require("./throttle");
|
|
34
|
+
Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return throttle_1.throttle; } });
|
|
35
|
+
var webApi_1 = require("./webApi");
|
|
36
|
+
Object.defineProperty(exports, "initializeStorage", { enumerable: true, get: function () { return webApi_1.initializeStorage; } });
|
|
37
|
+
Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return webApi_1.isBrowser; } });
|
|
38
|
+
Object.defineProperty(exports, "webApi", { enumerable: true, get: function () { return webApi_1.webApi; } });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pulseMerge = pulseMerge;
|
|
4
|
+
const objects_1 = require("./objects");
|
|
5
|
+
/**
|
|
6
|
+
* This function deep merges objects, concatenates array and handles promises as values.
|
|
7
|
+
*/
|
|
8
|
+
// biome-ignore lint/suspicious/noExplicitAny: -
|
|
9
|
+
function pulseMerge(target, ...sources) {
|
|
10
|
+
return sources.reduce((acc, source) => mergeValue(acc, source), target);
|
|
11
|
+
function innerMerge(target, source) {
|
|
12
|
+
for (const [key, value] of Object.entries(source)) {
|
|
13
|
+
target[key] = mergeValue(target[key], value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function mergeValue(targetValue, value) {
|
|
17
|
+
if ((0, objects_1.isPromise)(targetValue) || (0, objects_1.isPromise)(value)) {
|
|
18
|
+
return Promise.all([targetValue, value]).then(([targetValue, value]) => {
|
|
19
|
+
const copiedTarget = (0, objects_1.isPlainObject)(targetValue) ? { ...targetValue } : targetValue;
|
|
20
|
+
return mergeValue(copiedTarget, value);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
if (!Array.isArray(targetValue)) {
|
|
25
|
+
return value.filter((v) => v !== undefined);
|
|
26
|
+
}
|
|
27
|
+
return [...targetValue, ...value].filter((v) => v !== undefined);
|
|
28
|
+
}
|
|
29
|
+
if (typeof value === 'object') {
|
|
30
|
+
if (targetValue && value && typeof targetValue === 'object') {
|
|
31
|
+
innerMerge(targetValue, value);
|
|
32
|
+
return targetValue;
|
|
33
|
+
}
|
|
34
|
+
return value ? { ...value } : value;
|
|
35
|
+
}
|
|
36
|
+
return value ?? targetValue ?? undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObject = isObject;
|
|
4
|
+
exports.isPlainObject = isPlainObject;
|
|
5
|
+
exports.isFunction = isFunction;
|
|
6
|
+
exports.isString = isString;
|
|
7
|
+
exports.isPromise = isPromise;
|
|
8
|
+
exports.isObjectEmpty = isObjectEmpty;
|
|
9
|
+
function isObject(value) {
|
|
10
|
+
const type = typeof value;
|
|
11
|
+
return value != null && (type === 'object' || type === 'function');
|
|
12
|
+
}
|
|
13
|
+
function isPlainObject(value) {
|
|
14
|
+
return isObject(value) && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
// biome-ignore lint/suspicious/noExplicitAny: generic function
|
|
17
|
+
function isFunction(value) {
|
|
18
|
+
return typeof value === 'function';
|
|
19
|
+
}
|
|
20
|
+
function isString(s) {
|
|
21
|
+
return Object.prototype.toString.call(s) === '[object String]';
|
|
22
|
+
}
|
|
23
|
+
function isPromise(s) {
|
|
24
|
+
return s instanceof Promise;
|
|
25
|
+
}
|
|
26
|
+
function isObjectEmpty(obj) {
|
|
27
|
+
for (const prop in obj) {
|
|
28
|
+
// biome-ignore lint/suspicious/noPrototypeBuiltins: Object.hasOwn is not available in ES2020
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.omit = omit;
|
|
4
|
+
function omit(target, props) {
|
|
5
|
+
if (!target) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
return Object.fromEntries(Object.entries(target).filter(([key]) => !props.includes(key)));
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomString = randomString;
|
|
4
|
+
const webApi_1 = require("./webApi");
|
|
5
|
+
function randomString(length = 16) {
|
|
6
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
7
|
+
const charactersLength = characters.length;
|
|
8
|
+
let output = '';
|
|
9
|
+
if (length < 0) {
|
|
10
|
+
return output;
|
|
11
|
+
}
|
|
12
|
+
const randomValues = new Uint32Array(length);
|
|
13
|
+
webApi_1.webApi.crypto?.getRandomValues(randomValues);
|
|
14
|
+
randomValues.forEach((value) => {
|
|
15
|
+
output += characters.charAt(value % charactersLength);
|
|
16
|
+
});
|
|
17
|
+
return output;
|
|
18
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.throttle = throttle;
|
|
4
|
+
function throttle(func, wait = 0) {
|
|
5
|
+
let timeout;
|
|
6
|
+
let lastCallTime = 0;
|
|
7
|
+
const f = function (...args) {
|
|
8
|
+
const now = Date.now();
|
|
9
|
+
const remaining = wait - (now - lastCallTime);
|
|
10
|
+
if (remaining <= 0 || remaining > wait) {
|
|
11
|
+
if (timeout) {
|
|
12
|
+
clearTimeout(timeout);
|
|
13
|
+
timeout = null;
|
|
14
|
+
}
|
|
15
|
+
lastCallTime = now;
|
|
16
|
+
// @ts-expect-error
|
|
17
|
+
func.apply(this, args);
|
|
18
|
+
}
|
|
19
|
+
else if (!timeout) {
|
|
20
|
+
timeout = setTimeout(() => {
|
|
21
|
+
lastCallTime = Date.now();
|
|
22
|
+
timeout = null;
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
func.apply(this, args);
|
|
25
|
+
}, remaining);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
f.cancel = () => {
|
|
29
|
+
if (timeout) {
|
|
30
|
+
clearTimeout(timeout);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return f;
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webApi = exports.initializeStorage = exports.isBrowser = void 0;
|
|
4
|
+
exports.isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
5
|
+
const initializeStorage = (storageType) => {
|
|
6
|
+
if (!exports.isBrowser)
|
|
7
|
+
return;
|
|
8
|
+
try {
|
|
9
|
+
const storage = window[storageType];
|
|
10
|
+
return storage && typeof storage.getItem === 'function' ? storage : undefined;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.initializeStorage = initializeStorage;
|
|
17
|
+
exports.webApi = {
|
|
18
|
+
crypto: exports.isBrowser ? crypto : globalThis.crypto,
|
|
19
|
+
localStorage: (0, exports.initializeStorage)('localStorage'),
|
|
20
|
+
sessionStorage: (0, exports.initializeStorage)('sessionStorage'),
|
|
21
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { cookieConfig } from './cookie-config';
|
|
2
|
+
import { isBrowser } from './webApi';
|
|
3
|
+
const { USE_SECURE_COOKIES, USE_LOCALSTORAGE } = cookieConfig;
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
function getExpiryDate(expiresInDays = 1) {
|
|
8
|
+
const expireTimestamp = Date.now() + expiresInDays * 1000 * 60 * 60 * 24;
|
|
9
|
+
return new Date(expireTimestamp);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Read a cookie from localStorage or document.cookie.
|
|
13
|
+
*/
|
|
14
|
+
export function readCookie(key, useLocalStorage = USE_LOCALSTORAGE) {
|
|
15
|
+
if (!isBrowser) {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
if (useLocalStorage) {
|
|
19
|
+
const fromLocalStorage = localStorage.getItem(key) || '';
|
|
20
|
+
if (fromLocalStorage) {
|
|
21
|
+
return fromLocalStorage;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return decodeURIComponent(document.cookie.replace(new RegExp(`(?:(?:^|.*;)\\s*${encodeURIComponent(key).replace(/[-.+*]/g, '\\$&')}\\s*\\=\\s*([^;]*).*$)|^.*$`), '$1'));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Write a cookie to document.cookie and/or localStorage
|
|
28
|
+
*
|
|
29
|
+
* @param key The key for the cookie
|
|
30
|
+
* @param value The value for the cookie
|
|
31
|
+
* @param domain The domain for the cookie. You might want to use `getRootDomain()`
|
|
32
|
+
* for this to set the cookie at the "best" domain.
|
|
33
|
+
* @param expiresInDays The number of days until the cookie should expire. Defaults to 1.
|
|
34
|
+
* @param useLocalStorage Whether to use localStorage *in addition* to setting a cookie.
|
|
35
|
+
* Note that localStorage has the specific origin of the current window.location, so
|
|
36
|
+
* if you set `domain` to something more general, then other subdomains will not be able
|
|
37
|
+
* to read back from the same localStorage, but will be able to read back the cookie only.
|
|
38
|
+
* @param useSecureCookies Whether to write that have SameSite=None and Secure set. You usually want this.
|
|
39
|
+
*/
|
|
40
|
+
export function writeCookie(key, value, domain, expiresInDays = 1, useLocalStorage = USE_LOCALSTORAGE, useSecureCookies = USE_SECURE_COOKIES) {
|
|
41
|
+
if (isBrowser) {
|
|
42
|
+
const expires = getExpiryDate(expiresInDays).toUTCString();
|
|
43
|
+
let cookieString;
|
|
44
|
+
cookieString = `${key}=${encodeURIComponent(value)}`;
|
|
45
|
+
cookieString += ';path=/';
|
|
46
|
+
if (domain) {
|
|
47
|
+
cookieString += `;domain=${domain}`;
|
|
48
|
+
}
|
|
49
|
+
if (expiresInDays) {
|
|
50
|
+
cookieString += `;expires=${expires}`;
|
|
51
|
+
}
|
|
52
|
+
if (useSecureCookies &&
|
|
53
|
+
window.location.protocol === 'https:' &&
|
|
54
|
+
// 20200303
|
|
55
|
+
// This only detects safari on desktop
|
|
56
|
+
// (already fixed)
|
|
57
|
+
// https://bugs.webkit.org/show_bug.cgi?id=198181
|
|
58
|
+
// TODO: Remove this when market share with this
|
|
59
|
+
// bug is low.. maybe 2020-08-ish.
|
|
60
|
+
// biome-ignore lint/suspicious/noExplicitAny: -
|
|
61
|
+
window.safari === undefined) {
|
|
62
|
+
cookieString += ';SameSite=None;Secure';
|
|
63
|
+
}
|
|
64
|
+
// biome-ignore lint/suspicious/noDocumentCookie: -
|
|
65
|
+
document.cookie = cookieString;
|
|
66
|
+
if (useLocalStorage) {
|
|
67
|
+
if (value === '') {
|
|
68
|
+
localStorage.removeItem(key);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
localStorage.setItem(key, value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Delete a cookie
|
|
78
|
+
*/
|
|
79
|
+
export function deleteCookie(key, domain) {
|
|
80
|
+
writeCookie(key, '', domain, -1);
|
|
81
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { pulseMerge } from './merge';
|
|
2
|
+
import { isFunction, isObject, isPromise } from './objects';
|
|
3
|
+
/**
|
|
4
|
+
* @recursive
|
|
5
|
+
* @param eventInput
|
|
6
|
+
*/
|
|
7
|
+
export async function evaluateEventInput(eventInput) {
|
|
8
|
+
if (isPromise(eventInput)) {
|
|
9
|
+
return evaluateEventInput(await eventInput);
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(eventInput)) {
|
|
12
|
+
return Promise.all(eventInput.map(evaluateEventInput));
|
|
13
|
+
}
|
|
14
|
+
if (isFunction(eventInput)) {
|
|
15
|
+
return evaluateEventInput(eventInput());
|
|
16
|
+
}
|
|
17
|
+
if (isObject(eventInput)) {
|
|
18
|
+
const eventKeys = Object.getOwnPropertyNames(eventInput);
|
|
19
|
+
const evaluatedEventKeys = eventKeys.reduce((acc, key) => {
|
|
20
|
+
const eventInputProperty = eventInput[key];
|
|
21
|
+
if (isObject(eventInputProperty) || isFunction(eventInputProperty) || isPromise(eventInputProperty)) {
|
|
22
|
+
return acc.concat(evaluateEventInput(eventInputProperty));
|
|
23
|
+
}
|
|
24
|
+
return acc.concat([eventInputProperty]);
|
|
25
|
+
}, []);
|
|
26
|
+
const resolvedEventKeys = await Promise.all(evaluatedEventKeys);
|
|
27
|
+
return resolvedEventKeys.reduce((evaluatedEventInput, resolvedEventKey, index) => pulseMerge(evaluatedEventInput, { [eventKeys[index]]: resolvedEventKey }), {});
|
|
28
|
+
}
|
|
29
|
+
return eventInput;
|
|
30
|
+
}
|
|
31
|
+
export async function evaluateAndFlatten(builder) {
|
|
32
|
+
const builders = Array.isArray(builder) ? builder : [builder];
|
|
33
|
+
const results = await Promise.all(builders.map(evaluateEventInput));
|
|
34
|
+
return pulseMerge({}, ...results.filter(isObject));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Function for getting device type taken from the old SDK. It performs as well
|
|
38
|
+
* as one could expect from the size. It could be replaced with 'ua-parser-js'
|
|
39
|
+
* at the cost of 11kb minimized.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} userAgent
|
|
42
|
+
*
|
|
43
|
+
* @returns {string} the device type the user is using
|
|
44
|
+
*/
|
|
45
|
+
export function deviceType(userAgent) {
|
|
46
|
+
const knownDevices = {
|
|
47
|
+
mobile: [
|
|
48
|
+
/iPhone;/,
|
|
49
|
+
/iPod;/,
|
|
50
|
+
/iPod touch;/,
|
|
51
|
+
/^HTC/,
|
|
52
|
+
/Fennec/,
|
|
53
|
+
/IEMobile/,
|
|
54
|
+
/BB10;/,
|
|
55
|
+
/BlackBerry/,
|
|
56
|
+
/SymbianOS.*AppleWebKit/,
|
|
57
|
+
/^Mozilla.*Mobile.*Firefox/,
|
|
58
|
+
/^Mozilla.*Chrome.*Mobile/,
|
|
59
|
+
/Opera Mobi/,
|
|
60
|
+
/Android.*Mobile/,
|
|
61
|
+
/Android.*Mini/,
|
|
62
|
+
/Symbian/,
|
|
63
|
+
/^SonyEricsson/,
|
|
64
|
+
/^Nokia/,
|
|
65
|
+
/^SAMSUNG/,
|
|
66
|
+
/^LG/,
|
|
67
|
+
],
|
|
68
|
+
tablet: [/iPad/, /Android/],
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Hermes' apps (Shared app-platform for media) return "Hermes"&"_app_" as part of the user-agent
|
|
72
|
+
* Example UA: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6)
|
|
73
|
+
* AppleWebKit/605.1.15 (KHTML, like Gecko) iOS AP Hermes/64.0.0 _app_`
|
|
74
|
+
* @returns {boolean} Returns true if the user is inside the app.
|
|
75
|
+
*/
|
|
76
|
+
function isHermesApp() {
|
|
77
|
+
return userAgent.search(/Hermes.*_app_/) !== -1;
|
|
78
|
+
}
|
|
79
|
+
function isDeviceIn(devicesList) {
|
|
80
|
+
for (let i = 0; i < devicesList.length; i += 1) {
|
|
81
|
+
if (devicesList[i].test(userAgent)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (userAgent) {
|
|
88
|
+
if (isDeviceIn(knownDevices.mobile)) {
|
|
89
|
+
return 'mobile';
|
|
90
|
+
}
|
|
91
|
+
if (isDeviceIn(knownDevices.tablet)) {
|
|
92
|
+
return 'tablet';
|
|
93
|
+
}
|
|
94
|
+
if (isHermesApp()) {
|
|
95
|
+
// If not a detected device but inside app it's most likely a tablet masking itself as desktop
|
|
96
|
+
return 'tablet';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return 'desktop';
|
|
100
|
+
}
|
|
101
|
+
export function dateTime() {
|
|
102
|
+
return new Date().toISOString();
|
|
103
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isString } from './objects';
|
|
2
|
+
// biome-ignore lint/suspicious/noExplicitAny: -
|
|
3
|
+
export function get(object, path, defaultValue) {
|
|
4
|
+
if (!path || !isString(path)) {
|
|
5
|
+
return defaultValue;
|
|
6
|
+
}
|
|
7
|
+
const parts = path.split('.');
|
|
8
|
+
for (const part of parts) {
|
|
9
|
+
if (!object)
|
|
10
|
+
return defaultValue;
|
|
11
|
+
// biome-ignore lint/style/noParameterAssign: -
|
|
12
|
+
object = object[part];
|
|
13
|
+
}
|
|
14
|
+
return object ?? defaultValue;
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { deleteCookie, readCookie, writeCookie } from './cookie';
|
|
2
|
+
import { cookieConfig } from './cookie-config';
|
|
3
|
+
import { randomString } from './randomString';
|
|
4
|
+
import { isBrowser } from './webApi';
|
|
5
|
+
const { TEST_COOKIE_KEY } = cookieConfig;
|
|
6
|
+
// Exported for testing
|
|
7
|
+
export function makeGetRootDomainCached() {
|
|
8
|
+
let cache;
|
|
9
|
+
return () => {
|
|
10
|
+
if (!isBrowser) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
if (cache) {
|
|
14
|
+
return cache;
|
|
15
|
+
}
|
|
16
|
+
const parts = `${window.location.hostname}`.split('.');
|
|
17
|
+
const testValue = randomString();
|
|
18
|
+
let domain = window.location.hostname;
|
|
19
|
+
let test = '';
|
|
20
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
21
|
+
try {
|
|
22
|
+
domain = parts.slice(-(i + 1)).join('.');
|
|
23
|
+
writeCookie(TEST_COOKIE_KEY, testValue, domain, 1);
|
|
24
|
+
test = readCookie(TEST_COOKIE_KEY);
|
|
25
|
+
deleteCookie(TEST_COOKIE_KEY, domain);
|
|
26
|
+
if (test === testValue) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (_e) { }
|
|
31
|
+
}
|
|
32
|
+
cache = domain;
|
|
33
|
+
return domain;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export const resetGetRootDomain = () => {
|
|
37
|
+
getRootDomain = makeGetRootDomainCached();
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Function for getting the highest cookie domain where a cookie can be placed.
|
|
41
|
+
* This is done by trying to set and then read back a cookie at the tld, and
|
|
42
|
+
* then working downwards.
|
|
43
|
+
*
|
|
44
|
+
* This function is memoized as `window.location.hostname` is supposed to be
|
|
45
|
+
* immutable during the lifetime of the code.
|
|
46
|
+
*
|
|
47
|
+
* @returns {string} the top domain for setting cookies. Example: aftonbladet.se
|
|
48
|
+
*/
|
|
49
|
+
export let getRootDomain = makeGetRootDomainCached();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { deleteCookie, readCookie, writeCookie } from './cookie';
|
|
2
|
+
export { cookieConfig } from './cookie-config';
|
|
3
|
+
export { dateTime, deviceType, evaluateAndFlatten, evaluateEventInput } from './events';
|
|
4
|
+
export { get } from './get';
|
|
5
|
+
export { getRootDomain, resetGetRootDomain } from './getRootDomain';
|
|
6
|
+
export { pulseMerge } from './merge';
|
|
7
|
+
export { isFunction, isObject, isObjectEmpty, isPlainObject, isPromise, isString } from './objects';
|
|
8
|
+
export { omit } from './omit';
|
|
9
|
+
export { randomString } from './randomString';
|
|
10
|
+
export { throttle } from './throttle';
|
|
11
|
+
export { initializeStorage, isBrowser, webApi } from './webApi';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isPlainObject, isPromise } from './objects';
|
|
2
|
+
/**
|
|
3
|
+
* This function deep merges objects, concatenates array and handles promises as values.
|
|
4
|
+
*/
|
|
5
|
+
// biome-ignore lint/suspicious/noExplicitAny: -
|
|
6
|
+
export function pulseMerge(target, ...sources) {
|
|
7
|
+
return sources.reduce((acc, source) => mergeValue(acc, source), target);
|
|
8
|
+
function innerMerge(target, source) {
|
|
9
|
+
for (const [key, value] of Object.entries(source)) {
|
|
10
|
+
target[key] = mergeValue(target[key], value);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function mergeValue(targetValue, value) {
|
|
14
|
+
if (isPromise(targetValue) || isPromise(value)) {
|
|
15
|
+
return Promise.all([targetValue, value]).then(([targetValue, value]) => {
|
|
16
|
+
const copiedTarget = isPlainObject(targetValue) ? { ...targetValue } : targetValue;
|
|
17
|
+
return mergeValue(copiedTarget, value);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
if (!Array.isArray(targetValue)) {
|
|
22
|
+
return value.filter((v) => v !== undefined);
|
|
23
|
+
}
|
|
24
|
+
return [...targetValue, ...value].filter((v) => v !== undefined);
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === 'object') {
|
|
27
|
+
if (targetValue && value && typeof targetValue === 'object') {
|
|
28
|
+
innerMerge(targetValue, value);
|
|
29
|
+
return targetValue;
|
|
30
|
+
}
|
|
31
|
+
return value ? { ...value } : value;
|
|
32
|
+
}
|
|
33
|
+
return value ?? targetValue ?? undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function isObject(value) {
|
|
2
|
+
const type = typeof value;
|
|
3
|
+
return value != null && (type === 'object' || type === 'function');
|
|
4
|
+
}
|
|
5
|
+
export function isPlainObject(value) {
|
|
6
|
+
return isObject(value) && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
// biome-ignore lint/suspicious/noExplicitAny: generic function
|
|
9
|
+
export function isFunction(value) {
|
|
10
|
+
return typeof value === 'function';
|
|
11
|
+
}
|
|
12
|
+
export function isString(s) {
|
|
13
|
+
return Object.prototype.toString.call(s) === '[object String]';
|
|
14
|
+
}
|
|
15
|
+
export function isPromise(s) {
|
|
16
|
+
return s instanceof Promise;
|
|
17
|
+
}
|
|
18
|
+
export function isObjectEmpty(obj) {
|
|
19
|
+
for (const prop in obj) {
|
|
20
|
+
// biome-ignore lint/suspicious/noPrototypeBuiltins: Object.hasOwn is not available in ES2020
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { webApi } from './webApi';
|
|
2
|
+
export function randomString(length = 16) {
|
|
3
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
4
|
+
const charactersLength = characters.length;
|
|
5
|
+
let output = '';
|
|
6
|
+
if (length < 0) {
|
|
7
|
+
return output;
|
|
8
|
+
}
|
|
9
|
+
const randomValues = new Uint32Array(length);
|
|
10
|
+
webApi.crypto?.getRandomValues(randomValues);
|
|
11
|
+
randomValues.forEach((value) => {
|
|
12
|
+
output += characters.charAt(value % charactersLength);
|
|
13
|
+
});
|
|
14
|
+
return output;
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function throttle(func, wait = 0) {
|
|
2
|
+
let timeout;
|
|
3
|
+
let lastCallTime = 0;
|
|
4
|
+
const f = function (...args) {
|
|
5
|
+
const now = Date.now();
|
|
6
|
+
const remaining = wait - (now - lastCallTime);
|
|
7
|
+
if (remaining <= 0 || remaining > wait) {
|
|
8
|
+
if (timeout) {
|
|
9
|
+
clearTimeout(timeout);
|
|
10
|
+
timeout = null;
|
|
11
|
+
}
|
|
12
|
+
lastCallTime = now;
|
|
13
|
+
// @ts-expect-error
|
|
14
|
+
func.apply(this, args);
|
|
15
|
+
}
|
|
16
|
+
else if (!timeout) {
|
|
17
|
+
timeout = setTimeout(() => {
|
|
18
|
+
lastCallTime = Date.now();
|
|
19
|
+
timeout = null;
|
|
20
|
+
// @ts-expect-error
|
|
21
|
+
func.apply(this, args);
|
|
22
|
+
}, remaining);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
f.cancel = () => {
|
|
26
|
+
if (timeout) {
|
|
27
|
+
clearTimeout(timeout);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return f;
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
2
|
+
export const initializeStorage = (storageType) => {
|
|
3
|
+
if (!isBrowser)
|
|
4
|
+
return;
|
|
5
|
+
try {
|
|
6
|
+
const storage = window[storageType];
|
|
7
|
+
return storage && typeof storage.getItem === 'function' ? storage : undefined;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export const webApi = {
|
|
14
|
+
crypto: isBrowser ? crypto : globalThis.crypto,
|
|
15
|
+
localStorage: initializeStorage('localStorage'),
|
|
16
|
+
sessionStorage: initializeStorage('sessionStorage'),
|
|
17
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a cookie from localStorage or document.cookie.
|
|
3
|
+
*/
|
|
4
|
+
export declare function readCookie(key: string, useLocalStorage?: boolean): string;
|
|
5
|
+
/**
|
|
6
|
+
* Write a cookie to document.cookie and/or localStorage
|
|
7
|
+
*
|
|
8
|
+
* @param key The key for the cookie
|
|
9
|
+
* @param value The value for the cookie
|
|
10
|
+
* @param domain The domain for the cookie. You might want to use `getRootDomain()`
|
|
11
|
+
* for this to set the cookie at the "best" domain.
|
|
12
|
+
* @param expiresInDays The number of days until the cookie should expire. Defaults to 1.
|
|
13
|
+
* @param useLocalStorage Whether to use localStorage *in addition* to setting a cookie.
|
|
14
|
+
* Note that localStorage has the specific origin of the current window.location, so
|
|
15
|
+
* if you set `domain` to something more general, then other subdomains will not be able
|
|
16
|
+
* to read back from the same localStorage, but will be able to read back the cookie only.
|
|
17
|
+
* @param useSecureCookies Whether to write that have SameSite=None and Secure set. You usually want this.
|
|
18
|
+
*/
|
|
19
|
+
export declare function writeCookie(key: string, value: string, domain?: string, expiresInDays?: number, useLocalStorage?: boolean, useSecureCookies?: boolean): void;
|
|
20
|
+
/**
|
|
21
|
+
* Delete a cookie
|
|
22
|
+
*/
|
|
23
|
+
export declare function deleteCookie(key: string, domain?: string): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @recursive
|
|
3
|
+
* @param eventInput
|
|
4
|
+
*/
|
|
5
|
+
export declare function evaluateEventInput(eventInput: unknown): Promise<unknown>;
|
|
6
|
+
export declare function evaluateAndFlatten(builder: unknown): Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Function for getting device type taken from the old SDK. It performs as well
|
|
9
|
+
* as one could expect from the size. It could be replaced with 'ua-parser-js'
|
|
10
|
+
* at the cost of 11kb minimized.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} userAgent
|
|
13
|
+
*
|
|
14
|
+
* @returns {string} the device type the user is using
|
|
15
|
+
*/
|
|
16
|
+
export declare function deviceType(userAgent: string): string;
|
|
17
|
+
export declare function dateTime(): string;
|