@adobe/alloy 2.19.0-beta.8 → 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 (121) 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/{Personalization/utils/isPageWideScope.js → DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js} +10 -5
  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/constants/scopeType.js +6 -2
  20. package/libEs5/components/Personalization/createActionsProvider.js +72 -0
  21. package/libEs5/components/Personalization/createApplyPropositions.js +2 -2
  22. package/libEs5/components/Personalization/createClickStorage.js +21 -13
  23. package/libEs5/components/Personalization/createCollect.js +9 -4
  24. package/libEs5/components/Personalization/createComponent.js +5 -3
  25. package/libEs5/components/Personalization/createFetchDataHandler.js +2 -17
  26. package/libEs5/components/Personalization/createNotificationHandler.js +33 -0
  27. package/libEs5/components/Personalization/createOnClickHandler.js +9 -8
  28. package/libEs5/components/Personalization/createOnDecisionHandler.js +44 -0
  29. package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -5
  30. package/libEs5/components/Personalization/createPreprocessors.js +21 -0
  31. package/libEs5/components/Personalization/createViewCacheManager.js +11 -3
  32. package/libEs5/components/Personalization/dom-actions/clicks/collectClicks.js +43 -23
  33. package/libEs5/components/Personalization/dom-actions/createRedirect.js +11 -1
  34. package/libEs5/components/Personalization/event.js +25 -22
  35. package/libEs5/components/Personalization/handlers/createProcessDomAction.js +7 -1
  36. package/libEs5/components/Personalization/handlers/createProcessInAppMessage.js +76 -0
  37. package/libEs5/components/Personalization/handlers/createProcessRedirect.js +6 -3
  38. package/libEs5/components/Personalization/handlers/injectCreateProposition.js +13 -15
  39. package/libEs5/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +288 -0
  40. package/libEs5/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +23 -0
  41. package/libEs5/components/Personalization/in-app-message-actions/utils.js +53 -0
  42. package/libEs5/components/Personalization/index.js +20 -7
  43. package/libEs5/constants/contentType.js +18 -0
  44. package/libEs5/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +4 -8
  45. package/libEs5/constants/eventType.js +25 -0
  46. package/libEs5/{components/Personalization/constants/eventType.js → constants/handle.js} +4 -7
  47. package/libEs5/constants/libraryVersion.js +1 -1
  48. package/libEs5/constants/propositionEventType.js +33 -0
  49. package/libEs5/{components/Personalization/constants → constants}/schema.js +9 -1
  50. package/libEs5/core/componentCreators.js +2 -1
  51. package/libEs5/core/createEvent.js +26 -1
  52. package/libEs5/core/createEventManager.js +3 -0
  53. package/libEs5/core/createLifecycle.js +4 -1
  54. package/libEs5/utils/createSubscription.js +91 -0
  55. package/libEs5/utils/debounce.js +30 -0
  56. package/libEs5/utils/dom/selectNodesWithShadow.js +10 -3
  57. package/libEs5/utils/flattenArray.js +37 -0
  58. package/libEs5/utils/flattenObject.js +43 -0
  59. package/libEs5/utils/index.js +7 -0
  60. package/libEs5/utils/parseUrl.js +70 -0
  61. package/libEs6/components/DataCollector/index.js +2 -0
  62. package/libEs6/components/DataCollector/validateApplyResponse.js +2 -1
  63. package/libEs6/components/DataCollector/validateUserEventOptions.js +2 -1
  64. package/libEs6/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +30 -0
  65. package/libEs6/components/{Personalization/utils/isPageWideScope.js → DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js} +13 -4
  66. package/libEs6/components/DecisioningEngine/constants.js +25 -0
  67. package/libEs6/components/DecisioningEngine/createApplyResponse.js +31 -0
  68. package/libEs6/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
  69. package/libEs6/components/DecisioningEngine/createContextProvider.js +95 -0
  70. package/libEs6/components/DecisioningEngine/createDecisionHistory.js +25 -0
  71. package/libEs6/components/DecisioningEngine/createDecisionProvider.js +41 -0
  72. package/libEs6/components/DecisioningEngine/createEvaluableRulesetPayload.js +79 -0
  73. package/libEs6/components/DecisioningEngine/createEvaluateRulesetsCommand.js +45 -0
  74. package/libEs6/components/DecisioningEngine/createEventRegistry.js +120 -0
  75. package/libEs6/components/DecisioningEngine/createOnResponseHandler.js +45 -0
  76. package/libEs6/components/DecisioningEngine/createSubscribeRulesetItems.js +79 -0
  77. package/libEs6/components/DecisioningEngine/index.js +124 -0
  78. package/libEs6/components/DecisioningEngine/utils.js +83 -0
  79. package/libEs6/components/Personalization/constants/scopeType.js +3 -1
  80. package/libEs6/components/Personalization/createActionsProvider.js +70 -0
  81. package/libEs6/components/Personalization/createApplyPropositions.js +2 -2
  82. package/libEs6/components/Personalization/createClickStorage.js +18 -10
  83. package/libEs6/components/Personalization/createCollect.js +7 -4
  84. package/libEs6/components/Personalization/createComponent.js +5 -3
  85. package/libEs6/components/Personalization/createFetchDataHandler.js +3 -18
  86. package/libEs6/components/Personalization/createNotificationHandler.js +29 -0
  87. package/libEs6/components/Personalization/createOnClickHandler.js +10 -9
  88. package/libEs6/components/Personalization/createOnDecisionHandler.js +42 -0
  89. package/libEs6/components/Personalization/createPersonalizationDetails.js +8 -5
  90. package/libEs6/components/Personalization/createPreprocessors.js +19 -0
  91. package/libEs6/components/Personalization/createViewCacheManager.js +14 -4
  92. package/libEs6/components/Personalization/dom-actions/clicks/collectClicks.js +28 -12
  93. package/libEs6/components/Personalization/dom-actions/createRedirect.js +10 -1
  94. package/libEs6/components/Personalization/event.js +14 -9
  95. package/libEs6/components/Personalization/handlers/createProcessDomAction.js +5 -1
  96. package/libEs6/components/Personalization/handlers/createProcessInAppMessage.js +77 -0
  97. package/libEs6/components/Personalization/handlers/createProcessRedirect.js +6 -3
  98. package/libEs6/components/Personalization/handlers/injectCreateProposition.js +12 -15
  99. package/libEs6/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +291 -0
  100. package/libEs6/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +17 -0
  101. package/libEs6/components/Personalization/in-app-message-actions/utils.js +49 -0
  102. package/libEs6/components/Personalization/index.js +22 -8
  103. package/libEs6/{components/Personalization/constants/eventType.js → constants/contentType.js} +3 -4
  104. package/libEs6/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +2 -6
  105. package/libEs6/constants/eventType.js +17 -0
  106. package/libEs6/constants/handle.js +12 -0
  107. package/libEs6/constants/libraryVersion.js +1 -1
  108. package/libEs6/constants/propositionEventType.js +33 -0
  109. package/libEs6/{components/Personalization/constants → constants}/schema.js +4 -0
  110. package/libEs6/core/componentCreators.js +2 -1
  111. package/libEs6/core/createEvent.js +26 -1
  112. package/libEs6/core/createEventManager.js +2 -0
  113. package/libEs6/core/createLifecycle.js +4 -1
  114. package/libEs6/utils/createSubscription.js +70 -0
  115. package/libEs6/utils/debounce.js +22 -0
  116. package/libEs6/utils/dom/selectNodesWithShadow.js +10 -3
  117. package/libEs6/utils/flattenArray.js +26 -0
  118. package/libEs6/utils/flattenObject.js +28 -0
  119. package/libEs6/utils/index.js +1 -0
  120. package/libEs6/utils/parseUrl.js +62 -0
  121. package/package.json +6 -2
