@adobe/alloy 2.19.0-beta.6 → 2.19.0-beta.8
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 +12 -21
- package/libEs5/components/DataCollector/validateApplyResponse.js +2 -2
- package/libEs5/components/DataCollector/validateUserEventOptions.js +6 -4
- package/libEs5/components/Personalization/createApplyPropositions.js +4 -4
- package/libEs5/components/Personalization/createComponent.js +8 -5
- package/libEs5/components/Personalization/createFetchDataHandler.js +5 -5
- package/libEs5/components/Personalization/createPersonalizationDetails.js +6 -6
- package/libEs5/components/Personalization/createViewCacheManager.js +9 -10
- package/libEs5/components/Personalization/dom-actions/createRedirect.js +20 -0
- package/libEs5/components/Personalization/event.js +0 -5
- package/libEs5/components/Personalization/handlers/createProcessRedirect.js +2 -1
- package/libEs5/components/Personalization/index.js +7 -7
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/createEvent.js +1 -1
- package/libEs5/core/createEventManager.js +19 -26
- package/libEs6/components/DataCollector/index.js +7 -15
- package/libEs6/components/DataCollector/validateApplyResponse.js +2 -2
- package/libEs6/components/DataCollector/validateUserEventOptions.js +6 -4
- package/libEs6/components/Personalization/createApplyPropositions.js +4 -4
- package/libEs6/components/Personalization/createComponent.js +8 -5
- package/libEs6/components/Personalization/createFetchDataHandler.js +5 -5
- package/libEs6/components/Personalization/createPersonalizationDetails.js +6 -6
- package/libEs6/components/Personalization/createViewCacheManager.js +6 -9
- package/libEs6/components/Personalization/dom-actions/createRedirect.js +13 -0
- package/libEs6/components/Personalization/event.js +0 -5
- package/libEs6/components/Personalization/handlers/createProcessRedirect.js +2 -1
- package/libEs6/components/Personalization/index.js +7 -5
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/createEvent.js +1 -1
- package/libEs6/core/createEventManager.js +9 -19
- package/package.json +3 -3
|
@@ -4,6 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
var _validateUserEventOptions = require("./validateUserEventOptions");
|
|
5
5
|
var _validateApplyResponse = require("./validateApplyResponse");
|
|
6
6
|
var _utils = require("../../utils");
|
|
7
|
+
var _excluded = ["xdm", "data", "documentUnloading", "type", "mergeId", "datasetId", "edgeConfigOverrides"];
|
|
7
8
|
/*
|
|
8
9
|
Copyright 2019 Adobe. All rights reserved.
|
|
9
10
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -15,7 +16,8 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
16
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
17
|
governing permissions and limitations under the License.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
19
21
|
var createDataCollector = function createDataCollector(_ref) {
|
|
20
22
|
var eventManager = _ref.eventManager,
|
|
21
23
|
logger = _ref.logger;
|
|
@@ -31,18 +33,12 @@ var createDataCollector = function createDataCollector(_ref) {
|
|
|
31
33
|
run: function run(options) {
|
|
32
34
|
var xdm = options.xdm,
|
|
33
35
|
data = options.data,
|
|
34
|
-
|
|
35
|
-
documentUnloading = _options$documentUnlo === void 0 ? false : _options$documentUnlo,
|
|
36
|
+
documentUnloading = options.documentUnloading,
|
|
36
37
|
type = options.type,
|
|
37
38
|
mergeId = options.mergeId,
|
|
38
|
-
_options$renderDecisi = options.renderDecisions,
|
|
39
|
-
renderDecisions = _options$renderDecisi === void 0 ? false : _options$renderDecisi,
|
|
40
|
-
_options$decisionScop = options.decisionScopes,
|
|
41
|
-
decisionScopes = _options$decisionScop === void 0 ? [] : _options$decisionScop,
|
|
42
|
-
_options$personalizat = options.personalization,
|
|
43
|
-
personalization = _options$personalizat === void 0 ? {} : _options$personalizat,
|
|
44
39
|
datasetId = options.datasetId,
|
|
45
|
-
edgeConfigOverrides = options.edgeConfigOverrides
|
|
40
|
+
edgeConfigOverrides = options.edgeConfigOverrides,
|
|
41
|
+
eventManagerOptions = _objectWithoutProperties(options, _excluded);
|
|
46
42
|
var event = eventManager.createEvent();
|
|
47
43
|
if (documentUnloading) {
|
|
48
44
|
event.documentMayUnload();
|
|
@@ -59,18 +55,13 @@ var createDataCollector = function createDataCollector(_ref) {
|
|
|
59
55
|
eventMergeId: mergeId
|
|
60
56
|
});
|
|
61
57
|
}
|
|
62
|
-
var sendEventOptions = {
|
|
63
|
-
renderDecisions: renderDecisions,
|
|
64
|
-
decisionScopes: decisionScopes,
|
|
65
|
-
personalization: personalization
|
|
66
|
-
};
|
|
67
58
|
if (edgeConfigOverrides) {
|
|
68
|
-
|
|
59
|
+
eventManagerOptions.edgeConfigOverrides = edgeConfigOverrides;
|
|
69
60
|
}
|
|
70
61
|
if (datasetId) {
|
|
71
62
|
logger.warn("The 'datasetId' option has been deprecated. Please use 'edgeConfigOverrides.com_adobe_experience_platform.datasets.event.datasetId' instead.");
|
|
72
|
-
|
|
73
|
-
(0, _utils.deepAssign)(
|
|
63
|
+
eventManagerOptions.edgeConfigOverrides = edgeConfigOverrides || {};
|
|
64
|
+
(0, _utils.deepAssign)(eventManagerOptions.edgeConfigOverrides, {
|
|
74
65
|
com_adobe_experience_platform: {
|
|
75
66
|
datasets: {
|
|
76
67
|
event: {
|
|
@@ -80,7 +71,7 @@ var createDataCollector = function createDataCollector(_ref) {
|
|
|
80
71
|
}
|
|
81
72
|
});
|
|
82
73
|
}
|
|
83
|
-
return eventManager.sendEvent(event,
|
|
74
|
+
return eventManager.sendEvent(event, eventManagerOptions);
|
|
84
75
|
}
|
|
85
76
|
},
|
|
86
77
|
applyResponse: {
|
|
@@ -91,8 +82,8 @@ var createDataCollector = function createDataCollector(_ref) {
|
|
|
91
82
|
});
|
|
92
83
|
},
|
|
93
84
|
run: function run(options) {
|
|
94
|
-
var _options$
|
|
95
|
-
renderDecisions = _options$
|
|
85
|
+
var _options$renderDecisi = options.renderDecisions,
|
|
86
|
+
renderDecisions = _options$renderDecisi === void 0 ? false : _options$renderDecisi,
|
|
96
87
|
_options$responseHead = options.responseHeaders,
|
|
97
88
|
responseHeaders = _options$responseHead === void 0 ? {} : _options$responseHead,
|
|
98
89
|
_options$responseBody = options.responseBody,
|
|
@@ -25,9 +25,9 @@ var _default = function _default(_ref) {
|
|
|
25
25
|
})).required()
|
|
26
26
|
}).required(),
|
|
27
27
|
personalization: (0, _validation.objectOf)({
|
|
28
|
-
|
|
28
|
+
sendDisplayEvent: (0, _validation.boolean)().default(true)
|
|
29
29
|
}).default({
|
|
30
|
-
|
|
30
|
+
sendDisplayEvent: true
|
|
31
31
|
})
|
|
32
32
|
}).noUnknownFields();
|
|
33
33
|
return validator(options);
|
|
@@ -34,14 +34,16 @@ var _default = function _default(_ref) {
|
|
|
34
34
|
personalization: (0, _validation.objectOf)({
|
|
35
35
|
decisionScopes: (0, _validation.arrayOf)((0, _validation.string)()).uniqueItems(),
|
|
36
36
|
surfaces: (0, _validation.arrayOf)((0, _validation.string)()).uniqueItems(),
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
sendDisplayEvent: (0, _validation.boolean)().default(true),
|
|
38
|
+
includeRenderedPropositions: (0, _validation.boolean)().default(false),
|
|
39
|
+
requestPersonalization: (0, _validation.boolean)()
|
|
39
40
|
}).default({
|
|
40
|
-
|
|
41
|
+
sendDisplayEvent: true
|
|
41
42
|
}),
|
|
42
43
|
datasetId: (0, _validation.string)(),
|
|
43
44
|
mergeId: (0, _validation.string)(),
|
|
44
|
-
edgeConfigOverrides: _utils.validateConfigOverride
|
|
45
|
+
edgeConfigOverrides: _utils.validateConfigOverride,
|
|
46
|
+
initializePersonalization: (0, _validation.boolean)()
|
|
45
47
|
}).required().noUnknownFields();
|
|
46
48
|
return eventOptionsValidator(options);
|
|
47
49
|
};
|
|
@@ -27,7 +27,7 @@ var SUPPORTED_SCHEMAS = [_schema.DOM_ACTION, _schema.HTML_CONTENT_ITEM];
|
|
|
27
27
|
var _default = function _default(_ref) {
|
|
28
28
|
var processPropositions = _ref.processPropositions,
|
|
29
29
|
createProposition = _ref.createProposition,
|
|
30
|
-
|
|
30
|
+
renderedPropositions = _ref.renderedPropositions,
|
|
31
31
|
viewCache = _ref.viewCache;
|
|
32
32
|
var filterItemsPredicate = function filterItemsPredicate(item) {
|
|
33
33
|
return SUPPORTED_SCHEMAS.indexOf(item.schema) > -1;
|
|
@@ -86,8 +86,8 @@ var _default = function _default(_ref) {
|
|
|
86
86
|
viewName = _ref4.viewName;
|
|
87
87
|
// We need to immediately call concat so that subsequent sendEvent
|
|
88
88
|
// calls will wait for applyPropositions to complete before executing.
|
|
89
|
-
var
|
|
90
|
-
|
|
89
|
+
var renderedPropositionsDeferred = (0, _utils.defer)();
|
|
90
|
+
renderedPropositions.concat(renderedPropositionsDeferred.promise);
|
|
91
91
|
var propositionsToExecute = preparePropositions({
|
|
92
92
|
propositions: propositions,
|
|
93
93
|
metadata: metadata
|
|
@@ -103,7 +103,7 @@ var _default = function _default(_ref) {
|
|
|
103
103
|
var _processPropositions = processPropositions([].concat(_toConsumableArray(propositionsToExecute), _toConsumableArray(additionalPropositions))),
|
|
104
104
|
render = _processPropositions.render,
|
|
105
105
|
returnedPropositions = _processPropositions.returnedPropositions;
|
|
106
|
-
render().then(
|
|
106
|
+
render().then(renderedPropositionsDeferred.resolve);
|
|
107
107
|
return {
|
|
108
108
|
propositions: returnedPropositions
|
|
109
109
|
};
|
|
@@ -30,7 +30,7 @@ var _default = function _default(_ref) {
|
|
|
30
30
|
applyPropositions = _ref.applyPropositions,
|
|
31
31
|
setTargetMigration = _ref.setTargetMigration,
|
|
32
32
|
mergeDecisionsMeta = _ref.mergeDecisionsMeta,
|
|
33
|
-
|
|
33
|
+
renderedPropositions = _ref.renderedPropositions;
|
|
34
34
|
return {
|
|
35
35
|
lifecycle: {
|
|
36
36
|
onBeforeRequest: function onBeforeRequest(_ref2) {
|
|
@@ -77,8 +77,8 @@ var _default = function _default(_ref) {
|
|
|
77
77
|
logger: logger
|
|
78
78
|
});
|
|
79
79
|
var decisionsMetaPromises = [];
|
|
80
|
-
if (personalizationDetails.
|
|
81
|
-
decisionsMetaPromises.push(
|
|
80
|
+
if (personalizationDetails.shouldIncludeRenderedPropositions()) {
|
|
81
|
+
decisionsMetaPromises.push(renderedPropositions.clear());
|
|
82
82
|
}
|
|
83
83
|
if (personalizationDetails.shouldFetchData()) {
|
|
84
84
|
var cacheUpdate = viewCache.createCacheUpdate(personalizationDetails.getViewName());
|
|
@@ -107,9 +107,12 @@ var _default = function _default(_ref) {
|
|
|
107
107
|
return Promise.all(decisionsMetaPromises).then(function (decisionsMetas) {
|
|
108
108
|
// We only want to call mergeDecisionsMeta once, but we can get the propositions
|
|
109
109
|
// from two places: the pending display notifications and the view change handler.
|
|
110
|
-
|
|
110
|
+
var decisionsMeta = (0, _utils.flatMap)(decisionsMetas, function (dms) {
|
|
111
111
|
return dms;
|
|
112
|
-
})
|
|
112
|
+
});
|
|
113
|
+
if ((0, _utils.isNonEmptyArray)(decisionsMeta)) {
|
|
114
|
+
mergeDecisionsMeta(event, decisionsMeta, _propositionEventType.PropositionEventType.DISPLAY);
|
|
115
|
+
}
|
|
113
116
|
});
|
|
114
117
|
},
|
|
115
118
|
onClick: function onClick(_ref4) {
|
|
@@ -27,7 +27,7 @@ var _default = function _default(_ref) {
|
|
|
27
27
|
collect = _ref.collect,
|
|
28
28
|
processPropositions = _ref.processPropositions,
|
|
29
29
|
createProposition = _ref.createProposition,
|
|
30
|
-
|
|
30
|
+
renderedPropositions = _ref.renderedPropositions;
|
|
31
31
|
return function (_ref2) {
|
|
32
32
|
var cacheUpdate = _ref2.cacheUpdate,
|
|
33
33
|
personalizationDetails = _ref2.personalizationDetails,
|
|
@@ -40,7 +40,7 @@ var _default = function _default(_ref) {
|
|
|
40
40
|
}
|
|
41
41
|
mergeQuery(event, personalizationDetails.createQueryDetails());
|
|
42
42
|
var handleNotifications;
|
|
43
|
-
if (personalizationDetails.
|
|
43
|
+
if (personalizationDetails.isSendDisplayEvent()) {
|
|
44
44
|
handleNotifications = function handleNotifications(decisionsMeta) {
|
|
45
45
|
if (decisionsMeta.length > 0) {
|
|
46
46
|
collect({
|
|
@@ -50,9 +50,9 @@ var _default = function _default(_ref) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
} else {
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
handleNotifications =
|
|
53
|
+
var renderedPropositionsDeferred = (0, _utils.defer)();
|
|
54
|
+
renderedPropositions.concat(renderedPropositionsDeferred.promise);
|
|
55
|
+
handleNotifications = renderedPropositionsDeferred.resolve;
|
|
56
56
|
}
|
|
57
57
|
onResponse(function (_ref3) {
|
|
58
58
|
var response = _ref3.response;
|
|
@@ -50,11 +50,11 @@ var _default = function _default(_ref) {
|
|
|
50
50
|
isRenderDecisions: function isRenderDecisions() {
|
|
51
51
|
return renderDecisions;
|
|
52
52
|
},
|
|
53
|
-
|
|
54
|
-
return !!personalization.
|
|
53
|
+
isSendDisplayEvent: function isSendDisplayEvent() {
|
|
54
|
+
return !!personalization.sendDisplayEvent;
|
|
55
55
|
},
|
|
56
|
-
|
|
57
|
-
return !!personalization.
|
|
56
|
+
shouldIncludeRenderedPropositions: function shouldIncludeRenderedPropositions() {
|
|
57
|
+
return !!personalization.includeRenderedPropositions;
|
|
58
58
|
},
|
|
59
59
|
getViewName: function getViewName() {
|
|
60
60
|
return viewName;
|
|
@@ -74,7 +74,7 @@ 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()) {
|
|
77
|
+
if (!this.isCacheInitialized() || personalization.requestPersonalization) {
|
|
78
78
|
addPageWideScope(scopes);
|
|
79
79
|
addPageSurface(eventSurfaces, getPageLocation);
|
|
80
80
|
}
|
|
@@ -92,7 +92,7 @@ var _default = function _default(_ref) {
|
|
|
92
92
|
return _isCacheInitialized;
|
|
93
93
|
},
|
|
94
94
|
shouldFetchData: function shouldFetchData() {
|
|
95
|
-
return this.hasScopes() || this.hasSurfaces() || !this.isCacheInitialized();
|
|
95
|
+
return this.hasScopes() || this.hasSurfaces() || personalization.requestPersonalization || !this.isCacheInitialized() && personalization.requestPersonalization !== false;
|
|
96
96
|
},
|
|
97
97
|
shouldUseCachedData: function shouldUseCachedData() {
|
|
98
98
|
return this.hasViewName() && this.isCacheInitialized();
|
|
@@ -17,11 +17,10 @@ governing permissions and limitations under the License.
|
|
|
17
17
|
*/
|
|
18
18
|
var _default = function _default(_ref) {
|
|
19
19
|
var createProposition = _ref.createProposition;
|
|
20
|
-
var viewStorage = {};
|
|
21
20
|
var cacheUpdateCreatedAtLeastOnce = false;
|
|
22
|
-
var
|
|
23
|
-
var getViewPropositions = function getViewPropositions(
|
|
24
|
-
var viewPropositions =
|
|
21
|
+
var viewStoragePromise = Promise.resolve({});
|
|
22
|
+
var getViewPropositions = function getViewPropositions(viewStorage, viewName) {
|
|
23
|
+
var viewPropositions = viewStorage[viewName.toLowerCase()];
|
|
25
24
|
if (viewPropositions && viewPropositions.length > 0) {
|
|
26
25
|
return viewPropositions;
|
|
27
26
|
}
|
|
@@ -43,11 +42,11 @@ var _default = function _default(_ref) {
|
|
|
43
42
|
var createCacheUpdate = function createCacheUpdate(viewName) {
|
|
44
43
|
var updateCacheDeferred = (0, _defer.default)();
|
|
45
44
|
cacheUpdateCreatedAtLeastOnce = true;
|
|
46
|
-
|
|
47
|
-
return updateCacheDeferred.promise
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})
|
|
45
|
+
viewStoragePromise = viewStoragePromise.then(function (oldViewStorage) {
|
|
46
|
+
return updateCacheDeferred.promise.catch(function () {
|
|
47
|
+
return oldViewStorage;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
51
50
|
return {
|
|
52
51
|
update: function update(viewPropositions) {
|
|
53
52
|
var viewPropositionsWithScope = viewPropositions.filter(function (proposition) {
|
|
@@ -68,7 +67,7 @@ var _default = function _default(_ref) {
|
|
|
68
67
|
};
|
|
69
68
|
};
|
|
70
69
|
var getView = function getView(viewName) {
|
|
71
|
-
return
|
|
70
|
+
return viewStoragePromise.then(function (viewStorage) {
|
|
72
71
|
return getViewPropositions(viewStorage, viewName);
|
|
73
72
|
});
|
|
74
73
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2019 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(window) {
|
|
16
|
+
return function (url) {
|
|
17
|
+
return window.location.replace(url);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.default = _default;
|
|
@@ -21,11 +21,6 @@ var EVENT_TYPE_TRUE = 1;
|
|
|
21
21
|
/* eslint-disable no-underscore-dangle */
|
|
22
22
|
var mergeDecisionsMeta = function mergeDecisionsMeta(event, decisionsMeta, eventType) {
|
|
23
23
|
var eventLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
|
|
24
|
-
// Do not send a display notification with no decisions. Even empty view changes
|
|
25
|
-
// should include a proposition.
|
|
26
|
-
if (decisionsMeta.length === 0) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
24
|
var xdm = {
|
|
30
25
|
_experience: {
|
|
31
26
|
decisioning: {
|
|
@@ -25,7 +25,8 @@ var _default = function _default(_ref) {
|
|
|
25
25
|
}
|
|
26
26
|
var render = function render() {
|
|
27
27
|
return collect({
|
|
28
|
-
decisionsMeta: [item.getMeta()]
|
|
28
|
+
decisionsMeta: [item.getMeta()],
|
|
29
|
+
documentMayUnload: true
|
|
29
30
|
}).then(function () {
|
|
30
31
|
executeRedirect(content);
|
|
31
32
|
// We've already sent the display notification, so don't return anything
|
|
@@ -29,6 +29,7 @@ var _createProcessDomAction = require("./handlers/createProcessDomAction");
|
|
|
29
29
|
var _createProcessHtmlContent = require("./handlers/createProcessHtmlContent");
|
|
30
30
|
var _createProcessRedirect = require("./handlers/createProcessRedirect");
|
|
31
31
|
var _createProcessPropositions = require("./handlers/createProcessPropositions");
|
|
32
|
+
var _createRedirect = require("./dom-actions/createRedirect");
|
|
32
33
|
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; } /*
|
|
33
34
|
Copyright 2019 Adobe. All rights reserved.
|
|
34
35
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -67,6 +68,7 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
67
68
|
var viewCache = (0, _createViewCacheManager.default)({
|
|
68
69
|
createProposition: createProposition
|
|
69
70
|
});
|
|
71
|
+
var executeRedirect = (0, _createRedirect.default)(window);
|
|
70
72
|
var schemaProcessors = (_schemaProcessors = {}, _defineProperty(_schemaProcessors, schema.DEFAULT_CONTENT_ITEM, _processDefaultContent.default), _defineProperty(_schemaProcessors, schema.DOM_ACTION, (0, _createProcessDomAction.default)({
|
|
71
73
|
modules: modules,
|
|
72
74
|
logger: logger,
|
|
@@ -76,16 +78,14 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
76
78
|
logger: logger
|
|
77
79
|
})), _defineProperty(_schemaProcessors, schema.REDIRECT_ITEM, (0, _createProcessRedirect.default)({
|
|
78
80
|
logger: logger,
|
|
79
|
-
executeRedirect:
|
|
80
|
-
return window.location.replace(url);
|
|
81
|
-
},
|
|
81
|
+
executeRedirect: executeRedirect,
|
|
82
82
|
collect: collect
|
|
83
83
|
})), _schemaProcessors);
|
|
84
84
|
var processPropositions = (0, _createProcessPropositions.default)({
|
|
85
85
|
schemaProcessors: schemaProcessors,
|
|
86
86
|
logger: logger
|
|
87
87
|
});
|
|
88
|
-
var
|
|
88
|
+
var renderedPropositions = (0, _createAsyncArray.default)();
|
|
89
89
|
var fetchDataHandler = (0, _createFetchDataHandler.default)({
|
|
90
90
|
prehidingStyle: prehidingStyle,
|
|
91
91
|
showContainers: _flicker.showContainers,
|
|
@@ -94,7 +94,7 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
94
94
|
collect: collect,
|
|
95
95
|
processPropositions: processPropositions,
|
|
96
96
|
createProposition: createProposition,
|
|
97
|
-
|
|
97
|
+
renderedPropositions: renderedPropositions
|
|
98
98
|
});
|
|
99
99
|
var onClickHandler = (0, _createOnClickHandler.default)({
|
|
100
100
|
mergeDecisionsMeta: _event.mergeDecisionsMeta,
|
|
@@ -109,7 +109,7 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
109
109
|
var applyPropositions = (0, _createApplyPropositions.default)({
|
|
110
110
|
processPropositions: processPropositions,
|
|
111
111
|
createProposition: createProposition,
|
|
112
|
-
|
|
112
|
+
renderedPropositions: renderedPropositions,
|
|
113
113
|
viewCache: viewCache
|
|
114
114
|
});
|
|
115
115
|
var setTargetMigration = (0, _createSetTargetMigration.default)({
|
|
@@ -128,7 +128,7 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
128
128
|
applyPropositions: applyPropositions,
|
|
129
129
|
setTargetMigration: setTargetMigration,
|
|
130
130
|
mergeDecisionsMeta: _event.mergeDecisionsMeta,
|
|
131
|
-
|
|
131
|
+
renderedPropositions: renderedPropositions
|
|
132
132
|
});
|
|
133
133
|
};
|
|
134
134
|
createPersonalization.namespace = "Personalization";
|
|
@@ -14,5 +14,5 @@ governing permissions and limitations under the License.
|
|
|
14
14
|
*/
|
|
15
15
|
// The __VERSION__ keyword will be replace at alloy build time with the package.json version.
|
|
16
16
|
// see babel-plugin-version
|
|
17
|
-
var _default = "2.19.0-beta.
|
|
17
|
+
var _default = "2.19.0-beta.8";
|
|
18
18
|
exports.default = _default;
|
|
@@ -129,7 +129,7 @@ var _default = function _default() {
|
|
|
129
129
|
return shouldSendEvent;
|
|
130
130
|
},
|
|
131
131
|
getViewName: function getViewName() {
|
|
132
|
-
if (!userXdm || !userXdm.web || !userXdm.web.webPageDetails
|
|
132
|
+
if (!userXdm || !userXdm.web || !userXdm.web.webPageDetails) {
|
|
133
133
|
return undefined;
|
|
134
134
|
}
|
|
135
135
|
return userXdm.web.webPageDetails.viewName;
|
|
@@ -4,6 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
var _pageWideScope = require("../constants/pageWideScope");
|
|
5
5
|
var _utils = require("../utils");
|
|
6
6
|
var _request = require("../utils/request");
|
|
7
|
+
var _excluded = ["edgeConfigOverrides"];
|
|
7
8
|
/*
|
|
8
9
|
Copyright 2019 Adobe. All rights reserved.
|
|
9
10
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -15,7 +16,11 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
16
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
17
|
governing permissions and limitations under the License.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
19
24
|
var EVENT_CANCELLATION_MESSAGE = "Event was canceled because the onBeforeEventSend callback returned false.";
|
|
20
25
|
var _default = function _default(_ref) {
|
|
21
26
|
var config = _ref.config,
|
|
@@ -32,19 +37,13 @@ var _default = function _default(_ref) {
|
|
|
32
37
|
return {
|
|
33
38
|
createEvent: createEvent,
|
|
34
39
|
/**
|
|
35
|
-
* Sends an event. This includes running the event and payload through
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param {Object} event This will be JSON stringified and used inside
|
|
39
|
-
*
|
|
40
|
-
* @param {Object} [options]
|
|
41
|
-
*
|
|
42
|
-
* @param {Array} [options.decisionScopes] Note: this option will soon
|
|
43
|
-
* be deprecated, please use *personalization.decisionScopes* instead
|
|
44
|
-
* @param {Object} [options.personalization]
|
|
45
|
-
* @param {Object} [options.serverState]
|
|
46
|
-
* This will be passed to components
|
|
47
|
-
* so they can take appropriate action.
|
|
40
|
+
* Sends an event. This includes running the event and payload through the
|
|
41
|
+
* appropriate lifecycle hooks, sending the request to the server, and
|
|
42
|
+
* handling the response.
|
|
43
|
+
* @param {Object} event This will be JSON stringified and used inside the
|
|
44
|
+
* request payload.
|
|
45
|
+
* @param {Object} [options] Options to pass on to the onBeforeEvent
|
|
46
|
+
* lifecycle method
|
|
48
47
|
* @param {Object} [options.edgeConfigOverrides] Settings that take
|
|
49
48
|
* precedence over the global datastream configuration, including which
|
|
50
49
|
* datastream to use.
|
|
@@ -52,11 +51,8 @@ var _default = function _default(_ref) {
|
|
|
52
51
|
*/
|
|
53
52
|
sendEvent: function sendEvent(event) {
|
|
54
53
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
decisionScopes = options.decisionScopes,
|
|
58
|
-
localConfigOverrides = options.edgeConfigOverrides,
|
|
59
|
-
personalization = options.personalization;
|
|
54
|
+
var localConfigOverrides = options.edgeConfigOverrides,
|
|
55
|
+
otherOptions = _objectWithoutProperties(options, _excluded);
|
|
60
56
|
var requestParams = (0, _request.createRequestParams)({
|
|
61
57
|
payload: createDataCollectionRequestPayload(),
|
|
62
58
|
localConfigOverrides: localConfigOverrides,
|
|
@@ -65,14 +61,11 @@ var _default = function _default(_ref) {
|
|
|
65
61
|
var request = createDataCollectionRequest(requestParams);
|
|
66
62
|
var onResponseCallbackAggregator = (0, _utils.createCallbackAggregator)();
|
|
67
63
|
var onRequestFailureCallbackAggregator = (0, _utils.createCallbackAggregator)();
|
|
68
|
-
return lifecycle.onBeforeEvent({
|
|
64
|
+
return lifecycle.onBeforeEvent(_objectSpread(_objectSpread({}, otherOptions), {}, {
|
|
69
65
|
event: event,
|
|
70
|
-
renderDecisions: renderDecisions,
|
|
71
|
-
decisionScopes: decisionScopes,
|
|
72
|
-
personalization: personalization,
|
|
73
66
|
onResponse: onResponseCallbackAggregator.add,
|
|
74
67
|
onRequestFailure: onRequestFailureCallbackAggregator.add
|
|
75
|
-
}).then(function () {
|
|
68
|
+
})).then(function () {
|
|
76
69
|
requestParams.payload.addEvent(event);
|
|
77
70
|
return consent.awaitConsent();
|
|
78
71
|
}).then(function () {
|
|
@@ -110,8 +103,8 @@ var _default = function _default(_ref) {
|
|
|
110
103
|
},
|
|
111
104
|
applyResponse: function applyResponse(event) {
|
|
112
105
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
113
|
-
var _options$
|
|
114
|
-
renderDecisions = _options$
|
|
106
|
+
var _options$renderDecisi = options.renderDecisions,
|
|
107
|
+
renderDecisions = _options$renderDecisi === void 0 ? false : _options$renderDecisi,
|
|
115
108
|
_options$responseHead = options.responseHeaders,
|
|
116
109
|
responseHeaders = _options$responseHead === void 0 ? {} : _options$responseHead,
|
|
117
110
|
_options$responseBody = options.responseBody,
|
|
@@ -30,15 +30,12 @@ const createDataCollector = ({
|
|
|
30
30
|
const {
|
|
31
31
|
xdm,
|
|
32
32
|
data,
|
|
33
|
-
documentUnloading
|
|
33
|
+
documentUnloading,
|
|
34
34
|
type,
|
|
35
35
|
mergeId,
|
|
36
|
-
renderDecisions = false,
|
|
37
|
-
decisionScopes = [],
|
|
38
|
-
// Note: this option will soon be deprecated, please use personalization.decisionScopes instead
|
|
39
|
-
personalization = {},
|
|
40
36
|
datasetId,
|
|
41
|
-
edgeConfigOverrides
|
|
37
|
+
edgeConfigOverrides,
|
|
38
|
+
...eventManagerOptions
|
|
42
39
|
} = options;
|
|
43
40
|
const event = eventManager.createEvent();
|
|
44
41
|
if (documentUnloading) {
|
|
@@ -56,18 +53,13 @@ const createDataCollector = ({
|
|
|
56
53
|
eventMergeId: mergeId
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
|
-
const sendEventOptions = {
|
|
60
|
-
renderDecisions,
|
|
61
|
-
decisionScopes,
|
|
62
|
-
personalization
|
|
63
|
-
};
|
|
64
56
|
if (edgeConfigOverrides) {
|
|
65
|
-
|
|
57
|
+
eventManagerOptions.edgeConfigOverrides = edgeConfigOverrides;
|
|
66
58
|
}
|
|
67
59
|
if (datasetId) {
|
|
68
60
|
logger.warn("The 'datasetId' option has been deprecated. Please use 'edgeConfigOverrides.com_adobe_experience_platform.datasets.event.datasetId' instead.");
|
|
69
|
-
|
|
70
|
-
deepAssign(
|
|
61
|
+
eventManagerOptions.edgeConfigOverrides = edgeConfigOverrides || {};
|
|
62
|
+
deepAssign(eventManagerOptions.edgeConfigOverrides, {
|
|
71
63
|
com_adobe_experience_platform: {
|
|
72
64
|
datasets: {
|
|
73
65
|
event: {
|
|
@@ -77,7 +69,7 @@ const createDataCollector = ({
|
|
|
77
69
|
}
|
|
78
70
|
});
|
|
79
71
|
}
|
|
80
|
-
return eventManager.sendEvent(event,
|
|
72
|
+
return eventManager.sendEvent(event, eventManagerOptions);
|
|
81
73
|
}
|
|
82
74
|
},
|
|
83
75
|
applyResponse: {
|
|
@@ -23,9 +23,9 @@ export default (({
|
|
|
23
23
|
})).required()
|
|
24
24
|
}).required(),
|
|
25
25
|
personalization: objectOf({
|
|
26
|
-
|
|
26
|
+
sendDisplayEvent: boolean().default(true)
|
|
27
27
|
}).default({
|
|
28
|
-
|
|
28
|
+
sendDisplayEvent: true
|
|
29
29
|
})
|
|
30
30
|
}).noUnknownFields();
|
|
31
31
|
return validator(options);
|
|
@@ -33,14 +33,16 @@ export default (({
|
|
|
33
33
|
personalization: objectOf({
|
|
34
34
|
decisionScopes: arrayOf(string()).uniqueItems(),
|
|
35
35
|
surfaces: arrayOf(string()).uniqueItems(),
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
sendDisplayEvent: boolean().default(true),
|
|
37
|
+
includeRenderedPropositions: boolean().default(false),
|
|
38
|
+
requestPersonalization: boolean()
|
|
38
39
|
}).default({
|
|
39
|
-
|
|
40
|
+
sendDisplayEvent: true
|
|
40
41
|
}),
|
|
41
42
|
datasetId: string(),
|
|
42
43
|
mergeId: string(),
|
|
43
|
-
edgeConfigOverrides: validateConfigOverride
|
|
44
|
+
edgeConfigOverrides: validateConfigOverride,
|
|
45
|
+
initializePersonalization: boolean()
|
|
44
46
|
}).required().noUnknownFields();
|
|
45
47
|
return eventOptionsValidator(options);
|
|
46
48
|
});
|
|
@@ -17,7 +17,7 @@ const SUPPORTED_SCHEMAS = [DOM_ACTION, HTML_CONTENT_ITEM];
|
|
|
17
17
|
export default (({
|
|
18
18
|
processPropositions,
|
|
19
19
|
createProposition,
|
|
20
|
-
|
|
20
|
+
renderedPropositions,
|
|
21
21
|
viewCache
|
|
22
22
|
}) => {
|
|
23
23
|
const filterItemsPredicate = item => SUPPORTED_SCHEMAS.indexOf(item.schema) > -1;
|
|
@@ -78,8 +78,8 @@ export default (({
|
|
|
78
78
|
}) => {
|
|
79
79
|
// We need to immediately call concat so that subsequent sendEvent
|
|
80
80
|
// calls will wait for applyPropositions to complete before executing.
|
|
81
|
-
const
|
|
82
|
-
|
|
81
|
+
const renderedPropositionsDeferred = defer();
|
|
82
|
+
renderedPropositions.concat(renderedPropositionsDeferred.promise);
|
|
83
83
|
const propositionsToExecute = preparePropositions({
|
|
84
84
|
propositions,
|
|
85
85
|
metadata
|
|
@@ -94,7 +94,7 @@ export default (({
|
|
|
94
94
|
render,
|
|
95
95
|
returnedPropositions
|
|
96
96
|
} = processPropositions([...propositionsToExecute, ...additionalPropositions]);
|
|
97
|
-
render().then(
|
|
97
|
+
render().then(renderedPropositionsDeferred.resolve);
|
|
98
98
|
return {
|
|
99
99
|
propositions: returnedPropositions
|
|
100
100
|
};
|
|
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { noop, flatMap } from "../../utils";
|
|
13
|
+
import { noop, flatMap, isNonEmptyArray } from "../../utils";
|
|
14
14
|
import createPersonalizationDetails from "./createPersonalizationDetails";
|
|
15
15
|
import { AUTHORING_ENABLED } from "./constants/loggerMessage";
|
|
16
16
|
import validateApplyPropositionsOptions from "./validateApplyPropositionsOptions";
|
|
@@ -28,7 +28,7 @@ export default (({
|
|
|
28
28
|
applyPropositions,
|
|
29
29
|
setTargetMigration,
|
|
30
30
|
mergeDecisionsMeta,
|
|
31
|
-
|
|
31
|
+
renderedPropositions
|
|
32
32
|
}) => {
|
|
33
33
|
return {
|
|
34
34
|
lifecycle: {
|
|
@@ -70,8 +70,8 @@ export default (({
|
|
|
70
70
|
logger
|
|
71
71
|
});
|
|
72
72
|
const decisionsMetaPromises = [];
|
|
73
|
-
if (personalizationDetails.
|
|
74
|
-
decisionsMetaPromises.push(
|
|
73
|
+
if (personalizationDetails.shouldIncludeRenderedPropositions()) {
|
|
74
|
+
decisionsMetaPromises.push(renderedPropositions.clear());
|
|
75
75
|
}
|
|
76
76
|
if (personalizationDetails.shouldFetchData()) {
|
|
77
77
|
const cacheUpdate = viewCache.createCacheUpdate(personalizationDetails.getViewName());
|
|
@@ -98,7 +98,10 @@ export default (({
|
|
|
98
98
|
return Promise.all(decisionsMetaPromises).then(decisionsMetas => {
|
|
99
99
|
// We only want to call mergeDecisionsMeta once, but we can get the propositions
|
|
100
100
|
// from two places: the pending display notifications and the view change handler.
|
|
101
|
-
|
|
101
|
+
const decisionsMeta = flatMap(decisionsMetas, dms => dms);
|
|
102
|
+
if (isNonEmptyArray(decisionsMeta)) {
|
|
103
|
+
mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY);
|
|
104
|
+
}
|
|
102
105
|
});
|
|
103
106
|
},
|
|
104
107
|
onClick({
|
|
@@ -19,7 +19,7 @@ export default (({
|
|
|
19
19
|
collect,
|
|
20
20
|
processPropositions,
|
|
21
21
|
createProposition,
|
|
22
|
-
|
|
22
|
+
renderedPropositions
|
|
23
23
|
}) => {
|
|
24
24
|
return ({
|
|
25
25
|
cacheUpdate,
|
|
@@ -34,7 +34,7 @@ export default (({
|
|
|
34
34
|
}
|
|
35
35
|
mergeQuery(event, personalizationDetails.createQueryDetails());
|
|
36
36
|
let handleNotifications;
|
|
37
|
-
if (personalizationDetails.
|
|
37
|
+
if (personalizationDetails.isSendDisplayEvent()) {
|
|
38
38
|
handleNotifications = decisionsMeta => {
|
|
39
39
|
if (decisionsMeta.length > 0) {
|
|
40
40
|
collect({
|
|
@@ -44,9 +44,9 @@ export default (({
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
} else {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
handleNotifications =
|
|
47
|
+
const renderedPropositionsDeferred = defer();
|
|
48
|
+
renderedPropositions.concat(renderedPropositionsDeferred.promise);
|
|
49
|
+
handleNotifications = renderedPropositionsDeferred.resolve;
|
|
50
50
|
}
|
|
51
51
|
onResponse(({
|
|
52
52
|
response
|
|
@@ -40,11 +40,11 @@ export default (({
|
|
|
40
40
|
isRenderDecisions() {
|
|
41
41
|
return renderDecisions;
|
|
42
42
|
},
|
|
43
|
-
|
|
44
|
-
return !!personalization.
|
|
43
|
+
isSendDisplayEvent() {
|
|
44
|
+
return !!personalization.sendDisplayEvent;
|
|
45
45
|
},
|
|
46
|
-
|
|
47
|
-
return !!personalization.
|
|
46
|
+
shouldIncludeRenderedPropositions() {
|
|
47
|
+
return !!personalization.includeRenderedPropositions;
|
|
48
48
|
},
|
|
49
49
|
getViewName() {
|
|
50
50
|
return viewName;
|
|
@@ -64,7 +64,7 @@ export default (({
|
|
|
64
64
|
scopes.push(...personalization.decisionScopes);
|
|
65
65
|
}
|
|
66
66
|
const eventSurfaces = normalizeSurfaces(personalization.surfaces, getPageLocation, logger);
|
|
67
|
-
if (!this.isCacheInitialized()) {
|
|
67
|
+
if (!this.isCacheInitialized() || personalization.requestPersonalization) {
|
|
68
68
|
addPageWideScope(scopes);
|
|
69
69
|
addPageSurface(eventSurfaces, getPageLocation);
|
|
70
70
|
}
|
|
@@ -82,7 +82,7 @@ export default (({
|
|
|
82
82
|
return isCacheInitialized;
|
|
83
83
|
},
|
|
84
84
|
shouldFetchData() {
|
|
85
|
-
return this.hasScopes() || this.hasSurfaces() || !this.isCacheInitialized();
|
|
85
|
+
return this.hasScopes() || this.hasSurfaces() || personalization.requestPersonalization || !this.isCacheInitialized() && personalization.requestPersonalization !== false;
|
|
86
86
|
},
|
|
87
87
|
shouldUseCachedData() {
|
|
88
88
|
return this.hasViewName() && this.isCacheInitialized();
|
|
@@ -10,17 +10,16 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { groupBy } from "../../utils";
|
|
14
14
|
import defer from "../../utils/defer";
|
|
15
15
|
import { DEFAULT_CONTENT_ITEM } from "./constants/schema";
|
|
16
16
|
export default (({
|
|
17
17
|
createProposition
|
|
18
18
|
}) => {
|
|
19
|
-
const viewStorage = {};
|
|
20
19
|
let cacheUpdateCreatedAtLeastOnce = false;
|
|
21
|
-
let
|
|
22
|
-
const getViewPropositions = (
|
|
23
|
-
const viewPropositions =
|
|
20
|
+
let viewStoragePromise = Promise.resolve({});
|
|
21
|
+
const getViewPropositions = (viewStorage, viewName) => {
|
|
22
|
+
const viewPropositions = viewStorage[viewName.toLowerCase()];
|
|
24
23
|
if (viewPropositions && viewPropositions.length > 0) {
|
|
25
24
|
return viewPropositions;
|
|
26
25
|
}
|
|
@@ -42,9 +41,7 @@ export default (({
|
|
|
42
41
|
const createCacheUpdate = viewName => {
|
|
43
42
|
const updateCacheDeferred = defer();
|
|
44
43
|
cacheUpdateCreatedAtLeastOnce = true;
|
|
45
|
-
|
|
46
|
-
assign(viewStorage, newViewStorage);
|
|
47
|
-
}).catch(() => {});
|
|
44
|
+
viewStoragePromise = viewStoragePromise.then(oldViewStorage => updateCacheDeferred.promise.catch(() => oldViewStorage));
|
|
48
45
|
return {
|
|
49
46
|
update(viewPropositions) {
|
|
50
47
|
const viewPropositionsWithScope = viewPropositions.filter(proposition => proposition.getScope());
|
|
@@ -61,7 +58,7 @@ export default (({
|
|
|
61
58
|
};
|
|
62
59
|
};
|
|
63
60
|
const getView = viewName => {
|
|
64
|
-
return
|
|
61
|
+
return viewStoragePromise.then(viewStorage => getViewPropositions(viewStorage, viewName));
|
|
65
62
|
};
|
|
66
63
|
const isInitialized = () => {
|
|
67
64
|
return cacheUpdateCreatedAtLeastOnce;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2019 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default (window => url => window.location.replace(url));
|
|
@@ -14,11 +14,6 @@ const EVENT_TYPE_TRUE = 1;
|
|
|
14
14
|
|
|
15
15
|
/* eslint-disable no-underscore-dangle */
|
|
16
16
|
export const mergeDecisionsMeta = (event, decisionsMeta, eventType, eventLabel = "") => {
|
|
17
|
-
// Do not send a display notification with no decisions. Even empty view changes
|
|
18
|
-
// should include a proposition.
|
|
19
|
-
if (decisionsMeta.length === 0) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
17
|
const xdm = {
|
|
23
18
|
_experience: {
|
|
24
19
|
decisioning: {
|
|
@@ -23,7 +23,8 @@ export default (({
|
|
|
23
23
|
}
|
|
24
24
|
const render = () => {
|
|
25
25
|
return collect({
|
|
26
|
-
decisionsMeta: [item.getMeta()]
|
|
26
|
+
decisionsMeta: [item.getMeta()],
|
|
27
|
+
documentMayUnload: true
|
|
27
28
|
}).then(() => {
|
|
28
29
|
executeRedirect(content);
|
|
29
30
|
// We've already sent the display notification, so don't return anything
|
|
@@ -38,6 +38,7 @@ import createProcessDomAction from "./handlers/createProcessDomAction";
|
|
|
38
38
|
import createProcessHtmlContent from "./handlers/createProcessHtmlContent";
|
|
39
39
|
import createProcessRedirect from "./handlers/createProcessRedirect";
|
|
40
40
|
import createProcessPropositions from "./handlers/createProcessPropositions";
|
|
41
|
+
import createRedirect from "./dom-actions/createRedirect";
|
|
41
42
|
const createPersonalization = ({
|
|
42
43
|
config,
|
|
43
44
|
logger,
|
|
@@ -68,6 +69,7 @@ const createPersonalization = ({
|
|
|
68
69
|
const viewCache = createViewCacheManager({
|
|
69
70
|
createProposition
|
|
70
71
|
});
|
|
72
|
+
const executeRedirect = createRedirect(window);
|
|
71
73
|
const schemaProcessors = {
|
|
72
74
|
[schema.DEFAULT_CONTENT_ITEM]: processDefaultContent,
|
|
73
75
|
[schema.DOM_ACTION]: createProcessDomAction({
|
|
@@ -81,7 +83,7 @@ const createPersonalization = ({
|
|
|
81
83
|
}),
|
|
82
84
|
[schema.REDIRECT_ITEM]: createProcessRedirect({
|
|
83
85
|
logger,
|
|
84
|
-
executeRedirect
|
|
86
|
+
executeRedirect,
|
|
85
87
|
collect
|
|
86
88
|
})
|
|
87
89
|
};
|
|
@@ -89,7 +91,7 @@ const createPersonalization = ({
|
|
|
89
91
|
schemaProcessors,
|
|
90
92
|
logger
|
|
91
93
|
});
|
|
92
|
-
const
|
|
94
|
+
const renderedPropositions = createAsyncArray();
|
|
93
95
|
const fetchDataHandler = createFetchDataHandler({
|
|
94
96
|
prehidingStyle,
|
|
95
97
|
showContainers,
|
|
@@ -98,7 +100,7 @@ const createPersonalization = ({
|
|
|
98
100
|
collect,
|
|
99
101
|
processPropositions,
|
|
100
102
|
createProposition,
|
|
101
|
-
|
|
103
|
+
renderedPropositions
|
|
102
104
|
});
|
|
103
105
|
const onClickHandler = createOnClickHandler({
|
|
104
106
|
mergeDecisionsMeta,
|
|
@@ -113,7 +115,7 @@ const createPersonalization = ({
|
|
|
113
115
|
const applyPropositions = createApplyPropositions({
|
|
114
116
|
processPropositions,
|
|
115
117
|
createProposition,
|
|
116
|
-
|
|
118
|
+
renderedPropositions,
|
|
117
119
|
viewCache
|
|
118
120
|
});
|
|
119
121
|
const setTargetMigration = createSetTargetMigration({
|
|
@@ -132,7 +134,7 @@ const createPersonalization = ({
|
|
|
132
134
|
applyPropositions,
|
|
133
135
|
setTargetMigration,
|
|
134
136
|
mergeDecisionsMeta,
|
|
135
|
-
|
|
137
|
+
renderedPropositions
|
|
136
138
|
});
|
|
137
139
|
};
|
|
138
140
|
createPersonalization.namespace = "Personalization";
|
|
@@ -120,7 +120,7 @@ export default (() => {
|
|
|
120
120
|
return shouldSendEvent;
|
|
121
121
|
},
|
|
122
122
|
getViewName() {
|
|
123
|
-
if (!userXdm || !userXdm.web || !userXdm.web.webPageDetails
|
|
123
|
+
if (!userXdm || !userXdm.web || !userXdm.web.webPageDetails) {
|
|
124
124
|
return undefined;
|
|
125
125
|
}
|
|
126
126
|
return userXdm.web.webPageDetails.viewName;
|
|
@@ -32,19 +32,13 @@ export default (({
|
|
|
32
32
|
return {
|
|
33
33
|
createEvent,
|
|
34
34
|
/**
|
|
35
|
-
* Sends an event. This includes running the event and payload through
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param {Object} event This will be JSON stringified and used inside
|
|
39
|
-
*
|
|
40
|
-
* @param {Object} [options]
|
|
41
|
-
*
|
|
42
|
-
* @param {Array} [options.decisionScopes] Note: this option will soon
|
|
43
|
-
* be deprecated, please use *personalization.decisionScopes* instead
|
|
44
|
-
* @param {Object} [options.personalization]
|
|
45
|
-
* @param {Object} [options.serverState]
|
|
46
|
-
* This will be passed to components
|
|
47
|
-
* so they can take appropriate action.
|
|
35
|
+
* Sends an event. This includes running the event and payload through the
|
|
36
|
+
* appropriate lifecycle hooks, sending the request to the server, and
|
|
37
|
+
* handling the response.
|
|
38
|
+
* @param {Object} event This will be JSON stringified and used inside the
|
|
39
|
+
* request payload.
|
|
40
|
+
* @param {Object} [options] Options to pass on to the onBeforeEvent
|
|
41
|
+
* lifecycle method
|
|
48
42
|
* @param {Object} [options.edgeConfigOverrides] Settings that take
|
|
49
43
|
* precedence over the global datastream configuration, including which
|
|
50
44
|
* datastream to use.
|
|
@@ -52,10 +46,8 @@ export default (({
|
|
|
52
46
|
*/
|
|
53
47
|
sendEvent(event, options = {}) {
|
|
54
48
|
const {
|
|
55
|
-
renderDecisions = false,
|
|
56
|
-
decisionScopes,
|
|
57
49
|
edgeConfigOverrides: localConfigOverrides,
|
|
58
|
-
|
|
50
|
+
...otherOptions
|
|
59
51
|
} = options;
|
|
60
52
|
const requestParams = createRequestParams({
|
|
61
53
|
payload: createDataCollectionRequestPayload(),
|
|
@@ -66,10 +58,8 @@ export default (({
|
|
|
66
58
|
const onResponseCallbackAggregator = createCallbackAggregator();
|
|
67
59
|
const onRequestFailureCallbackAggregator = createCallbackAggregator();
|
|
68
60
|
return lifecycle.onBeforeEvent({
|
|
61
|
+
...otherOptions,
|
|
69
62
|
event,
|
|
70
|
-
renderDecisions,
|
|
71
|
-
decisionScopes,
|
|
72
|
-
personalization,
|
|
73
63
|
onResponse: onResponseCallbackAggregator.add,
|
|
74
64
|
onRequestFailure: onRequestFailureCallbackAggregator.add
|
|
75
65
|
}).then(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.19.0-beta.
|
|
3
|
+
"version": "2.19.0-beta.8",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"main": "libEs5/index.js",
|
|
6
6
|
"module": "libEs6/index.js",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"uuid": "^3.3.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@adobe/alloy": "^2.19.0-beta.
|
|
69
|
+
"@adobe/alloy": "^2.19.0-beta.7",
|
|
70
70
|
"@babel/cli": "^7.12.8",
|
|
71
71
|
"@babel/core": "^7.2.2",
|
|
72
72
|
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"eslint-config-airbnb-base": "^14.0.0",
|
|
85
85
|
"eslint-config-prettier": "^6.4.0",
|
|
86
86
|
"eslint-plugin-ban": "^1.5.2",
|
|
87
|
-
"eslint-plugin-import": "^2.
|
|
87
|
+
"eslint-plugin-import": "^2.28.1",
|
|
88
88
|
"eslint-plugin-prettier": "^3.0.1",
|
|
89
89
|
"eslint-plugin-testcafe": "^0.2.1",
|
|
90
90
|
"glob": "^7.1.3",
|