diff --git a/sandbox/src/components/InAppMessagesDemo/InAppMessages.js b/sandbox/src/components/InAppMessagesDemo/InAppMessages.js index 7fba21916..8d5f46a69 100644 --- a/sandbox/src/components/InAppMessagesDemo/InAppMessages.js +++ b/sandbox/src/components/InAppMessagesDemo/InAppMessages.js @@ -28,7 +28,7 @@ const config = { alloyInstance: window.iamAlloy, datastreamId: "8cefc5ca-1c2a-479f-88f2-3d42cc302514", orgId: "906E3A095DC834230A495FD6@AdobeOrg", - surface: "mobileapp://com.adobe.aguaAppIos", + surface: "web://localhost:3000/inAppMessages", decisionContext: {}, edgeDomain: "edge.adobedc.net", activeCampaigns: [ diff --git a/src/components/Personalization/createCollect.js b/src/components/Personalization/createCollect.js index 54bc6fad1..07de13458 100644 --- a/src/components/Personalization/createCollect.js +++ b/src/components/Personalization/createCollect.js @@ -20,7 +20,7 @@ export default ({ eventManager, mergeDecisionsMeta }) => { propositionAction, documentMayUnload = false, eventType = DISPLAY, - propositionEventType = getPropositionEventType(eventType), + propositionEventTypes = [getPropositionEventType(eventType)], viewName }) => { const event = eventManager.createEvent(); @@ -35,7 +35,7 @@ export default ({ eventManager, mergeDecisionsMeta }) => { mergeDecisionsMeta( event, decisionsMeta, - propositionEventType, + propositionEventTypes, propositionAction ); } diff --git a/src/components/Personalization/createComponent.js b/src/components/Personalization/createComponent.js index 236c56002..e7464ee83 100644 --- a/src/components/Personalization/createComponent.js +++ b/src/components/Personalization/createComponent.js @@ -33,9 +33,7 @@ export default ({ }) => { return { lifecycle: { - onDecision({ viewName, renderDecisions, propositions }) { - return onDecisionHandler({ viewName, renderDecisions, propositions }); - }, + onDecision: onDecisionHandler, onBeforeRequest({ request }) { setTargetMigration(request); return Promise.resolve(); diff --git a/src/components/Personalization/createOnClickHandler.js b/src/components/Personalization/createOnClickHandler.js index cbf51f7d6..b6f8d5207 100644 --- a/src/components/Personalization/createOnClickHandler.js +++ b/src/components/Personalization/createOnClickHandler.js @@ -47,7 +47,7 @@ export default ({ mergeDecisionsMeta( event, decisionsMeta, - PropositionEventType.INTERACT, + [PropositionEventType.INTERACT], eventLabel ? { label: eventLabel } : undefined ); } diff --git a/src/components/Personalization/createPendingNotificationsHandler.js b/src/components/Personalization/createPendingNotificationsHandler.js index 6fa3b488b..8b786d3c9 100644 --- a/src/components/Personalization/createPendingNotificationsHandler.js +++ b/src/components/Personalization/createPendingNotificationsHandler.js @@ -15,6 +15,6 @@ export default ({ pendingDisplayNotifications, mergeDecisionsMeta }) => ({ event }) => { return pendingDisplayNotifications.clear().then(decisionsMeta => { - mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY); + mergeDecisionsMeta(event, decisionsMeta, [PropositionEventType.DISPLAY]); }); }; diff --git a/src/components/Personalization/createViewChangeHandler.js b/src/components/Personalization/createViewChangeHandler.js index f745223a4..02dd66c64 100644 --- a/src/components/Personalization/createViewChangeHandler.js +++ b/src/components/Personalization/createViewChangeHandler.js @@ -44,7 +44,9 @@ export default ({ mergeDecisionsMeta, processPropositions, viewCache }) => { return []; }) .then(decisionsMeta => { - mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY); + mergeDecisionsMeta(event, decisionsMeta, [ + PropositionEventType.DISPLAY + ]); }); }; }; diff --git a/src/components/Personalization/event.js b/src/components/Personalization/event.js index c7fa19e7a..ef97f2818 100644 --- a/src/components/Personalization/event.js +++ b/src/components/Personalization/event.js @@ -16,16 +16,20 @@ import { EVENT_TYPE_TRUE } from "../../constants/eventType"; export const mergeDecisionsMeta = ( event, decisionsMeta, - propositionEventType, + propositionEventTypes, propositionAction ) => { + const propositionEventType = {}; + + propositionEventTypes.forEach(type => { + propositionEventType[type] = EVENT_TYPE_TRUE; + }); + const xdm = { _experience: { decisioning: { propositions: decisionsMeta, - propositionEventType: { - [propositionEventType]: EVENT_TYPE_TRUE - } + propositionEventType } } }; diff --git a/src/components/Personalization/in-app-message-actions/actions/displayIframeContent.js b/src/components/Personalization/in-app-message-actions/actions/displayIframeContent.js index 4a768eb26..fa9372299 100644 --- a/src/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +++ b/src/components/Personalization/in-app-message-actions/actions/displayIframeContent.js @@ -14,7 +14,8 @@ import { getNonce } from "../../dom-actions/dom"; import { createElement, parseAnchor, removeElementById } from "../utils"; import { TEXT_HTML } from "../../constants/contentType"; import { assign } from "../../../../utils"; -import { getEventType } from "../../../../constants/propositionEventType"; +import { PropositionEventType } from "../../../../constants/propositionEventType"; +import { INTERACT } from "../../../../constants/eventType"; const ALLOY_MESSAGING_CONTAINER_ID = "alloy-messaging-container"; const ALLOY_OVERLAY_CONTAINER_ID = "alloy-overlay-container"; @@ -290,10 +291,18 @@ export default (settings, collect) => { return new Promise(resolve => { const { meta } = settings; displayHTMLContentInIframe(settings, (action, propositionAction) => { + const propositionEventTypes = new Set(); + propositionEventTypes.add(PropositionEventType.INTERACT); + + if (Object.values(PropositionEventType).indexOf(action) !== -1) { + propositionEventTypes.add(action); + } + collect({ decisionsMeta: [meta], propositionAction, - eventType: getEventType(action) + eventType: INTERACT, + propositionEventTypes: Array.from(propositionEventTypes) }); }); diff --git a/test/unit/specs/components/Personalization/createCollect.spec.js b/test/unit/specs/components/Personalization/createCollect.spec.js index fc4fb4e1e..8c3ef3a1c 100644 --- a/test/unit/specs/components/Personalization/createCollect.spec.js +++ b/test/unit/specs/components/Personalization/createCollect.spec.js @@ -43,7 +43,7 @@ describe("Personalization::createCollect", () => { expect(mergeDecisionsMeta).toHaveBeenCalledWith( event, decisionsMeta, - PropositionEventType.DISPLAY, + [PropositionEventType.DISPLAY], undefined ); expect(eventManager.sendEvent).toHaveBeenCalled(); diff --git a/test/unit/specs/components/Personalization/createPendingNotificationsHandler.spec.js b/test/unit/specs/components/Personalization/createPendingNotificationsHandler.spec.js index 6982f2e86..a5a1bfd88 100644 --- a/test/unit/specs/components/Personalization/createPendingNotificationsHandler.spec.js +++ b/test/unit/specs/components/Personalization/createPendingNotificationsHandler.spec.js @@ -38,7 +38,7 @@ describe("Personalization::createPendingNotificationsHandler", () => { expect(mergeDecisionsMeta).toHaveBeenCalledOnceWith( event, ["mymeta1", "mymeta2"], - "display" + ["display"] ); }); }); diff --git a/test/unit/specs/components/Personalization/createViewChangeHandler.spec.js b/test/unit/specs/components/Personalization/createViewChangeHandler.spec.js index feed84e82..550fb87b6 100644 --- a/test/unit/specs/components/Personalization/createViewChangeHandler.spec.js +++ b/test/unit/specs/components/Personalization/createViewChangeHandler.spec.js @@ -73,11 +73,9 @@ describe("Personalization::createViewChangeHandler", () => { const result = await run(); expect(processPropositions).toHaveBeenCalledTimes(1); - expect(mergeDecisionsMeta).toHaveBeenCalledWith( - "myevent", - "decisionMeta", + expect(mergeDecisionsMeta).toHaveBeenCalledWith("myevent", "decisionMeta", [ PropositionEventType.DISPLAY - ); + ]); expect(result.decisions).toEqual(CART_VIEW_DECISIONS); }); }); diff --git a/test/unit/specs/components/Personalization/event.spec.js b/test/unit/specs/components/Personalization/event.spec.js index 91f8a1b1a..b769ff5b2 100644 --- a/test/unit/specs/components/Personalization/event.spec.js +++ b/test/unit/specs/components/Personalization/event.spec.js @@ -35,7 +35,7 @@ describe("Personalization::event", () => { scope: "cart" } ]; - mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY); + mergeDecisionsMeta(event, decisionsMeta, [PropositionEventType.DISPLAY]); expect(event.mergeXdm).toHaveBeenCalledWith({ _experience: { decisioning: {