@@ -2,9 +2,8 @@
2
2
 
3
3
  exports.default = void 0;
4
4
  var _utils = require("../../utils");
5
- var _eventType = require("./constants/eventType");
6
- var _propositionEventType = require("./constants/propositionEventType");
7
- var _pageWideScope = require("../../constants/pageWideScope");
5
+ var _eventType = require("../../constants/eventType");
6
+ var _propositionEventType = require("../../constants/propositionEventType");
8
7
  /*
9
8
  Copyright 2020 Adobe. All rights reserved.
10
9
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -29,21 +28,23 @@ var _default = function _default(_ref) {
29
28
  if ((0, _utils.isNonEmptyArray)(selectors)) {
30
29
  var _collectClicks = collectClicks(clickedElement, selectors, getClickMetasBySelector),
31
30
  decisionsMeta = _collectClicks.decisionsMeta,
32
- eventLabel = _collectClicks.eventLabel;
31
+ eventLabel = _collectClicks.eventLabel,
32
+ viewName = _collectClicks.viewName;
33
33
  if ((0, _utils.isNonEmptyArray)(decisionsMeta)) {
34
34
  var xdm = {
35
35
  eventType: _eventType.INTERACT
36
36
  };
37
- var scope = decisionsMeta[0].scope;
38
- if ((0, _utils.isNonEmptyString)(scope) && scope !== _pageWideScope.default) {
37
+ if (viewName) {
39
38
  xdm.web = {
40
39
  webPageDetails: {
41
- viewName: scope.toLowerCase()
40
+ viewName: viewName
42
41
  }
43
42
  };
44
43
  }
45
44
  event.mergeXdm(xdm);
46
- mergeDecisionsMeta(event, decisionsMeta, _propositionEventType.PropositionEventType.INTERACT, eventLabel);
45
+ mergeDecisionsMeta(event, decisionsMeta, [_propositionEventType.PropositionEventType.INTERACT], eventLabel ? {
46
+ label: eventLabel
47
+ } : undefined);
47
48
  }
48
49
  }
49
50
  };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ /*
5
+ Copyright 2023 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
15
+ var _default = function _default(_ref) {
16
+ var processPropositions = _ref.processPropositions,
17
+ createProposition = _ref.createProposition,
18
+ notificationHandler = _ref.notificationHandler;
19
+ return function (_ref2) {
20
+ var renderDecisions = _ref2.renderDecisions,
21
+ propositions = _ref2.propositions,
22
+ event = _ref2.event,
23
+ _ref2$personalization = _ref2.personalization,
24
+ personalization = _ref2$personalization === void 0 ? {} : _ref2$personalization;
25
+ if (!renderDecisions) {
26
+ return Promise.resolve();
27
+ }
28
+ var _personalization$send = personalization.sendDisplayEvent,
29
+ sendDisplayEvent = _personalization$send === void 0 ? true : _personalization$send;
30
+ var viewName = event ? event.getViewName() : undefined;
31
+ var propositionsToExecute = propositions.map(function (proposition) {
32
+ return createProposition(proposition, true);
33
+ });
34
+ var _processPropositions = processPropositions(propositionsToExecute),
35
+ render = _processPropositions.render,
36
+ returnedPropositions = _processPropositions.returnedPropositions;
37
+ var handleNotifications = notificationHandler(sendDisplayEvent, viewName);
38
+ render().then(handleNotifications);
39
+ return Promise.resolve({
40
+ propositions: returnedPropositions
41
+ });
42
+ };
43
+ };
44
+ exports.default = _default;
@@ -4,7 +4,7 @@ exports.default = void 0;
4
4
  var _utils = require("../../utils");
5
5
  var _surfaceUtils = require("./utils/surfaceUtils");
6
6
  var _pageWideScope = require("../../constants/pageWideScope");
7
- var _schema = require("./constants/schema");
7
+ var _schema = require("../../constants/schema");
8
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -74,11 +74,11 @@ var _default = function _default(_ref) {
74
74
  scopes.push.apply(scopes, _toConsumableArray(personalization.decisionScopes));
75
75
  }
76
76
  var eventSurfaces = (0, _surfaceUtils.normalizeSurfaces)(personalization.surfaces, getPageLocation, logger);
77
- if (!this.isCacheInitialized() || personalization.requestPersonalization) {
77
+ if (this.shouldRequestDefaultPersonalization()) {
78
78
  addPageWideScope(scopes);
79
79
  addPageSurface(eventSurfaces, getPageLocation);
80
80
  }
81
- var schemas = [_schema.DEFAULT_CONTENT_ITEM, _schema.HTML_CONTENT_ITEM, _schema.JSON_CONTENT_ITEM, _schema.REDIRECT_ITEM];
81
+ var schemas = [_schema.DEFAULT_CONTENT_ITEM, _schema.HTML_CONTENT_ITEM, _schema.JSON_CONTENT_ITEM, _schema.REDIRECT_ITEM, _schema.RULESET_ITEM, _schema.MESSAGE_IN_APP, _schema.MESSAGE_FEED_ITEM];
82
82
  if ((0, _utils.includes)(scopes, _pageWideScope.default)) {
83
83
  schemas.push(_schema.DOM_ACTION);
84
84
  }
@@ -92,10 +92,13 @@ var _default = function _default(_ref) {
92
92
  return _isCacheInitialized;
93
93
  },
94
94
  shouldFetchData: function shouldFetchData() {
95
- return this.hasScopes() || this.hasSurfaces() || personalization.requestPersonalization || !this.isCacheInitialized() && personalization.requestPersonalization !== false;
95
+ return this.hasScopes() || this.hasSurfaces() || this.shouldRequestDefaultPersonalization();
96
96
  },
97
97
  shouldUseCachedData: function shouldUseCachedData() {
98
- return this.hasViewName() && this.isCacheInitialized();
98
+ return this.hasViewName() && !this.shouldFetchData();
99
+ },
100
+ shouldRequestDefaultPersonalization: function shouldRequestDefaultPersonalization() {
101
+ return personalization.defaultPersonalizationEnabled || !this.isCacheInitialized() && personalization.defaultPersonalizationEnabled !== false;
99
102
  }
100
103
  };
101
104
  };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _schema = require("../../constants/schema");
5
+ var _remapHeadOffers = require("./dom-actions/remapHeadOffers");
6
+ var _remapCustomCodeOffers = require("./dom-actions/remapCustomCodeOffers");
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /*
8
+ Copyright 2023 Adobe. All rights reserved.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
17
+ */
18
+ var _default = function _default() {
19
+ return _defineProperty({}, _schema.DOM_ACTION, [_remapHeadOffers.default, _remapCustomCodeOffers.default]);
20
+ };
21
+ exports.default = _default;
@@ -3,7 +3,8 @@
3
3
  exports.default = void 0;
