@adobe/alloy 2.32.1-beta.1 → 2.33.0
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 +7 -2
- package/dist/alloy.js +11283 -11142
- package/dist/alloy.min.js +1 -1
- package/dist/alloyServiceWorker.js +1 -1
- 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 +3 -0
- package/dist/types/browser/src/components/requiredComponentCreators.d.ts +1 -0
- package/dist/types/core/src/components/Identity/injectAddQueryStringIdentityToPayload.d.ts +2 -1
- package/dist/types/core/src/core/componentCreators.d.ts +0 -3
- package/dist/types/core/src/core/requiredComponentCreators.d.ts +0 -1
- package/dist/types/core/src/types.d.ts +0 -4
- package/package.json +2 -2
- 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 +3 -0
- package/src/components/requiredComponentCreators.js +13 -0
- package/src/createEventListeners.js +81 -0
- package/src/index.js +5 -1
- package/src/serviceWorker.js +2 -2
- 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 → 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,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { getAttribute, setAttribute } from "../dom-actions/dom/index.js";
|
|
13
|
+
import { noop } from "@adobe/alloy-core/utils";
|
|
14
|
+
import { DOM_ACTION_CLICK } from "../dom-actions/initDomActionsModules.js";
|
|
15
|
+
import {
|
|
16
|
+
ALWAYS,
|
|
17
|
+
DECORATED_ELEMENTS_ONLY,
|
|
18
|
+
} from "@adobe/alloy-core/constants/propositionInteractionType.js";
|
|
19
|
+
|
|
20
|
+
export const INTERACT_ID_DATA_ATTRIBUTE = "data-aep-interact-id";
|
|
21
|
+
export const CLICK_LABEL_DATA_ATTRIBUTE = "data-aep-click-label";
|
|
22
|
+
export const CLICK_TOKEN_DATA_ATTRIBUTE = "data-aep-click-token";
|
|
23
|
+
|
|
24
|
+
let lastInteractId = 0;
|
|
25
|
+
|
|
26
|
+
const getInteractId = (propositionId, existingInteractId) => {
|
|
27
|
+
if (existingInteractId) {
|
|
28
|
+
return parseInt(existingInteractId, 10);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return ++lastInteractId;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const interactionTrackingSupported = (
|
|
35
|
+
autoCollectPropositionInteractions,
|
|
36
|
+
decisionProvider,
|
|
37
|
+
) => {
|
|
38
|
+
if (!autoCollectPropositionInteractions) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!autoCollectPropositionInteractions[decisionProvider]) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return [ALWAYS, DECORATED_ELEMENTS_ONLY].includes(
|
|
47
|
+
autoCollectPropositionInteractions[decisionProvider],
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const createDecorateProposition = (
|
|
52
|
+
autoCollectPropositionInteractions,
|
|
53
|
+
type,
|
|
54
|
+
propositionId,
|
|
55
|
+
itemId,
|
|
56
|
+
trackingLabel,
|
|
57
|
+
scopeType,
|
|
58
|
+
notification,
|
|
59
|
+
storeInteractionMeta,
|
|
60
|
+
) => {
|
|
61
|
+
const { scopeDetails = {} } = notification;
|
|
62
|
+
const { decisionProvider } = scopeDetails;
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
!interactionTrackingSupported(
|
|
66
|
+
autoCollectPropositionInteractions,
|
|
67
|
+
decisionProvider,
|
|
68
|
+
) &&
|
|
69
|
+
type !== DOM_ACTION_CLICK
|
|
70
|
+
) {
|
|
71
|
+
return noop;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (element) => {
|
|
75
|
+
if (!element.tagName) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const interactId = getInteractId(
|
|
80
|
+
propositionId,
|
|
81
|
+
getAttribute(element, INTERACT_ID_DATA_ATTRIBUTE),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
storeInteractionMeta(
|
|
85
|
+
propositionId,
|
|
86
|
+
itemId,
|
|
87
|
+
scopeType,
|
|
88
|
+
notification,
|
|
89
|
+
interactId,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
setAttribute(element, INTERACT_ID_DATA_ATTRIBUTE, interactId);
|
|
93
|
+
|
|
94
|
+
if (trackingLabel && !getAttribute(element, CLICK_LABEL_DATA_ATTRIBUTE)) {
|
|
95
|
+
setAttribute(element, CLICK_LABEL_DATA_ATTRIBUTE, trackingLabel);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export default createDecorateProposition;
|
|
@@ -0,0 +1,79 @@
|
|
|
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 createDecorateProposition from "./createDecorateProposition.js";
|
|
14
|
+
import createRenderStatusHandler from "./createRenderStatusHandler.js";
|
|
15
|
+
import { DOM_ACTION_CLICK } from "../dom-actions/initDomActionsModules.js";
|
|
16
|
+
|
|
17
|
+
export default ({
|
|
18
|
+
modules,
|
|
19
|
+
logger,
|
|
20
|
+
storeInteractionMeta,
|
|
21
|
+
storeClickMeta,
|
|
22
|
+
autoCollectPropositionInteractions,
|
|
23
|
+
}) =>
|
|
24
|
+
(item) => {
|
|
25
|
+
const { type, selector } = item.getData() || {};
|
|
26
|
+
|
|
27
|
+
if (!type) {
|
|
28
|
+
logger.warn("Invalid DOM action data: missing type.", item.getData());
|
|
29
|
+
return { setRenderAttempted: false, includeInNotification: false };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (type === DOM_ACTION_CLICK) {
|
|
33
|
+
if (!selector) {
|
|
34
|
+
logger.warn(
|
|
35
|
+
"Invalid DOM action data: missing selector.",
|
|
36
|
+
item.getData(),
|
|
37
|
+
);
|
|
38
|
+
return { setRenderAttempted: false, includeInNotification: false };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
storeClickMeta({
|
|
42
|
+
selector,
|
|
43
|
+
meta: {
|
|
44
|
+
...item.getProposition().getNotification(),
|
|
45
|
+
trackingLabel: item.getTrackingLabel(),
|
|
46
|
+
scopeType: item.getProposition().getScopeType(),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return { setRenderAttempted: true, includeInNotification: false };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!modules[type]) {
|
|
54
|
+
logger.warn("Invalid DOM action data: unknown type.", item.getData());
|
|
55
|
+
return { setRenderAttempted: false, includeInNotification: false };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const renderStatusHandler = createRenderStatusHandler(
|
|
59
|
+
item.getProposition().getScopeType(),
|
|
60
|
+
item.getId(),
|
|
61
|
+
);
|
|
62
|
+
const decorateProposition = createDecorateProposition(
|
|
63
|
+
autoCollectPropositionInteractions,
|
|
64
|
+
type,
|
|
65
|
+
item.getProposition().getId(),
|
|
66
|
+
item.getId(),
|
|
67
|
+
item.getTrackingLabel(),
|
|
68
|
+
item.getProposition().getScopeType(),
|
|
69
|
+
item.getProposition().getNotification(),
|
|
70
|
+
storeInteractionMeta,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
render: () =>
|
|
75
|
+
modules[type](item.getData(), decorateProposition, renderStatusHandler),
|
|
76
|
+
setRenderAttempted: true,
|
|
77
|
+
includeInNotification: true,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
import createDecorateProposition from "./createDecorateProposition.js";
|
|
13
|
+
import createRenderStatusHandler from "./createRenderStatusHandler.js";
|
|
14
|
+
|
|
15
|
+
export default ({
|
|
16
|
+
modules,
|
|
17
|
+
logger,
|
|
18
|
+
storeInteractionMeta,
|
|
19
|
+
autoCollectPropositionInteractions,
|
|
20
|
+
}) =>
|
|
21
|
+
(item) => {
|
|
22
|
+
const { type, selector } = item.getData() || {};
|
|
23
|
+
|
|
24
|
+
if (!selector || !type) {
|
|
25
|
+
return { setRenderAttempted: false, includeInNotification: false };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!modules[type]) {
|
|
29
|
+
logger.warn("Invalid HTML content data", item.getData());
|
|
30
|
+
return { setRenderAttempted: false, includeInNotification: false };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const decorateProposition = createDecorateProposition(
|
|
34
|
+
autoCollectPropositionInteractions,
|
|
35
|
+
type,
|
|
36
|
+
item.getProposition().getId(),
|
|
37
|
+
item.getId(),
|
|
38
|
+
item.getTrackingLabel(),
|
|
39
|
+
item.getProposition().getScopeType(),
|
|
40
|
+
item.getProposition().getNotification(),
|
|
41
|
+
storeInteractionMeta,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const renderStatusHandler = createRenderStatusHandler(
|
|
45
|
+
item.getProposition().getScopeType(),
|
|
46
|
+
item.getId(),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
render: () => {
|
|
51
|
+
return modules[type](
|
|
52
|
+
item.getData(),
|
|
53
|
+
decorateProposition,
|
|
54
|
+
renderStatusHandler,
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
setRenderAttempted: true,
|
|
58
|
+
includeInNotification: true,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
import { APPLICATION_JSON } from "@adobe/alloy-core/constants/contentType.js";
|
|
13
|
+
|
|
14
|
+
const DEFAULT_CONTENT = "defaultContent";
|
|
15
|
+
|
|
16
|
+
const expectedProps = ["content", "contentType"];
|
|
17
|
+
const expectedContentProps = ["mobileParameters", "webParameters", "html"];
|
|
18
|
+
|
|
19
|
+
const isValidInAppMessage = (data, logger) => {
|
|
20
|
+
for (let i = 0; i < expectedProps.length; i += 1) {
|
|
21
|
+
const prop = expectedProps[i];
|
|
22
|
+
if (!Object.prototype.hasOwnProperty.call(data, prop)) {
|
|
23
|
+
logger.warn(
|
|
24
|
+
`Invalid in-app message data: missing property '${prop}'.`,
|
|
25
|
+
data,
|
|
26
|
+
);
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { content, contentType } = data;
|
|
32
|
+
|
|
33
|
+
if (contentType === APPLICATION_JSON) {
|
|
34
|
+
for (let i = 0; i < expectedContentProps.length; i += 1) {
|
|
35
|
+
const prop = expectedContentProps[i];
|
|
36
|
+
if (!Object.prototype.hasOwnProperty.call(content, prop)) {
|
|
37
|
+
logger.warn(
|
|
38
|
+
`Invalid in-app message data.content: missing property '${prop}'.`,
|
|
39
|
+
data,
|
|
40
|
+
);
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default ({ modules, logger }) => {
|
|
50
|
+
return (item) => {
|
|
51
|
+
const data = item.getData();
|
|
52
|
+
const proposition = item.getProposition();
|
|
53
|
+
const meta = { ...proposition.getNotification() };
|
|
54
|
+
const shouldSuppressDisplay = proposition.shouldSuppressDisplay();
|
|
55
|
+
|
|
56
|
+
if (!data) {
|
|
57
|
+
logger.warn("Invalid in-app message data: undefined.", data);
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { type = DEFAULT_CONTENT } = data;
|
|
62
|
+
|
|
63
|
+
if (!modules[type]) {
|
|
64
|
+
logger.warn("Invalid in-app message data: unknown type.", data);
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!isValidInAppMessage(data, logger)) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!meta) {
|
|
73
|
+
logger.warn("Invalid in-app message meta: undefined.", meta);
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
render: () => {
|
|
79
|
+
return shouldSuppressDisplay
|
|
80
|
+
? null
|
|
81
|
+
: modules[type]({
|
|
82
|
+
...data,
|
|
83
|
+
meta,
|
|
84
|
+
identityMap: proposition.getIdentityMap(),
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
setRenderAttempted: true,
|
|
88
|
+
includeInNotification: true,
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
@@ -0,0 +1,228 @@
|
|
|
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 { groupBy, isNonEmptyArray } from "@adobe/alloy-core/utils";
|
|
14
|
+
|
|
15
|
+
export default ({ schemaProcessors, logger }) => {
|
|
16
|
+
const wrapRenderWithLogging = (render, item) => () => {
|
|
17
|
+
return Promise.resolve()
|
|
18
|
+
.then(render)
|
|
19
|
+
.then(() => {
|
|
20
|
+
if (logger.enabled) {
|
|
21
|
+
logger.info(`Action ${item.toString()} executed.`);
|
|
22
|
+
}
|
|
23
|
+
return item.toJSON();
|
|
24
|
+
})
|
|
25
|
+
.catch((error) => {
|
|
26
|
+
const { message, stack } = error;
|
|
27
|
+
const warning = `Failed to execute action ${item.toString()}. ${message} ${stack}`;
|
|
28
|
+
logger.logOnContentRendering({
|
|
29
|
+
status: "rendering-failed",
|
|
30
|
+
detail: {
|
|
31
|
+
propositionDetails: item.getProposition().getNotification(),
|
|
32
|
+
item: item.toJSON(),
|
|
33
|
+
},
|
|
34
|
+
error,
|
|
35
|
+
message: warning,
|
|
36
|
+
logLevel: "warn",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return undefined;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const renderItems = async (renderers, meta) => {
|
|
44
|
+
const results = await Promise.allSettled(
|
|
45
|
+
renderers.map((renderer) => renderer()),
|
|
46
|
+
);
|
|
47
|
+
const successes = results
|
|
48
|
+
.filter((result) => result.status === "fulfilled")
|
|
49
|
+
.map((result) => result.value);
|
|
50
|
+
// as long as at least one renderer succeeds, we want to add the notification
|
|
51
|
+
// to the display notifications
|
|
52
|
+
if (meta && isNonEmptyArray(successes)) {
|
|
53
|
+
return { ...meta, items: successes };
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const processItem = (item) => {
|
|
59
|
+
const processor = schemaProcessors[item.getSchema()];
|
|
60
|
+
if (!processor) {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
return processor(item);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const processItems = ({
|
|
67
|
+
renderers: existingRenderers,
|
|
68
|
+
returnedPropositions: existingReturnedPropositions,
|
|
69
|
+
returnedDecisions: existingReturnedDecisions,
|
|
70
|
+
items,
|
|
71
|
+
proposition,
|
|
72
|
+
}) => {
|
|
73
|
+
let renderers = [...existingRenderers];
|
|
74
|
+
let returnedPropositions = [...existingReturnedPropositions];
|
|
75
|
+
let returnedDecisions = [...existingReturnedDecisions];
|
|
76
|
+
let renderedItems = [];
|
|
77
|
+
let nonRenderedItems = [];
|
|
78
|
+
let itemRenderers = [];
|
|
79
|
+
let atLeastOneWithNotification = false;
|
|
80
|
+
let render;
|
|
81
|
+
let setRenderAttempted;
|
|
82
|
+
let includeInNotification;
|
|
83
|
+
let onlyRenderThis = false;
|
|
84
|
+
let i = 0;
|
|
85
|
+
let item;
|
|
86
|
+
|
|
87
|
+
while (items.length > i) {
|
|
88
|
+
item = items[i];
|
|
89
|
+
({ render, setRenderAttempted, includeInNotification, onlyRenderThis } =
|
|
90
|
+
processItem(item));
|
|
91
|
+
|
|
92
|
+
if (onlyRenderThis) {
|
|
93
|
+
returnedPropositions = [];
|
|
94
|
+
returnedDecisions = [];
|
|
95
|
+
if (setRenderAttempted) {
|
|
96
|
+
renderedItems = [item];
|
|
97
|
+
nonRenderedItems = [];
|
|
98
|
+
} else {
|
|
99
|
+
renderedItems = [];
|
|
100
|
+
nonRenderedItems = [item];
|
|
101
|
+
}
|
|
102
|
+
renderers = [];
|
|
103
|
+
itemRenderers = [render];
|
|
104
|
+
atLeastOneWithNotification = includeInNotification;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (render) {
|
|
109
|
+
itemRenderers.push(wrapRenderWithLogging(render, item));
|
|
110
|
+
}
|
|
111
|
+
if (includeInNotification) {
|
|
112
|
+
atLeastOneWithNotification = true;
|
|
113
|
+
}
|
|
114
|
+
if (setRenderAttempted) {
|
|
115
|
+
renderedItems.push(item);
|
|
116
|
+
} else {
|
|
117
|
+
nonRenderedItems.push(item);
|
|
118
|
+
}
|
|
119
|
+
i += 1;
|
|
120
|
+
}
|
|
121
|
+
if (itemRenderers.length > 0) {
|
|
122
|
+
const meta = atLeastOneWithNotification
|
|
123
|
+
? proposition.getNotification()
|
|
124
|
+
: undefined;
|
|
125
|
+
renderers.push(() => renderItems(itemRenderers, meta));
|
|
126
|
+
} else if (atLeastOneWithNotification) {
|
|
127
|
+
renderers.push(() => Promise.resolve(proposition.getNotification()));
|
|
128
|
+
}
|
|
129
|
+
if (renderedItems.length > 0) {
|
|
130
|
+
proposition.addToReturnValues(
|
|
131
|
+
returnedPropositions,
|
|
132
|
+
returnedDecisions,
|
|
133
|
+
renderedItems,
|
|
134
|
+
true,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
if (nonRenderedItems.length > 0) {
|
|
138
|
+
proposition.addToReturnValues(
|
|
139
|
+
returnedPropositions,
|
|
140
|
+
returnedDecisions,
|
|
141
|
+
nonRenderedItems,
|
|
142
|
+
false,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
renderers,
|
|
148
|
+
returnedPropositions,
|
|
149
|
+
returnedDecisions,
|
|
150
|
+
onlyRenderThis,
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return (renderPropositions, nonRenderPropositions = []) => {
|
|
155
|
+
let renderers = [];
|
|
156
|
+
let returnedPropositions = [];
|
|
157
|
+
let returnedDecisions = [];
|
|
158
|
+
let onlyRenderThis;
|
|
159
|
+
let i = 0;
|
|
160
|
+
let proposition;
|
|
161
|
+
let items;
|
|
162
|
+
|
|
163
|
+
while (renderPropositions.length > i) {
|
|
164
|
+
proposition = renderPropositions[i];
|
|
165
|
+
items = proposition.getItems();
|
|
166
|
+
({ renderers, returnedPropositions, returnedDecisions, onlyRenderThis } =
|
|
167
|
+
processItems({
|
|
168
|
+
renderers,
|
|
169
|
+
returnedPropositions,
|
|
170
|
+
returnedDecisions,
|
|
171
|
+
items,
|
|
172
|
+
proposition,
|
|
173
|
+
}));
|
|
174
|
+
if (onlyRenderThis) {
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
i += 1;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (onlyRenderThis) {
|
|
181
|
+
// if onlyRenderThis is true, that means returnedPropositions and returnedDecisions
|
|
182
|
+
// only contains the proposition that triggered only rendering this. We need to
|
|
183
|
+
// add the other propositions to the returnedPropositions and returnedDecisions.
|
|
184
|
+
renderPropositions.forEach((p, index) => {
|
|
185
|
+
if (index !== i) {
|
|
186
|
+
p.addToReturnValues(
|
|
187
|
+
returnedPropositions,
|
|
188
|
+
returnedDecisions,
|
|
189
|
+
p.getItems(),
|
|
190
|
+
false,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
nonRenderPropositions.forEach((p) => {
|
|
197
|
+
p.addToReturnValues(
|
|
198
|
+
returnedPropositions,
|
|
199
|
+
returnedDecisions,
|
|
200
|
+
p.getItems(),
|
|
201
|
+
false,
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const render = () => {
|
|
206
|
+
return Promise.all(renderers.map((renderer) => renderer())).then(
|
|
207
|
+
(metas) => {
|
|
208
|
+
const propositions = metas.filter((meta) => meta);
|
|
209
|
+
const renderedPropositions = propositions.map((prop) => {
|
|
210
|
+
const { id, scope, scopeDetails } = prop;
|
|
211
|
+
return { id, scope, scopeDetails };
|
|
212
|
+
});
|
|
213
|
+
if (isNonEmptyArray(propositions)) {
|
|
214
|
+
const propsByScope = groupBy(propositions, (p) => p.scope);
|
|
215
|
+
logger.logOnContentRendering({
|
|
216
|
+
status: "rendering-succeeded",
|
|
217
|
+
detail: { ...propsByScope },
|
|
218
|
+
message: `Scopes: ${JSON.stringify(propsByScope)} successfully executed.`,
|
|
219
|
+
logLevel: "info",
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return renderedPropositions;
|
|
223
|
+
},
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
return { returnedPropositions, returnedDecisions, render };
|
|
227
|
+
};
|
|
228
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
import { hideElements, showElements } from "../flicker/index.js";
|
|
13
|
+
|
|
14
|
+
const REDIRECT_HIDING_ELEMENT = "BODY";
|
|
15
|
+
export default ({ logger, executeRedirect, collect }) =>
|
|
16
|
+
(item) => {
|
|
17
|
+
const { content } = item.getData() || {};
|
|
18
|
+
|
|
19
|
+
if (!content) {
|
|
20
|
+
logger.warn("Invalid Redirect data", item.getData());
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const render = () => {
|
|
25
|
+
hideElements(REDIRECT_HIDING_ELEMENT);
|
|
26
|
+
return collect({
|
|
27
|
+
decisionsMeta: [item.getProposition().getNotification()],
|
|
28
|
+
documentMayUnload: true,
|
|
29
|
+
identityMap: item.getProposition().getIdentityMap(),
|
|
30
|
+
})
|
|
31
|
+
.then(() => {
|
|
32
|
+
logger.logOnContentRendering({
|
|
33
|
+
status: "rendering-redirect",
|
|
34
|
+
detail: {
|
|
35
|
+
propositionDetails: item.getProposition().getNotification(),
|
|
36
|
+
redirect: content,
|
|
37
|
+
},
|
|
38
|
+
message: `Redirect action ${item.toString()} executed.`,
|
|
39
|
+
logLevel: "info",
|
|
40
|
+
});
|
|
41
|
+
return executeRedirect(content);
|
|
42
|
+
// Execute redirect will never resolve. If there are bottom of page events that are waiting
|
|
43
|
+
// for display notifications from this request, they will never run because this promise will
|
|
44
|
+
// not resolve. This is intentional because we don't want to run bottom of page events if
|
|
45
|
+
// there is a redirect.
|
|
46
|
+
})
|
|
47
|
+
.catch((error) => {
|
|
48
|
+
showElements(REDIRECT_HIDING_ELEMENT);
|
|
49
|
+
throw error;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return { render, setRenderAttempted: true, onlyRenderThis: true };
|
|
54
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
import { VIEW_SCOPE_TYPE } from "../constants/scopeType.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates a handler to manage the rendering status of elements in personalization
|
|
16
|
+
*
|
|
17
|
+
* @param {string} scopeType - The type of scope (e.g. 'view', 'page')
|
|
18
|
+
* @param {string} itemId - The unique identifier for the item being rendered
|
|
19
|
+
*/
|
|
20
|
+
export default (scopeType, itemId) => {
|
|
21
|
+
// We only care about tracking renders for view scope
|
|
22
|
+
if (scopeType !== VIEW_SCOPE_TYPE) {
|
|
23
|
+
return {
|
|
24
|
+
shouldRender: () => true,
|
|
25
|
+
markAsRendered: () => {},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
/**
|
|
30
|
+
* Determines if an element should be rendered based on scopeType and previous render status
|
|
31
|
+
*
|
|
32
|
+
* @param {Element|null} propositionContainer - The DOM element to check
|
|
33
|
+
* @returns {boolean} True if the element should be rendered, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
shouldRender: (propositionContainer) => {
|
|
36
|
+
if (!propositionContainer) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const previouslyRendered = (
|
|
40
|
+
propositionContainer.dataset.adobePropositionIds ?? ""
|
|
41
|
+
).split(",");
|
|
42
|
+
return !previouslyRendered.includes(itemId);
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Marks an element as rendered by setting a data attribute
|
|
46
|
+
*
|
|
47
|
+
* @param {Element} propositionContainer - The DOM element to mark as rendered
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
markAsRendered: (propositionContainer) => {
|
|
51
|
+
const previouslyRendered = (
|
|
52
|
+
propositionContainer.dataset.adobePropositionIds ?? ""
|
|
53
|
+
).split(",");
|
|
54
|
+
if (!previouslyRendered.includes(itemId)) {
|
|
55
|
+
previouslyRendered.push(itemId);
|
|
56
|
+
}
|
|
57
|
+
propositionContainer.dataset.adobePropositionIds = previouslyRendered
|
|
58
|
+
.sort()
|
|
59
|
+
.join(",");
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
};
|