@adobe/alloy 2.19.0-beta.9 → 2.19.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.
Files changed (111) hide show
  1. package/libEs5/components/DataCollector/index.js +3 -0
  2. package/libEs5/components/DataCollector/validateApplyResponse.js +2 -1
  3. package/libEs5/components/DataCollector/validateUserEventOptions.js +2 -1
  4. package/libEs5/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +32 -0
  5. package/libEs5/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js +25 -0
  6. package/libEs5/components/DecisioningEngine/constants.js +31 -0
  7. package/libEs5/components/DecisioningEngine/createApplyResponse.js +36 -0
  8. package/libEs5/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
  9. package/libEs5/components/DecisioningEngine/createContextProvider.js +93 -0
  10. package/libEs5/components/DecisioningEngine/createDecisionHistory.js +28 -0
  11. package/libEs5/components/DecisioningEngine/createDecisionProvider.js +51 -0
  12. package/libEs5/components/DecisioningEngine/createEvaluableRulesetPayload.js +80 -0
  13. package/libEs5/components/DecisioningEngine/createEvaluateRulesetsCommand.js +49 -0
  14. package/libEs5/components/DecisioningEngine/createEventRegistry.js +130 -0
  15. package/libEs5/components/DecisioningEngine/createOnResponseHandler.js +46 -0
  16. package/libEs5/components/DecisioningEngine/createSubscribeRulesetItems.js +87 -0
  17. package/libEs5/components/DecisioningEngine/index.js +119 -0
  18. package/libEs5/components/DecisioningEngine/utils.js +90 -0
  19. package/libEs5/components/Personalization/createActionsProvider.js +72 -0
  20. package/libEs5/components/Personalization/createApplyPropositions.js +2 -2
  21. package/libEs5/components/Personalization/createCollect.js +9 -4
  22. package/libEs5/components/Personalization/createComponent.js +5 -3
  23. package/libEs5/components/Personalization/createFetchDataHandler.js +2 -17
  24. package/libEs5/components/Personalization/createNotificationHandler.js +33 -0
  25. package/libEs5/components/Personalization/createOnClickHandler.js +5 -3
  26. package/libEs5/components/Personalization/createOnDecisionHandler.js +44 -0
  27. package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -5
  28. package/libEs5/components/Personalization/createPreprocessors.js +21 -0
  29. package/libEs5/components/Personalization/createViewCacheManager.js +9 -2
  30. package/libEs5/components/Personalization/dom-actions/createRedirect.js +11 -1
  31. package/libEs5/components/Personalization/event.js +25 -22
  32. package/libEs5/components/Personalization/handlers/createProcessInAppMessage.js +76 -0
  33. package/libEs5/components/Personalization/handlers/createProcessRedirect.js +5 -2
  34. package/libEs5/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +288 -0
  35. package/libEs5/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +23 -0
  36. package/libEs5/components/Personalization/in-app-message-actions/utils.js +53 -0
  37. package/libEs5/components/Personalization/index.js +20 -7
  38. package/libEs5/constants/contentType.js +18 -0
  39. package/libEs5/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +4 -8
  40. package/libEs5/constants/eventType.js +25 -0
  41. package/libEs5/{components/Personalization/constants/eventType.js → constants/handle.js} +4 -7
  42. package/libEs5/constants/libraryVersion.js +1 -1
  43. package/libEs5/constants/propositionEventType.js +33 -0
  44. package/libEs5/{components/Personalization/constants → constants}/schema.js +9 -1
  45. package/libEs5/core/componentCreators.js +2 -1
  46. package/libEs5/core/createEvent.js +26 -1
  47. package/libEs5/core/createEventManager.js +3 -0
  48. package/libEs5/core/createLifecycle.js +4 -1
  49. package/libEs5/utils/createSubscription.js +91 -0
  50. package/libEs5/utils/debounce.js +30 -0
  51. package/libEs5/utils/dom/selectNodesWithShadow.js +10 -3
  52. package/libEs5/utils/flattenArray.js +37 -0
  53. package/libEs5/utils/flattenObject.js +43 -0
  54. package/libEs5/utils/index.js +7 -0
  55. package/libEs5/utils/parseUrl.js +70 -0
  56. package/libEs6/components/DataCollector/index.js +2 -0
  57. package/libEs6/components/DataCollector/validateApplyResponse.js +2 -1
  58. package/libEs6/components/DataCollector/validateUserEventOptions.js +2 -1
  59. package/libEs6/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +30 -0
  60. package/libEs6/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js +24 -0
  61. package/libEs6/components/DecisioningEngine/constants.js +25 -0
  62. package/libEs6/components/DecisioningEngine/createApplyResponse.js +31 -0
  63. package/libEs6/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
  64. package/libEs6/components/DecisioningEngine/createContextProvider.js +95 -0
  65. package/libEs6/components/DecisioningEngine/createDecisionHistory.js +25 -0
  66. package/libEs6/components/DecisioningEngine/createDecisionProvider.js +41 -0
  67. package/libEs6/components/DecisioningEngine/createEvaluableRulesetPayload.js +79 -0
  68. package/libEs6/components/DecisioningEngine/createEvaluateRulesetsCommand.js +45 -0
  69. package/libEs6/components/DecisioningEngine/createEventRegistry.js +120 -0
  70. package/libEs6/components/DecisioningEngine/createOnResponseHandler.js +45 -0
  71. package/libEs6/components/DecisioningEngine/createSubscribeRulesetItems.js +79 -0
  72. package/libEs6/components/DecisioningEngine/index.js +124 -0
  73. package/libEs6/components/DecisioningEngine/utils.js +83 -0
  74. package/libEs6/components/Personalization/createActionsProvider.js +70 -0
  75. package/libEs6/components/Personalization/createApplyPropositions.js +2 -2
  76. package/libEs6/components/Personalization/createCollect.js +7 -4
  77. package/libEs6/components/Personalization/createComponent.js +5 -3
  78. package/libEs6/components/Personalization/createFetchDataHandler.js +3 -18
  79. package/libEs6/components/Personalization/createNotificationHandler.js +29 -0
  80. package/libEs6/components/Personalization/createOnClickHandler.js +5 -3
  81. package/libEs6/components/Personalization/createOnDecisionHandler.js +42 -0
  82. package/libEs6/components/Personalization/createPersonalizationDetails.js +8 -5
  83. package/libEs6/components/Personalization/createPreprocessors.js +19 -0
  84. package/libEs6/components/Personalization/createViewCacheManager.js +12 -3
  85. package/libEs6/components/Personalization/dom-actions/createRedirect.js +10 -1
  86. package/libEs6/components/Personalization/event.js +14 -9
  87. package/libEs6/components/Personalization/handlers/createProcessInAppMessage.js +77 -0
  88. package/libEs6/components/Personalization/handlers/createProcessRedirect.js +5 -2
  89. package/libEs6/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +291 -0
  90. package/libEs6/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +17 -0
  91. package/libEs6/components/Personalization/in-app-message-actions/utils.js +49 -0
  92. package/libEs6/components/Personalization/index.js +22 -8
  93. package/libEs6/{components/Personalization/constants/eventType.js → constants/contentType.js} +3 -4
  94. package/libEs6/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +2 -6
  95. package/libEs6/constants/eventType.js +17 -0
  96. package/libEs6/constants/handle.js +12 -0
  97. package/libEs6/constants/libraryVersion.js +1 -1
  98. package/libEs6/constants/propositionEventType.js +33 -0
  99. package/libEs6/{components/Personalization/constants → constants}/schema.js +4 -0
  100. package/libEs6/core/componentCreators.js +2 -1
  101. package/libEs6/core/createEvent.js +26 -1
  102. package/libEs6/core/createEventManager.js +2 -0
  103. package/libEs6/core/createLifecycle.js +4 -1
  104. package/libEs6/utils/createSubscription.js +70 -0
  105. package/libEs6/utils/debounce.js +22 -0
  106. package/libEs6/utils/dom/selectNodesWithShadow.js +10 -3
  107. package/libEs6/utils/flattenArray.js +26 -0
  108. package/libEs6/utils/flattenObject.js +28 -0
  109. package/libEs6/utils/index.js +1 -0
  110. package/libEs6/utils/parseUrl.js +62 -0
  111. package/package.json +6 -2
