@adobe/alloy 2.19.0-beta.7 → 2.19.0-beta.9
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/constants/scopeType.js +6 -2
- package/libEs5/components/Personalization/createApplyPropositions.js +4 -4
- package/libEs5/components/Personalization/createClickStorage.js +21 -13
- package/libEs5/components/Personalization/createComponent.js +3 -3
- package/libEs5/components/Personalization/createFetchDataHandler.js +5 -5
- package/libEs5/components/Personalization/createOnClickHandler.js +4 -5
- package/libEs5/components/Personalization/createPersonalizationDetails.js +6 -6
- package/libEs5/components/Personalization/createViewCacheManager.js +11 -11
- package/libEs5/components/Personalization/dom-actions/clicks/collectClicks.js +43 -23
- package/libEs5/components/Personalization/handlers/createProcessDomAction.js +7 -1
- package/libEs5/components/Personalization/handlers/createProcessRedirect.js +1 -1
- package/libEs5/components/Personalization/handlers/injectCreateProposition.js +13 -15
- package/libEs5/components/Personalization/index.js +4 -4
- package/libEs5/constants/libraryVersion.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/constants/scopeType.js +3 -1
- package/libEs6/components/Personalization/createApplyPropositions.js +4 -4
- package/libEs6/components/Personalization/createClickStorage.js +18 -10
- package/libEs6/components/Personalization/createComponent.js +3 -3
- package/libEs6/components/Personalization/createFetchDataHandler.js +5 -5
- package/libEs6/components/Personalization/createOnClickHandler.js +5 -6
- package/libEs6/components/Personalization/createPersonalizationDetails.js +6 -6
- package/libEs6/components/Personalization/createViewCacheManager.js +8 -10
- package/libEs6/components/Personalization/dom-actions/clicks/collectClicks.js +28 -12
- package/libEs6/components/Personalization/handlers/createProcessDomAction.js +5 -1
- package/libEs6/components/Personalization/handlers/createProcessRedirect.js +1 -1
- package/libEs6/components/Personalization/handlers/injectCreateProposition.js +12 -15
- package/libEs6/components/Personalization/index.js +4 -4
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/createEventManager.js +9 -19
- package/package.json +3 -3
- package/libEs5/components/Personalization/utils/isPageWideScope.js +0 -20
- package/libEs6/components/Personalization/utils/isPageWideScope.js +0 -15
|
@@ -85,7 +85,7 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
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.9";
|
|
18
18
|
exports.default = _default;
|
|
@@ -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
|
});
|
|
@@ -10,4 +10,6 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export const VIEW_SCOPE_TYPE = "view";
|
|
13
|
+
export const VIEW_SCOPE_TYPE = "view";
|
|
14
|
+
export const PAGE_SCOPE_TYPE = "page";
|
|
15
|
+
export const PROPOSITION_SCOPE_TYPE = "proposition";
|
|
@@ -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
|
};
|
|
@@ -14,22 +14,30 @@ const metasToArray = metas => {
|
|
|
14
14
|
return Object.keys(metas).map(key => {
|
|
15
15
|
return {
|
|
16
16
|
id: key,
|
|
17
|
-
|
|
18
|
-
scopeDetails: metas[key].scopeDetails,
|
|
19
|
-
trackingLabel: metas[key].trackingLabel
|
|
17
|
+
...metas[key]
|
|
20
18
|
};
|
|
21
19
|
});
|
|
22
20
|
};
|
|
23
21
|
export default (() => {
|
|
24
22
|
const clickStorage = {};
|
|
25
|
-
const storeClickMetrics =
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const storeClickMetrics = ({
|
|
24
|
+
selector,
|
|
25
|
+
meta: {
|
|
26
|
+
id,
|
|
27
|
+
scope,
|
|
28
|
+
scopeDetails,
|
|
29
|
+
trackingLabel,
|
|
30
|
+
scopeType
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
}) => {
|
|
33
|
+
if (!clickStorage[selector]) {
|
|
34
|
+
clickStorage[selector] = {};
|
|
35
|
+
}
|
|
36
|
+
clickStorage[selector][id] = {
|
|
37
|
+
scope,
|
|
38
|
+
scopeDetails,
|
|
39
|
+
trackingLabel,
|
|
40
|
+
scopeType
|
|
33
41
|
};
|
|
34
42
|
};
|
|
35
43
|
const getClickSelectors = () => {
|
|
@@ -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());
|
|
@@ -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
|
|
@@ -10,10 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { isNonEmptyArray
|
|
13
|
+
import { isNonEmptyArray } from "../../utils";
|
|
14
14
|
import { INTERACT } from "./constants/eventType";
|
|
15
15
|
import { PropositionEventType } from "./constants/propositionEventType";
|
|
16
|
-
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
|
|
17
16
|
export default (({
|
|
18
17
|
mergeDecisionsMeta,
|
|
19
18
|
collectClicks,
|
|
@@ -29,17 +28,17 @@ export default (({
|
|
|
29
28
|
if (isNonEmptyArray(selectors)) {
|
|
30
29
|
const {
|
|
31
30
|
decisionsMeta,
|
|
32
|
-
eventLabel
|
|
31
|
+
eventLabel,
|
|
32
|
+
viewName
|
|
33
33
|
} = collectClicks(clickedElement, selectors, getClickMetasBySelector);
|
|
34
34
|
if (isNonEmptyArray(decisionsMeta)) {
|
|
35
35
|
const xdm = {
|
|
36
36
|
eventType: INTERACT
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
if (isNonEmptyString(scope) && scope !== PAGE_WIDE_SCOPE) {
|
|
38
|
+
if (viewName) {
|
|
40
39
|
xdm.web = {
|
|
41
40
|
webPageDetails: {
|
|
42
|
-
viewName
|
|
41
|
+
viewName
|
|
43
42
|
}
|
|
44
43
|
};
|
|
45
44
|
}
|
|
@@ -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,17 @@ 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
|
+
import { VIEW_SCOPE_TYPE } from "./constants/scopeType";
|
|
16
17
|
export default (({
|
|
17
18
|
createProposition
|
|
18
19
|
}) => {
|
|
19
|
-
const viewStorage = {};
|
|
20
20
|
let cacheUpdateCreatedAtLeastOnce = false;
|
|
21
|
-
let
|
|
22
|
-
const getViewPropositions = (
|
|
23
|
-
const viewPropositions =
|
|
21
|
+
let viewStoragePromise = Promise.resolve({});
|
|
22
|
+
const getViewPropositions = (viewStorage, viewName) => {
|
|
23
|
+
const viewPropositions = viewStorage[viewName.toLowerCase()];
|
|
24
24
|
if (viewPropositions && viewPropositions.length > 0) {
|
|
25
25
|
return viewPropositions;
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ export default (({
|
|
|
28
28
|
scope: viewName,
|
|
29
29
|
scopeDetails: {
|
|
30
30
|
characteristics: {
|
|
31
|
-
scopeType:
|
|
31
|
+
scopeType: VIEW_SCOPE_TYPE
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
items: [{
|
|
@@ -42,9 +42,7 @@ export default (({
|
|
|
42
42
|
const createCacheUpdate = viewName => {
|
|
43
43
|
const updateCacheDeferred = defer();
|
|
44
44
|
cacheUpdateCreatedAtLeastOnce = true;
|
|
45
|
-
|
|
46
|
-
assign(viewStorage, newViewStorage);
|
|
47
|
-
}).catch(() => {});
|
|
45
|
+
viewStoragePromise = viewStoragePromise.then(oldViewStorage => updateCacheDeferred.promise.catch(() => oldViewStorage));
|
|
48
46
|
return {
|
|
49
47
|
update(viewPropositions) {
|
|
50
48
|
const viewPropositionsWithScope = viewPropositions.filter(proposition => proposition.getScope());
|
|
@@ -61,7 +59,7 @@ export default (({
|
|
|
61
59
|
};
|
|
62
60
|
};
|
|
63
61
|
const getView = viewName => {
|
|
64
|
-
return
|
|
62
|
+
return viewStoragePromise.then(viewStorage => getViewPropositions(viewStorage, viewName));
|
|
65
63
|
};
|
|
66
64
|
const isInitialized = () => {
|
|
67
65
|
return cacheUpdateCreatedAtLeastOnce;
|
|
@@ -11,6 +11,7 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import matchesSelectorWithEq from "../dom/matchesSelectorWithEq";
|
|
14
|
+
import { VIEW_SCOPE_TYPE } from "../../constants/scopeType";
|
|
14
15
|
const getMetasIfMatches = (clickedElement, selector, getClickMetasBySelector) => {
|
|
15
16
|
const {
|
|
16
17
|
documentElement
|
|
@@ -20,17 +21,20 @@ const getMetasIfMatches = (clickedElement, selector, getClickMetasBySelector) =>
|
|
|
20
21
|
while (element && element !== documentElement) {
|
|
21
22
|
if (matchesSelectorWithEq(selector, element)) {
|
|
22
23
|
const matchedMetas = getClickMetasBySelector(selector);
|
|
24
|
+
const returnValue = {
|
|
25
|
+
metas: matchedMetas
|
|
26
|
+
};
|
|
23
27
|
const foundMetaWithLabel = matchedMetas.find(meta => meta.trackingLabel);
|
|
24
28
|
if (foundMetaWithLabel) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
label: foundMetaWithLabel.trackingLabel,
|
|
28
|
-
weight: i
|
|
29
|
-
};
|
|
29
|
+
returnValue.label = foundMetaWithLabel.trackingLabel;
|
|
30
|
+
returnValue.weight = i;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const foundMetaWithScopeTypeView = matchedMetas.find(meta => meta.scopeType === VIEW_SCOPE_TYPE);
|
|
33
|
+
if (foundMetaWithScopeTypeView) {
|
|
34
|
+
returnValue.viewName = foundMetaWithScopeTypeView.scope;
|
|
35
|
+
returnValue.weight = i;
|
|
36
|
+
}
|
|
37
|
+
return returnValue;
|
|
34
38
|
}
|
|
35
39
|
element = element.parentNode;
|
|
36
40
|
i += 1;
|
|
@@ -40,8 +44,12 @@ const getMetasIfMatches = (clickedElement, selector, getClickMetasBySelector) =>
|
|
|
40
44
|
};
|
|
41
45
|
};
|
|
42
46
|
const cleanMetas = metas => metas.map(meta => {
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
const {
|
|
48
|
+
trackingLabel,
|
|
49
|
+
scopeType,
|
|
50
|
+
...rest
|
|
51
|
+
} = meta;
|
|
52
|
+
return rest;
|
|
45
53
|
});
|
|
46
54
|
const dedupMetas = metas => metas.filter((meta, index) => {
|
|
47
55
|
const stringifiedMeta = JSON.stringify(meta);
|
|
@@ -51,13 +59,16 @@ export default ((clickedElement, selectors, getClickMetasBySelector) => {
|
|
|
51
59
|
const result = [];
|
|
52
60
|
let resultLabel = "";
|
|
53
61
|
let resultLabelWeight = Number.MAX_SAFE_INTEGER;
|
|
62
|
+
let resultViewName;
|
|
63
|
+
let resultViewNameWeight = Number.MAX_SAFE_INTEGER;
|
|
54
64
|
|
|
55
65
|
/* eslint-disable no-continue */
|
|
56
66
|
for (let i = 0; i < selectors.length; i += 1) {
|
|
57
67
|
const {
|
|
58
68
|
metas,
|
|
59
69
|
label,
|
|
60
|
-
weight
|
|
70
|
+
weight,
|
|
71
|
+
viewName
|
|
61
72
|
} = getMetasIfMatches(clickedElement, selectors[i], getClickMetasBySelector);
|
|
62
73
|
if (!metas) {
|
|
63
74
|
continue;
|
|
@@ -66,10 +77,15 @@ export default ((clickedElement, selectors, getClickMetasBySelector) => {
|
|
|
66
77
|
resultLabel = label;
|
|
67
78
|
resultLabelWeight = weight;
|
|
68
79
|
}
|
|
80
|
+
if (viewName && weight <= resultViewNameWeight) {
|
|
81
|
+
resultViewName = viewName;
|
|
82
|
+
resultViewNameWeight = weight;
|
|
83
|
+
}
|
|
69
84
|
result.push(...cleanMetas(metas));
|
|
70
85
|
}
|
|
71
86
|
return {
|
|
72
87
|
decisionsMeta: dedupMetas(result),
|
|
73
|
-
eventLabel: resultLabel
|
|
88
|
+
eventLabel: resultLabel,
|
|
89
|
+
viewName: resultViewName
|
|
74
90
|
};
|
|
75
91
|
});
|
|
@@ -35,7 +35,11 @@ export default (({
|
|
|
35
35
|
}
|
|
36
36
|
storeClickMetrics({
|
|
37
37
|
selector,
|
|
38
|
-
meta:
|
|
38
|
+
meta: {
|
|
39
|
+
...item.getProposition().getNotification(),
|
|
40
|
+
trackingLabel: item.getTrackingLabel(),
|
|
41
|
+
scopeType: item.getProposition().getScopeType()
|
|
42
|
+
}
|
|
39
43
|
});
|
|
40
44
|
return {
|
|
41
45
|
setRenderAttempted: true,
|
|
@@ -11,11 +11,12 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import PAGE_WIDE_SCOPE from "../../../constants/pageWideScope";
|
|
14
|
+
import { VIEW_SCOPE_TYPE, PAGE_SCOPE_TYPE, PROPOSITION_SCOPE_TYPE } from "../constants/scopeType";
|
|
14
15
|
export default (({
|
|
15
16
|
preprocess,
|
|
16
17
|
isPageWideSurface
|
|
17
18
|
}) => {
|
|
18
|
-
const createItem = (item,
|
|
19
|
+
const createItem = (item, proposition) => {
|
|
19
20
|
const {
|
|
20
21
|
schema,
|
|
21
22
|
data,
|
|
@@ -24,9 +25,6 @@ export default (({
|
|
|
24
25
|
} = {}
|
|
25
26
|
} = item;
|
|
26
27
|
const processedData = preprocess(data);
|
|
27
|
-
if (trackingLabel) {
|
|
28
|
-
meta.trackingLabel = trackingLabel;
|
|
29
|
-
}
|
|
30
28
|
return {
|
|
31
29
|
getSchema() {
|
|
32
30
|
return schema;
|
|
@@ -34,8 +32,11 @@ export default (({
|
|
|
34
32
|
getData() {
|
|
35
33
|
return processedData;
|
|
36
34
|
},
|
|
37
|
-
|
|
38
|
-
return
|
|
35
|
+
getProposition() {
|
|
36
|
+
return proposition;
|
|
37
|
+
},
|
|
38
|
+
getTrackingLabel() {
|
|
39
|
+
return trackingLabel;
|
|
39
40
|
},
|
|
40
41
|
getOriginalItem() {
|
|
41
42
|
return item;
|
|
@@ -69,19 +70,15 @@ export default (({
|
|
|
69
70
|
},
|
|
70
71
|
getScopeType() {
|
|
71
72
|
if (scope === PAGE_WIDE_SCOPE || isPageWideSurface(scope)) {
|
|
72
|
-
return
|
|
73
|
+
return PAGE_SCOPE_TYPE;
|
|
73
74
|
}
|
|
74
|
-
if (scopeType ===
|
|
75
|
-
return
|
|
75
|
+
if (scopeType === VIEW_SCOPE_TYPE) {
|
|
76
|
+
return VIEW_SCOPE_TYPE;
|
|
76
77
|
}
|
|
77
|
-
return
|
|
78
|
+
return PROPOSITION_SCOPE_TYPE;
|
|
78
79
|
},
|
|
79
80
|
getItems() {
|
|
80
|
-
return items.map(item => createItem(item,
|
|
81
|
-
id,
|
|
82
|
-
scope,
|
|
83
|
-
scopeDetails
|
|
84
|
-
}));
|
|
81
|
+
return items.map(item => createItem(item, this));
|
|
85
82
|
},
|
|
86
83
|
getNotification() {
|
|
87
84
|
return {
|