@adobe/alloy 2.18.0-beta.3 → 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.
- package/libEs5/components/DataCollector/index.js +4 -2
- package/libEs5/components/DataCollector/validateApplyResponse.js +6 -1
- package/libEs5/components/DataCollector/validateUserEventOptions.js +5 -1
- package/libEs5/components/Personalization/createApplyPropositions.js +38 -25
- package/libEs5/components/Personalization/createComponent.js +22 -14
- package/libEs5/components/Personalization/createFetchDataHandler.js +83 -18
- package/libEs5/components/Personalization/createOnClickHandler.js +2 -2
- package/libEs5/components/Personalization/createPendingNotificationsHandler.js +29 -0
- package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -2
- package/libEs5/components/Personalization/createViewCacheManager.js +60 -21
- package/libEs5/components/Personalization/createViewChangeHandler.js +25 -30
- package/libEs5/components/Personalization/dom-actions/action.js +5 -20
- package/{libEs6/components/Personalization/utils/composePersonalizationResultingObject.js → libEs5/components/Personalization/dom-actions/createPreprocess.js} +17 -13
- package/libEs5/components/Personalization/dom-actions/index.js +1 -9
- package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +2 -10
- package/libEs5/components/Personalization/dom-actions/remapHeadOffers.js +4 -0
- package/libEs5/components/Personalization/handlers/createProcessDomAction.js +61 -0
- package/libEs5/components/Personalization/handlers/createProcessHtmlContent.js +43 -0
- package/libEs5/components/Personalization/handlers/createProcessPropositions.js +240 -0
- package/libEs5/components/Personalization/handlers/createProcessRedirect.js +45 -0
- package/libEs5/components/Personalization/handlers/injectCreateProposition.js +124 -0
- package/libEs5/components/Personalization/{dom-actions/clicks/index.js → handlers/processDefaultContent.js} +8 -4
- package/libEs5/components/Personalization/index.js +70 -53
- package/libEs5/components/Personalization/utils/createAsyncArray.js +42 -0
- package/libEs5/components/Personalization/validateApplyPropositionsOptions.js +3 -2
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/createEvent.js +31 -13
- package/libEs5/core/createEventManager.js +3 -2
- package/libEs5/{components/Personalization/utils/composePersonalizationResultingObject.js → utils/deduplicateArray.js} +16 -14
- package/libEs5/utils/index.js +8 -0
- package/libEs6/components/DataCollector/index.js +4 -2
- package/libEs6/components/DataCollector/validateApplyResponse.js +6 -1
- package/libEs6/components/DataCollector/validateUserEventOptions.js +5 -1
- package/libEs6/components/Personalization/createApplyPropositions.js +25 -24
- package/libEs6/components/Personalization/createComponent.js +23 -15
- package/libEs6/components/Personalization/createFetchDataHandler.js +65 -9
- package/libEs6/components/Personalization/createOnClickHandler.js +3 -3
- package/{libEs5/components/Personalization/dom-actions/click.js → libEs6/components/Personalization/createPendingNotificationsHandler.js} +11 -15
- package/libEs6/components/Personalization/createPersonalizationDetails.js +10 -2
- package/libEs6/components/Personalization/createViewCacheManager.js +55 -20
- package/libEs6/components/Personalization/createViewChangeHandler.js +25 -28
- package/libEs6/components/Personalization/dom-actions/action.js +4 -12
- package/libEs6/components/Personalization/dom-actions/{click.js → createPreprocess.js} +8 -11
- package/libEs6/components/Personalization/dom-actions/index.js +1 -2
- package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +3 -7
- package/libEs6/components/Personalization/dom-actions/remapHeadOffers.js +4 -0
- package/libEs6/components/Personalization/handlers/createProcessDomAction.js +53 -0
- package/libEs6/components/Personalization/handlers/createProcessHtmlContent.js +37 -0
- package/libEs6/components/Personalization/handlers/createProcessPropositions.js +202 -0
- package/libEs6/components/Personalization/handlers/createProcessRedirect.js +39 -0
- package/libEs6/components/Personalization/handlers/injectCreateProposition.js +129 -0
- package/libEs6/components/Personalization/{dom-actions/clicks/index.js → handlers/processDefaultContent.js} +7 -3
- package/libEs6/components/Personalization/index.js +60 -40
- package/libEs6/components/Personalization/utils/createAsyncArray.js +37 -0
- package/libEs6/components/Personalization/validateApplyPropositionsOptions.js +4 -3
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/createEvent.js +19 -3
- package/libEs6/core/createEventManager.js +3 -2
- package/libEs6/utils/deduplicateArray.js +26 -0
- package/libEs6/utils/index.js +1 -0
- package/package.json +2 -2
- package/libEs5/components/Personalization/createAutoRenderingHandler.js +0 -92
- package/libEs5/components/Personalization/createExecuteDecisions.js +0 -89
- package/libEs5/components/Personalization/createNonRenderingHandler.js +0 -66
- package/libEs5/components/Personalization/createOnResponseHandler.js +0 -73
- package/libEs5/components/Personalization/createRedirectHandler.js +0 -58
- package/libEs5/components/Personalization/dom-actions/executeActions.js +0 -75
- package/libEs5/components/Personalization/groupDecisions.js +0 -160
- package/libEs6/components/Personalization/createAutoRenderingHandler.js +0 -84
- package/libEs6/components/Personalization/createExecuteDecisions.js +0 -77
- package/libEs6/components/Personalization/createNonRenderingHandler.js +0 -56
- package/libEs6/components/Personalization/createOnResponseHandler.js +0 -68
- package/libEs6/components/Personalization/createRedirectHandler.js +0 -57
- package/libEs6/components/Personalization/dom-actions/executeActions.js +0 -66
- package/libEs6/components/Personalization/groupDecisions.js +0 -131
|
@@ -10,8 +10,6 @@ var _domActions = require("./dom-actions");
|
|
|
10
10
|
|
|
11
11
|
var _createCollect = require("./createCollect");
|
|
12
12
|
|
|
13
|
-
var _createExecuteDecisions = require("./createExecuteDecisions");
|
|
14
|
-
|
|
15
13
|
var _flicker = require("./flicker");
|
|
16
14
|
|
|
17
15
|
var _createFetchDataHandler = require("./createFetchDataHandler");
|
|
@@ -28,36 +26,45 @@ var _createViewCacheManager = require("./createViewCacheManager");
|
|
|
28
26
|
|
|
29
27
|
var _createViewChangeHandler = require("./createViewChangeHandler");
|
|
30
28
|
|
|
31
|
-
var
|
|
29
|
+
var _createClickStorage2 = require("./createClickStorage");
|
|
32
30
|
|
|
33
|
-
var
|
|
31
|
+
var _createApplyPropositions = require("./createApplyPropositions");
|
|
34
32
|
|
|
35
|
-
var
|
|
33
|
+
var _createGetPageLocation = require("./createGetPageLocation");
|
|
36
34
|
|
|
37
|
-
var
|
|
35
|
+
var _createSetTargetMigration = require("./createSetTargetMigration");
|
|
38
36
|
|
|
39
|
-
var
|
|
37
|
+
var _remapCustomCodeOffers = require("./dom-actions/remapCustomCodeOffers");
|
|
40
38
|
|
|
41
|
-
var
|
|
39
|
+
var _remapHeadOffers = require("./dom-actions/remapHeadOffers");
|
|
42
40
|
|
|
43
|
-
var
|
|
41
|
+
var _createPreprocess = require("./dom-actions/createPreprocess");
|
|
44
42
|
|
|
45
|
-
var
|
|
43
|
+
var _injectCreateProposition = require("./handlers/injectCreateProposition");
|
|
46
44
|
|
|
47
|
-
var
|
|
45
|
+
var _createAsyncArray = require("./utils/createAsyncArray");
|
|
46
|
+
|
|
47
|
+
var _createPendingNotificationsHandler = require("./createPendingNotificationsHandler");
|
|
48
|
+
|
|
49
|
+
var schema = require("./constants/schema");
|
|
50
|
+
|
|
51
|
+
var _processDefaultContent = require("./handlers/processDefaultContent");
|
|
52
|
+
|
|
53
|
+
var _surfaceUtils = require("./utils/surfaceUtils");
|
|
54
|
+
|
|
55
|
+
var _createProcessDomAction = require("./handlers/createProcessDomAction");
|
|
56
|
+
|
|
57
|
+
var _createProcessHtmlContent = require("./handlers/createProcessHtmlContent");
|
|
58
|
+
|
|
59
|
+
var _createProcessRedirect = require("./handlers/createProcessRedirect");
|
|
60
|
+
|
|
61
|
+
var _createProcessPropositions = require("./handlers/createProcessPropositions");
|
|
62
|
+
|
|
63
|
+
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; }
|
|
48
64
|
|
|
49
|
-
/*
|
|
50
|
-
Copyright 2019 Adobe. All rights reserved.
|
|
51
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
52
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
53
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
54
|
-
|
|
55
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
56
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
57
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
58
|
-
governing permissions and limitations under the License.
|
|
59
|
-
*/
|
|
60
65
|
var createPersonalization = function createPersonalization(_ref) {
|
|
66
|
+
var _schemaProcessors;
|
|
67
|
+
|
|
61
68
|
var config = _ref.config,
|
|
62
69
|
logger = _ref.logger,
|
|
63
70
|
eventManager = _ref.eventManager;
|
|
@@ -76,43 +83,47 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
76
83
|
var getPageLocation = (0, _createGetPageLocation.default)({
|
|
77
84
|
window: window
|
|
78
85
|
});
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
var
|
|
86
|
+
var modules = (0, _domActions.initDomActionsModules)();
|
|
87
|
+
var preprocess = (0, _createPreprocess.default)([_remapHeadOffers.default, _remapCustomCodeOffers.default]);
|
|
88
|
+
var createProposition = (0, _injectCreateProposition.default)({
|
|
89
|
+
preprocess: preprocess,
|
|
90
|
+
isPageWideSurface: _surfaceUtils.isPageWideSurface
|
|
91
|
+
});
|
|
92
|
+
var viewCache = (0, _createViewCacheManager.default)({
|
|
93
|
+
createProposition: createProposition
|
|
94
|
+
});
|
|
95
|
+
var schemaProcessors = (_schemaProcessors = {}, _defineProperty(_schemaProcessors, schema.DEFAULT_CONTENT_ITEM, _processDefaultContent.default), _defineProperty(_schemaProcessors, schema.DOM_ACTION, (0, _createProcessDomAction.default)({
|
|
82
96
|
modules: modules,
|
|
83
97
|
logger: logger,
|
|
84
|
-
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
storeClickMetrics: storeClickMetrics
|
|
99
|
+
})), _defineProperty(_schemaProcessors, schema.HTML_CONTENT_ITEM, (0, _createProcessHtmlContent.default)({
|
|
100
|
+
modules: modules,
|
|
101
|
+
logger: logger
|
|
102
|
+
})), _defineProperty(_schemaProcessors, schema.REDIRECT_ITEM, (0, _createProcessRedirect.default)({
|
|
89
103
|
logger: logger,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
viewCache: viewCache,
|
|
94
|
-
executeDecisions: executeDecisions,
|
|
95
|
-
showContainers: _flicker.showContainers,
|
|
104
|
+
executeRedirect: function executeRedirect(url) {
|
|
105
|
+
return window.location.replace(url);
|
|
106
|
+
},
|
|
96
107
|
collect: collect
|
|
108
|
+
})), _schemaProcessors);
|
|
109
|
+
var processPropositions = (0, _createProcessPropositions.default)({
|
|
110
|
+
schemaProcessors: schemaProcessors,
|
|
111
|
+
logger: logger
|
|
97
112
|
});
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
viewCache: viewCache
|
|
103
|
-
});
|
|
104
|
-
var responseHandler = (0, _createOnResponseHandler.default)({
|
|
105
|
-
autoRenderingHandler: autoRenderingHandler,
|
|
106
|
-
nonRenderingHandler: nonRenderingHandler,
|
|
107
|
-
groupDecisions: _groupDecisions.default,
|
|
108
|
-
handleRedirectDecisions: handleRedirectDecisions,
|
|
109
|
-
showContainers: _flicker.showContainers
|
|
113
|
+
var pendingDisplayNotifications = (0, _createAsyncArray.default)();
|
|
114
|
+
var pendingNotificationsHandler = (0, _createPendingNotificationsHandler.default)({
|
|
115
|
+
pendingDisplayNotifications: pendingDisplayNotifications,
|
|
116
|
+
mergeDecisionsMeta: _event.mergeDecisionsMeta
|
|
110
117
|
});
|
|
111
118
|
var fetchDataHandler = (0, _createFetchDataHandler.default)({
|
|
112
119
|
prehidingStyle: prehidingStyle,
|
|
113
|
-
|
|
120
|
+
showContainers: _flicker.showContainers,
|
|
114
121
|
hideContainers: _flicker.hideContainers,
|
|
115
|
-
mergeQuery: _event.mergeQuery
|
|
122
|
+
mergeQuery: _event.mergeQuery,
|
|
123
|
+
collect: collect,
|
|
124
|
+
processPropositions: processPropositions,
|
|
125
|
+
createProposition: createProposition,
|
|
126
|
+
pendingDisplayNotifications: pendingDisplayNotifications
|
|
116
127
|
});
|
|
117
128
|
var onClickHandler = (0, _createOnClickHandler.default)({
|
|
118
129
|
mergeDecisionsMeta: _event.mergeDecisionsMeta,
|
|
@@ -122,8 +133,13 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
122
133
|
});
|
|
123
134
|
var viewChangeHandler = (0, _createViewChangeHandler.default)({
|
|
124
135
|
mergeDecisionsMeta: _event.mergeDecisionsMeta,
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
processPropositions: processPropositions,
|
|
137
|
+
viewCache: viewCache
|
|
138
|
+
});
|
|
139
|
+
var applyPropositions = (0, _createApplyPropositions.default)({
|
|
140
|
+
processPropositions: processPropositions,
|
|
141
|
+
createProposition: createProposition,
|
|
142
|
+
pendingDisplayNotifications: pendingDisplayNotifications,
|
|
127
143
|
viewCache: viewCache
|
|
128
144
|
});
|
|
129
145
|
var setTargetMigration = (0, _createSetTargetMigration.default)({
|
|
@@ -140,7 +156,8 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
140
156
|
viewCache: viewCache,
|
|
141
157
|
showContainers: _flicker.showContainers,
|
|
142
158
|
applyPropositions: applyPropositions,
|
|
143
|
-
setTargetMigration: setTargetMigration
|
|
159
|
+
setTargetMigration: setTargetMigration,
|
|
160
|
+
pendingNotificationsHandler: pendingNotificationsHandler
|
|
144
161
|
});
|
|
145
162
|
};
|
|
146
163
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default() {
|
|
17
|
+
var latest = Promise.resolve([]);
|
|
18
|
+
return {
|
|
19
|
+
concat: function concat(promise) {
|
|
20
|
+
latest = latest.then(function (existingPropositions) {
|
|
21
|
+
return promise.then(function (newPropositions) {
|
|
22
|
+
return existingPropositions.concat(newPropositions);
|
|
23
|
+
}).catch(function () {
|
|
24
|
+
return existingPropositions;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Clears the saved propositions, waiting until the next propositions are resolved and available.
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<Array>} A promise that resolves to the latest propositions.
|
|
33
|
+
*/
|
|
34
|
+
clear: function clear() {
|
|
35
|
+
var oldLatest = latest;
|
|
36
|
+
latest = Promise.resolve([]);
|
|
37
|
+
return oldLatest;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.default = _default;
|
|
@@ -24,8 +24,9 @@ var _default = function _default(_ref) {
|
|
|
24
24
|
var logger = _ref.logger,
|
|
25
25
|
options = _ref.options;
|
|
26
26
|
var applyPropositionsOptionsValidator = (0, _validation.objectOf)({
|
|
27
|
-
propositions: (0, _validation.arrayOf)((0, _validation.objectOf)((0, _validation.anything)()))
|
|
28
|
-
metadata: (0, _validation.objectOf)((0, _validation.anything)())
|
|
27
|
+
propositions: (0, _validation.arrayOf)((0, _validation.objectOf)((0, _validation.anything)())),
|
|
28
|
+
metadata: (0, _validation.objectOf)((0, _validation.anything)()),
|
|
29
|
+
viewName: (0, _validation.string)()
|
|
29
30
|
}).required();
|
|
30
31
|
|
|
31
32
|
try {
|
|
@@ -15,5 +15,5 @@ governing permissions and limitations under the License.
|
|
|
15
15
|
*/
|
|
16
16
|
// The __VERSION__ keyword will be replace at alloy build time with the package.json version.
|
|
17
17
|
// see babel-plugin-version
|
|
18
|
-
var _default = "2.
|
|
18
|
+
var _default = "2.19.0-beta.0";
|
|
19
19
|
exports.default = _default;
|
|
@@ -4,17 +4,26 @@ exports.default = void 0;
|
|
|
4
4
|
|
|
5
5
|
var _utils = require("../utils");
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
|
|
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
|
+
|
|
11
|
+
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); }
|
|
12
|
+
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
+
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
var getXdmPropositions = function getXdmPropositions(xdm) {
|
|
20
|
+
return xdm && // eslint-disable-next-line no-underscore-dangle
|
|
21
|
+
xdm._experience && // eslint-disable-next-line no-underscore-dangle
|
|
22
|
+
xdm._experience.decisioning && // eslint-disable-next-line no-underscore-dangle
|
|
23
|
+
(0, _utils.isNonEmptyArray)(xdm._experience.decisioning.propositions) ? // eslint-disable-next-line no-underscore-dangle
|
|
24
|
+
xdm._experience.decisioning.propositions : [];
|
|
25
|
+
};
|
|
26
|
+
|
|
18
27
|
var _default = function _default() {
|
|
19
28
|
var content = {};
|
|
20
29
|
var userXdm;
|
|
@@ -73,8 +82,17 @@ var _default = function _default() {
|
|
|
73
82
|
return;
|
|
74
83
|
}
|
|
75
84
|
|
|
85
|
+
var newPropositions = (0, _utils.deduplicateArray)([].concat(_toConsumableArray(getXdmPropositions(userXdm)), _toConsumableArray(getXdmPropositions(content.xdm))), function (a, b) {
|
|
86
|
+
return a === b || a.id && b.id && a.id === b.id && a.scope && b.scope && a.scope === b.scope;
|
|
87
|
+
});
|
|
88
|
+
|
|
76
89
|
if (userXdm) {
|
|
77
|
-
|
|
90
|
+
this.mergeXdm(userXdm);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (newPropositions.length > 0) {
|
|
94
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
95
|
+
content.xdm._experience.decisioning.propositions = newPropositions;
|
|
78
96
|
}
|
|
79
97
|
|
|
80
98
|
if (userData) {
|
|
@@ -117,7 +135,7 @@ var _default = function _default() {
|
|
|
117
135
|
return shouldSendEvent;
|
|
118
136
|
},
|
|
119
137
|
getViewName: function getViewName() {
|
|
120
|
-
if (!userXdm || !userXdm.web || !userXdm.web.webPageDetails) {
|
|
138
|
+
if (!userXdm || !userXdm.web || !userXdm.web.webPageDetails || !userXdm.web.webPageDetails.viewName) {
|
|
121
139
|
return undefined;
|
|
122
140
|
}
|
|
123
141
|
|
|
@@ -123,7 +123,8 @@ var _default = function _default(_ref) {
|
|
|
123
123
|
_options$responseBody = options.responseBody,
|
|
124
124
|
responseBody = _options$responseBody === void 0 ? {
|
|
125
125
|
handle: []
|
|
126
|
-
} : _options$responseBody
|
|
126
|
+
} : _options$responseBody,
|
|
127
|
+
personalization = options.personalization;
|
|
127
128
|
var payload = createDataCollectionRequestPayload();
|
|
128
129
|
var request = createDataCollectionRequest({
|
|
129
130
|
payload: payload
|
|
@@ -133,7 +134,7 @@ var _default = function _default(_ref) {
|
|
|
133
134
|
event: event,
|
|
134
135
|
renderDecisions: renderDecisions,
|
|
135
136
|
decisionScopes: [_pageWideScope.default],
|
|
136
|
-
personalization:
|
|
137
|
+
personalization: personalization,
|
|
137
138
|
onResponse: onResponseCallbackAggregator.add,
|
|
138
139
|
onRequestFailure: _utils.noop
|
|
139
140
|
}).then(function () {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var _addRenderAttemptedToDecisions = require("./addRenderAttemptedToDecisions");
|
|
6
|
-
|
|
7
5
|
/*
|
|
8
6
|
Copyright 2023 Adobe. All rights reserved.
|
|
9
7
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -15,21 +13,25 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
14
|
governing permissions and limitations under the License.
|
|
17
15
|
*/
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var resultingObject = {
|
|
22
|
-
propositions: (0, _addRenderAttemptedToDecisions.default)({
|
|
23
|
-
decisions: decisions,
|
|
24
|
-
renderAttempted: renderDecisions
|
|
25
|
-
})
|
|
26
|
-
};
|
|
16
|
+
var REFERENCE_EQUALITY = function REFERENCE_EQUALITY(a, b) {
|
|
17
|
+
return a === b;
|
|
18
|
+
};
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
var findIndex = function findIndex(array, item, isEqual) {
|
|
21
|
+
for (var i = 0; i < array.length; i += 1) {
|
|
22
|
+
if (isEqual(array[i], item)) {
|
|
23
|
+
return i;
|
|
24
|
+
}
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
return
|
|
27
|
+
return -1;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var _default = function _default(array) {
|
|
31
|
+
var isEqual = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : REFERENCE_EQUALITY;
|
|
32
|
+
return array.filter(function (item, index) {
|
|
33
|
+
return findIndex(array, item, isEqual) === index;
|
|
34
|
+
});
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
exports.default = _default;
|
package/libEs5/utils/index.js
CHANGED
|
@@ -60,6 +60,12 @@ Object.defineProperty(exports, "createTaskQueue", {
|
|
|
60
60
|
return _createTaskQueue.default;
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
+
Object.defineProperty(exports, "deduplicateArray", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function get() {
|
|
66
|
+
return _deduplicateArray.default;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
63
69
|
Object.defineProperty(exports, "deepAssign", {
|
|
64
70
|
enumerable: true,
|
|
65
71
|
get: function get() {
|
|
@@ -353,6 +359,8 @@ var _crc = require("./crc32");
|
|
|
353
359
|
|
|
354
360
|
var _defer = require("./defer");
|
|
355
361
|
|
|
362
|
+
var _deduplicateArray = require("./deduplicateArray");
|
|
363
|
+
|
|
356
364
|
var _deepAssign = require("./deepAssign");
|
|
357
365
|
|
|
358
366
|
var _endsWith = require("./endsWith");
|
|
@@ -101,13 +101,15 @@ const createDataCollector = ({
|
|
|
101
101
|
responseHeaders = {},
|
|
102
102
|
responseBody = {
|
|
103
103
|
handle: []
|
|
104
|
-
}
|
|
104
|
+
},
|
|
105
|
+
personalization
|
|
105
106
|
} = options;
|
|
106
107
|
const event = eventManager.createEvent();
|
|
107
108
|
return eventManager.applyResponse(event, {
|
|
108
109
|
renderDecisions,
|
|
109
110
|
responseHeaders,
|
|
110
|
-
responseBody
|
|
111
|
+
responseBody,
|
|
112
|
+
personalization
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
115
|
}
|
|
@@ -21,7 +21,12 @@ export default (({
|
|
|
21
21
|
type: string().required(),
|
|
22
22
|
payload: anything().required()
|
|
23
23
|
})).required()
|
|
24
|
-
}).required()
|
|
24
|
+
}).required(),
|
|
25
|
+
personalization: objectOf({
|
|
26
|
+
sendDisplayNotifications: boolean().default(true)
|
|
27
|
+
}).default({
|
|
28
|
+
sendDisplayNotifications: true
|
|
29
|
+
})
|
|
25
30
|
}).noUnknownFields();
|
|
26
31
|
return validator(options);
|
|
27
32
|
});
|
|
@@ -32,7 +32,11 @@ export default (({
|
|
|
32
32
|
decisionScopes: arrayOf(string()).uniqueItems(),
|
|
33
33
|
personalization: objectOf({
|
|
34
34
|
decisionScopes: arrayOf(string()).uniqueItems(),
|
|
35
|
-
surfaces: arrayOf(string()).uniqueItems()
|
|
35
|
+
surfaces: arrayOf(string()).uniqueItems(),
|
|
36
|
+
sendDisplayNotifications: boolean().default(true),
|
|
37
|
+
includePendingDisplayNotifications: boolean().default(false)
|
|
38
|
+
}).default({
|
|
39
|
+
sendDisplayNotifications: true
|
|
36
40
|
}),
|
|
37
41
|
datasetId: string(),
|
|
38
42
|
mergeId: string(),
|
|
@@ -9,14 +9,15 @@ 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
12
|
import { isNonEmptyArray, isObject } from "../../utils";
|
|
14
13
|
import { DOM_ACTION, HTML_CONTENT_ITEM } from "./constants/schema";
|
|
15
14
|
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
|
|
16
|
-
|
|
17
|
-
export const SUPPORTED_SCHEMAS = [DOM_ACTION, HTML_CONTENT_ITEM];
|
|
15
|
+
const SUPPORTED_SCHEMAS = [DOM_ACTION, HTML_CONTENT_ITEM];
|
|
18
16
|
export default (({
|
|
19
|
-
|
|
17
|
+
processPropositions,
|
|
18
|
+
createProposition,
|
|
19
|
+
pendingDisplayNotifications,
|
|
20
|
+
viewCache
|
|
20
21
|
}) => {
|
|
21
22
|
const filterItemsPredicate = item => SUPPORTED_SCHEMAS.indexOf(item.schema) > -1;
|
|
22
23
|
|
|
@@ -73,30 +74,30 @@ export default (({
|
|
|
73
74
|
}).filter(proposition => isNonEmptyArray(proposition.items));
|
|
74
75
|
};
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
propositions,
|
|
78
|
-
metadata
|
|
77
|
+
return ({
|
|
78
|
+
propositions = [],
|
|
79
|
+
metadata = {},
|
|
80
|
+
viewName
|
|
79
81
|
}) => {
|
|
80
82
|
const propositionsToExecute = preparePropositions({
|
|
81
83
|
propositions,
|
|
82
84
|
metadata
|
|
83
|
-
});
|
|
84
|
-
return
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return ({
|
|
90
|
-
propositions,
|
|
91
|
-
metadata = {}
|
|
92
|
-
}) => {
|
|
93
|
-
if (isNonEmptyArray(propositions)) {
|
|
94
|
-
return applyPropositions({
|
|
95
|
-
propositions,
|
|
96
|
-
metadata
|
|
97
|
-
});
|
|
98
|
-
}
|
|
85
|
+
}).map(proposition => createProposition(proposition));
|
|
86
|
+
return Promise.resolve().then(() => {
|
|
87
|
+
if (viewName) {
|
|
88
|
+
return viewCache.getView(viewName);
|
|
89
|
+
}
|
|
99
90
|
|
|
100
|
-
|
|
91
|
+
return [];
|
|
92
|
+
}).then(additionalPropositions => {
|
|
93
|
+
const {
|
|
94
|
+
render,
|
|
95
|
+
returnedPropositions
|
|
96
|
+
} = processPropositions([...propositionsToExecute, ...additionalPropositions]);
|
|
97
|
+
pendingDisplayNotifications.concat(render());
|
|
98
|
+
return {
|
|
99
|
+
propositions: returnedPropositions
|
|
100
|
+
};
|
|
101
|
+
});
|
|
101
102
|
};
|
|
102
103
|
});
|
|
@@ -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 { noop
|
|
12
|
+
import { noop } from "../../utils";
|
|
13
13
|
import createPersonalizationDetails from "./createPersonalizationDetails";
|
|
14
14
|
import { AUTHORING_ENABLED } from "./constants/loggerMessage";
|
|
15
15
|
import validateApplyPropositionsOptions from "./validateApplyPropositionsOptions";
|
|
@@ -24,7 +24,8 @@ export default (({
|
|
|
24
24
|
viewCache,
|
|
25
25
|
showContainers,
|
|
26
26
|
applyPropositions,
|
|
27
|
-
setTargetMigration
|
|
27
|
+
setTargetMigration,
|
|
28
|
+
pendingNotificationsHandler
|
|
28
29
|
}) => {
|
|
29
30
|
return {
|
|
30
31
|
lifecycle: {
|
|
@@ -55,7 +56,7 @@ export default (({
|
|
|
55
56
|
mergeQuery(event, {
|
|
56
57
|
enabled: false
|
|
57
58
|
});
|
|
58
|
-
return;
|
|
59
|
+
return Promise.resolve();
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
const personalizationDetails = createPersonalizationDetails({
|
|
@@ -64,32 +65,39 @@ export default (({
|
|
|
64
65
|
decisionScopes,
|
|
65
66
|
personalization,
|
|
66
67
|
event,
|
|
67
|
-
viewCache,
|
|
68
|
+
isCacheInitialized: viewCache.isInitialized(),
|
|
68
69
|
logger
|
|
69
70
|
});
|
|
71
|
+
const handlerPromises = [];
|
|
72
|
+
|
|
73
|
+
if (personalizationDetails.shouldAddPendingDisplayNotifications()) {
|
|
74
|
+
handlerPromises.push(pendingNotificationsHandler({
|
|
75
|
+
event
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
70
78
|
|
|
71
79
|
if (personalizationDetails.shouldFetchData()) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
onRequestFailure(() => decisionsDeferred.reject());
|
|
80
|
+
const cacheUpdate = viewCache.createCacheUpdate(personalizationDetails.getViewName());
|
|
81
|
+
onRequestFailure(() => cacheUpdate.cancel());
|
|
75
82
|
fetchDataHandler({
|
|
76
|
-
|
|
83
|
+
cacheUpdate,
|
|
77
84
|
personalizationDetails,
|
|
78
85
|
event,
|
|
79
86
|
onResponse
|
|
80
87
|
});
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (personalizationDetails.shouldUseCachedData()) {
|
|
88
|
+
} else if (personalizationDetails.shouldUseCachedData()) {
|
|
85
89
|
// eslint-disable-next-line consistent-return
|
|
86
|
-
|
|
90
|
+
handlerPromises.push(viewChangeHandler({
|
|
87
91
|
personalizationDetails,
|
|
88
92
|
event,
|
|
89
93
|
onResponse,
|
|
90
94
|
onRequestFailure
|
|
91
|
-
});
|
|
92
|
-
}
|
|
95
|
+
}));
|
|
96
|
+
} // We can wait for personalization to be applied and for
|
|
97
|
+
// the fetch data request to complete in parallel.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
return Promise.all(handlerPromises);
|
|
93
101
|
},
|
|
94
102
|
|
|
95
103
|
onClick({
|