@@ -10,9 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { groupBy } from "../../utils";
13
+ import { assign, groupBy } from "../../utils";
14
14
  import defer from "../../utils/defer";
15
- import { DEFAULT_CONTENT_ITEM } from "./constants/schema";
15
+ import { DEFAULT_CONTENT_ITEM } from "../../constants/schema";
16
16
  import { VIEW_SCOPE_TYPE } from "./constants/scopeType";
17
17
  export default (({
18
18
  createProposition
@@ -42,7 +42,16 @@ export default (({
42
42
  const createCacheUpdate = viewName => {
43
43
  const updateCacheDeferred = defer();
44
44
  cacheUpdateCreatedAtLeastOnce = true;
45
- viewStoragePromise = viewStoragePromise.then(oldViewStorage => updateCacheDeferred.promise.catch(() => oldViewStorage));
45
+
46
+ // Additional updates will merge the new view propositions with the old.
47
+ // i.e. if there are new "cart" view propositions they will overwrite the
48
+ // old "cart" view propositions, but if there are no new "cart" view
49
+ // propositions the old "cart" view propositions will remain.
50
+ viewStoragePromise = viewStoragePromise.then(oldViewStorage => {
51
+ return updateCacheDeferred.promise.then(newViewStorage => {
52
+ return assign({}, oldViewStorage, newViewStorage);
53
+ }).catch(() => oldViewStorage);
54
+ });
46
55
  return {
47
56
  update(viewPropositions) {
48
57
  const viewPropositionsWithScope = viewPropositions.filter(proposition => proposition.getScope());
@@ -10,4 +10,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export default (window => url => window.location.replace(url));
13
+ export default (window => (url, preserveHistory = false) => {
14
+ if (preserveHistory) {
15
+ window.location.href = url;
16
+ } else {
17
+ window.location.replace(url);
18
+ }
19
+ // Return a promise that never resolves because redirects never complete
20
+ // within the current page.
21
+ return new Promise(() => undefined);
22
+ });
@@ -10,24 +10,29 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- const EVENT_TYPE_TRUE = 1;
13
+ import { EVENT_TYPE_TRUE } from "../../constants/eventType";
14
14
 
15
15
  /* eslint-disable no-underscore-dangle */
16
- export const mergeDecisionsMeta = (event, decisionsMeta, eventType, eventLabel = "") => {
16
+ export const mergeDecisionsMeta = (event, decisionsMeta, propositionEventTypes, propositionAction) => {
17
+ // Do not send a display notification with no decisions. Even empty view changes
18
+ // should include a proposition.
19
+ if (decisionsMeta.length === 0) {
20
+ return;
21
+ }
22
+ const propositionEventType = {};
23
+ propositionEventTypes.forEach(type => {
24
+ propositionEventType[type] = EVENT_TYPE_TRUE;
25
+ });
17
26
  const xdm = {
18
27
  _experience: {
19
28
  decisioning: {
20
29
  propositions: decisionsMeta,
21
- propositionEventType: {
22
- [eventType]: EVENT_TYPE_TRUE
23
- }
30
+ propositionEventType
24
31
  }
25
32
  }
26
33
  };
27
- if (eventLabel) {
28
- xdm._experience.decisioning.propositionAction = {
29
- label: eventLabel
30
- };
34
+ if (propositionAction) {
35
+ xdm._experience.decisioning.propositionAction = propositionAction;
31
36
  }
32
37
  event.mergeXdm(xdm);
33
38
  };
@@ -0,0 +1,77 @@
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 "../../../constants/contentType";
13
+ const DEFAULT_CONTENT = "defaultContent";
14
+ const expectedProps = ["content", "contentType"];
15
+ const expectedContentProps = ["mobileParameters", "webParameters", "html"];
16
+ const isValidInAppMessage = (data, logger) => {
17
+ for (let i = 0; i < expectedProps.length; i += 1) {
18
+ const prop = expectedProps[i];
19
+ if (!Object.prototype.hasOwnProperty.call(data, prop)) {
20
+ logger.warn(`Invalid in-app message data: missing property '${prop}'.`, data);
21
+ return false;
22
+ }
23
+ }
24
+ const {
25
+ content,
26
+ contentType
27
+ } = data;
28
+ if (contentType === APPLICATION_JSON) {
29
+ for (let i = 0; i < expectedContentProps.length; i += 1) {
30
+ const prop = expectedContentProps[i];
31
+ if (!Object.prototype.hasOwnProperty.call(content, prop)) {
32
+ logger.warn(`Invalid in-app message data.content: missing property '${prop}'.`, data);
33
+ return false;
34
+ }
35
+ }
36
+ }
37
+ return true;
38
+ };
39
+ export default (({
40
+ modules,
41
+ logger
42
+ }) => {
43
+ return item => {
44
+ const data = item.getData();
45
+ const meta = {
46
+ ...item.getProposition().getNotification()
47
+ };
48
+ if (!data) {
49
+ logger.warn("Invalid in-app message data: undefined.", data);
50
+ return {};
51
+ }
52
+ const {
53
+ type = DEFAULT_CONTENT
54
+ } = data;
55
+ if (!modules[type]) {
56
+ logger.warn("Invalid in-app message data: unknown type.", data);
57
+ return {};
58
+ }
59
+ if (!isValidInAppMessage(data, logger)) {
60
+ return {};
61
+ }
62
+ if (!meta) {
63
+ logger.warn("Invalid in-app message meta: undefined.", meta);
64
+ return {};
65
+ }
66
+ return {
67
+ render: () => {
68
+ return modules[type]({
69
+ ...data,
70
+ meta
71
+ });
72
+ },
73
+ setRenderAttempted: true,
74
+ includeInNotification: true
75
+ };
76
+ };
77
+ });
@@ -26,8 +26,11 @@ export default (({
26
26
  decisionsMeta: [item.getProposition().getNotification()],
27
27
  documentMayUnload: true
28
28
  }).then(() => {
29
- executeRedirect(content);
30
- // We've already sent the display notification, so don't return anything
29
+ return executeRedirect(content);
30
+ // Execute redirect will never resolve. If there are bottom of page events that are waiting
31
+ // for display notifications from this request, they will never run because this promise will
32
+ // not resolve. This is intentional because we don't want to run bottom of page events if
33
+ // there is a redirect.
31
34
  });
32
35
  };
33
36
 
@@ -0,0 +1,291 @@
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 { getNonce } from "../../dom-actions/dom";
14
+ import { parseAnchor, removeElementById } from "../utils";
15
+ import { TEXT_HTML } from "../../../../constants/contentType";
16
+ import { assign, includes, isNonEmptyString, values } from "../../../../utils";
17
+ import { createNode } from "../../../../utils/dom";
18
+ import { objectOf } from "../../../../utils/validation";
19
+ import { PropositionEventType } from "../../../../constants/propositionEventType";
20
+ import { EVENT_TYPE_TRUE, INTERACT } from "../../../../constants/eventType";
21
+ import createRedirect from "../../dom-actions/createRedirect";
22
+ const MESSAGING_CONTAINER_ID = "alloy-messaging-container";
23
+ const OVERLAY_CONTAINER_ID = "alloy-overlay-container";
24
+ const IFRAME_ID = "alloy-content-iframe";
25
+ const dismissMessage = () => [MESSAGING_CONTAINER_ID, OVERLAY_CONTAINER_ID].forEach(removeElementById);
26
+ export const createIframeClickHandler = (interact, navigateToUrl = createRedirect(window)) => {
27
+ return event => {
28
+ event.preventDefault();
29
+ event.stopImmediatePropagation();
30
+ const {
31
+ target
32
+ } = event;
33
+ const anchor = target.tagName.toLowerCase() === "a" ? target : target.closest("a");
34
+ if (!anchor) {
35
+ return;
36
+ }
37
+ const {
38
+ action,
39
+ interaction,
40
+ link,
41
+ label,
42
+ uuid
43
+ } = parseAnchor(anchor);
44
+ interact(action, {
45
+ label,
46
+ id: interaction,
47
+ uuid,
48
+ link
49
+ });
50
+ if (action === "dismiss") {
51
+ dismissMessage();
52
+ }
53
+ if (isNonEmptyString(link) && link.length > 0) {
54
+ navigateToUrl(link, true);
55
+ }
56
+ };
57
+ };
58
+ export const createIframe = (htmlContent, clickHandler) => {
59
+ const parser = new DOMParser();
60
+ const htmlDocument = parser.parseFromString(htmlContent, TEXT_HTML);
61
+ const scriptTag = htmlDocument.querySelector("script");
62
+ if (scriptTag) {
63
+ scriptTag.setAttribute("nonce", getNonce());
64
+ }
65
+ const element = createNode("iframe", {
66
+ src: URL.createObjectURL(new Blob([htmlDocument.documentElement.outerHTML], {
67
+ type: "text/html"
68
+ })),
69
+ id: IFRAME_ID
70
+ });
71
+ element.addEventListener("load", () => {
72
+ const {
73
+ addEventListener
74
+ } = element.contentDocument || element.contentWindow.document;
75
+ addEventListener("click", clickHandler);
76
+ });
77
+ return element;
78
+ };
79
+ const renderMessage = (iframe, webParameters, container, overlay) => {
80
+ [{
81
+ id: OVERLAY_CONTAINER_ID,
82
+ element: overlay
83
+ }, {
84
+ id: MESSAGING_CONTAINER_ID,
85
+ element: container
86
+ }, {
87
+ id: IFRAME_ID,
88
+ element: iframe
89
+ }].forEach(({
90
+ id,
91
+ element
92
+ }) => {
93
+ const {
94
+ style = {},
95
+ params = {}
96
+ } = webParameters[id];
97
+ assign(element.style, style);
98
+ const {
99
+ parentElement = "body",
100
+ insertionMethod = "appendChild",
101
+ enabled = true
102
+ } = params;
103
+ const parent = document.querySelector(parentElement);
104
+ if (enabled && parent && typeof parent[insertionMethod] === "function") {
105
+ parent[insertionMethod](element);
106
+ }
107
+ });
108
+ };
109
+ export const buildStyleFromMobileParameters = mobileParameters => {
110
+ const {
111
+ verticalAlign,
112
+ width,
113
+ horizontalAlign,
114
+ backdropColor,
115
+ height,
116
+ cornerRadius,
117
+ horizontalInset,
118
+ verticalInset,
119
+ uiTakeover = false
120
+ } = mobileParameters;
121
+ const style = {
122
+ width: width ? `${width}%` : "100%",
123
+ backgroundColor: backdropColor || "rgba(0, 0, 0, 0.5)",
124
+ borderRadius: cornerRadius ? `${cornerRadius}px` : "0px",
125
+ border: "none",
126
+ position: uiTakeover ? "fixed" : "relative",
127
+ overflow: "hidden"
128
+ };
129
+ if (horizontalAlign === "left") {
130
+ style.left = horizontalInset ? `${horizontalInset}%` : "0";
131
+ } else if (horizontalAlign === "right") {
132
+ style.right = horizontalInset ? `${horizontalInset}%` : "0";
133
+ } else if (horizontalAlign === "center") {
134
+ style.left = "50%";
135
+ style.transform = "translateX(-50%)";
136
+ }
137
+ if (verticalAlign === "top") {
138
+ style.top = verticalInset ? `${verticalInset}%` : "0";
139
+ } else if (verticalAlign === "bottom") {
140
+ style.position = "fixed";
141
+ style.bottom = verticalInset ? `${verticalInset}%` : "0";
142
+ } else if (verticalAlign === "center") {
143
+ style.top = "50%";
144
+ style.transform = `${horizontalAlign === "center" ? `${style.transform} ` : ""}translateY(-50%)`;
145
+ style.display = "flex";
146
+ style.alignItems = "center";
147
+ style.justifyContent = "center";
148
+ }
149
+ if (height) {
150
+ style.height = `${height}vh`;
151
+ } else {
152
+ style.height = "100%";
153
+ }
154
+ return style;
155
+ };
156
+ export const mobileOverlay = mobileParameters => {
157
+ const {
158
+ backdropOpacity,
159
+ backdropColor
160
+ } = mobileParameters;
161
+ const opacity = backdropOpacity || 0.5;
162
+ const color = backdropColor || "#FFFFFF";
163
+ const style = {
164
+ position: "fixed",
165
+ top: "0",
166
+ left: "0",
167
+ width: "100%",
168
+ height: "100%",
169
+ background: "transparent",
170
+ opacity,
171
+ backgroundColor: color
172
+ };
173
+ return style;
174
+ };
175
+ const REQUIRED_PARAMS = ["enabled", "parentElement", "insertionMethod"];
176
+ const isValidWebParameters = webParameters => {
177
+ if (!webParameters) {
178
+ return false;
179
+ }
180
+ const ids = Object.keys(webParameters);
181
+ if (!includes(ids, MESSAGING_CONTAINER_ID)) {
182
+ return false;
183
+ }
184
+ if (!includes(ids, OVERLAY_CONTAINER_ID)) {
185
+ return false;
186
+ }
187
+ const valuesArray = values(webParameters);
188
+ for (let i = 0; i < valuesArray.length; i += 1) {
189
+ if (!objectOf(valuesArray[i], "style")) {
190
+ return false;
191
+ }
192
+ if (!objectOf(valuesArray[i], "params")) {
193
+ return false;
194
+ }
195
+ for (let j = 0; j < REQUIRED_PARAMS.length; j += 1) {
196
+ if (!objectOf(valuesArray[i].params, REQUIRED_PARAMS[j])) {
197
+ return false;
198
+ }
199
+ }
200
+ }
201
+ return true;
202
+ };
203
+ const generateWebParameters = mobileParameters => {
204
+ if (!mobileParameters) {
205
+ return undefined;
206
+ }
207
+ const {
208
+ uiTakeover = false
209
+ } = mobileParameters;
210
+ return {
211
+ [IFRAME_ID]: {
212
+ style: {
213
+ border: "none",
214
+ width: "100%",
215
+ height: "100%"
216
+ },
217
+ params: {
218
+ enabled: true,
219
+ parentElement: "#alloy-messaging-container",
220
+ insertionMethod: "appendChild"
221
+ }
222
+ },
223
+ [MESSAGING_CONTAINER_ID]: {
224
+ style: buildStyleFromMobileParameters(mobileParameters),
225
+ params: {
226
+ enabled: true,
227
+ parentElement: "body",
228
+ insertionMethod: "appendChild"
229
+ }
230
+ },
231
+ [OVERLAY_CONTAINER_ID]: {
232
+ style: mobileOverlay(mobileParameters),
233
+ params: {
234
+ enabled: uiTakeover === true,
235
+ parentElement: "body",
236
+ insertionMethod: "appendChild"
237
+ }
238
+ }
239
+ };
240
+ };
241
+ export const displayHTMLContentInIframe = (settings = {}, interact) => {
242
+ dismissMessage();
243
+ const {
244
+ content,
245
+ contentType,
246
+ mobileParameters
247
+ } = settings;
248
+ let {
249
+ webParameters
250
+ } = settings;
251
+ if (contentType !== TEXT_HTML) {
252
+ return;
253
+ }
254
+ const container = createNode("div", {
255
+ id: MESSAGING_CONTAINER_ID
256
+ });
257
+ const iframe = createIframe(content, createIframeClickHandler(interact));
258
+ const overlay = createNode("div", {
259
+ id: OVERLAY_CONTAINER_ID
260
+ });
261
+ if (!isValidWebParameters(webParameters)) {
262
+ webParameters = generateWebParameters(mobileParameters);
263
+ }
264
+ if (!webParameters) {
265
+ return;
266
+ }
267
+ renderMessage(iframe, webParameters, container, overlay);
268
+ };
269
+ export default ((settings, collect) => {
270
+ return new Promise(resolve => {
271
+ const {
272
+ meta
273
+ } = settings;
274
+ displayHTMLContentInIframe(settings, (action, propositionAction) => {
275
+ const propositionEventTypes = {};
276
+ propositionEventTypes[PropositionEventType.INTERACT] = EVENT_TYPE_TRUE;
277
+ if (Object.values(PropositionEventType).indexOf(action) !== -1) {
278
+ propositionEventTypes[action] = EVENT_TYPE_TRUE;
279
+ }
280
+ collect({
281
+ decisionsMeta: [meta],
282
+ propositionAction,
283
+ eventType: INTERACT,
284
+ propositionEventTypes: Object.keys(propositionEventTypes)
285
+ });
286
+ });
287
+ resolve({
288
+ meta
289
+ });
290
+ });
291
+ });
@@ -0,0 +1,17 @@
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 displayIframeContent from "./actions/displayIframeContent";
13
+ export default (collect => {
14
+ return {
15
+ defaultContent: settings => displayIframeContent(settings, collect)
16
+ };
17
+ });
@@ -0,0 +1,49 @@
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 { isNonEmptyArray, queryString, startsWith } from "../../../utils";
13
+ import { removeNode, selectNodes } from "../../../utils/dom";
14
+ export const removeElementById = id => {
15
+ const element = selectNodes(`#${id}`, document);
16
+ if (element && element.length > 0) {
17
+ removeNode(element[0]);
18
+ }
19
+ };
20
+ export const parseAnchor = anchor => {
21
+ const nothing = {};
22
+ if (!anchor || anchor.tagName.toLowerCase() !== "a") {
23
+ return nothing;
24
+ }
25
+ const {
26
+ href
27
+ } = anchor;
28
+ if (!href || !startsWith(href, "adbinapp://")) {
29
+ return nothing;
30
+ }
31
+ const hrefParts = href.split("?");
32
+ const action = hrefParts[0].split("://")[1];
33
+ const label = anchor.innerText;
34
+ const uuid = anchor.getAttribute("data-uuid") || "";
35
+ let interaction;
36
+ let link;
37
+ if (isNonEmptyArray(hrefParts)) {
38
+ const queryParams = queryString.parse(hrefParts[1]);
39
+ interaction = queryParams.interaction || "";
40
+ link = decodeURIComponent(queryParams.link || "");
41
+ }
42
+ return {
43
+ action,
44
+ interaction,
45
+ link,
46
+ label,
47
+ uuid
48
+ };
49
+ };
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { string, boolean, objectOf } from "../../utils/validation";
13
+ import { boolean, objectOf, string } from "../../utils/validation";
14
14
  import createComponent from "./createComponent";
15
15
  import { initDomActionsModules } from "./dom-actions";
16
16
  import createCollect from "./createCollect";
@@ -31,14 +31,18 @@ import remapHeadOffers from "./dom-actions/remapHeadOffers";
31
31
  import createPreprocess from "./dom-actions/createPreprocess";
32
32
  import injectCreateProposition from "./handlers/injectCreateProposition";
33
33
  import createAsyncArray from "./utils/createAsyncArray";
34
- import * as schema from "./constants/schema";
34
+ import * as schema from "../../constants/schema";
35
35
  import processDefaultContent from "./handlers/processDefaultContent";
36
36
  import { isPageWideSurface } from "./utils/surfaceUtils";
37
37
  import createProcessDomAction from "./handlers/createProcessDomAction";
38
38
  import createProcessHtmlContent from "./handlers/createProcessHtmlContent";
39
39
  import createProcessRedirect from "./handlers/createProcessRedirect";
40
40
  import createProcessPropositions from "./handlers/createProcessPropositions";
41
+ import createOnDecisionHandler from "./createOnDecisionHandler";
42
+ import createProcessInAppMessage from "./handlers/createProcessInAppMessage";
43
+ import initInAppMessageActionsModules from "./in-app-message-actions/initInAppMessageActionsModules";
41
44
  import createRedirect from "./dom-actions/createRedirect";
45
+ import createNotificationHandler from "./createNotificationHandler";
42
46
  const createPersonalization = ({
43
47
  config,
44
48
  logger,
@@ -60,7 +64,7 @@ const createPersonalization = ({
60
64
  const getPageLocation = createGetPageLocation({
61
65
  window
62
66
  });
63
- const modules = initDomActionsModules();
67
+ const domActionsModules = initDomActionsModules();
64
68
  const preprocess = createPreprocess([remapHeadOffers, remapCustomCodeOffers]);
65
69
  const createProposition = injectCreateProposition({
66
70
  preprocess,
@@ -73,18 +77,22 @@ const createPersonalization = ({
73
77
  const schemaProcessors = {
74
78
  [schema.DEFAULT_CONTENT_ITEM]: processDefaultContent,
75
79
  [schema.DOM_ACTION]: createProcessDomAction({
76
- modules,
80
+ modules: domActionsModules,
77
81
  logger,
78
82
  storeClickMetrics
79
83
  }),
80
84
  [schema.HTML_CONTENT_ITEM]: createProcessHtmlContent({
81
- modules,
85
+ modules: domActionsModules,
82
86
  logger
83
87
  }),
84
88
  [schema.REDIRECT_ITEM]: createProcessRedirect({
85
89
  logger,
86
90
  executeRedirect,
87
91
  collect
92
+ }),
93
+ [schema.MESSAGE_IN_APP]: createProcessInAppMessage({
94
+ modules: initInAppMessageActionsModules(collect),
95
+ logger
88
96
  })
89
97
  };
90
98
  const processPropositions = createProcessPropositions({
@@ -92,15 +100,15 @@ const createPersonalization = ({
92
100
  logger
93
101
  });
94
102
  const renderedPropositions = createAsyncArray();
103
+ const notificationHandler = createNotificationHandler(collect, renderedPropositions);
95
104
  const fetchDataHandler = createFetchDataHandler({
96
105
  prehidingStyle,
97
106
  showContainers,
98
107
  hideContainers,
99
108
  mergeQuery,
100
- collect,
101
109
  processPropositions,
102
110
  createProposition,
103
- renderedPropositions
111
+ notificationHandler
104
112
  });
105
113
  const onClickHandler = createOnClickHandler({
106
114
  mergeDecisionsMeta,
@@ -121,6 +129,11 @@ const createPersonalization = ({
121
129
  const setTargetMigration = createSetTargetMigration({
122
130
  targetMigrationEnabled
123
131
  });
132
+ const onDecisionHandler = createOnDecisionHandler({
133
+ processPropositions,
134
+ createProposition,
135
+ notificationHandler
136
+ });
124
137
  return createComponent({
125
138
  getPageLocation,
126
139
  logger,
@@ -134,7 +147,8 @@ const createPersonalization = ({
134
147
  applyPropositions,
135
148
  setTargetMigration,
136
149
  mergeDecisionsMeta,
137
- renderedPropositions
150
+ renderedPropositions,
151
+ onDecisionHandler
138
152
  });
139
153
  };
140
154
  createPersonalization.namespace = "Personalization";
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2022 Adobe. All rights reserved.
2
+ Copyright 2023 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -9,6 +9,5 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
-
13
- export const DISPLAY = "decisioning.propositionDisplay";
14
- export const INTERACT = "decisioning.propositionInteract";
12
+ export const TEXT_HTML = "text/html";
13
+ export const APPLICATION_JSON = "application/json";
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2022 Adobe. All rights reserved.
2
+ Copyright 2023 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -9,8 +9,4 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
-
13
- export const PropositionEventType = {
14
- DISPLAY: "display",
15
- INTERACT: "interact"
16
- };
12
+ export const ADOBE_JOURNEY_OPTIMIZER = "AJO";