@adobe/alloy 2.18.0 → 2.19.0-beta.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 (75) hide show
  1. package/libEs5/components/DataCollector/index.js +4 -2
  2. package/libEs5/components/DataCollector/validateApplyResponse.js +6 -1
  3. package/libEs5/components/DataCollector/validateUserEventOptions.js +5 -1
  4. package/libEs5/components/Personalization/createApplyPropositions.js +38 -25
  5. package/libEs5/components/Personalization/createComponent.js +22 -14
  6. package/libEs5/components/Personalization/createFetchDataHandler.js +83 -18
  7. package/libEs5/components/Personalization/createOnClickHandler.js +2 -2
  8. package/libEs5/components/Personalization/createPendingNotificationsHandler.js +29 -0
  9. package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -2
  10. package/libEs5/components/Personalization/createViewCacheManager.js +60 -21
  11. package/libEs5/components/Personalization/createViewChangeHandler.js +25 -30
  12. package/libEs5/components/Personalization/dom-actions/action.js +5 -20
  13. package/{libEs6/components/Personalization/utils/composePersonalizationResultingObject.js → libEs5/components/Personalization/dom-actions/createPreprocess.js} +17 -13
  14. package/libEs5/components/Personalization/dom-actions/index.js +1 -9
  15. package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +2 -10
  16. package/libEs5/components/Personalization/dom-actions/remapHeadOffers.js +4 -0
  17. package/libEs5/components/Personalization/handlers/createProcessDomAction.js +61 -0
  18. package/libEs5/components/Personalization/handlers/createProcessHtmlContent.js +43 -0
  19. package/libEs5/components/Personalization/handlers/createProcessPropositions.js +240 -0
  20. package/libEs5/components/Personalization/handlers/createProcessRedirect.js +45 -0
  21. package/libEs5/components/Personalization/handlers/injectCreateProposition.js +124 -0
  22. package/libEs5/components/Personalization/{dom-actions/clicks/index.js → handlers/processDefaultContent.js} +8 -4
  23. package/libEs5/components/Personalization/index.js +70 -53
  24. package/libEs5/components/Personalization/utils/createAsyncArray.js +42 -0
  25. package/libEs5/components/Personalization/validateApplyPropositionsOptions.js +3 -2
  26. package/libEs5/constants/libraryVersion.js +1 -1
  27. package/libEs5/core/createEvent.js +31 -13
  28. package/libEs5/core/createEventManager.js +3 -2
  29. package/libEs5/{components/Personalization/utils/composePersonalizationResultingObject.js → utils/deduplicateArray.js} +16 -14
  30. package/libEs5/utils/index.js +8 -0
  31. package/libEs6/components/DataCollector/index.js +4 -2
  32. package/libEs6/components/DataCollector/validateApplyResponse.js +6 -1
  33. package/libEs6/components/DataCollector/validateUserEventOptions.js +5 -1
  34. package/libEs6/components/Personalization/createApplyPropositions.js +25 -24
  35. package/libEs6/components/Personalization/createComponent.js +23 -15
  36. package/libEs6/components/Personalization/createFetchDataHandler.js +65 -9
  37. package/libEs6/components/Personalization/createOnClickHandler.js +3 -3
  38. package/{libEs5/components/Personalization/dom-actions/click.js → libEs6/components/Personalization/createPendingNotificationsHandler.js} +11 -15
  39. package/libEs6/components/Personalization/createPersonalizationDetails.js +10 -2
  40. package/libEs6/components/Personalization/createViewCacheManager.js +55 -20
  41. package/libEs6/components/Personalization/createViewChangeHandler.js +25 -28
  42. package/libEs6/components/Personalization/dom-actions/action.js +4 -12
  43. package/libEs6/components/Personalization/dom-actions/{click.js → createPreprocess.js} +8 -11
  44. package/libEs6/components/Personalization/dom-actions/index.js +1 -2
  45. package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +3 -7
  46. package/libEs6/components/Personalization/dom-actions/remapHeadOffers.js +4 -0
  47. package/libEs6/components/Personalization/handlers/createProcessDomAction.js +53 -0
  48. package/libEs6/components/Personalization/handlers/createProcessHtmlContent.js +37 -0
  49. package/libEs6/components/Personalization/handlers/createProcessPropositions.js +202 -0
  50. package/libEs6/components/Personalization/handlers/createProcessRedirect.js +39 -0
  51. package/libEs6/components/Personalization/handlers/injectCreateProposition.js +129 -0
  52. package/libEs6/components/Personalization/{dom-actions/clicks/index.js → handlers/processDefaultContent.js} +7 -3
  53. package/libEs6/components/Personalization/index.js +60 -40
  54. package/libEs6/components/Personalization/utils/createAsyncArray.js +37 -0
  55. package/libEs6/components/Personalization/validateApplyPropositionsOptions.js +4 -3
  56. package/libEs6/constants/libraryVersion.js +1 -1
  57. package/libEs6/core/createEvent.js +19 -3
  58. package/libEs6/core/createEventManager.js +3 -2
  59. package/libEs6/utils/deduplicateArray.js +26 -0
  60. package/libEs6/utils/index.js +1 -0
  61. package/package.json +2 -2
  62. package/libEs5/components/Personalization/createAutoRenderingHandler.js +0 -92
  63. package/libEs5/components/Personalization/createExecuteDecisions.js +0 -89
  64. package/libEs5/components/Personalization/createNonRenderingHandler.js +0 -66
  65. package/libEs5/components/Personalization/createOnResponseHandler.js +0 -73
  66. package/libEs5/components/Personalization/createRedirectHandler.js +0 -58
  67. package/libEs5/components/Personalization/dom-actions/executeActions.js +0 -75
  68. package/libEs5/components/Personalization/groupDecisions.js +0 -160
  69. package/libEs6/components/Personalization/createAutoRenderingHandler.js +0 -84
  70. package/libEs6/components/Personalization/createExecuteDecisions.js +0 -77
  71. package/libEs6/components/Personalization/createNonRenderingHandler.js +0 -56
  72. package/libEs6/components/Personalization/createOnResponseHandler.js +0 -68
  73. package/libEs6/components/Personalization/createRedirectHandler.js +0 -57
  74. package/libEs6/components/Personalization/dom-actions/executeActions.js +0 -66
  75. package/libEs6/components/Personalization/groupDecisions.js +0 -131
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020 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,14 +9,20 @@ 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
+ import { defer, groupBy } from "../../utils";
13
+ const DECISIONS_HANDLE = "personalization:decisions";
12
14
  export default (({
13
15
  prehidingStyle,
14
- responseHandler,
16
+ showContainers,
15
17
  hideContainers,
16
- mergeQuery
18
+ mergeQuery,
19
+ collect,
20
+ processPropositions,
21
+ createProposition,
22
+ pendingDisplayNotifications
17
23
  }) => {
18
24
  return ({
19
- decisionsDeferred,
25
+ cacheUpdate,
20
26
  personalizationDetails,
21
27
  event,
22
28
  onResponse
@@ -26,12 +32,62 @@ export default (({
26
32
  }
27
33
 
28
34
  mergeQuery(event, personalizationDetails.createQueryDetails());
35
+ let handleNotifications;
36
+
37
+ if (personalizationDetails.isSendDisplayNotifications()) {
38
+ handleNotifications = decisionsMeta => {
39
+ if (decisionsMeta.length > 0) {
40
+ collect({
41
+ decisionsMeta,
42
+ viewName: personalizationDetails.getViewName()
43
+ });
44
+ }
45
+ };
46
+ } else {
47
+ const displayNotificationsDeferred = defer();
48
+ pendingDisplayNotifications.concat(displayNotificationsDeferred.promise);
49
+ handleNotifications = displayNotificationsDeferred.resolve;
50
+ }
51
+
29
52
  onResponse(({
30
53
  response
31
- }) => responseHandler({
32
- decisionsDeferred,
33
- personalizationDetails,
34
- response
35
- }));
54
+ }) => {
55
+ const handles = response.getPayloadsByType(DECISIONS_HANDLE);
56
+ const propositions = handles.map(handle => createProposition(handle));
57
+ const {
58
+ page: pagePropositions = [],
59
+ view: viewPropositions = [],
60
+ proposition: nonRenderedPropositions = []
61
+ } = groupBy(propositions, p => p.getScopeType());
62
+ const currentViewPropositions = cacheUpdate.update(viewPropositions);
63
+ let render;
64
+ let returnedPropositions;
65
+ let returnedDecisions;
66
+
67
+ if (personalizationDetails.isRenderDecisions()) {
68
+ ({
69
+ render,
70
+ returnedPropositions,
71
+ returnedDecisions
72
+ } = processPropositions([...pagePropositions, ...currentViewPropositions], nonRenderedPropositions));
73
+ render().then(decisionsMeta => {
74
+ showContainers();
75
+ handleNotifications(decisionsMeta);
76
+ }).catch(e => {
77
+ showContainers();
78
+ throw e;
79
+ });
80
+ } else {
81
+ ({
82
+ returnedPropositions,
83
+ returnedDecisions
84
+ } = processPropositions([], [...pagePropositions, ...currentViewPropositions, ...nonRenderedPropositions]));
85
+ }
86
+
87
+ return {
88
+ propositions: returnedPropositions,
89
+ decisions: returnedDecisions
90
+ };
91
+ });
36
92
  };
37
93
  });
