@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,265 @@
|
|
|
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 { loadScript } from "@adobe/alloy-core/utils/dom";
|
|
14
|
+
import { RAMP_ID, RAMP_ID_EXPIRES } from "../constants/index.js";
|
|
15
|
+
|
|
16
|
+
const RETRY_CONFIG = {
|
|
17
|
+
MAX_COUNT: 15,
|
|
18
|
+
MAX_TIME_MS: 30000,
|
|
19
|
+
DELAY_BASE_MS: 500,
|
|
20
|
+
MAX_DELAY_MS: 5000,
|
|
21
|
+
SHORT_TIMEOUT_MS: 2000,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const state = {
|
|
25
|
+
rampIdEnv: undefined,
|
|
26
|
+
rampIdCallInitiated: false,
|
|
27
|
+
inProgressRampIdPromise: null,
|
|
28
|
+
scriptLoadingInitiated: false,
|
|
29
|
+
envelopeRetrievalInProgress: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const processEnvelope = (envelope, resolve, cookieManager, logger) => {
|
|
33
|
+
let parsedEnvelope;
|
|
34
|
+
try {
|
|
35
|
+
parsedEnvelope = JSON.parse(envelope).envelope;
|
|
36
|
+
} catch {
|
|
37
|
+
parsedEnvelope = envelope;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (parsedEnvelope && !state.rampIdCallInitiated) {
|
|
41
|
+
state.rampIdCallInitiated = true;
|
|
42
|
+
state.rampIdEnv = parsedEnvelope;
|
|
43
|
+
state.envelopeRetrievalInProgress = false;
|
|
44
|
+
state.inProgressRampIdPromise = null;
|
|
45
|
+
cookieManager.setValue(RAMP_ID, state.rampIdEnv);
|
|
46
|
+
cookieManager.setValue(RAMP_ID_EXPIRES, Date.now() + 48 * 60 * 60 * 1000); //expires in 48 hours
|
|
47
|
+
resolve(state.rampIdEnv);
|
|
48
|
+
} else {
|
|
49
|
+
logger.warn("Invalid RampID envelope received", {
|
|
50
|
+
envelope: parsedEnvelope,
|
|
51
|
+
});
|
|
52
|
+
state.envelopeRetrievalInProgress = false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const retrieveEnvelopeWithRetries = (
|
|
57
|
+
resolve,
|
|
58
|
+
reject,
|
|
59
|
+
cookieManager,
|
|
60
|
+
logger,
|
|
61
|
+
) => {
|
|
62
|
+
let retryCount = RETRY_CONFIG.MAX_COUNT;
|
|
63
|
+
let timerMultiplier = 1;
|
|
64
|
+
let totalElapsedTime = 0;
|
|
65
|
+
|
|
66
|
+
const tryToRetrieve = () => {
|
|
67
|
+
if (state.rampIdEnv) return;
|
|
68
|
+
|
|
69
|
+
if (totalElapsedTime > RETRY_CONFIG.MAX_TIME_MS) {
|
|
70
|
+
logger.error("Maximum retry time exceeded");
|
|
71
|
+
state.envelopeRetrievalInProgress = false;
|
|
72
|
+
reject(new Error("Failed to retrieve RampID - timeout"));
|
|
73
|
+
state.inProgressRampIdPromise = null;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (retryCount === 0) {
|
|
78
|
+
logger.error("Maximum retries exceeded");
|
|
79
|
+
state.envelopeRetrievalInProgress = false;
|
|
80
|
+
reject(new Error("Failed to retrieve RampID after maximum retries"));
|
|
81
|
+
state.inProgressRampIdPromise = null;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const delay = Math.min(
|
|
86
|
+
RETRY_CONFIG.DELAY_BASE_MS * timerMultiplier,
|
|
87
|
+
RETRY_CONFIG.MAX_DELAY_MS,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
totalElapsedTime += delay;
|
|
92
|
+
retryCount -= 1;
|
|
93
|
+
timerMultiplier += 1;
|
|
94
|
+
|
|
95
|
+
if (
|
|
96
|
+
typeof window.ats !== "undefined" &&
|
|
97
|
+
window.ats !== null &&
|
|
98
|
+
!state.rampIdEnv &&
|
|
99
|
+
!state.envelopeRetrievalInProgress
|
|
100
|
+
) {
|
|
101
|
+
state.envelopeRetrievalInProgress = true;
|
|
102
|
+
window.ats.retrieveEnvelope().then(
|
|
103
|
+
(rampIdResponse) => {
|
|
104
|
+
processEnvelope(rampIdResponse, resolve, cookieManager, logger);
|
|
105
|
+
if (!state.rampIdEnv) tryToRetrieve();
|
|
106
|
+
},
|
|
107
|
+
() => {
|
|
108
|
+
logger.warn("Failed to retrieve envelope");
|
|
109
|
+
state.envelopeRetrievalInProgress = false;
|
|
110
|
+
tryToRetrieve();
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
} else {
|
|
114
|
+
tryToRetrieve();
|
|
115
|
+
}
|
|
116
|
+
}, delay);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
tryToRetrieve();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const initiateRampIDCall = (
|
|
123
|
+
rampIdScriptPath,
|
|
124
|
+
cookieManager,
|
|
125
|
+
logger,
|
|
126
|
+
useShortTimeout = false,
|
|
127
|
+
) => {
|
|
128
|
+
if (state.inProgressRampIdPromise) {
|
|
129
|
+
return state.inProgressRampIdPromise;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const timeoutMs = useShortTimeout
|
|
133
|
+
? RETRY_CONFIG.SHORT_TIMEOUT_MS
|
|
134
|
+
: RETRY_CONFIG.MAX_TIME_MS;
|
|
135
|
+
|
|
136
|
+
let timedOut = false;
|
|
137
|
+
|
|
138
|
+
const mainPromise = new Promise((resolve, reject) => {
|
|
139
|
+
loadScript(rampIdScriptPath, {
|
|
140
|
+
onLoad: () => {
|
|
141
|
+
if (
|
|
142
|
+
typeof window.ats !== "undefined" &&
|
|
143
|
+
!state.envelopeRetrievalInProgress
|
|
144
|
+
) {
|
|
145
|
+
state.envelopeRetrievalInProgress = true;
|
|
146
|
+
window.ats
|
|
147
|
+
.retrieveEnvelope()
|
|
148
|
+
.then((envelopeResponse) => {
|
|
149
|
+
if (envelopeResponse) {
|
|
150
|
+
if (!timedOut) {
|
|
151
|
+
processEnvelope(
|
|
152
|
+
envelopeResponse,
|
|
153
|
+
resolve,
|
|
154
|
+
cookieManager,
|
|
155
|
+
logger,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
state.envelopeRetrievalInProgress = false;
|
|
160
|
+
window.addEventListener("lrEnvelopePresent", () => {
|
|
161
|
+
if (state.envelopeRetrievalInProgress || timedOut) return;
|
|
162
|
+
state.envelopeRetrievalInProgress = true;
|
|
163
|
+
window.ats.retrieveEnvelope().then(
|
|
164
|
+
(envelopeResult) => {
|
|
165
|
+
if (!timedOut) {
|
|
166
|
+
processEnvelope(
|
|
167
|
+
envelopeResult,
|
|
168
|
+
resolve,
|
|
169
|
+
cookieManager,
|
|
170
|
+
logger,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
(error) => {
|
|
175
|
+
if (!timedOut) {
|
|
176
|
+
logger.error(
|
|
177
|
+
"Failed to retrieve envelope after event",
|
|
178
|
+
error,
|
|
179
|
+
);
|
|
180
|
+
state.envelopeRetrievalInProgress = false;
|
|
181
|
+
reject(error);
|
|
182
|
+
state.inProgressRampIdPromise = null;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
.catch((error) => {
|
|
190
|
+
if (!timedOut) {
|
|
191
|
+
logger.error("Error retrieving envelope", error);
|
|
192
|
+
state.envelopeRetrievalInProgress = false;
|
|
193
|
+
reject(error);
|
|
194
|
+
state.inProgressRampIdPromise = null;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
retrieveEnvelopeWithRetries(
|
|
200
|
+
(val) => {
|
|
201
|
+
if (!timedOut) resolve(val);
|
|
202
|
+
},
|
|
203
|
+
(err) => {
|
|
204
|
+
if (!timedOut) reject(err);
|
|
205
|
+
},
|
|
206
|
+
cookieManager,
|
|
207
|
+
logger,
|
|
208
|
+
);
|
|
209
|
+
},
|
|
210
|
+
onError: (error) => {
|
|
211
|
+
if (!timedOut) {
|
|
212
|
+
reject(error);
|
|
213
|
+
}
|
|
214
|
+
state.inProgressRampIdPromise = null;
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
220
|
+
setTimeout(() => {
|
|
221
|
+
timedOut = true;
|
|
222
|
+
resolve(null);
|
|
223
|
+
}, timeoutMs);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
state.inProgressRampIdPromise = Promise.race([
|
|
227
|
+
mainPromise,
|
|
228
|
+
timeoutPromise,
|
|
229
|
+
]).finally(() => {
|
|
230
|
+
state.inProgressRampIdPromise = null;
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
return state.inProgressRampIdPromise;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const getRampId = (
|
|
237
|
+
logger,
|
|
238
|
+
rampIdScriptPath,
|
|
239
|
+
cookieManager,
|
|
240
|
+
resolveRampIdIfNotAvailable = true,
|
|
241
|
+
useShortTimeout = false,
|
|
242
|
+
) => {
|
|
243
|
+
if (state.rampIdEnv) {
|
|
244
|
+
return Promise.resolve(state.rampIdEnv);
|
|
245
|
+
}
|
|
246
|
+
if (cookieManager) {
|
|
247
|
+
const rampIdFromCookie = cookieManager.getValue(RAMP_ID);
|
|
248
|
+
const rampIdExpires = cookieManager.getValue(RAMP_ID_EXPIRES);
|
|
249
|
+
if (rampIdFromCookie && rampIdExpires && rampIdExpires > Date.now()) {
|
|
250
|
+
state.rampIdEnv = rampIdFromCookie;
|
|
251
|
+
return Promise.resolve(rampIdFromCookie);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (!resolveRampIdIfNotAvailable || rampIdScriptPath == null) {
|
|
255
|
+
return Promise.resolve(null);
|
|
256
|
+
}
|
|
257
|
+
return initiateRampIDCall(
|
|
258
|
+
rampIdScriptPath,
|
|
259
|
+
cookieManager,
|
|
260
|
+
logger,
|
|
261
|
+
useShortTimeout,
|
|
262
|
+
);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export { getRampId, initiateRampIDCall };
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
DISPLAY_CLICK_COOKIE_KEY,
|
|
15
|
+
SURFER_ID,
|
|
16
|
+
DISPLAY_CLICK_COOKIE_KEY_EXPIRES,
|
|
17
|
+
} from "../constants/index.js";
|
|
18
|
+
import { injectAreThirdPartyCookiesSupportedByDefault } from "@adobe/alloy-core/utils";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Factory for surferId collection. Cache lives at closure scope — no module-level state.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} deps
|
|
24
|
+
* @param {Function} deps.initiateAdvertisingIdentityCall
|
|
25
|
+
* @param {Object} deps.cookieManager
|
|
26
|
+
* @param {Function} deps.getBrowser
|
|
27
|
+
* @returns {Function} collectSurferId(useShortTimeout?)
|
|
28
|
+
*/
|
|
29
|
+
const createCollectSurferId = ({
|
|
30
|
+
initiateAdvertisingIdentityCall,
|
|
31
|
+
cookieManager,
|
|
32
|
+
getBrowser,
|
|
33
|
+
}) => {
|
|
34
|
+
let cachedSurferId = cookieManager.getValue(SURFER_ID) || "";
|
|
35
|
+
|
|
36
|
+
return (resolveSurferIdIfNotAvailable = true) => {
|
|
37
|
+
if (cachedSurferId) {
|
|
38
|
+
return Promise.resolve(cachedSurferId);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!resolveSurferIdIfNotAvailable) {
|
|
42
|
+
return Promise.resolve(null);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return initiateAdvertisingIdentityCall().then((resolvedId) => {
|
|
46
|
+
const areThirdPartyCookiesSupported =
|
|
47
|
+
!getBrowser ||
|
|
48
|
+
injectAreThirdPartyCookiesSupportedByDefault({ getBrowser })();
|
|
49
|
+
|
|
50
|
+
if (resolvedId && areThirdPartyCookiesSupported) {
|
|
51
|
+
if (resolvedId.surferId) {
|
|
52
|
+
cachedSurferId = resolvedId.surferId;
|
|
53
|
+
cookieManager.setValue(SURFER_ID, resolvedId.surferId);
|
|
54
|
+
}
|
|
55
|
+
if (resolvedId.displayClickCookie) {
|
|
56
|
+
cookieManager.setValue(
|
|
57
|
+
DISPLAY_CLICK_COOKIE_KEY,
|
|
58
|
+
resolvedId.displayClickCookie,
|
|
59
|
+
);
|
|
60
|
+
cookieManager.setValue(
|
|
61
|
+
DISPLAY_CLICK_COOKIE_KEY_EXPIRES,
|
|
62
|
+
Date.now() + 15 * 60 * 1000,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return areThirdPartyCookiesSupported ? resolvedId.surferId : null;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default createCollectSurferId;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 murmurHash128GuavaHex from "../utils/murmurHash128GuavaHex.js";
|
|
14
|
+
import { HASHED_IP_ADDR } from "../constants/index.js";
|
|
15
|
+
|
|
16
|
+
export default ({ cookieManager, hash = murmurHash128GuavaHex }) => {
|
|
17
|
+
let cached = cookieManager.getValue(HASHED_IP_ADDR) || "";
|
|
18
|
+
|
|
19
|
+
const captureFromIframe = (clientIp) => {
|
|
20
|
+
if (!clientIp) return;
|
|
21
|
+
cached = hash(clientIp);
|
|
22
|
+
cookieManager.setValue(HASHED_IP_ADDR, cached);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
captureFromIframe,
|
|
27
|
+
get: () => cached,
|
|
28
|
+
collect: (initiateCallFn) => {
|
|
29
|
+
if (cached) return Promise.resolve(cached);
|
|
30
|
+
return initiateCallFn().then((result) => {
|
|
31
|
+
captureFromIframe(result.clientIp);
|
|
32
|
+
return cached;
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
DISPLAY_CLICK_COOKIE_KEY,
|
|
15
|
+
SURFER_PIXEL_HOST,
|
|
16
|
+
SURFER_USER_ID,
|
|
17
|
+
SURFER_TIMEOUT_MS,
|
|
18
|
+
SURFER_TRUSTED_ORIGIN,
|
|
19
|
+
SURFER_PARAM_KEY,
|
|
20
|
+
SURFER_IP,
|
|
21
|
+
} from "../constants/index.js";
|
|
22
|
+
import {
|
|
23
|
+
appendNode,
|
|
24
|
+
awaitSelector,
|
|
25
|
+
createNode,
|
|
26
|
+
} from "@adobe/alloy-core/utils/dom/index.js";
|
|
27
|
+
import { BODY } from "@adobe/alloy-core/constants/tagName.js";
|
|
28
|
+
|
|
29
|
+
const IFRAME_PROPS = {
|
|
30
|
+
height: 0,
|
|
31
|
+
width: 0,
|
|
32
|
+
frameBorder: 0,
|
|
33
|
+
style: { display: "none" },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a shared advertising identity caller. Both the SurferID and hashed-IP
|
|
38
|
+
* flows call this so the pixel iframe is only loaded once per page per request.
|
|
39
|
+
*
|
|
40
|
+
* @param {Object} [deps]
|
|
41
|
+
* @param {Function} [deps.appendNode]
|
|
42
|
+
* @param {Function} [deps.awaitSelector]
|
|
43
|
+
* @param {Function} [deps.createNode]
|
|
44
|
+
* @returns {Function} initiateAdvertisingIdentityCall
|
|
45
|
+
*/
|
|
46
|
+
export const createInitiateAdvertisingIdentityCall = ({
|
|
47
|
+
appendNode: appendNodeFn = appendNode,
|
|
48
|
+
awaitSelector: awaitSelectorFn = awaitSelector,
|
|
49
|
+
createNode: createNodeFn = createNode,
|
|
50
|
+
} = {}) => {
|
|
51
|
+
let inProgressPromise = null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Initiates the advertising identity iframe request. Shared by SurferID
|
|
55
|
+
* and hashed-IP flows so the pixel is only loaded once per page.
|
|
56
|
+
* `clientIp` is the raw IP — hashing is the caller's responsibility
|
|
57
|
+
* (see createHashedIpHandler).
|
|
58
|
+
* @returns {Promise<{ surferId: string|null, displayClickCookie: string|null, clientIp: string }>}
|
|
59
|
+
*/
|
|
60
|
+
return () => {
|
|
61
|
+
if (inProgressPromise) {
|
|
62
|
+
return inProgressPromise;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
inProgressPromise = new Promise((resolve, reject) => {
|
|
66
|
+
const scheme =
|
|
67
|
+
document.location.protocol === "https:" ? "https:" : "http:";
|
|
68
|
+
|
|
69
|
+
const nestedParams = new URLSearchParams({
|
|
70
|
+
google: "__EFGCK__",
|
|
71
|
+
gsurfer: "__EFGSURFER__",
|
|
72
|
+
imsId: "__EFIMSORGID__",
|
|
73
|
+
is_fb_cookie_synced: "__EFFB__",
|
|
74
|
+
optout: "__EFOPTOUT__",
|
|
75
|
+
throttleCookie: "__EFSYNC__",
|
|
76
|
+
time: "__EFTIME__",
|
|
77
|
+
ev_lcc: "__LCC__",
|
|
78
|
+
clientIp: "__EFREMOTEADDR__",
|
|
79
|
+
});
|
|
80
|
+
const nestedUrl = `${scheme}//www.everestjs.net/static/pixel_details.html#${nestedParams.toString()}`;
|
|
81
|
+
|
|
82
|
+
const mainParams = new URLSearchParams({
|
|
83
|
+
ev_gb: "0",
|
|
84
|
+
url: nestedUrl,
|
|
85
|
+
});
|
|
86
|
+
const pixelDetailsUrl = `${scheme}//${SURFER_PIXEL_HOST}/${SURFER_USER_ID}/gr?${mainParams.toString()}`;
|
|
87
|
+
|
|
88
|
+
const iframeElement = createNodeFn(
|
|
89
|
+
"iframe",
|
|
90
|
+
{ src: pixelDetailsUrl },
|
|
91
|
+
IFRAME_PROPS,
|
|
92
|
+
[],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
let timeoutId;
|
|
96
|
+
|
|
97
|
+
// Single cleanup — called on every exit path (success, no-hash, error, timeout)
|
|
98
|
+
// so the listener and timer never leak.
|
|
99
|
+
const pixelDetailsReceiver = (message) => {
|
|
100
|
+
if (!message.origin.includes(SURFER_TRUSTED_ORIGIN)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
clearTimeout(timeoutId);
|
|
105
|
+
window.removeEventListener("message", pixelDetailsReceiver, false);
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
const pixelRedirectUri = message.data;
|
|
109
|
+
const hashIndex = pixelRedirectUri.indexOf("#");
|
|
110
|
+
|
|
111
|
+
if (hashIndex === -1) {
|
|
112
|
+
resolve({ surferId: null, displayClickCookie: null, clientIp: "" });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const hashParams = new URLSearchParams(
|
|
117
|
+
pixelRedirectUri.substring(hashIndex + 1),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const surferValue = hashParams.get(SURFER_PARAM_KEY) || null;
|
|
121
|
+
const clientIp = hashParams.get(SURFER_IP) || "";
|
|
122
|
+
const displayClickValue = hashParams.get(DISPLAY_CLICK_COOKIE_KEY);
|
|
123
|
+
const displayClickCookie =
|
|
124
|
+
displayClickValue && displayClickValue !== "__LCC__"
|
|
125
|
+
? displayClickValue
|
|
126
|
+
: null;
|
|
127
|
+
|
|
128
|
+
resolve({ surferId: surferValue, displayClickCookie, clientIp });
|
|
129
|
+
} catch (err) {
|
|
130
|
+
reject(err);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Reject if the iframe never responds (ad blocker, CSP, network failure, etc.)
|
|
135
|
+
timeoutId = setTimeout(() => {
|
|
136
|
+
window.removeEventListener("message", pixelDetailsReceiver, false);
|
|
137
|
+
reject(new Error("Advertising identity call timed out"));
|
|
138
|
+
}, SURFER_TIMEOUT_MS);
|
|
139
|
+
|
|
140
|
+
window.addEventListener("message", pixelDetailsReceiver, false);
|
|
141
|
+
|
|
142
|
+
// Use awaitSelector(BODY) — consistent with injectFireReferrerHideableImage.js
|
|
143
|
+
// and more robust than document.body check + load event fallback.
|
|
144
|
+
awaitSelectorFn(BODY).then(([body]) => {
|
|
145
|
+
appendNodeFn(body, iframeElement);
|
|
146
|
+
});
|
|
147
|
+
}).finally(() => {
|
|
148
|
+
inProgressPromise = null;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return inProgressPromise;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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 createComponent from "./createComponent.js";
|
|
14
|
+
import configValidators from "./configValidators.js";
|
|
15
|
+
import {
|
|
16
|
+
createDataCollectionRequest,
|
|
17
|
+
createDataCollectionRequestPayload,
|
|
18
|
+
} from "@adobe/alloy-core/utils/request";
|
|
19
|
+
import createAdConversionHandler from "./handlers/createAdConversionHandler.js";
|
|
20
|
+
import createCookieManager from "./utils/advertisingCookieManager.js";
|
|
21
|
+
import createHandleOnBeforeSendEvent from "./handlers/createOnBeforeSendEventHandler.js";
|
|
22
|
+
import createSendAdConversion from "./handlers/sendAdConversion.js";
|
|
23
|
+
import createCollectSurferId from "./identities/collectSurferId.js";
|
|
24
|
+
import { getID5Id } from "./identities/collectID5Id.js";
|
|
25
|
+
import { getRampId } from "./identities/collectRampId.js";
|
|
26
|
+
import { createInitiateAdvertisingIdentityCall } from "./identities/initiateAdvertisingIdentityCall.js";
|
|
27
|
+
import createHashedIpHandler from "./identities/createHashedIpHandler.js";
|
|
28
|
+
import {
|
|
29
|
+
appendAdvertisingIdQueryToEvent,
|
|
30
|
+
appendAdCloudIdentityToEvent,
|
|
31
|
+
getUrlParams,
|
|
32
|
+
isThrottled,
|
|
33
|
+
normalizeAdvertiser,
|
|
34
|
+
} from "./utils/helpers.js";
|
|
35
|
+
|
|
36
|
+
const createAdvertising = ({
|
|
37
|
+
logger,
|
|
38
|
+
config,
|
|
39
|
+
eventManager,
|
|
40
|
+
sendEdgeNetworkRequest,
|
|
41
|
+
consent,
|
|
42
|
+
getBrowser,
|
|
43
|
+
}) => {
|
|
44
|
+
const componentConfig = config.advertising;
|
|
45
|
+
const cookieManager = createCookieManager({
|
|
46
|
+
orgId: config.orgId,
|
|
47
|
+
logger,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// One shared iframe call — both collectSurferId and hashedIpHandler use it
|
|
51
|
+
// so the pixel is only loaded once per page.
|
|
52
|
+
const initiateAdvertisingIdentityCall =
|
|
53
|
+
createInitiateAdvertisingIdentityCall();
|
|
54
|
+
|
|
55
|
+
const collectSurferId = createCollectSurferId({
|
|
56
|
+
initiateAdvertisingIdentityCall,
|
|
57
|
+
cookieManager,
|
|
58
|
+
getBrowser,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const hashedIpHandler = createHashedIpHandler({ cookieManager });
|
|
62
|
+
|
|
63
|
+
const adConversionHandler = createAdConversionHandler({
|
|
64
|
+
eventManager,
|
|
65
|
+
sendEdgeNetworkRequest,
|
|
66
|
+
consent,
|
|
67
|
+
createDataCollectionRequest,
|
|
68
|
+
createDataCollectionRequestPayload,
|
|
69
|
+
logger,
|
|
70
|
+
});
|
|
71
|
+
const handleOnBeforeSendEvent = createHandleOnBeforeSendEvent({
|
|
72
|
+
cookieManager,
|
|
73
|
+
logger,
|
|
74
|
+
getBrowser,
|
|
75
|
+
consent,
|
|
76
|
+
componentConfig,
|
|
77
|
+
collectSurferId,
|
|
78
|
+
getID5Id,
|
|
79
|
+
getRampId,
|
|
80
|
+
appendAdvertisingIdQueryToEvent,
|
|
81
|
+
appendAdCloudIdentityToEvent,
|
|
82
|
+
collectHashedIPAddr: () =>
|
|
83
|
+
hashedIpHandler.collect(initiateAdvertisingIdentityCall),
|
|
84
|
+
getUrlParams,
|
|
85
|
+
isThrottled,
|
|
86
|
+
normalizeAdvertiser,
|
|
87
|
+
});
|
|
88
|
+
const sendAdConversionHandler = createSendAdConversion({
|
|
89
|
+
eventManager,
|
|
90
|
+
cookieManager,
|
|
91
|
+
adConversionHandler,
|
|
92
|
+
logger,
|
|
93
|
+
componentConfig,
|
|
94
|
+
getBrowser,
|
|
95
|
+
consent,
|
|
96
|
+
collectSurferId,
|
|
97
|
+
collectHashedIPAddr: () =>
|
|
98
|
+
hashedIpHandler.collect(initiateAdvertisingIdentityCall),
|
|
99
|
+
});
|
|
100
|
+
return createComponent({
|
|
101
|
+
handleOnBeforeSendEvent,
|
|
102
|
+
sendAdConversionHandler,
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
createAdvertising.namespace = "Advertising";
|
|
107
|
+
createAdvertising.configValidators = configValidators;
|
|
108
|
+
|
|
109
|
+
export default createAdvertising;
|