@adobe/alloy 2.32.1-beta.0 → 2.33.0-beta.2
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/components.json +9 -0
- package/dist/alloy.js +13696 -12143
- package/dist/alloy.min.js +1 -1
- package/dist/alloyServiceWorker.js +8 -20
- package/dist/alloyServiceWorker.min.js +1 -1
- package/dist/types/browser/src/allOptionalComponents.d.ts +2 -0
- package/dist/types/{core → browser}/src/components/Advertising/constants/index.d.ts +3 -0
- package/dist/types/{core → browser}/src/components/Advertising/handlers/createOnBeforeSendEventHandler.d.ts +4 -1
- package/dist/types/{core → browser}/src/components/Advertising/handlers/sendAdConversion.d.ts +3 -1
- package/dist/types/{core → browser}/src/components/Advertising/handlers/viewThroughHandler.d.ts +3 -1
- package/dist/types/{core → browser}/src/components/Advertising/identities/collectAllIdentities.d.ts +1 -1
- package/dist/types/browser/src/components/Advertising/identities/collectSurferId.d.ts +15 -0
- package/dist/types/browser/src/components/Advertising/identities/createHashedIpHandler.d.ts +9 -0
- package/dist/types/browser/src/components/Advertising/identities/initiateAdvertisingIdentityCall.d.ts +5 -0
- package/dist/types/{core → browser}/src/components/Advertising/utils/helpers.d.ts +14 -0
- package/dist/types/browser/src/components/Advertising/utils/murmurHash128GuavaHex.d.ts +2 -0
- package/dist/types/browser/src/components/Personalization/constants/surface.d.ts +4 -0
- package/dist/types/browser/src/components/Personalization/dom-actions/dom/isDomElement.d.ts +2 -0
- package/dist/types/browser/src/components/Personalization/utils/addRenderAttemptedToDecisions.d.ts +5 -0
- package/dist/types/browser/src/components/Personalization/utils/surfaceUtils.d.ts +3 -0
- package/dist/types/{core → browser}/src/components/PushNotifications/helpers/saveToIndexedDb.d.ts +1 -1
- package/dist/types/{core → browser}/src/components/PushNotifications/index.d.ts +6 -6
- package/dist/types/{core → browser}/src/components/PushNotifications/request/createSendPushSubscriptionPayload.d.ts +2 -2
- package/dist/types/browser/src/components/PushNotifications/request/createSendPushSubscriptionRequest.d.ts +6 -0
- package/dist/types/{core → browser}/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts +6 -6
- package/dist/types/{core → browser}/src/components/PushNotifications/types.d.ts +1 -1
- package/dist/types/browser/src/components/componentCreators.d.ts +4 -0
- package/dist/types/browser/src/components/requiredComponentCreators.d.ts +1 -0
- package/dist/types/browser/src/index.d.ts +4 -2
- package/dist/types/browser/src/initializeStandalone.d.ts +4 -0
- package/dist/types/core/src/components/Identity/injectAddQueryStringIdentityToPayload.d.ts +2 -1
- package/dist/types/core/src/components/MediaAnalyticsBridge/createGetInstance.d.ts +1 -1
- package/dist/types/core/src/components/MediaAnalyticsBridge/createMediaHelper.d.ts +7 -56
- package/dist/types/core/src/core/componentCreators.d.ts +0 -4
- package/dist/types/core/src/core/requiredComponentCreators.d.ts +0 -1
- package/dist/types/core/src/types.d.ts +0 -4
- package/dist/utils/createEventMergeId.js +38 -30
- package/dist/utils/deepAssign.js +10 -4
- package/package.json +9 -13
- package/rollup.config.js +9 -15
- package/scripts/alloyBuilder.js +34 -42
- package/scripts/helpers/componentMetadata.js +25 -0
- package/scripts/helpers/generateEntryPoint.js +29 -0
- package/src/allOptionalComponents.js +14 -0
- package/src/components/ActivityCollector/attachClickActivityCollector.js +55 -0
- package/src/components/ActivityCollector/configValidators.js +52 -0
- package/src/components/ActivityCollector/createClickActivityStorage.js +33 -0
- package/src/components/ActivityCollector/createClickedElementProperties.js +224 -0
- package/src/components/ActivityCollector/createGetClickedElementProperties.js +68 -0
- package/src/components/ActivityCollector/createInjectClickedElementProperties.js +80 -0
- package/src/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +45 -0
- package/src/components/ActivityCollector/createStorePageViewProperties.js +20 -0
- package/src/components/ActivityCollector/getLinkName.js +145 -0
- package/src/components/ActivityCollector/getLinkRegion.js +65 -0
- package/src/components/ActivityCollector/index.js +132 -0
- package/src/components/ActivityCollector/utils/activityMapExtensionEnabled.js +16 -0
- package/src/components/ActivityCollector/utils/createTransientStorage.js +26 -0
- package/src/components/ActivityCollector/utils/determineLinkType.js +27 -0
- package/src/components/ActivityCollector/utils/dom/elementHasClickHandler.js +15 -0
- package/src/components/ActivityCollector/utils/dom/extractDomain.js +20 -0
- package/src/components/ActivityCollector/utils/dom/findClickableElement.js +36 -0
- package/src/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +25 -0
- package/src/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +15 -0
- package/src/components/ActivityCollector/utils/dom/isDownloadLink.js +27 -0
- package/src/components/ActivityCollector/utils/dom/isExitLink.js +24 -0
- package/src/components/ActivityCollector/utils/dom/isInputSubmitElement.js +26 -0
- package/src/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +24 -0
- package/src/components/ActivityCollector/utils/dom/isSupportedTextNode.js +27 -0
- package/src/components/ActivityCollector/utils/hasPageName.js +23 -0
- package/src/components/ActivityCollector/utils/isDifferentDomains.js +19 -0
- package/src/components/ActivityCollector/utils/trimQueryFromUrl.js +31 -0
- package/src/components/ActivityCollector/utils/truncateWhiteSpace.js +22 -0
- package/src/components/ActivityCollector/validateClickCollectionConfig.js +47 -0
- package/src/components/Advertising/configValidators.js +32 -0
- package/src/components/Advertising/constants/index.js +80 -0
- package/src/components/Advertising/createComponent.js +24 -0
- package/src/components/Advertising/handlers/clickThroughHandler.js +94 -0
- package/src/components/Advertising/handlers/createAdConversionHandler.js +50 -0
- package/src/components/Advertising/handlers/createOnBeforeSendEventHandler.js +177 -0
- package/src/components/Advertising/handlers/sendAdConversion.js +74 -0
- package/src/components/Advertising/handlers/viewThroughHandler.js +107 -0
- package/src/components/Advertising/identities/collectAllIdentities.js +57 -0
- package/src/components/Advertising/identities/collectID5Id.js +133 -0
- package/src/components/Advertising/identities/collectRampId.js +265 -0
- package/src/components/Advertising/identities/collectSurferId.js +72 -0
- package/src/components/Advertising/identities/createHashedIpHandler.js +36 -0
- package/src/components/Advertising/identities/initiateAdvertisingIdentityCall.js +153 -0
- package/src/components/Advertising/index.js +109 -0
- package/src/components/Advertising/utils/advertisingCookieManager.js +92 -0
- package/src/components/Advertising/utils/helpers.js +190 -0
- package/src/components/Advertising/utils/murmurHash128GuavaHex.js +195 -0
- package/src/components/Context/createComponent.js +35 -0
- package/src/components/Context/implementationDetails.js +23 -0
- package/src/components/Context/index.js +56 -0
- package/src/components/Context/injectDevice.js +77 -0
- package/src/components/Context/injectEnvironment.js +38 -0
- package/src/components/Context/injectHighEntropyUserAgentHints.js +55 -0
- package/src/components/Context/injectOneTimeAnalyticsReferrer.js +61 -0
- package/src/components/Context/injectPlaceContext.js +38 -0
- package/src/components/Context/injectWeb.js +26 -0
- package/src/components/Personalization/constants/loggerMessage.js +14 -0
- package/src/components/Personalization/constants/scopeType.js +15 -0
- package/src/components/Personalization/constants/surface.js +16 -0
- package/src/components/Personalization/createApplyPropositions.js +136 -0
- package/src/components/Personalization/createClickStorage.js +56 -0
- package/src/components/Personalization/createComponent.js +133 -0
- package/src/components/Personalization/createFetchDataHandler.js +149 -0
- package/src/components/Personalization/createGetPageLocation.js +16 -0
- package/src/components/Personalization/createHandleConsentFlicker.js +22 -0
- package/src/components/Personalization/createInteractionStorage.js +104 -0
- package/src/components/Personalization/createNotificationHandler.js +49 -0
- package/src/components/Personalization/createOnClickHandler.js +102 -0
- package/src/components/Personalization/createOnDecisionHandler.js +98 -0
- package/src/components/Personalization/createPersonalizationDetails.js +138 -0
- package/src/components/Personalization/createSetTargetMigration.js +22 -0
- package/src/components/Personalization/createViewCacheManager.js +101 -0
- package/src/components/Personalization/createViewChangeHandler.js +53 -0
- package/src/components/Personalization/dom-actions/action.js +97 -0
- package/src/components/Personalization/dom-actions/addNonceToInlineStyleElements.js +37 -0
- package/src/components/Personalization/dom-actions/appendHtml.js +42 -0
- package/src/components/Personalization/dom-actions/clicks/collectClicks.js +89 -0
- package/src/components/Personalization/dom-actions/clicks/collectInteractions.js +113 -0
- package/src/components/Personalization/dom-actions/collectInteractions.js +15 -0
- package/src/components/Personalization/dom-actions/createPreprocess.js +21 -0
- package/src/components/Personalization/dom-actions/createRedirect.js +23 -0
- package/src/components/Personalization/dom-actions/dom/createFragment.js +18 -0
- package/src/components/Personalization/dom-actions/dom/getAttribute.js +15 -0
- package/src/components/Personalization/dom-actions/dom/getChildNodes.js +23 -0
- package/src/components/Personalization/dom-actions/dom/getChildren.js +23 -0
- package/src/components/Personalization/dom-actions/dom/getElementById.js +21 -0
- package/src/components/Personalization/dom-actions/dom/getFirstChild.js +15 -0
- package/src/components/Personalization/dom-actions/dom/getNextSibling.js +15 -0
- package/src/components/Personalization/dom-actions/dom/getNonce.js +33 -0
- package/src/components/Personalization/dom-actions/dom/getParent.js +15 -0
- package/src/components/Personalization/dom-actions/dom/helperForEq.js +22 -0
- package/src/components/Personalization/dom-actions/dom/index.js +26 -0
- package/src/components/Personalization/dom-actions/dom/insertAfter.js +26 -0
- package/src/components/Personalization/dom-actions/dom/insertBefore.js +25 -0
- package/src/components/Personalization/dom-actions/dom/isDomElement.js +13 -0
- package/src/components/Personalization/dom-actions/dom/matchesSelectorWithEq.js +37 -0
- package/src/components/Personalization/dom-actions/dom/removeAttribute.js +15 -0
- package/src/components/Personalization/dom-actions/dom/selectNodesWithEq.js +101 -0
- package/src/components/Personalization/dom-actions/dom/setAttribute.js +15 -0
- package/src/components/Personalization/dom-actions/dom/setStyle.js +23 -0
- package/src/components/Personalization/dom-actions/dom/util.js +17 -0
- package/src/components/Personalization/dom-actions/images.js +34 -0
- package/src/components/Personalization/dom-actions/index.js +13 -0
- package/src/components/Personalization/dom-actions/initDomActionsModules.js +67 -0
- package/src/components/Personalization/dom-actions/insertHtmlAfter.js +43 -0
- package/src/components/Personalization/dom-actions/insertHtmlBefore.js +40 -0
- package/src/components/Personalization/dom-actions/move.js +28 -0
- package/src/components/Personalization/dom-actions/prependHtml.js +60 -0
- package/src/components/Personalization/dom-actions/rearrangeChildren.js +34 -0
- package/src/components/Personalization/dom-actions/remapCustomCodeOffers.js +33 -0
- package/src/components/Personalization/dom-actions/remapHeadOffers.js +63 -0
- package/src/components/Personalization/dom-actions/replaceHtml.js +20 -0
- package/src/components/Personalization/dom-actions/resize.js +28 -0
- package/src/components/Personalization/dom-actions/scripts.js +106 -0
- package/src/components/Personalization/dom-actions/setAttributes.js +21 -0
- package/src/components/Personalization/dom-actions/setHtml.js +27 -0
- package/src/components/Personalization/dom-actions/setStyles.js +23 -0
- package/src/components/Personalization/dom-actions/setText.js +16 -0
- package/src/components/Personalization/dom-actions/swapImage.js +32 -0
- package/src/components/Personalization/flicker/index.js +106 -0
- package/src/components/Personalization/handlers/createDecorateProposition.js +100 -0
- package/src/components/Personalization/handlers/createProcessDomAction.js +79 -0
- package/src/components/Personalization/handlers/createProcessHtmlContent.js +60 -0
- package/src/components/Personalization/handlers/createProcessInAppMessage.js +91 -0
- package/src/components/Personalization/handlers/createProcessPropositions.js +228 -0
- package/src/components/Personalization/handlers/createProcessRedirect.js +54 -0
- package/src/components/Personalization/handlers/createRenderStatusHandler.js +62 -0
- package/src/components/Personalization/handlers/injectCreateProposition.js +121 -0
- package/src/components/Personalization/handlers/processDefaultContent.js +20 -0
- package/src/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +309 -0
- package/src/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +18 -0
- package/src/components/Personalization/in-app-message-actions/utils.js +55 -0
- package/src/components/Personalization/index.js +223 -0
- package/src/components/Personalization/utils/addRenderAttemptedToDecisions.js +15 -0
- package/src/components/Personalization/utils/createAsyncArray.js +37 -0
- package/src/components/Personalization/utils/isAuthoringModeEnabled.js +15 -0
- package/src/components/Personalization/utils/metaUtils.js +27 -0
- package/src/components/Personalization/utils/surfaceUtils.js +120 -0
- package/src/components/Personalization/validateApplyPropositionsOptions.js +56 -0
- package/src/components/PushNotifications/helpers/constants.js +16 -0
- package/src/components/PushNotifications/helpers/getPushSubscriptionDetails.js +122 -0
- package/src/components/PushNotifications/helpers/readFromIndexedDb.js +50 -0
- package/src/components/PushNotifications/helpers/saveToIndexedDb.js +64 -0
- package/src/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.js +84 -0
- package/src/components/PushNotifications/helpers/serviceWorkerPushListener.js +72 -0
- package/src/components/PushNotifications/index.js +128 -0
- package/src/components/PushNotifications/request/createSendPushSubscriptionPayload.js +66 -0
- package/src/components/PushNotifications/request/createSendPushSubscriptionRequest.js +35 -0
- package/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +98 -0
- package/src/components/PushNotifications/request/makeSendServiceWorkerTrackingData.js +154 -0
- package/src/components/PushNotifications/types.js +104 -0
- package/src/components/componentCreators.js +16 -0
- package/src/components/requiredComponentCreators.js +13 -0
- package/src/createEventListeners.js +81 -0
- package/src/index.js +14 -2
- package/src/initializeStandalone.js +34 -0
- package/src/serviceWorker.js +2 -2
- package/src/standalone.js +3 -26
- package/.browserslistrc +0 -2
- package/babel.config.js +0 -76
- package/dist/types/core/src/components/Advertising/identities/collectSurferId.d.ts +0 -2
- package/dist/types/core/src/components/PushNotifications/request/createSendPushSubscriptionRequest.d.ts +0 -6
- package/dist/types/core/src/constants/sessionDataKeys.d.ts +0 -1
- package/scripts/helpers/entryPointGeneratorBabelPlugin.js +0 -101
- /package/dist/types/{core → browser}/src/components/ActivityCollector/attachClickActivityCollector.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/configValidators.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createClickActivityStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createGetClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createInjectClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createRecallAndInjectClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createStorePageViewProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/getLinkName.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/getLinkRegion.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/activityMapExtensionEnabled.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/createTransientStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/determineLinkType.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/elementHasClickHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/extractDomain.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/findClickableElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isButtonSubmitElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isDownloadLink.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isExitLink.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isInputSubmitElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isSupportedAnchorElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isSupportedTextNode.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/hasPageName.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/isDifferentDomains.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/trimQueryFromUrl.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/truncateWhiteSpace.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/validateClickCollectionConfig.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/configValidators.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/createComponent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/handlers/clickThroughHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/handlers/createAdConversionHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/identities/collectID5Id.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/identities/collectRampId.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/utils/advertisingCookieManager.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/createComponent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/implementationDetails.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectDevice.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectEnvironment.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectHighEntropyUserAgentHints.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectOneTimeAnalyticsReferrer.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectPlaceContext.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectWeb.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/constants/loggerMessage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/constants/scopeType.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createApplyPropositions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createClickStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createComponent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createFetchDataHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createGetPageLocation.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createHandleConsentFlicker.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createInteractionStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createNotificationHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createOnClickHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createOnDecisionHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createPersonalizationDetails.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createSetTargetMigration.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createViewCacheManager.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createViewChangeHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/action.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/addNonceToInlineStyleElements.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/appendHtml.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/clicks/collectClicks.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/clicks/collectInteractions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/collectInteractions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/createPreprocess.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/createRedirect.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/createFragment.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getAttribute.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getChildNodes.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getChildren.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getElementById.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getFirstChild.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getNextSibling.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getNonce.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getParent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/helperForEq.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/insertAfter.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/insertBefore.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/matchesSelectorWithEq.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/removeAttribute.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/selectNodesWithEq.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/setAttribute.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/setStyle.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/util.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/images.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/initDomActionsModules.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/insertHtmlAfter.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/insertHtmlBefore.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/move.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/prependHtml.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/rearrangeChildren.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/remapCustomCodeOffers.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/remapHeadOffers.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/replaceHtml.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/resize.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/scripts.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/setAttributes.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/setHtml.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/setStyles.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/setText.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/swapImage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/flicker/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createDecorateProposition.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessDomAction.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessHtmlContent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessInAppMessage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessPropositions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessRedirect.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createRenderStatusHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/injectCreateProposition.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/processDefaultContent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/in-app-message-actions/actions/displayIframeContent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/in-app-message-actions/utils.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/utils/createAsyncArray.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/utils/isAuthoringModeEnabled.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/utils/metaUtils.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/validateApplyPropositionsOptions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/constants.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/getPushSubscriptionDetails.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/readFromIndexedDb.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/serviceWorkerPushListener.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/request/makeSendServiceWorkerTrackingData.d.ts +0 -0
- /package/dist/types/{core → browser}/src/createEventListeners.d.ts +0 -0
- /package/dist/types/core/src/{components/Context → utils}/injectTimestamp.d.ts +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { getNamespacedCookieName, cookieJar } from "@adobe/alloy-core/utils";
|
|
14
|
+
import createLoggingCookieJar from "@adobe/alloy-core/utils/createLoggingCookieJar.js";
|
|
15
|
+
import {
|
|
16
|
+
ADVERTISING_COOKIE_KEY,
|
|
17
|
+
DEFAULT_COOKIE_EXPIRATION_MINUTES,
|
|
18
|
+
DEFAULT_THROTTLE_MINUTES,
|
|
19
|
+
} from "../constants/index.js";
|
|
20
|
+
|
|
21
|
+
export default ({ orgId, logger }) => {
|
|
22
|
+
const loggingCookieJar = createLoggingCookieJar({ logger, cookieJar });
|
|
23
|
+
|
|
24
|
+
const getCookieName = (key, useNamespace = true) =>
|
|
25
|
+
useNamespace ? getNamespacedCookieName(orgId, key) : key;
|
|
26
|
+
|
|
27
|
+
const getDefaultExpiration = (minutes = DEFAULT_THROTTLE_MINUTES) =>
|
|
28
|
+
new Date(Date.now() + minutes * 60 * 1000);
|
|
29
|
+
|
|
30
|
+
const safeJsonParse = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
if (value?.startsWith("%7B") || value?.startsWith("{")) {
|
|
33
|
+
return JSON.parse(decodeURIComponent(value));
|
|
34
|
+
}
|
|
35
|
+
} catch {
|
|
36
|
+
// pass
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const safeJsonStringify = (value) =>
|
|
42
|
+
typeof value === "object" && value !== null
|
|
43
|
+
? encodeURIComponent(JSON.stringify(value))
|
|
44
|
+
: value;
|
|
45
|
+
|
|
46
|
+
const readCookie = (key, useNamespace = true) => {
|
|
47
|
+
try {
|
|
48
|
+
const name = getCookieName(key, useNamespace);
|
|
49
|
+
const value = loggingCookieJar.get(name);
|
|
50
|
+
return value ? safeJsonParse(value) : null;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
logger.error(`Error reading cookie: ${key}`, error);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const writeCookie = (key, value, options = {}, useNamespace = true) => {
|
|
58
|
+
try {
|
|
59
|
+
const name = getCookieName(key, useNamespace);
|
|
60
|
+
const storedValue = safeJsonStringify(value);
|
|
61
|
+
loggingCookieJar.set(name, storedValue, options);
|
|
62
|
+
return true;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
logger.error(`Error writing cookie: ${key}`, error);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const setValue = (key, value, options = {}) => {
|
|
70
|
+
const existing = readCookie(ADVERTISING_COOKIE_KEY) || {};
|
|
71
|
+
|
|
72
|
+
const updated = {
|
|
73
|
+
...existing,
|
|
74
|
+
[key]: value,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return writeCookie(ADVERTISING_COOKIE_KEY, updated, {
|
|
78
|
+
expires: getDefaultExpiration(DEFAULT_COOKIE_EXPIRATION_MINUTES),
|
|
79
|
+
...options,
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const getValue = (key) => {
|
|
84
|
+
const data = readCookie(ADVERTISING_COOKIE_KEY) || {};
|
|
85
|
+
return data[key];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
setValue,
|
|
90
|
+
getValue,
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
SKWCID_PARAM,
|
|
15
|
+
EFID_PARAM,
|
|
16
|
+
UNKNOWN_ADVERTISER,
|
|
17
|
+
LAST_CLICK_COOKIE_KEY,
|
|
18
|
+
LOG_ID_CONVERSION_SUCCESS,
|
|
19
|
+
LAST_CONVERSION_TIME_KEY,
|
|
20
|
+
DISPLAY_CLICK_COOKIE_KEY,
|
|
21
|
+
AD_CONVERSION_VIEW_EVENT_TYPE,
|
|
22
|
+
SURFER_ID,
|
|
23
|
+
HASHED_IP,
|
|
24
|
+
ID5_ID,
|
|
25
|
+
RAMP_ID,
|
|
26
|
+
DISPLAY_CLICK_COOKIE_KEY_EXPIRES,
|
|
27
|
+
} from "../constants/index.js";
|
|
28
|
+
|
|
29
|
+
import { queryString } from "@adobe/alloy-core/utils";
|
|
30
|
+
|
|
31
|
+
const getUrlParams = () => {
|
|
32
|
+
const parsedParams = queryString.parse(window.location.search);
|
|
33
|
+
return {
|
|
34
|
+
skwcid: parsedParams[SKWCID_PARAM], // "s_kwcid"
|
|
35
|
+
efid: parsedParams[EFID_PARAM], // "ef_id"
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Manages a single, ongoing asynchronous operation to prevent redundant calls.
|
|
41
|
+
* @param {string} operationName - A name for the operation for logging purposes.
|
|
42
|
+
* @param {Function} workerFn - A function that returns a Promise to be executed.
|
|
43
|
+
* @returns {Function} A function that, when called, will either start the worker or return the in-progress promise.
|
|
44
|
+
*/
|
|
45
|
+
const createManagedAsyncOperation = (operationName, workerFn) => {
|
|
46
|
+
let inProgressPromise = null;
|
|
47
|
+
|
|
48
|
+
return (...args) => {
|
|
49
|
+
if (inProgressPromise) {
|
|
50
|
+
return inProgressPromise;
|
|
51
|
+
}
|
|
52
|
+
inProgressPromise = workerFn(...args).finally(() => {
|
|
53
|
+
inProgressPromise = null;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return inProgressPromise;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Normalizes advertiser settings - extracts enabled advertiser IDs
|
|
62
|
+
* @param {Object[]} advertiserSettings - Array of advertiserSettings objects with advertiserId and enabled properties
|
|
63
|
+
* @returns {string} Comma-separated string of enabled advertiser IDs
|
|
64
|
+
*/
|
|
65
|
+
const normalizeAdvertiser = (advertiserSettings) => {
|
|
66
|
+
if (!advertiserSettings || !Array.isArray(advertiserSettings)) {
|
|
67
|
+
return UNKNOWN_ADVERTISER;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return advertiserSettings
|
|
71
|
+
.filter((item) => item && item.enabled === true && item.advertiserId)
|
|
72
|
+
.map((item) => item.advertiserId)
|
|
73
|
+
.join(", ");
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Appends AdCloud identity data to the event XDM as _experience.adcloud.stitchId.
|
|
78
|
+
* @param {{ surferId?: string, hashedIp?: string, id5Id?: string, rampId?: string, adfId?: string }} idsToInclude
|
|
79
|
+
* @param {{ mergeXdm: (xdm: Object) => void }} event
|
|
80
|
+
*/
|
|
81
|
+
const appendAdCloudIdentityToEvent = (idsToInclude, event) => {
|
|
82
|
+
const ID_SEPARATOR = "|";
|
|
83
|
+
// Order is a downstream AdCloud contract — consumers parse this string positionally.
|
|
84
|
+
// Do not reorder. adfId is a forward-looking placeholder for a future ID type; always serializes as an empty slot for now.
|
|
85
|
+
const ADCLOUD_ID_ORDER = [SURFER_ID, HASHED_IP, ID5_ID, RAMP_ID, "adfId"];
|
|
86
|
+
const concatenatedId = ADCLOUD_ID_ORDER.map(
|
|
87
|
+
(key) => idsToInclude[key] ?? "",
|
|
88
|
+
).join(ID_SEPARATOR);
|
|
89
|
+
|
|
90
|
+
event.mergeXdm({
|
|
91
|
+
_experience: {
|
|
92
|
+
adcloud: {
|
|
93
|
+
stitchId: concatenatedId,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const appendAdvertisingIdQueryToEvent = (
|
|
100
|
+
idsToInclude,
|
|
101
|
+
event,
|
|
102
|
+
cookieManager,
|
|
103
|
+
componentConfig,
|
|
104
|
+
addEventType = false,
|
|
105
|
+
) => {
|
|
106
|
+
const searchClickData = cookieManager.getValue(LAST_CLICK_COOKIE_KEY);
|
|
107
|
+
let displayClickCookie = null;
|
|
108
|
+
const displayClickCookieExpires = cookieManager.getValue(
|
|
109
|
+
DISPLAY_CLICK_COOKIE_KEY_EXPIRES,
|
|
110
|
+
);
|
|
111
|
+
if (displayClickCookieExpires && displayClickCookieExpires > Date.now()) {
|
|
112
|
+
displayClickCookie = cookieManager.getValue(DISPLAY_CLICK_COOKIE_KEY);
|
|
113
|
+
}
|
|
114
|
+
const query = {
|
|
115
|
+
advertising: {
|
|
116
|
+
...(searchClickData?.click_time && {
|
|
117
|
+
lastSearchClick: searchClickData.click_time,
|
|
118
|
+
}),
|
|
119
|
+
...(displayClickCookie && {
|
|
120
|
+
lastDisplayClick: displayClickCookie,
|
|
121
|
+
}),
|
|
122
|
+
stitchIds: {
|
|
123
|
+
...(idsToInclude[SURFER_ID] && {
|
|
124
|
+
surferId: idsToInclude[SURFER_ID],
|
|
125
|
+
}),
|
|
126
|
+
...(idsToInclude[ID5_ID] && { id5: idsToInclude[ID5_ID] }),
|
|
127
|
+
...(idsToInclude[RAMP_ID] && { rampIdEnv: idsToInclude[RAMP_ID] }),
|
|
128
|
+
...(idsToInclude[HASHED_IP] && {
|
|
129
|
+
hashedIp: idsToInclude[HASHED_IP],
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
advIds: normalizeAdvertiser(componentConfig.advertiserSettings),
|
|
133
|
+
...(addEventType && { eventType: AD_CONVERSION_VIEW_EVENT_TYPE }),
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
event.mergeQuery(query);
|
|
138
|
+
return event;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const isAnyIdUnused = (availableIds, conversionCalled) => {
|
|
142
|
+
return Object.entries(availableIds).some(([idType]) => {
|
|
143
|
+
return !conversionCalled[idType];
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const markIdsAsConverted = (
|
|
148
|
+
idTypes,
|
|
149
|
+
conversionCalled,
|
|
150
|
+
cookieManager,
|
|
151
|
+
logger,
|
|
152
|
+
) => {
|
|
153
|
+
const now = Date.now();
|
|
154
|
+
|
|
155
|
+
idTypes.forEach((idType) => {
|
|
156
|
+
conversionCalled[idType] = true;
|
|
157
|
+
cookieManager.setValue(`${idType}_last_conversion`, now);
|
|
158
|
+
logger.info(LOG_ID_CONVERSION_SUCCESS.replace("{0}", idType));
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
cookieManager.setValue(LAST_CONVERSION_TIME_KEY, now);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const isThrottled = (idType, cookieManager) => {
|
|
165
|
+
const now = Date.now();
|
|
166
|
+
const THROTTLE_WINDOW = 30 * 60 * 1000; // 30 minutes
|
|
167
|
+
const lastSuccessfulConversion = cookieManager.getValue(
|
|
168
|
+
`${idType}_last_conversion`,
|
|
169
|
+
);
|
|
170
|
+
return Boolean(
|
|
171
|
+
lastSuccessfulConversion &&
|
|
172
|
+
now - lastSuccessfulConversion < THROTTLE_WINDOW,
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const shouldThrottle = (idType, cookieManager) => {
|
|
177
|
+
return isThrottled(idType, cookieManager);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export {
|
|
181
|
+
getUrlParams,
|
|
182
|
+
normalizeAdvertiser,
|
|
183
|
+
createManagedAsyncOperation,
|
|
184
|
+
appendAdvertisingIdQueryToEvent,
|
|
185
|
+
appendAdCloudIdentityToEvent,
|
|
186
|
+
isAnyIdUnused,
|
|
187
|
+
markIdsAsConverted,
|
|
188
|
+
isThrottled,
|
|
189
|
+
shouldThrottle,
|
|
190
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/* eslint-disable no-bitwise */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* MurmurHash3 128-bit (x64) — matches Guava
|
|
17
|
+
* `com.google.common.hash.Hashing.murmur3_128(seed).hashString(str, UTF_8).toString()`.
|
|
18
|
+
*
|
|
19
|
+
* Implementation follows Guava’s `Murmur3_128HashFunction` (same as smhasher
|
|
20
|
+
* `MurmurHash3_x64_128` with Guava’s seeding and byte order for `HashCode.toString()`).
|
|
21
|
+
*
|
|
22
|
+
* @see https://github.com/google/guava/blob/master/guava/src/com/google/common/hash/Murmur3_128HashFunction.java
|
|
23
|
+
*
|
|
24
|
+
* Returns **32** lowercase hex characters (128 bits).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const U64 = 0xffffffffffffffffn;
|
|
28
|
+
|
|
29
|
+
const rotl64 = (x, r) => ((x << BigInt(r)) | (x >> BigInt(64 - r))) & U64;
|
|
30
|
+
|
|
31
|
+
const u8 = (b) => BigInt(b & 0xff);
|
|
32
|
+
|
|
33
|
+
const readInt64LE = (bytes, offset) => {
|
|
34
|
+
let v = 0n;
|
|
35
|
+
for (let i = 0; i < 8; i += 1) {
|
|
36
|
+
v |= u8(bytes[offset + i]) << (8n * BigInt(i));
|
|
37
|
+
}
|
|
38
|
+
return v & U64;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const C1 = 0x87c37b91114253d5n;
|
|
42
|
+
const C2 = 0x4cf5ad432745937fn;
|
|
43
|
+
|
|
44
|
+
const mixK1 = (k1) => {
|
|
45
|
+
let k = k1 & U64;
|
|
46
|
+
k = (k * C1) & U64;
|
|
47
|
+
k = rotl64(k, 31);
|
|
48
|
+
k = (k * C2) & U64;
|
|
49
|
+
return k;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const mixK2 = (k2) => {
|
|
53
|
+
let k = k2 & U64;
|
|
54
|
+
k = (k * C2) & U64;
|
|
55
|
+
k = rotl64(k, 33);
|
|
56
|
+
k = (k * C1) & U64;
|
|
57
|
+
return k;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const fmix64 = (k) => {
|
|
61
|
+
let x = k & U64;
|
|
62
|
+
x ^= x >> 33n;
|
|
63
|
+
x = (x * 0xff51afd7ed558ccdn) & U64;
|
|
64
|
+
x ^= x >> 33n;
|
|
65
|
+
x = (x * 0xc4ceb9fe1a85ec53n) & U64;
|
|
66
|
+
x ^= x >> 33n;
|
|
67
|
+
return x & U64;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** Java `int` seed sign-extended to 64-bit (Guava `Murmur3_128Hasher` initial state). */
|
|
71
|
+
const intSeedToLong64 = (seed) =>
|
|
72
|
+
BigInt.asIntN(64, BigInt.asIntN(32, BigInt(Math.trunc(Number(seed)))));
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 128-bit MurmurHash3 (Guava-compatible), lowercase hex, no `0x` prefix.
|
|
76
|
+
* @param {string} str - hashed as UTF-8 bytes
|
|
77
|
+
* @param {number} [seed=0] - 32-bit seed (Guava `murmur3_128(int seed)`)
|
|
78
|
+
* @returns {string} 32 hex characters
|
|
79
|
+
*/
|
|
80
|
+
export const murmurHash128GuavaHex = (str, seed = 0) => {
|
|
81
|
+
// Match Java long bit pattern for (long) int seed (e.g. -1 → 0xff…ff)
|
|
82
|
+
const hSeed = intSeedToLong64(seed) & U64;
|
|
83
|
+
let h1 = hSeed;
|
|
84
|
+
let h2 = hSeed;
|
|
85
|
+
let length = 0;
|
|
86
|
+
|
|
87
|
+
const bytes = new TextEncoder().encode(str);
|
|
88
|
+
|
|
89
|
+
const bmix64 = (k1, k2) => {
|
|
90
|
+
h1 ^= mixK1(k1);
|
|
91
|
+
h1 = rotl64(h1, 27);
|
|
92
|
+
h1 = (h1 + h2) & U64;
|
|
93
|
+
h1 = (h1 * 5n + 0x52dce729n) & U64;
|
|
94
|
+
|
|
95
|
+
h2 ^= mixK2(k2);
|
|
96
|
+
h2 = rotl64(h2, 31);
|
|
97
|
+
h2 = (h2 + h1) & U64;
|
|
98
|
+
h2 = (h2 * 5n + 0x38495ab5n) & U64;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
let offset = 0;
|
|
102
|
+
const nblocks = Math.floor(bytes.length / 16);
|
|
103
|
+
for (let i = 0; i < nblocks; i += 1) {
|
|
104
|
+
bmix64(readInt64LE(bytes, offset), readInt64LE(bytes, offset + 8));
|
|
105
|
+
offset += 16;
|
|
106
|
+
length += 16;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const rem = bytes.length - offset;
|
|
110
|
+
length += rem;
|
|
111
|
+
let k1 = 0n;
|
|
112
|
+
let k2 = 0n;
|
|
113
|
+
const t = offset;
|
|
114
|
+
|
|
115
|
+
switch (rem) {
|
|
116
|
+
case 15:
|
|
117
|
+
k2 ^= u8(bytes[t + 14]) << 48n;
|
|
118
|
+
// falls through
|
|
119
|
+
case 14:
|
|
120
|
+
k2 ^= u8(bytes[t + 13]) << 40n;
|
|
121
|
+
// falls through
|
|
122
|
+
case 13:
|
|
123
|
+
k2 ^= u8(bytes[t + 12]) << 32n;
|
|
124
|
+
// falls through
|
|
125
|
+
case 12:
|
|
126
|
+
k2 ^= u8(bytes[t + 11]) << 24n;
|
|
127
|
+
// falls through
|
|
128
|
+
case 11:
|
|
129
|
+
k2 ^= u8(bytes[t + 10]) << 16n;
|
|
130
|
+
// falls through
|
|
131
|
+
case 10:
|
|
132
|
+
k2 ^= u8(bytes[t + 9]) << 8n;
|
|
133
|
+
// falls through
|
|
134
|
+
case 9:
|
|
135
|
+
k2 ^= u8(bytes[t + 8]);
|
|
136
|
+
// falls through
|
|
137
|
+
case 8:
|
|
138
|
+
k1 ^= readInt64LE(bytes, t);
|
|
139
|
+
break;
|
|
140
|
+
case 7:
|
|
141
|
+
k1 ^= u8(bytes[t + 6]) << 48n;
|
|
142
|
+
// falls through
|
|
143
|
+
case 6:
|
|
144
|
+
k1 ^= u8(bytes[t + 5]) << 40n;
|
|
145
|
+
// falls through
|
|
146
|
+
case 5:
|
|
147
|
+
k1 ^= u8(bytes[t + 4]) << 32n;
|
|
148
|
+
// falls through
|
|
149
|
+
case 4:
|
|
150
|
+
k1 ^= u8(bytes[t + 3]) << 24n;
|
|
151
|
+
// falls through
|
|
152
|
+
case 3:
|
|
153
|
+
k1 ^= u8(bytes[t + 2]) << 16n;
|
|
154
|
+
// falls through
|
|
155
|
+
case 2:
|
|
156
|
+
k1 ^= u8(bytes[t + 1]) << 8n;
|
|
157
|
+
// falls through
|
|
158
|
+
case 1:
|
|
159
|
+
k1 ^= u8(bytes[t]);
|
|
160
|
+
break;
|
|
161
|
+
default:
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
h1 ^= mixK1(k1);
|
|
166
|
+
h2 ^= mixK2(k2);
|
|
167
|
+
|
|
168
|
+
const len64 = BigInt(length >>> 0);
|
|
169
|
+
h1 ^= len64;
|
|
170
|
+
h2 ^= len64;
|
|
171
|
+
|
|
172
|
+
h1 = (h1 + h2) & U64;
|
|
173
|
+
h2 = (h2 + h1) & U64;
|
|
174
|
+
|
|
175
|
+
h1 = fmix64(h1);
|
|
176
|
+
h2 = fmix64(h2);
|
|
177
|
+
|
|
178
|
+
h1 = (h1 + h2) & U64;
|
|
179
|
+
h2 = (h2 + h1) & U64;
|
|
180
|
+
|
|
181
|
+
const out = new Uint8Array(16);
|
|
182
|
+
const writeLongLE = (val, pos) => {
|
|
183
|
+
let v = val & U64;
|
|
184
|
+
for (let i = 0; i < 8; i += 1) {
|
|
185
|
+
out[pos + i] = Number(v & 0xffn);
|
|
186
|
+
v >>= 8n;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
writeLongLE(h1, 0);
|
|
190
|
+
writeLongLE(h2, 8);
|
|
191
|
+
|
|
192
|
+
return [...out].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export default murmurHash128GuavaHex;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2019 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export default (config, logger, optionalContexts, requiredContexts) => {
|
|
13
|
+
const configuredContexts = config.context;
|
|
14
|
+
|
|
15
|
+
const contexts = configuredContexts
|
|
16
|
+
.flatMap((context, i) => {
|
|
17
|
+
if (optionalContexts[context]) {
|
|
18
|
+
return [optionalContexts[context]];
|
|
19
|
+
}
|
|
20
|
+
logger.warn(`Invalid context[${i}]: '${context}' is not available.`);
|
|
21
|
+
return [];
|
|
22
|
+
})
|
|
23
|
+
.concat(requiredContexts);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
namespace: "Context",
|
|
27
|
+
lifecycle: {
|
|
28
|
+
onBeforeEvent({ event }) {
|
|
29
|
+
return Promise.all(
|
|
30
|
+
contexts.map((context) => Promise.resolve(context(event, logger))),
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2019 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import libraryName from "@adobe/alloy-core/constants/libraryName.js";
|
|
13
|
+
import libraryVersion from "@adobe/alloy-core/constants/libraryVersion.js";
|
|
14
|
+
|
|
15
|
+
export default (event) => {
|
|
16
|
+
event.mergeXdm({
|
|
17
|
+
implementationDetails: {
|
|
18
|
+
name: libraryName,
|
|
19
|
+
version: libraryVersion,
|
|
20
|
+
environment: "browser",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2019 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import injectWeb from "./injectWeb.js";
|
|
14
|
+
import injectDevice from "./injectDevice.js";
|
|
15
|
+
import injectEnvironment from "./injectEnvironment.js";
|
|
16
|
+
import injectPlaceContext from "./injectPlaceContext.js";
|
|
17
|
+
import injectTimestamp from "@adobe/alloy-core/utils/injectTimestamp.js";
|
|
18
|
+
import implementationDetails from "./implementationDetails.js";
|
|
19
|
+
import createComponent from "./createComponent.js";
|
|
20
|
+
import injectHighEntropyUserAgentHints from "./injectHighEntropyUserAgentHints.js";
|
|
21
|
+
import injectOneTimeAnalyticsReferrer from "./injectOneTimeAnalyticsReferrer.js";
|
|
22
|
+
import { arrayOf, objectOf, string } from "@adobe/alloy-core/utils/validation";
|
|
23
|
+
|
|
24
|
+
const web = injectWeb(window);
|
|
25
|
+
const device = injectDevice(window);
|
|
26
|
+
const environment = injectEnvironment(window);
|
|
27
|
+
const placeContext = injectPlaceContext(() => new Date());
|
|
28
|
+
const timestamp = injectTimestamp(() => new Date());
|
|
29
|
+
const highEntropyUserAgentHints = injectHighEntropyUserAgentHints(navigator);
|
|
30
|
+
const oneTimeAnalyticsReferrer = injectOneTimeAnalyticsReferrer(window);
|
|
31
|
+
|
|
32
|
+
const defaultEnabledContexts = {
|
|
33
|
+
web,
|
|
34
|
+
device,
|
|
35
|
+
environment,
|
|
36
|
+
placeContext,
|
|
37
|
+
};
|
|
38
|
+
const defaultDisabledContexts = {
|
|
39
|
+
highEntropyUserAgentHints,
|
|
40
|
+
oneTimeAnalyticsReferrer,
|
|
41
|
+
};
|
|
42
|
+
const optionalContexts = {
|
|
43
|
+
...defaultEnabledContexts,
|
|
44
|
+
...defaultDisabledContexts,
|
|
45
|
+
};
|
|
46
|
+
const requiredContexts = [timestamp, implementationDetails];
|
|
47
|
+
|
|
48
|
+
const createContext = ({ config, logger }) => {
|
|
49
|
+
return createComponent(config, logger, optionalContexts, requiredContexts);
|
|
50
|
+
};
|
|
51
|
+
createContext.namespace = "Context";
|
|
52
|
+
createContext.configValidators = objectOf({
|
|
53
|
+
context: arrayOf(string()).default(Object.keys(defaultEnabledContexts)),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export default createContext;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2019 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { isFunction, toInteger } from "@adobe/alloy-core/utils";
|
|
14
|
+
|
|
15
|
+
const getScreenOrientationViaProperty = (window) => {
|
|
16
|
+
const {
|
|
17
|
+
screen: { orientation },
|
|
18
|
+
} = window;
|
|
19
|
+
|
|
20
|
+
if (orientation == null || orientation.type == null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const parts = orientation.type.split("-");
|
|
25
|
+
|
|
26
|
+
if (parts.length === 0) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (parts[0] !== "portrait" && parts[0] !== "landscape") {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return parts[0];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const getScreenOrientationViaMediaQuery = (window) => {
|
|
38
|
+
if (isFunction(window.matchMedia)) {
|
|
39
|
+
if (window.matchMedia("(orientation: portrait)").matches) {
|
|
40
|
+
return "portrait";
|
|
41
|
+
}
|
|
42
|
+
if (window.matchMedia("(orientation: landscape)").matches) {
|
|
43
|
+
return "landscape";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default (window) => {
|
|
51
|
+
return (event) => {
|
|
52
|
+
const {
|
|
53
|
+
screen: { width, height },
|
|
54
|
+
} = window;
|
|
55
|
+
const device = {};
|
|
56
|
+
|
|
57
|
+
const screenHeight = toInteger(height);
|
|
58
|
+
if (screenHeight >= 0) {
|
|
59
|
+
device.screenHeight = screenHeight;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const screenWidth = toInteger(width);
|
|
63
|
+
if (screenWidth >= 0) {
|
|
64
|
+
device.screenWidth = screenWidth;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const orientation =
|
|
68
|
+
getScreenOrientationViaProperty(window) ||
|
|
69
|
+
getScreenOrientationViaMediaQuery(window);
|
|
70
|
+
if (orientation) {
|
|
71
|
+
device.screenOrientation = orientation;
|
|
72
|
+
}
|
|
73
|
+
if (Object.keys(device).length > 0) {
|
|
74
|
+
event.mergeXdm({ device });
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|