@@ -9,7 +9,7 @@ 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
- import { isNonEmptyArray } from "../../utils";
12
+ import { isNonEmptyArray, isNonEmptyString } from "../../utils";
13
13
  import { INTERACT } from "./constants/eventType";
14
14
  import { PropositionEventType } from "./constants/propositionEventType";
15
15
  import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
@@ -38,10 +38,10 @@ export default (({
38
38
  };
39
39
  const scope = decisionsMeta[0].scope;
40
40
 
41
- if (scope !== PAGE_WIDE_SCOPE) {
41
+ if (isNonEmptyString(scope) && scope !== PAGE_WIDE_SCOPE) {
42
42
  xdm.web = {
43
43
  webPageDetails: {
44
- viewName: scope
44
+ viewName: scope.toLowerCase()
45
45
  }
46
46
  };
47
47
  }
@@ -1,9 +1,5 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
-
5
1
  /*
6
- Copyright 2019 Adobe. All rights reserved.
2
+ Copyright 2023 Adobe. All rights reserved.
7
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
4
  you may not use this file except in compliance with the License. You may obtain a copy
9
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -13,14 +9,14 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
13
9
  OF ANY KIND, either express or implied. See the License for the specific language
14
10
  governing permissions and limitations under the License.
15
11
  */
16
- var _default = function _default(settings, store) {
17
- var selector = settings.selector,
18
- meta = settings.meta;
19
- store({
20
- selector: selector,
21
- meta: meta
12
+ import { PropositionEventType } from "./constants/propositionEventType";
13
+ export default (({
14
+ pendingDisplayNotifications,
15
+ mergeDecisionsMeta
16
+ }) => ({
17
+ event
18
+ }) => {
19
+ return pendingDisplayNotifications.clear().then(decisionsMeta => {
20
+ mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY);
22
21
  });
23
- return Promise.resolve();
24
- };
25
-
26
- exports.default = _default;
22
+ });
@@ -36,7 +36,7 @@ export default (({
36
36
  decisionScopes,
37
37
  personalization,
38
38
  event,
39
- viewCache,
39
+ isCacheInitialized,
40
40
  logger
41
41
  }) => {
42
42
  const viewName = event.getViewName();
@@ -45,6 +45,14 @@ export default (({
45
45
  return renderDecisions;
46
46
  },
47
47
 
48
+ isSendDisplayNotifications() {
49
+ return !!personalization.sendDisplayNotifications;
50
+ },
51
+
52
+ shouldAddPendingDisplayNotifications() {
53
+ return !!personalization.includePendingDisplayNotifications;
54
+ },
55
+
48
56
  getViewName() {
49
57
  return viewName;
50
58
  },
@@ -89,7 +97,7 @@ export default (({
89
97
  },
90
98
 
91
99
  isCacheInitialized() {
92
- return viewCache.isInitialized();
100
+ return isCacheInitialized;
93
101
  },
94
102
 
95
103
  shouldFetchData() {
@@ -9,39 +9,74 @@ 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
- import { assign } from "../../utils";
12
+ import { assign, groupBy } from "../../utils";
13
13
  import defer from "../../utils/defer";
14
- export default (() => {
15
- let viewStorage;
16
- const viewStorageDeferred = defer();
17
-
18
- const storeViews = decisionsPromise => {
19
- decisionsPromise.then(decisions => {
20
- if (viewStorage === undefined) {
21
- viewStorage = {};
22
- }
14
+ import { DEFAULT_CONTENT_ITEM } from "./constants/schema";
15
+ export default (({
16
+ createProposition
17
+ }) => {
18
+ const viewStorage = {};
19
+ let cacheUpdateCreatedAtLeastOnce = false;
20
+ let previousUpdateCacheComplete = Promise.resolve();
21
+
22
+ const getViewPropositions = (currentViewStorage, viewName) => {
23
+ const viewPropositions = currentViewStorage[viewName.toLowerCase()];
24
+
25
+ if (viewPropositions && viewPropositions.length > 0) {
26
+ return viewPropositions;
27
+ }
28
+
29
+ const emptyViewProposition = createProposition({
30
+ scope: viewName,
31
+ scopeDetails: {
32
+ characteristics: {
33
+ scopeType: "view"
34
+ }
35
+ },
36
+ items: [{
37
+ schema: DEFAULT_CONTENT_ITEM
38
+ }]
39
+ }, false);
40
+ return [emptyViewProposition];
41
+ }; // This should be called before making the request to experience edge.
42
+
43
+
44
+ const createCacheUpdate = viewName => {
45
+ const updateCacheDeferred = defer();
46
+ cacheUpdateCreatedAtLeastOnce = true;
47
+ previousUpdateCacheComplete = previousUpdateCacheComplete.then(() => updateCacheDeferred.promise).then(newViewStorage => {
48
+ assign(viewStorage, newViewStorage);
49
+ }).catch(() => {});
50
+ return {
51
+ update(viewPropositions) {
52
+ const viewPropositionsWithScope = viewPropositions.filter(proposition => proposition.getScope());
53
+ const newViewStorage = groupBy(viewPropositionsWithScope, proposition => proposition.getScope().toLowerCase());
54
+ updateCacheDeferred.resolve(newViewStorage);
55
+
56
+ if (viewName) {
57
+ return getViewPropositions(newViewStorage, viewName);
58
+ }
59
+
60
+ return [];
61
+ },
23
62
 
24
- assign(viewStorage, decisions);
25
- viewStorageDeferred.resolve();
26
- }).catch(() => {
27
- if (viewStorage === undefined) {
28
- viewStorage = {};
63
+ cancel() {
64
+ updateCacheDeferred.reject();
29
65
  }
30
66
 
31
- viewStorageDeferred.resolve();
32
- });
67
+ };
33
68
  };
34
69
 
35
70
  const getView = viewName => {
36
- return viewStorageDeferred.promise.then(() => viewStorage[viewName] || []);
71
+ return previousUpdateCacheComplete.then(() => getViewPropositions(viewStorage, viewName));
37
72
  };
38
73
 
39
74
  const isInitialized = () => {
40
- return !(viewStorage === undefined);
75
+ return cacheUpdateCreatedAtLeastOnce;
41
76
  };
42
77
 
43
78
  return {
44
- storeViews,
79
+ createCacheUpdate,
45
80
  getView,
46
81
  isInitialized
47
82
  };
@@ -9,13 +9,10 @@ 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
- import composePersonalizationResultingObject from "./utils/composePersonalizationResultingObject";
13
- import { isNonEmptyArray } from "../../utils";
14
12
  import { PropositionEventType } from "./constants/propositionEventType";
15
13
  export default (({
16
14
  mergeDecisionsMeta,
17
- collect,
18
- executeDecisions,
15
+ processPropositions,
19
16
  viewCache
20
17
  }) => {
21
18
  return ({
@@ -23,34 +20,34 @@ export default (({
23
20
  event,
24
21
  onResponse
25
22
  }) => {
23
+ let returnedPropositions;
24
+ let returnedDecisions;
26
25
  const viewName = personalizationDetails.getViewName();
27
- return viewCache.getView(viewName).then(viewDecisions => {
28
- if (personalizationDetails.isRenderDecisions()) {
29
- return executeDecisions(viewDecisions).then(decisionsMeta => {
30
- // if there are decisions to be rendered we render them and attach the result in experience.decisions.propositions
31
- if (isNonEmptyArray(decisionsMeta)) {
32
- mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY);
33
- onResponse(() => {
34
- return composePersonalizationResultingObject(viewDecisions, true);
35
- });
36
- return;
37
- } // if there are no decisions in cache for this view, we will send a empty notification
38
-
26
+ onResponse(() => {
27
+ return {
28
+ propositions: returnedPropositions,
29
+ decisions: returnedDecisions
30
+ };
31
+ });
32
+ return viewCache.getView(viewName).then(propositions => {
33
+ let render;
39
34
 
40
- onResponse(() => {
41
- collect({
42
- decisionsMeta: [],
43
- viewName
44
- });
45
- return composePersonalizationResultingObject(viewDecisions, true);
46
- });
47
- });
35
+ if (personalizationDetails.isRenderDecisions()) {
36
+ ({
37
+ render,
38
+ returnedPropositions,
39
+ returnedDecisions
40
+ } = processPropositions(propositions));
41
+ return render();
48
42
  }
49
43
 
50
- onResponse(() => {
51
- return composePersonalizationResultingObject(viewDecisions, false);
52
- });
53
- return {};
44
+ ({
45
+ returnedPropositions,
46
+ returnedDecisions
47
+ } = processPropositions([], propositions));
48
+ return [];
49
+ }).then(decisionsMeta => {
50
+ mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY);
54
51
  });
55
52
  };
56
53
  });
@@ -23,7 +23,6 @@ export { default as setStyles } from "./setStyles";
23
23
  export { default as setAttributes } from "./setAttributes";
24
24
  export { default as swapImage } from "./swapImage";
25
25
  export { default as rearrangeChildren } from "./rearrangeChildren";
26
- export { default as click } from "./click";
27
26
 
28
27
  const renderContent = (elements, content, renderFunc) => {
29
28
  const executions = elements.map(element => renderFunc(element, content));
@@ -31,28 +30,21 @@ const renderContent = (elements, content, renderFunc) => {
31
30
  };
32
31
 
33
32
  export const createAction = renderFunc => {
34
- return settings => {
33
+ return itemData => {
35
34
  const {
36
35
  selector,
37
36
  prehidingSelector,
38
- content,
39
- meta
40
- } = settings;
37
+ content
38
+ } = itemData;
41
39
  hideElements(prehidingSelector);
42
40
  return awaitSelector(selector, selectNodesWithEq).then(elements => renderContent(elements, content, renderFunc)).then(() => {
43
41
  // if everything is OK, show elements
44
42
  showElements(prehidingSelector);
45
- return {
46
- meta
47
- };
48
43
  }, error => {
49
44
  // in case of awaiting timing or error, we need to remove the style tag
50
45
  // hence showing the pre-hidden elements
51
46
  showElements(prehidingSelector);
52
- return {
53
- meta,
54
- error
55
- };
47
+ throw error;
56
48
  });
57
49
  };
58
50
  };
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2019 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,14 +9,11 @@ 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
- export default ((settings, store) => {
13
- const {
14
- selector,
15
- meta
16
- } = settings;
17
- store({
18
- selector,
19
- meta
20
- });
21
- return Promise.resolve();
12
+ import { assign } from "../../../utils";
13
+ export default (preprocessors => action => {
14
+ if (!action) {
15
+ return action;
16
+ }
17
+
18
+ return preprocessors.reduce((processed, fn) => assign(processed, fn(processed)), action);
22
19
  });
@@ -9,5 +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
- export { default as initDomActionsModules } from "./initDomActionsModules";
13
- export { default as executeActions } from "./executeActions";
12
+ export { default as initDomActionsModules } from "./initDomActionsModules";
@@ -10,8 +10,8 @@ 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
  import { removeNode } from "../../../utils/dom";
13
- import { createAction, setHtml, setText, setAttributes, swapImage, setStyles, rearrangeChildren, replaceHtml, appendHtml, prependHtml, insertHtmlAfter, insertHtmlBefore, click } from "./action";
14
- export default (store => {
13
+ import { createAction, setHtml, setText, setAttributes, swapImage, setStyles, rearrangeChildren, replaceHtml, appendHtml, prependHtml, insertHtmlAfter, insertHtmlBefore } from "./action";
14
+ export default (() => {
15
15
  return {
16
16
  setHtml: createAction(setHtml),
17
17
  customCode: createAction(prependHtml),
@@ -27,10 +27,6 @@ export default (store => {
27
27
  insertBefore: createAction(insertHtmlBefore),
28
28
  replaceHtml: createAction(replaceHtml),
29
29
  prependHtml: createAction(prependHtml),
30
- appendHtml: createAction(appendHtml),
31
- click: settings => click(settings, store),
32
- defaultContent: settings => Promise.resolve({
33
- meta: settings.meta
34
- })
30
+ appendHtml: createAction(appendHtml)
35
31
  };
36
32
  });
@@ -41,6 +41,10 @@ export default (action => {
41
41
  return result;
42
42
  }
43
43
 
44
+ if (selector == null) {
45
+ return result;
46
+ }
47
+
44
48
  const container = selectNodesWithEq(selector);
45
49
 
46
50
  if (!is(container[0], HEAD)) {
@@ -0,0 +1,53 @@
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
+ export default (({
13
+ modules,
14
+ logger,
15
+ storeClickMetrics
16
+ }) => item => {
17
+ const {
18
+ type,
19
+ selector
20
+ } = item.getData() || {};
21
+
22
+ if (!type) {
23
+ logger.warn("Invalid DOM action data: missing type.", item.getData());
24
+ return {};
25
+ }
26
+
27
+ if (type === "click") {
28
+ if (!selector) {
29
+ logger.warn("Invalid DOM action data: missing selector.", item.getData());
30
+ return {};
31
+ }
32
+
33
+ storeClickMetrics({
34
+ selector,
35
+ meta: item.getMeta()
36
+ });
37
+ return {
38
+ setRenderAttempted: true,
39
+ includeInNotification: false
40
+ };
41
+ }
42
+
43
+ if (!modules[type]) {
44
+ logger.warn("Invalid DOM action data: unknown type.", item.getData());
45
+ return {};
46
+ }
47
+
48
+ return {
49
+ render: () => modules[type](item.getData()),
50
+ setRenderAttempted: true,
51
+ includeInNotification: true
52
+ };
53
+ });
@@ -0,0 +1,37 @@
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
+ export default (({
13
+ modules,
14
+ logger
15
+ }) => item => {
16
+ const {
17
+ type,
18
+ selector
19
+ } = item.getData() || {};
20
+
21
+ if (!selector || !type) {
22
+ return {};
23
+ }
24
+
25
+ if (!modules[type]) {
26
+ logger.warn("Invalid HTML content data", item.getData());
27
+ return {};
28
+ }
29
+
30
+ return {
31
+ render: () => {
32
+ modules[type](item.getData());
33
+ },
34
+ setRenderAttempted: true,
35
+ includeInNotification: true
36
+ };
37
+ });