4
4
  var _utils = require("../../utils");
5
5
  var _defer = require("../../utils/defer");
6
- var _schema = require("./constants/schema");
6
+ var _schema = require("../../constants/schema");
7
+ var _scopeType = require("./constants/scopeType");
7
8
  /*
8
9
  Copyright 2020 Adobe. All rights reserved.
9
10
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -28,7 +29,7 @@ var _default = function _default(_ref) {
28
29
  scope: viewName,
29
30
  scopeDetails: {
30
31
  characteristics: {
31
- scopeType: "view"
32
+ scopeType: _scopeType.VIEW_SCOPE_TYPE
32
33
  }
33
34
  },
34
35
  items: [{
@@ -42,8 +43,15 @@ var _default = function _default(_ref) {
42
43
  var createCacheUpdate = function createCacheUpdate(viewName) {
43
44
  var updateCacheDeferred = (0, _defer.default)();
44
45
  cacheUpdateCreatedAtLeastOnce = true;
46
+
47
+ // Additional updates will merge the new view propositions with the old.
48
+ // i.e. if there are new "cart" view propositions they will overwrite the
49
+ // old "cart" view propositions, but if there are no new "cart" view
50
+ // propositions the old "cart" view propositions will remain.
45
51
  viewStoragePromise = viewStoragePromise.then(function (oldViewStorage) {
46
- return updateCacheDeferred.promise.catch(function () {
52
+ return updateCacheDeferred.promise.then(function (newViewStorage) {
53
+ return (0, _utils.assign)({}, oldViewStorage, newViewStorage);
54
+ }).catch(function () {
47
55
  return oldViewStorage;
48
56
  });
49
57
  });
@@ -2,22 +2,27 @@
2
2
 
3
3
  exports.default = void 0;
4
4
  var _matchesSelectorWithEq = require("../dom/matchesSelectorWithEq");
5
+ var _scopeType = require("../../constants/scopeType");
6
+ var _excluded = ["trackingLabel", "scopeType"];
7
+ /*
8
+ Copyright 2019 Adobe. All rights reserved.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
17
+ */
5
18
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
19
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
20
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
21
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
22
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } /*
11
- Copyright 2019 Adobe. All rights reserved.
12
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
- you may not use this file except in compliance with the License. You may obtain a copy
14
- of the License at http://www.apache.org/licenses/LICENSE-2.0
15
-
16
- Unless required by applicable law or agreed to in writing, software distributed under
17
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
- OF ANY KIND, either express or implied. See the License for the specific language
19
- governing permissions and limitations under the License.
20
- */
23
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
25
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
26
  var getMetasIfMatches = function getMetasIfMatches(clickedElement, selector, getClickMetasBySelector) {
22
27
  var _document = document,
23
28
  documentElement = _document.documentElement;
@@ -26,19 +31,24 @@ var getMetasIfMatches = function getMetasIfMatches(clickedElement, selector, get
26
31
  while (element && element !== documentElement) {
27
32
  if ((0, _matchesSelectorWithEq.default)(selector, element)) {
28
33
  var matchedMetas = getClickMetasBySelector(selector);
34
+ var returnValue = {
35
+ metas: matchedMetas
36
+ };
29
37
  var foundMetaWithLabel = matchedMetas.find(function (meta) {
30
38
  return meta.trackingLabel;
31
39
  });
32
40
  if (foundMetaWithLabel) {
33
- return {
34
- metas: matchedMetas,
35
- label: foundMetaWithLabel.trackingLabel,
36
- weight: i
37
- };
41
+ returnValue.label = foundMetaWithLabel.trackingLabel;
42
+ returnValue.weight = i;
38
43
  }
39
- return {
40
- metas: matchedMetas
41
- };
44
+ var foundMetaWithScopeTypeView = matchedMetas.find(function (meta) {
45
+ return meta.scopeType === _scopeType.VIEW_SCOPE_TYPE;
46
+ });
47
+ if (foundMetaWithScopeTypeView) {
48
+ returnValue.viewName = foundMetaWithScopeTypeView.scope;
49
+ returnValue.weight = i;
50
+ }
51
+ return returnValue;
42
52
  }
43
53
  element = element.parentNode;
44
54
  i += 1;
@@ -49,8 +59,10 @@ var getMetasIfMatches = function getMetasIfMatches(clickedElement, selector, get
49
59
  };
50
60
  var cleanMetas = function cleanMetas(metas) {
51
61
  return metas.map(function (meta) {
52
- delete meta.trackingLabel;
53
- return meta;
62
+ var trackingLabel = meta.trackingLabel,
63
+ scopeType = meta.scopeType,
64
+ rest = _objectWithoutProperties(meta, _excluded);
65
+ return rest;
54
66
  });
55
67
  };
56
68
  var dedupMetas = function dedupMetas(metas) {
@@ -65,13 +77,16 @@ var _default = function _default(clickedElement, selectors, getClickMetasBySelec
65
77
  var result = [];
66
78
  var resultLabel = "";
67
79
  var resultLabelWeight = Number.MAX_SAFE_INTEGER;
80
+ var resultViewName;
81
+ var resultViewNameWeight = Number.MAX_SAFE_INTEGER;
68
82
 
69
83
  /* eslint-disable no-continue */
70
84
  for (var i = 0; i < selectors.length; i += 1) {
71
85
  var _getMetasIfMatches = getMetasIfMatches(clickedElement, selectors[i], getClickMetasBySelector),
72
86
  metas = _getMetasIfMatches.metas,
73
87
  label = _getMetasIfMatches.label,
74
- weight = _getMetasIfMatches.weight;
88
+ weight = _getMetasIfMatches.weight,
89
+ viewName = _getMetasIfMatches.viewName;
75
90
  if (!metas) {
76
91
  continue;
77
92
  }
@@ -79,11 +94,16 @@ var _default = function _default(clickedElement, selectors, getClickMetasBySelec
79
94
  resultLabel = label;
80
95
  resultLabelWeight = weight;
81
96
  }
97
+ if (viewName && weight <= resultViewNameWeight) {
98
+ resultViewName = viewName;
99
+ resultViewNameWeight = weight;
100
+ }
82
101
  result.push.apply(result, _toConsumableArray(cleanMetas(metas)));
83
102
  }
84
103
  return {
85
104
  decisionsMeta: dedupMetas(result),
86
- eventLabel: resultLabel
105
+ eventLabel: resultLabel,
106
+ viewName: resultViewName
87
107
  };
88
108
  };
89
109
  exports.default = _default;
@@ -14,7 +14,17 @@ governing permissions and limitations under the License.
14
14
  */
15
15
  var _default = function _default(window) {
16
16
  return function (url) {
17
- return window.location.replace(url);
17
+ var preserveHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
18
+ if (preserveHistory) {
19
+ window.location.href = url;
20
+ } else {
21
+ window.location.replace(url);
22
+ }
23
+ // Return a promise that never resolves because redirects never complete
24
+ // within the current page.
25
+ return new Promise(function () {
26
+ return undefined;
27
+ });
18
28
  };
19
29
  };
20
30
  exports.default = _default;
@@ -1,38 +1,41 @@
1
1
  "use strict";
2
2
 
3
3
  exports.mergeQuery = exports.mergeDecisionsMeta = void 0;
4
+ var _eventType = require("../../constants/eventType");
4
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
- /*
8
- Copyright 2019 Adobe. All rights reserved.
9
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- you may not use this file except in compliance with the License. You may obtain a copy
11
- of the License at http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- Unless required by applicable law or agreed to in writing, software distributed under
14
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- OF ANY KIND, either express or implied. See the License for the specific language
16
- governing permissions and limitations under the License.
17
- */
18
-
19
- var EVENT_TYPE_TRUE = 1;
20
-
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /*
8
+ Copyright 2019 Adobe. All rights reserved.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
17
+ */
21
18
  /* eslint-disable no-underscore-dangle */
22
- var mergeDecisionsMeta = function mergeDecisionsMeta(event, decisionsMeta, eventType) {
23
- var eventLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
19
+ var mergeDecisionsMeta = function mergeDecisionsMeta(event, decisionsMeta, propositionEventTypes, propositionAction) {
20
+ // Do not send a display notification with no decisions. Even empty view changes
21
+ // should include a proposition.
22
+ if (decisionsMeta.length === 0) {
23
+ return;
24
+ }
25
+ var propositionEventType = {};
26
+ propositionEventTypes.forEach(function (type) {
27
+ propositionEventType[type] = _eventType.EVENT_TYPE_TRUE;
28
+ });
24
29
  var xdm = {
25
30
  _experience: {
26
31
  decisioning: {
27
32
  propositions: decisionsMeta,
28
- propositionEventType: _defineProperty({}, eventType, EVENT_TYPE_TRUE)
33
+ propositionEventType: propositionEventType
29
34
  }
30
35
  }
31
36
  };
32
- if (eventLabel) {
33
- xdm._experience.decisioning.propositionAction = {
34
- label: eventLabel
35
- };
37
+ if (propositionAction) {
38
+ xdm._experience.decisioning.propositionAction = propositionAction;
36
39
  }
37
40
  event.mergeXdm(xdm);
38
41
  };
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  exports.default = void 0;
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
7
  /*
5
8
  Copyright 2023 Adobe. All rights reserved.
6
9
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -37,7 +40,10 @@ var _default = function _default(_ref) {
37
40
  }
38
41
  storeClickMetrics({
39
42
  selector: selector,
40
- meta: item.getMeta()
43
+ meta: _objectSpread(_objectSpread({}, item.getProposition().getNotification()), {}, {
44
+ trackingLabel: item.getTrackingLabel(),
45
+ scopeType: item.getProposition().getScopeType()
46
+ })
41
47
  });
42
48
  return {
43
49
  setRenderAttempted: true,
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _contentType = require("../../../constants/contentType");
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /*
8
+ Copyright 2023 Adobe. All rights reserved.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
17
+ */
18
+ var DEFAULT_CONTENT = "defaultContent";
19
+ var expectedProps = ["content", "contentType"];
20
+ var expectedContentProps = ["mobileParameters", "webParameters", "html"];
21
+ var isValidInAppMessage = function isValidInAppMessage(data, logger) {
22
+ for (var i = 0; i < expectedProps.length; i += 1) {
23
+ var prop = expectedProps[i];
24
+ if (!Object.prototype.hasOwnProperty.call(data, prop)) {
25
+ logger.warn("Invalid in-app message data: missing property '" + prop + "'.", data);
26
+ return false;
27
+ }
28
+ }
29
+ var content = data.content,
30
+ contentType = data.contentType;
31
+ if (contentType === _contentType.APPLICATION_JSON) {
32
+ for (var _i = 0; _i < expectedContentProps.length; _i += 1) {
33
+ var _prop = expectedContentProps[_i];
34
+ if (!Object.prototype.hasOwnProperty.call(content, _prop)) {
35
+ logger.warn("Invalid in-app message data.content: missing property '" + _prop + "'.", data);
36
+ return false;
37
+ }
38
+ }
39
+ }
40
+ return true;
41
+ };
42
+ var _default = function _default(_ref) {
43
+ var modules = _ref.modules,
44
+ logger = _ref.logger;
45
+ return function (item) {
46
+ var data = item.getData();
47
+ var meta = _objectSpread({}, item.getProposition().getNotification());
48
+ if (!data) {
49
+ logger.warn("Invalid in-app message data: undefined.", data);
50
+ return {};
51
+ }
52
+ var _data$type = data.type,
53
+ type = _data$type === void 0 ? DEFAULT_CONTENT : _data$type;
54
+ if (!modules[type]) {
55
+ logger.warn("Invalid in-app message data: unknown type.", data);
56
+ return {};
57
+ }
58
+ if (!isValidInAppMessage(data, logger)) {
59
+ return {};
60
+ }
61
+ if (!meta) {
62
+ logger.warn("Invalid in-app message meta: undefined.", meta);
63
+ return {};
64
+ }
65
+ return {
66
+ render: function render() {
67
+ return modules[type](_objectSpread(_objectSpread({}, data), {}, {
68
+ meta: meta
69
+ }));
70
+ },
71
+ setRenderAttempted: true,
72
+ includeInNotification: true
73
+ };
74
+ };
75
+ };
76
+ exports.default = _default;
@@ -25,11 +25,14 @@ var _default = function _default(_ref) {
25
25
  }
26
26
  var render = function render() {
27
27
  return collect({
28
- decisionsMeta: [item.getMeta()],
28
+ decisionsMeta: [item.getProposition().getNotification()],
29
29
  documentMayUnload: true
30
30
  }).then(function () {
31
- executeRedirect(content);
32
- // We've already sent the display notification, so don't return anything
31
+ return executeRedirect(content);
32
+ // Execute redirect will never resolve. If there are bottom of page events that are waiting
33
+ // for display notifications from this request, they will never run because this promise will
34
+ // not resolve. This is intentional because we don't want to run bottom of page events if
35
+ // there is a redirect.
33
36
  });
34
37
  };
35
38
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  exports.default = void 0;
4
4
  var _pageWideScope = require("../../../constants/pageWideScope");
5
+ var _scopeType = require("../constants/scopeType");
5
6
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
8
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /*
@@ -18,16 +19,13 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
18
19
  var _default = function _default(_ref) {
19
20
  var preprocess = _ref.preprocess,
20
21
  isPageWideSurface = _ref.isPageWideSurface;
21
- var createItem = function createItem(item, meta) {
22
+ var createItem = function createItem(item, proposition) {
22
23
  var schema = item.schema,
23
24
  data = item.data,
24
25
  _item$characteristics = item.characteristics;
25
26
  _item$characteristics = _item$characteristics === void 0 ? {} : _item$characteristics;
26
27
  var trackingLabel = _item$characteristics.trackingLabel;
27
28
  var processedData = preprocess(data);
28
- if (trackingLabel) {
29
- meta.trackingLabel = trackingLabel;
30
- }
31
29
  return {
32
30
  getSchema: function getSchema() {
33
31
  return schema;
@@ -35,8 +33,11 @@ var _default = function _default(_ref) {
35
33
  getData: function getData() {
36
34
  return processedData;
37
35
  },
38
- getMeta: function getMeta() {
39
- return meta;
36
+ getProposition: function getProposition() {
37
+ return proposition;
38
+ },
39
+ getTrackingLabel: function getTrackingLabel() {
40
+ return trackingLabel;
40
41
  },
41
42
  getOriginalItem: function getOriginalItem() {
42
43
  return item;
@@ -69,20 +70,17 @@ var _default = function _default(_ref) {
69
70
  },
70
71
  getScopeType: function getScopeType() {
71
72
  if (scope === _pageWideScope.default || isPageWideSurface(scope)) {
72
- return "page";
73
+ return _scopeType.PAGE_SCOPE_TYPE;
73
74
  }
74
- if (scopeType === "view") {
75
- return "view";
75
+ if (scopeType === _scopeType.VIEW_SCOPE_TYPE) {
76
+ return _scopeType.VIEW_SCOPE_TYPE;
76
77
  }
77
- return "proposition";
78
+ return _scopeType.PROPOSITION_SCOPE_TYPE;
78
79
  },
79
80
  getItems: function getItems() {
81
+ var _this = this;
80
82
  return items.map(function (item) {
81
- return createItem(item, {
82
- id: id,
83
- scope: scope,
84
- scopeDetails: scopeDetails
85
- });
83
+ return createItem(item, _this);
86
84
  });
87
85
  },
88
86
  getNotification: function getNotification() {