@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,64 @@
|
|
|
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 { Logger } from '@adobe/alloy-core/core/types.js' */
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
openIndexedDb,
|
|
17
|
+
getFromIndexedDbStore,
|
|
18
|
+
putToIndexedDbStore,
|
|
19
|
+
} from "@adobe/alloy-core/utils/indexedDb.js";
|
|
20
|
+
|
|
21
|
+
import { DB_NAME, DB_VERSION, STORE_NAME, INDEX_KEY } from "./constants.js";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {Object} data
|
|
25
|
+
* @param {Logger} logger
|
|
26
|
+
*
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
export default async function saveToIndexedDB(data, logger) {
|
|
30
|
+
try {
|
|
31
|
+
const db = await openIndexedDb(
|
|
32
|
+
DB_NAME,
|
|
33
|
+
DB_VERSION,
|
|
34
|
+
(/** @type {IDBDatabase} */ db) => {
|
|
35
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
36
|
+
db.createObjectStore(STORE_NAME, { keyPath: "id" });
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const existingConfigData = await getFromIndexedDbStore(
|
|
42
|
+
db,
|
|
43
|
+
STORE_NAME,
|
|
44
|
+
INDEX_KEY,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const updatedConfigData = {
|
|
48
|
+
...(existingConfigData || {}),
|
|
49
|
+
...data,
|
|
50
|
+
id: INDEX_KEY,
|
|
51
|
+
timestamp: Date.now(),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
await putToIndexedDbStore(db, STORE_NAME, updatedConfigData);
|
|
55
|
+
db.close();
|
|
56
|
+
|
|
57
|
+
logger.info(
|
|
58
|
+
"Successfully saved web SDK config to IndexedDB",
|
|
59
|
+
updatedConfigData,
|
|
60
|
+
);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
logger.error("Failed to save config to IndexedDB", { error });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
// @ts-check
|
|
14
|
+
/// <reference lib="webworker" />
|
|
15
|
+
|
|
16
|
+
/** @import { ServiceWorkerLogger } from '../types.js' */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} type
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
const canHandleUrl = (type) => ["DEEPLINK", "WEBURL"].includes(type);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {Object} dependencies
|
|
26
|
+
* @param {(options: { xdm: Object, actionLabel?: string, applicationLaunches?: number }) => Promise<boolean>} dependencies.makeSendServiceWorkerTrackingData
|
|
27
|
+
* @param {ServiceWorkerGlobalScope} dependencies.sw
|
|
28
|
+
* @param {ServiceWorkerLogger} dependencies.logger
|
|
29
|
+
*/
|
|
30
|
+
export default ({ makeSendServiceWorkerTrackingData, sw, logger }) => {
|
|
31
|
+
/**
|
|
32
|
+
* @function
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} options
|
|
35
|
+
* @param {NotificationEvent} options.event
|
|
36
|
+
*/
|
|
37
|
+
return ({ event }) => {
|
|
38
|
+
event.notification.close();
|
|
39
|
+
|
|
40
|
+
const data = event.notification.data;
|
|
41
|
+
let targetUrl = null;
|
|
42
|
+
let actionLabel = null;
|
|
43
|
+
|
|
44
|
+
if (event.action) {
|
|
45
|
+
const actionIndex = parseInt(event.action.replace("action_", ""), 10);
|
|
46
|
+
if (data?.actions?.buttons[actionIndex]) {
|
|
47
|
+
const button = data.actions.buttons[actionIndex];
|
|
48
|
+
actionLabel = button.label;
|
|
49
|
+
if (canHandleUrl(button.type) && button.uri) {
|
|
50
|
+
targetUrl = button.uri;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} else if (
|
|
54
|
+
canHandleUrl(data?.interaction?.type) &&
|
|
55
|
+
data?.interaction?.uri
|
|
56
|
+
) {
|
|
57
|
+
targetUrl = data.interaction.uri;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
makeSendServiceWorkerTrackingData({
|
|
61
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
62
|
+
xdm: data._xdm.mixins,
|
|
63
|
+
actionLabel,
|
|
64
|
+
applicationLaunches: 1,
|
|
65
|
+
}).catch((error) => {
|
|
66
|
+
logger.error("Failed to send tracking call:", error);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (targetUrl) {
|
|
70
|
+
event.waitUntil(
|
|
71
|
+
sw.clients.matchAll({ type: "window" }).then((clientList) => {
|
|
72
|
+
for (const client of clientList) {
|
|
73
|
+
if (client.url === targetUrl && "focus" in client) {
|
|
74
|
+
return client.focus();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (sw.clients.openWindow) {
|
|
78
|
+
return sw.clients.openWindow(targetUrl);
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
};
|
|
@@ -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
|
+
// @ts-check
|
|
14
|
+
/// <reference lib="webworker" />
|
|
15
|
+
|
|
16
|
+
/** @import { PushNotificationData } from '../types.js' */
|
|
17
|
+
/** @import { ServiceWorkerLogger } from '../types.js' */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @async
|
|
21
|
+
* @function
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} options
|
|
24
|
+
* @param {ServiceWorkerGlobalScope} options.sw
|
|
25
|
+
* @param {PushEvent} options.event
|
|
26
|
+
* @param {ServiceWorkerLogger} options.logger
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
export default async ({ sw, event, logger }) => {
|
|
30
|
+
if (!event.data) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @type {PushNotificationData} */
|
|
35
|
+
let notificationData;
|
|
36
|
+
try {
|
|
37
|
+
notificationData = event.data.json();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
logger.error("Error decoding notification JSON data:", error);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const webData = notificationData.web;
|
|
44
|
+
if (!webData?.title) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const notificationOptions = {
|
|
49
|
+
body: webData.body,
|
|
50
|
+
icon: webData.media,
|
|
51
|
+
image: webData.media,
|
|
52
|
+
data: webData,
|
|
53
|
+
actions: [],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
Object.keys(notificationOptions).forEach((k) => {
|
|
57
|
+
if (notificationOptions[k] == null) {
|
|
58
|
+
delete notificationOptions[k];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (webData.actions && webData.actions.buttons) {
|
|
63
|
+
notificationOptions.actions = webData.actions.buttons.map(
|
|
64
|
+
(button, index) => ({
|
|
65
|
+
action: `action_${index}`,
|
|
66
|
+
title: button.label,
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return sw.registration.showNotification(webData.title, notificationOptions);
|
|
72
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
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 { StorageCreator } from '@adobe/alloy-core/utils/types.js' */
|
|
14
|
+
/** @import { EventManager, Logger } from '@adobe/alloy-core/core/types.js' */
|
|
15
|
+
/** @import { IdentityManager } from '@adobe/alloy-core/core/identity/types.js' */
|
|
16
|
+
/** @import { ConsentManager } from '@adobe/alloy-core/core/consent/types.js' */
|
|
17
|
+
/** @import { EdgeRequestExecutor } from '@adobe/alloy-core/core/edgeNetwork/types.js' */
|
|
18
|
+
|
|
19
|
+
import { objectOf, string } from "@adobe/alloy-core/utils/validation";
|
|
20
|
+
import { sanitizeOrgIdForCookieName } from "@adobe/alloy-core/utils";
|
|
21
|
+
import makeSendPushSubscriptionRequest from "./request/makeSendPushSubscriptionRequest.js";
|
|
22
|
+
import saveToIndexedDb from "./helpers/saveToIndexedDb.js";
|
|
23
|
+
|
|
24
|
+
const isComponentConfigured = ({
|
|
25
|
+
orgId,
|
|
26
|
+
pushNotifications: { vapidPublicKey, appId, trackingDatasetId } = {
|
|
27
|
+
vapidPublicKey: undefined,
|
|
28
|
+
appId: undefined,
|
|
29
|
+
trackingDatasetId: undefined,
|
|
30
|
+
},
|
|
31
|
+
}) => orgId && vapidPublicKey && appId && trackingDatasetId;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @function
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} options
|
|
37
|
+
* @param {{ orgId: string, datastreamId: string, edgeDomain: string, edgeBasePath: string, pushNotifications: { vapidPublicKey: string, appId: string, trackingDatasetId: string }}} options.config
|
|
38
|
+
* @param {StorageCreator} options.createNamespacedStorage
|
|
39
|
+
* @param {EventManager} options.eventManager
|
|
40
|
+
* @param {Logger} options.logger
|
|
41
|
+
* @param {ConsentManager} options.consent
|
|
42
|
+
* @param {IdentityManager} options.identity
|
|
43
|
+
* @param {function(): string} options.getBrowser
|
|
44
|
+
* @param {EdgeRequestExecutor} options.sendEdgeNetworkRequest
|
|
45
|
+
* @returns {{ lifecycle: object, commands: { sendPushSubscription: object } }}
|
|
46
|
+
*/
|
|
47
|
+
const createPushNotifications = ({
|
|
48
|
+
createNamespacedStorage,
|
|
49
|
+
eventManager,
|
|
50
|
+
config,
|
|
51
|
+
logger,
|
|
52
|
+
consent,
|
|
53
|
+
identity,
|
|
54
|
+
getBrowser,
|
|
55
|
+
sendEdgeNetworkRequest,
|
|
56
|
+
}) => {
|
|
57
|
+
return {
|
|
58
|
+
lifecycle: {
|
|
59
|
+
async onComponentsRegistered() {
|
|
60
|
+
if (isComponentConfigured(config)) {
|
|
61
|
+
const {
|
|
62
|
+
datastreamId,
|
|
63
|
+
edgeDomain,
|
|
64
|
+
edgeBasePath,
|
|
65
|
+
pushNotifications: { trackingDatasetId },
|
|
66
|
+
} = config;
|
|
67
|
+
await saveToIndexedDb(
|
|
68
|
+
{
|
|
69
|
+
datastreamId,
|
|
70
|
+
edgeDomain,
|
|
71
|
+
edgeBasePath,
|
|
72
|
+
datasetId: trackingDatasetId,
|
|
73
|
+
browser: getBrowser(),
|
|
74
|
+
},
|
|
75
|
+
logger,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
commands: {
|
|
81
|
+
sendPushSubscription: {
|
|
82
|
+
run: async () => {
|
|
83
|
+
if (!isComponentConfigured(config)) {
|
|
84
|
+
throw new Error("Push notifications module is not configured.");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const {
|
|
88
|
+
orgId,
|
|
89
|
+
pushNotifications: { vapidPublicKey, appId } = {
|
|
90
|
+
vapidPublicKey: undefined,
|
|
91
|
+
appId: undefined,
|
|
92
|
+
},
|
|
93
|
+
} = config || {};
|
|
94
|
+
|
|
95
|
+
const storage = createNamespacedStorage(
|
|
96
|
+
`${sanitizeOrgIdForCookieName(orgId)}.pushNotifications.`,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return makeSendPushSubscriptionRequest({
|
|
100
|
+
config: {
|
|
101
|
+
vapidPublicKey,
|
|
102
|
+
appId,
|
|
103
|
+
},
|
|
104
|
+
storage: storage.persistent,
|
|
105
|
+
logger,
|
|
106
|
+
sendEdgeNetworkRequest,
|
|
107
|
+
consent,
|
|
108
|
+
eventManager,
|
|
109
|
+
identity,
|
|
110
|
+
window,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
optionsValidator: objectOf({}).noUnknownFields(),
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
createPushNotifications.namespace = "Push Notifications";
|
|
120
|
+
createPushNotifications.configValidators = objectOf({
|
|
121
|
+
pushNotifications: objectOf({
|
|
122
|
+
vapidPublicKey: string().required(),
|
|
123
|
+
appId: string().required(),
|
|
124
|
+
trackingDatasetId: string().required(),
|
|
125
|
+
}).noUnknownFields(),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export default createPushNotifications;
|
|
@@ -0,0 +1,66 @@
|
|
|
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 { EventManager } from "@adobe/alloy-core/core/types.js" */
|
|
14
|
+
/** @import { DataCollectionRequestPayload } from "@adobe/alloy-core/utils/request/types.js" */
|
|
15
|
+
|
|
16
|
+
import createDataCollectionRequestPayload from "@adobe/alloy-core/utils/request/createDataCollectionRequestPayload.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a data collection request payload for sending push subscription details to Adobe Experience Platform.
|
|
20
|
+
*
|
|
21
|
+
* This function constructs an event containing push notification subscription information,
|
|
22
|
+
* including the subscription details, platform information, and identity data. The event
|
|
23
|
+
* is then packaged into a data collection request payload for transmission to the edge network.
|
|
24
|
+
*
|
|
25
|
+
* @async
|
|
26
|
+
* @function
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} options
|
|
29
|
+
* @param {string} options.ecid
|
|
30
|
+
* @param {EventManager} options.eventManager
|
|
31
|
+
* @param {string} options.serializedPushSubscriptionDetails
|
|
32
|
+
* @param {string} options.appId
|
|
33
|
+
*
|
|
34
|
+
* @returns {Promise<DataCollectionRequestPayload>}
|
|
35
|
+
*/
|
|
36
|
+
export default async ({
|
|
37
|
+
ecid,
|
|
38
|
+
eventManager,
|
|
39
|
+
serializedPushSubscriptionDetails,
|
|
40
|
+
appId,
|
|
41
|
+
}) => {
|
|
42
|
+
const event = eventManager.createEvent();
|
|
43
|
+
|
|
44
|
+
event.setUserData({
|
|
45
|
+
pushNotificationDetails: [
|
|
46
|
+
{
|
|
47
|
+
appID: appId,
|
|
48
|
+
token: serializedPushSubscriptionDetails,
|
|
49
|
+
platform: "web",
|
|
50
|
+
denylisted: false,
|
|
51
|
+
identity: {
|
|
52
|
+
namespace: {
|
|
53
|
+
code: "ECID",
|
|
54
|
+
},
|
|
55
|
+
id: ecid,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
event.finalize();
|
|
61
|
+
|
|
62
|
+
const payload = createDataCollectionRequestPayload();
|
|
63
|
+
payload.addEvent(event);
|
|
64
|
+
|
|
65
|
+
return payload;
|
|
66
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { DataCollectionRequestPayload, Request } from '@adobe/alloy-core/utils/request/types.js' */
|
|
14
|
+
|
|
15
|
+
import { createRequest } from "@adobe/alloy-core/utils/request";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @function
|
|
19
|
+
*
|
|
20
|
+
* @param {{ payload: DataCollectionRequestPayload }} options
|
|
21
|
+
*
|
|
22
|
+
* @returns {Request}
|
|
23
|
+
*/
|
|
24
|
+
export default ({ payload }) =>
|
|
25
|
+
createRequest({
|
|
26
|
+
payload,
|
|
27
|
+
|
|
28
|
+
getAction() {
|
|
29
|
+
return "interact";
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
getUseSendBeacon() {
|
|
33
|
+
return false;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { Storage } from '@adobe/alloy-core/utils/types.js' */
|
|
14
|
+
/** @import { EventManager, Logger } from '@adobe/alloy-core/core/types.js' */
|
|
15
|
+
/** @import { IdentityManager } from '@adobe/alloy-core/core/identity/types.js' */
|
|
16
|
+
/** @import { ConsentManager } from '@adobe/alloy-core/core/consent/types.js' */
|
|
17
|
+
/** @import { EdgeRequestExecutor } from '@adobe/alloy-core/core/edgeNetwork/types.js' */
|
|
18
|
+
|
|
19
|
+
import { sortObjectKeysRecursively } from "@adobe/alloy-core/utils";
|
|
20
|
+
import getPushSubscriptionDetailsDefault from "../helpers/getPushSubscriptionDetails.js";
|
|
21
|
+
import createSendPushSubscriptionRequest from "./createSendPushSubscriptionRequest.js";
|
|
22
|
+
import createSendPushSubscriptionPayload from "./createSendPushSubscriptionPayload.js";
|
|
23
|
+
import saveToIndexedDb from "../helpers/saveToIndexedDb.js";
|
|
24
|
+
|
|
25
|
+
const SUBSCRIPTION_DETAILS = "subscriptionDetails";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves and returns push subscription details with sorted object keys.
|
|
29
|
+
*
|
|
30
|
+
* This function gets the push subscription details using the provided VAPID public key
|
|
31
|
+
* and returns the details with all object keys sorted recursively for consistent output.
|
|
32
|
+
*
|
|
33
|
+
* @async
|
|
34
|
+
* @function
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} options
|
|
37
|
+
* @param {{vapidPublicKey: string, appId: string}} options.config
|
|
38
|
+
* @param {Storage} options.storage
|
|
39
|
+
* @param {Logger} options.logger
|
|
40
|
+
* @param {EventManager} options.eventManager
|
|
41
|
+
* @param {IdentityManager} options.identity
|
|
42
|
+
* @param {EdgeRequestExecutor} options.sendEdgeNetworkRequest
|
|
43
|
+
* @param {ConsentManager} options.consent
|
|
44
|
+
* @param {Window} options.window
|
|
45
|
+
*
|
|
46
|
+
* @returns {Promise<void>}
|
|
47
|
+
*/
|
|
48
|
+
export default async ({
|
|
49
|
+
config: { vapidPublicKey, appId },
|
|
50
|
+
storage,
|
|
51
|
+
logger,
|
|
52
|
+
sendEdgeNetworkRequest,
|
|
53
|
+
consent,
|
|
54
|
+
eventManager,
|
|
55
|
+
identity,
|
|
56
|
+
window,
|
|
57
|
+
getPushSubscriptionDetails = getPushSubscriptionDetailsDefault,
|
|
58
|
+
}) => {
|
|
59
|
+
await identity.awaitIdentity();
|
|
60
|
+
const ecid = identity.getEcidFromCookie();
|
|
61
|
+
|
|
62
|
+
const pushSubscriptionDetails = await getPushSubscriptionDetails({
|
|
63
|
+
vapidPublicKey,
|
|
64
|
+
window,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const serializedPushSubscriptionDetails = JSON.stringify(
|
|
68
|
+
sortObjectKeysRecursively(pushSubscriptionDetails),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const cacheValue = `${ecid}${serializedPushSubscriptionDetails}`;
|
|
72
|
+
|
|
73
|
+
if (cacheValue === storage.getItem(SUBSCRIPTION_DETAILS)) {
|
|
74
|
+
logger.info(
|
|
75
|
+
"Subscription details have not changed. Not sending to the server.",
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
storage.setItem(SUBSCRIPTION_DETAILS, cacheValue);
|
|
82
|
+
|
|
83
|
+
const payload = await createSendPushSubscriptionPayload({
|
|
84
|
+
eventManager,
|
|
85
|
+
ecid,
|
|
86
|
+
serializedPushSubscriptionDetails,
|
|
87
|
+
appId,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const request = createSendPushSubscriptionRequest({
|
|
91
|
+
payload,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await consent.awaitConsent();
|
|
95
|
+
await sendEdgeNetworkRequest({ request });
|
|
96
|
+
|
|
97
|
+
await saveToIndexedDb({ ecid }, logger);
|
|
98
|
+
};
|