@adobe/alloy 2.20.0 → 2.21.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/Personalization/createApplyPropositions.js +27 -10
- package/libEs5/components/Personalization/createClickStorage.js +4 -4
- package/libEs5/components/Personalization/createInteractionStorage.js +102 -0
- package/libEs5/components/Personalization/createOnClickHandler.js +49 -21
- package/libEs5/components/Personalization/dom-actions/action.js +4 -4
- package/libEs5/components/Personalization/dom-actions/appendHtml.js +2 -1
- package/libEs5/components/Personalization/dom-actions/clicks/collectClicks.js +15 -33
- package/libEs5/components/Personalization/dom-actions/clicks/collectInteractions.js +81 -0
- package/libEs5/components/Personalization/dom-actions/collectInteractions.js +17 -0
- package/libEs5/components/Personalization/dom-actions/dom/isDomElement.js +17 -0
- package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +36 -19
- package/libEs5/components/Personalization/dom-actions/insertHtmlAfter.js +5 -2
- package/libEs5/components/Personalization/dom-actions/insertHtmlBefore.js +2 -1
- package/libEs5/components/Personalization/dom-actions/prependHtml.js +2 -1
- package/libEs5/components/Personalization/dom-actions/rearrangeChildren.js +3 -1
- package/libEs5/components/Personalization/dom-actions/remapCustomCodeOffers.js +2 -2
- package/libEs5/components/Personalization/dom-actions/remapHeadOffers.js +2 -2
- package/libEs5/components/Personalization/dom-actions/replaceHtml.js +4 -3
- package/libEs5/components/Personalization/dom-actions/setAttributes.js +2 -1
- package/libEs5/components/Personalization/dom-actions/setHtml.js +2 -2
- package/libEs5/components/Personalization/dom-actions/setStyles.js +2 -1
- package/libEs5/components/Personalization/dom-actions/setText.js +2 -1
- package/libEs5/components/Personalization/dom-actions/swapImage.js +2 -1
- package/libEs5/components/Personalization/handlers/createDecorateProposition.js +60 -0
- package/libEs5/components/Personalization/handlers/createProcessDomAction.js +10 -6
- package/libEs5/components/Personalization/handlers/createProcessHtmlContent.js +6 -2
- package/libEs5/components/Personalization/handlers/createProcessPropositions.js +1 -1
- package/libEs5/components/Personalization/handlers/injectCreateProposition.js +12 -1
- package/libEs5/components/Personalization/index.js +26 -7
- package/libEs5/components/Personalization/utils/metaUtils.js +33 -0
- package/libEs5/components/Personalization/validateApplyPropositionsOptions.js +12 -1
- package/libEs5/constants/decisionProvider.js +3 -2
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/constants/propositionInteractionType.js +18 -0
- package/libEs5/utils/dom/awaitSelector.js +5 -1
- package/libEs6/components/Personalization/createApplyPropositions.js +25 -10
- package/libEs6/components/Personalization/createClickStorage.js +4 -4
- package/libEs6/components/Personalization/createInteractionStorage.js +85 -0
- package/libEs6/components/Personalization/createOnClickHandler.js +49 -22
- package/libEs6/components/Personalization/dom-actions/action.js +4 -4
- package/libEs6/components/Personalization/dom-actions/appendHtml.js +3 -2
- package/libEs6/components/Personalization/dom-actions/clicks/collectClicks.js +8 -18
- package/libEs6/components/Personalization/dom-actions/clicks/collectInteractions.js +74 -0
- package/libEs6/components/Personalization/dom-actions/collectInteractions.js +15 -0
- package/libEs6/components/Personalization/dom-actions/dom/isDomElement.js +12 -0
- package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +46 -16
- package/libEs6/components/Personalization/dom-actions/insertHtmlAfter.js +5 -2
- package/libEs6/components/Personalization/dom-actions/insertHtmlBefore.js +3 -2
- package/libEs6/components/Personalization/dom-actions/prependHtml.js +3 -2
- package/libEs6/components/Personalization/dom-actions/rearrangeChildren.js +3 -1
- package/libEs6/components/Personalization/dom-actions/remapCustomCodeOffers.js +2 -2
- package/libEs6/components/Personalization/dom-actions/remapHeadOffers.js +2 -2
- package/libEs6/components/Personalization/dom-actions/replaceHtml.js +4 -3
- package/libEs6/components/Personalization/dom-actions/setAttributes.js +2 -1
- package/libEs6/components/Personalization/dom-actions/setHtml.js +2 -2
- package/libEs6/components/Personalization/dom-actions/setStyles.js +2 -1
- package/libEs6/components/Personalization/dom-actions/setText.js +2 -1
- package/libEs6/components/Personalization/dom-actions/swapImage.js +3 -2
- package/libEs6/components/Personalization/handlers/createDecorateProposition.js +59 -0
- package/libEs6/components/Personalization/handlers/createProcessDomAction.js +10 -4
- package/libEs6/components/Personalization/handlers/createProcessHtmlContent.js +6 -2
- package/libEs6/components/Personalization/handlers/createProcessPropositions.js +1 -1
- package/libEs6/components/Personalization/handlers/injectCreateProposition.js +12 -1
- package/libEs6/components/Personalization/index.js +32 -8
- package/libEs6/components/Personalization/utils/metaUtils.js +23 -0
- package/libEs6/components/Personalization/validateApplyPropositionsOptions.js +12 -1
- package/libEs6/constants/decisionProvider.js +2 -1
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/constants/propositionInteractionType.js +15 -0
- package/libEs6/utils/dom/awaitSelector.js +5 -1
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
16
16
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
17
|
governing permissions and limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
var _default = exports.default = function _default(container, html) {
|
|
19
|
+
var _default = exports.default = function _default(container, html, decorateProposition) {
|
|
20
20
|
var fragment = (0, _index.createFragment)(html);
|
|
21
21
|
(0, _addNonceToInlineStyleElements.default)(fragment);
|
|
22
22
|
var elements = (0, _index.getChildNodes)(fragment);
|
|
@@ -24,6 +24,7 @@ var _default = exports.default = function _default(container, html) {
|
|
|
24
24
|
var scriptsUrls = (0, _scripts.getRemoteScriptsUrls)(fragment);
|
|
25
25
|
(0, _images.loadImages)(fragment);
|
|
26
26
|
elements.forEach(function (element) {
|
|
27
|
+
decorateProposition(element);
|
|
27
28
|
(0, _index.insertBefore)(container, element);
|
|
28
29
|
});
|
|
29
30
|
(0, _scripts.executeInlineScripts)(container, scripts);
|
|
@@ -17,7 +17,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
17
17
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
|
-
var _default = exports.default = function _default(container, html) {
|
|
20
|
+
var _default = exports.default = function _default(container, html, decorateProposition) {
|
|
21
21
|
var fragment = (0, _index2.createFragment)(html);
|
|
22
22
|
(0, _addNonceToInlineStyleElements.default)(fragment);
|
|
23
23
|
var elements = (0, _index2.getChildNodes)(fragment);
|
|
@@ -32,6 +32,7 @@ var _default = exports.default = function _default(container, html) {
|
|
|
32
32
|
// We are inserting elements in reverse order
|
|
33
33
|
while (i >= 0) {
|
|
34
34
|
var element = elements[i];
|
|
35
|
+
decorateProposition(element);
|
|
35
36
|
var firstChild = (0, _index2.getFirstChild)(container);
|
|
36
37
|
if (firstChild) {
|
|
37
38
|
(0, _index2.insertBefore)(firstChild, element);
|
|
@@ -13,7 +13,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
13
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
var _default = exports.default = function _default(container, _ref) {
|
|
16
|
+
var _default = exports.default = function _default(container, _ref, decorateProposition) {
|
|
17
17
|
var from = _ref.from,
|
|
18
18
|
to = _ref.to;
|
|
19
19
|
var children = (0, _index.getChildren)(container);
|
|
@@ -29,4 +29,6 @@ var _default = exports.default = function _default(container, _ref) {
|
|
|
29
29
|
} else {
|
|
30
30
|
(0, _index.insertBefore)(elementTo, elementFrom);
|
|
31
31
|
}
|
|
32
|
+
decorateProposition(elementTo);
|
|
33
|
+
decorateProposition(elementFrom);
|
|
32
34
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
var _index = require("../../../utils/index.js");
|
|
5
|
+
var _initDomActionsModules = require("./initDomActionsModules.js");
|
|
5
6
|
/*
|
|
6
7
|
Copyright 2021 Adobe. All rights reserved.
|
|
7
8
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -19,12 +20,11 @@ governing permissions and limitations under the License.
|
|
|
19
20
|
* target offers, to align with the way it works in at.js.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
|
-
var ACTION_CUSTOM_CODE = "customCode";
|
|
23
23
|
var TARGET_BODY_SELECTOR = "BODY > *:eq(0)";
|
|
24
24
|
var _default = exports.default = function _default(action) {
|
|
25
25
|
var selector = action.selector,
|
|
26
26
|
type = action.type;
|
|
27
|
-
if (type !==
|
|
27
|
+
if (type !== _initDomActionsModules.DOM_ACTION_CUSTOM_CODE) {
|
|
28
28
|
return action;
|
|
29
29
|
}
|
|
30
30
|
if (selector !== TARGET_BODY_SELECTOR) {
|
|
@@ -7,6 +7,7 @@ var _index2 = require("./dom/index.js");
|
|
|
7
7
|
var _index3 = require("../../../utils/index.js");
|
|
8
8
|
var _isBlankString = require("../../../utils/isBlankString.js");
|
|
9
9
|
var _tagName = require("../../../constants/tagName.js");
|
|
10
|
+
var _initDomActionsModules = require("./initDomActionsModules.js");
|
|
10
11
|
/*
|
|
11
12
|
Copyright 2021 Adobe. All rights reserved.
|
|
12
13
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -25,7 +26,6 @@ governing permissions and limitations under the License.
|
|
|
25
26
|
* Offer content should also be filtered, so that only tags allowed in HEAD are preserved.
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
|
-
var APPEND_HTML = "appendHtml";
|
|
29
29
|
var HEAD_TAGS_SELECTOR = "SCRIPT,LINK,STYLE";
|
|
30
30
|
var filterHeadContent = function filterHeadContent(content) {
|
|
31
31
|
var container = (0, _index2.createFragment)(content);
|
|
@@ -48,7 +48,7 @@ var _default = exports.default = function _default(action) {
|
|
|
48
48
|
if (!(0, _scripts.is)(container[0], _tagName.HEAD)) {
|
|
49
49
|
return result;
|
|
50
50
|
}
|
|
51
|
-
result.type =
|
|
51
|
+
result.type = _initDomActionsModules.DOM_ACTION_APPEND_HTML;
|
|
52
52
|
result.content = filterHeadContent(content);
|
|
53
53
|
return result;
|
|
54
54
|
};
|
|
@@ -14,7 +14,8 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
14
14
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
15
|
governing permissions and limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var _default = exports.default = function _default(container, html) {
|
|
18
|
-
(0, _insertHtmlBefore.default)(container, html)
|
|
19
|
-
|
|
17
|
+
var _default = exports.default = function _default(container, html, decorateProposition) {
|
|
18
|
+
return (0, _insertHtmlBefore.default)(container, html, decorateProposition).then(function () {
|
|
19
|
+
(0, _index.removeNode)(container);
|
|
20
|
+
});
|
|
20
21
|
};
|
|
@@ -13,8 +13,9 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
13
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
var _default = exports.default = function _default(container, attributes) {
|
|
16
|
+
var _default = exports.default = function _default(container, attributes, decorateProposition) {
|
|
17
17
|
Object.keys(attributes).forEach(function (key) {
|
|
18
18
|
(0, _index.setAttribute)(container, key, attributes[key]);
|
|
19
19
|
});
|
|
20
|
+
decorateProposition(container);
|
|
20
21
|
};
|
|
@@ -21,7 +21,7 @@ var clear = function clear(container) {
|
|
|
21
21
|
var childNodes = (0, _index2.getChildNodes)(container);
|
|
22
22
|
childNodes.forEach(_index.removeNode);
|
|
23
23
|
};
|
|
24
|
-
var _default = exports.default = function _default(container, html) {
|
|
24
|
+
var _default = exports.default = function _default(container, html, decorateProposition) {
|
|
25
25
|
clear(container);
|
|
26
|
-
(0, _appendHtml.default)(container, html);
|
|
26
|
+
return (0, _appendHtml.default)(container, html, decorateProposition);
|
|
27
27
|
};
|
|
@@ -16,10 +16,11 @@ governing permissions and limitations under the License.
|
|
|
16
16
|
*/
|
|
17
17
|
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; }
|
|
18
18
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
19
|
-
var _default = exports.default = function _default(container, styles) {
|
|
19
|
+
var _default = exports.default = function _default(container, styles, decorateProposition) {
|
|
20
20
|
var priority = styles.priority,
|
|
21
21
|
style = _objectWithoutProperties(styles, _excluded);
|
|
22
22
|
Object.keys(style).forEach(function (key) {
|
|
23
23
|
(0, _index.setStyle)(container, key, style[key], priority);
|
|
24
24
|
});
|
|
25
|
+
decorateProposition(container);
|
|
25
26
|
};
|
|
@@ -12,6 +12,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
12
12
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
13
|
governing permissions and limitations under the License.
|
|
14
14
|
*/
|
|
15
|
-
var _default = exports.default = function _default(container, text) {
|
|
15
|
+
var _default = exports.default = function _default(container, text, decorateProposition) {
|
|
16
|
+
decorateProposition(container);
|
|
16
17
|
container.textContent = text;
|
|
17
18
|
};
|
|
@@ -15,13 +15,14 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
15
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
16
|
governing permissions and limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
var _default = exports.default = function _default(container, url) {
|
|
18
|
+
var _default = exports.default = function _default(container, url, decorateProposition) {
|
|
19
19
|
if (!(0, _images.isImage)(container)) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Start downloading the image
|
|
24
24
|
(0, _images.loadImage)(url);
|
|
25
|
+
decorateProposition(container);
|
|
25
26
|
|
|
26
27
|
// Remove "src" so there is no flicker
|
|
27
28
|
(0, _index.removeAttribute)(container, _elementAttribute.SRC);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = exports.INTERACT_ID_DATA_ATTRIBUTE = exports.CLICK_TOKEN_DATA_ATTRIBUTE = exports.CLICK_LABEL_DATA_ATTRIBUTE = void 0;
|
|
4
|
+
var _index = require("../dom-actions/dom/index.js");
|
|
5
|
+
var _index2 = require("../../../utils/index.js");
|
|
6
|
+
var _initDomActionsModules = require("../dom-actions/initDomActionsModules.js");
|
|
7
|
+
var _propositionInteractionType = require("../../../constants/propositionInteractionType.js");
|
|
8
|
+
/*
|
|
9
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
10
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
+
governing permissions and limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
var INTERACT_ID_DATA_ATTRIBUTE = exports.INTERACT_ID_DATA_ATTRIBUTE = "data-aep-interact-id";
|
|
21
|
+
var CLICK_LABEL_DATA_ATTRIBUTE = exports.CLICK_LABEL_DATA_ATTRIBUTE = "data-aep-click-label";
|
|
22
|
+
var CLICK_TOKEN_DATA_ATTRIBUTE = exports.CLICK_TOKEN_DATA_ATTRIBUTE = "data-aep-click-token";
|
|
23
|
+
var lastInteractId = 0;
|
|
24
|
+
var getInteractId = function getInteractId(propositionId, existingInteractId) {
|
|
25
|
+
if (existingInteractId) {
|
|
26
|
+
return parseInt(existingInteractId, 10);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line no-plusplus
|
|
30
|
+
return ++lastInteractId;
|
|
31
|
+
};
|
|
32
|
+
var interactionTrackingSupported = function interactionTrackingSupported(autoCollectPropositionInteractions, decisionProvider) {
|
|
33
|
+
if (!autoCollectPropositionInteractions) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (!autoCollectPropositionInteractions[decisionProvider]) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return (0, _index2.includes)([_propositionInteractionType.ALWAYS, _propositionInteractionType.DECORATED_ELEMENTS_ONLY], autoCollectPropositionInteractions[decisionProvider]);
|
|
40
|
+
};
|
|
41
|
+
var createDecorateProposition = function createDecorateProposition(autoCollectPropositionInteractions, type, propositionId, itemId, trackingLabel, scopeType, notification, storeInteractionMeta) {
|
|
42
|
+
var _notification$scopeDe = notification.scopeDetails,
|
|
43
|
+
scopeDetails = _notification$scopeDe === void 0 ? {} : _notification$scopeDe;
|
|
44
|
+
var decisionProvider = scopeDetails.decisionProvider;
|
|
45
|
+
if (!interactionTrackingSupported(autoCollectPropositionInteractions, decisionProvider) && type !== _initDomActionsModules.DOM_ACTION_CLICK) {
|
|
46
|
+
return _index2.noop;
|
|
47
|
+
}
|
|
48
|
+
return function (element) {
|
|
49
|
+
if (!element.tagName) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
var interactId = getInteractId(propositionId, (0, _index.getAttribute)(element, INTERACT_ID_DATA_ATTRIBUTE));
|
|
53
|
+
storeInteractionMeta(propositionId, itemId, scopeType, notification, interactId);
|
|
54
|
+
(0, _index.setAttribute)(element, INTERACT_ID_DATA_ATTRIBUTE, interactId);
|
|
55
|
+
if (trackingLabel && !(0, _index.getAttribute)(element, CLICK_LABEL_DATA_ATTRIBUTE)) {
|
|
56
|
+
(0, _index.setAttribute)(element, CLICK_LABEL_DATA_ATTRIBUTE, trackingLabel);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
var _default = exports.default = createDecorateProposition;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
|
+
var _createDecorateProposition = require("./createDecorateProposition.js");
|
|
5
|
+
var _initDomActionsModules = require("../dom-actions/initDomActionsModules.js");
|
|
4
6
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
9
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
-
/*
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
11
12
|
Copyright 2023 Adobe. All rights reserved.
|
|
12
13
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
14
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -21,7 +22,9 @@ governing permissions and limitations under the License.
|
|
|
21
22
|
var _default = exports.default = function _default(_ref) {
|
|
22
23
|
var modules = _ref.modules,
|
|
23
24
|
logger = _ref.logger,
|
|
24
|
-
|
|
25
|
+
storeInteractionMeta = _ref.storeInteractionMeta,
|
|
26
|
+
storeClickMeta = _ref.storeClickMeta,
|
|
27
|
+
autoCollectPropositionInteractions = _ref.autoCollectPropositionInteractions;
|
|
25
28
|
return function (item) {
|
|
26
29
|
var _ref2 = item.getData() || {},
|
|
27
30
|
type = _ref2.type,
|
|
@@ -33,7 +36,7 @@ var _default = exports.default = function _default(_ref) {
|
|
|
33
36
|
includeInNotification: false
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
|
-
if (type ===
|
|
39
|
+
if (type === _initDomActionsModules.DOM_ACTION_CLICK) {
|
|
37
40
|
if (!selector) {
|
|
38
41
|
logger.warn("Invalid DOM action data: missing selector.", item.getData());
|
|
39
42
|
return {
|
|
@@ -41,7 +44,7 @@ var _default = exports.default = function _default(_ref) {
|
|
|
41
44
|
includeInNotification: false
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
|
-
|
|
47
|
+
storeClickMeta({
|
|
45
48
|
selector: selector,
|
|
46
49
|
meta: _objectSpread(_objectSpread({}, item.getProposition().getNotification()), {}, {
|
|
47
50
|
trackingLabel: item.getTrackingLabel(),
|
|
@@ -60,9 +63,10 @@ var _default = exports.default = function _default(_ref) {
|
|
|
60
63
|
includeInNotification: false
|
|
61
64
|
};
|
|
62
65
|
}
|
|
66
|
+
var decorateProposition = (0, _createDecorateProposition.default)(autoCollectPropositionInteractions, type, item.getProposition().getId(), item.getId(), item.getTrackingLabel(), item.getProposition().getScopeType(), item.getProposition().getNotification(), storeInteractionMeta);
|
|
63
67
|
return {
|
|
64
68
|
render: function render() {
|
|
65
|
-
return modules[type](item.getData());
|
|
69
|
+
return modules[type](item.getData(), decorateProposition);
|
|
66
70
|
},
|
|
67
71
|
setRenderAttempted: true,
|
|
68
72
|
includeInNotification: true
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
|
+
var _createDecorateProposition = require("./createDecorateProposition.js");
|
|
4
5
|
/*
|
|
5
6
|
Copyright 2023 Adobe. All rights reserved.
|
|
6
7
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -14,7 +15,9 @@ governing permissions and limitations under the License.
|
|
|
14
15
|
*/
|
|
15
16
|
var _default = exports.default = function _default(_ref) {
|
|
16
17
|
var modules = _ref.modules,
|
|
17
|
-
logger = _ref.logger
|
|
18
|
+
logger = _ref.logger,
|
|
19
|
+
storeInteractionMeta = _ref.storeInteractionMeta,
|
|
20
|
+
autoCollectPropositionInteractions = _ref.autoCollectPropositionInteractions;
|
|
18
21
|
return function (item) {
|
|
19
22
|
var _ref2 = item.getData() || {},
|
|
20
23
|
type = _ref2.type,
|
|
@@ -32,9 +35,10 @@ var _default = exports.default = function _default(_ref) {
|
|
|
32
35
|
includeInNotification: false
|
|
33
36
|
};
|
|
34
37
|
}
|
|
38
|
+
var decorateProposition = (0, _createDecorateProposition.default)(autoCollectPropositionInteractions, type, item.getProposition().getId(), item.getId(), item.getTrackingLabel(), item.getProposition().getScopeType(), item.getProposition().getNotification(), storeInteractionMeta);
|
|
35
39
|
return {
|
|
36
40
|
render: function render() {
|
|
37
|
-
modules[type](item.getData());
|
|
41
|
+
return modules[type](item.getData(), decorateProposition);
|
|
38
42
|
},
|
|
39
43
|
setRenderAttempted: true,
|
|
40
44
|
includeInNotification: true
|
|
@@ -119,7 +119,7 @@ var _default = exports.default = function _default(_ref) {
|
|
|
119
119
|
});
|
|
120
120
|
} else if (atLeastOneWithNotification) {
|
|
121
121
|
renderers.push(function () {
|
|
122
|
-
return proposition.getNotification();
|
|
122
|
+
return Promise.resolve(proposition.getNotification());
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
if (renderedItems.length > 0) {
|
|
@@ -23,16 +23,24 @@ var _default = exports.default = function _default(_ref) {
|
|
|
23
23
|
var preprocess = _ref.preprocess,
|
|
24
24
|
isPageWideSurface = _ref.isPageWideSurface;
|
|
25
25
|
var createItem = function createItem(item, proposition) {
|
|
26
|
-
var
|
|
26
|
+
var id = item.id,
|
|
27
|
+
schema = item.schema,
|
|
27
28
|
data = item.data,
|
|
28
29
|
_item$characteristics = item.characteristics,
|
|
29
30
|
_item$characteristics2 = _item$characteristics === void 0 ? {} : _item$characteristics,
|
|
30
31
|
trackingLabel = _item$characteristics2.trackingLabel;
|
|
32
|
+
var schemaType = data ? data.type : undefined;
|
|
31
33
|
var processedData = preprocess(data);
|
|
32
34
|
return {
|
|
35
|
+
getId: function getId() {
|
|
36
|
+
return id;
|
|
37
|
+
},
|
|
33
38
|
getSchema: function getSchema() {
|
|
34
39
|
return schema;
|
|
35
40
|
},
|
|
41
|
+
getSchemaType: function getSchemaType() {
|
|
42
|
+
return schemaType;
|
|
43
|
+
},
|
|
36
44
|
getData: function getData() {
|
|
37
45
|
return processedData;
|
|
38
46
|
},
|
|
@@ -93,6 +101,9 @@ var _default = exports.default = function _default(_ref) {
|
|
|
93
101
|
scopeDetails: scopeDetails
|
|
94
102
|
};
|
|
95
103
|
},
|
|
104
|
+
getId: function getId() {
|
|
105
|
+
return id;
|
|
106
|
+
},
|
|
96
107
|
toJSON: function toJSON() {
|
|
97
108
|
return payload;
|
|
98
109
|
},
|
|
@@ -14,6 +14,7 @@ var _createOnClickHandler = require("./createOnClickHandler.js");
|
|
|
14
14
|
var _createViewCacheManager = require("./createViewCacheManager.js");
|
|
15
15
|
var _createViewChangeHandler = require("./createViewChangeHandler.js");
|
|
16
16
|
var _createClickStorage2 = require("./createClickStorage.js");
|
|
17
|
+
var _createInteractionStorage = require("./createInteractionStorage.js");
|
|
17
18
|
var _createApplyPropositions = require("./createApplyPropositions.js");
|
|
18
19
|
var _createGetPageLocation = require("./createGetPageLocation.js");
|
|
19
20
|
var _createSetTargetMigration = require("./createSetTargetMigration.js");
|
|
@@ -35,6 +36,9 @@ var _initInAppMessageActionsModules = require("./in-app-message-actions/initInAp
|
|
|
35
36
|
var _createRedirect = require("./dom-actions/createRedirect.js");
|
|
36
37
|
var _createNotificationHandler = require("./createNotificationHandler.js");
|
|
37
38
|
var _createHandleConsentFlicker = require("./createHandleConsentFlicker.js");
|
|
39
|
+
var _collectInteractions = require("./dom-actions/clicks/collectInteractions.js");
|
|
40
|
+
var _propositionInteractionType = require("../../constants/propositionInteractionType.js");
|
|
41
|
+
var _decisionProvider = require("../../constants/decisionProvider.js");
|
|
38
42
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
39
43
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
40
44
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
@@ -55,15 +59,19 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
55
59
|
eventManager = _ref.eventManager,
|
|
56
60
|
consent = _ref.consent;
|
|
57
61
|
var targetMigrationEnabled = config.targetMigrationEnabled,
|
|
58
|
-
prehidingStyle = config.prehidingStyle
|
|
62
|
+
prehidingStyle = config.prehidingStyle,
|
|
63
|
+
autoCollectPropositionInteractions = config.autoCollectPropositionInteractions;
|
|
59
64
|
var collect = (0, _createCollect.default)({
|
|
60
65
|
eventManager: eventManager,
|
|
61
66
|
mergeDecisionsMeta: _event.mergeDecisionsMeta
|
|
62
67
|
});
|
|
68
|
+
var _createInteractionSto = (0, _createInteractionStorage.default)(),
|
|
69
|
+
storeInteractionMeta = _createInteractionSto.storeInteractionMeta,
|
|
70
|
+
getInteractionMetas = _createInteractionSto.getInteractionMetas;
|
|
63
71
|
var _createClickStorage = (0, _createClickStorage2.default)(),
|
|
64
|
-
|
|
72
|
+
storeClickMeta = _createClickStorage.storeClickMeta,
|
|
65
73
|
getClickSelectors = _createClickStorage.getClickSelectors,
|
|
66
|
-
|
|
74
|
+
getClickMetas = _createClickStorage.getClickMetas;
|
|
67
75
|
var getPageLocation = (0, _createGetPageLocation.default)({
|
|
68
76
|
window: window
|
|
69
77
|
});
|
|
@@ -80,10 +88,14 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
80
88
|
var schemaProcessors = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, schema.DEFAULT_CONTENT_ITEM, _processDefaultContent.default), schema.DOM_ACTION, (0, _createProcessDomAction.default)({
|
|
81
89
|
modules: domActionsModules,
|
|
82
90
|
logger: logger,
|
|
83
|
-
|
|
91
|
+
storeInteractionMeta: storeInteractionMeta,
|
|
92
|
+
storeClickMeta: storeClickMeta,
|
|
93
|
+
autoCollectPropositionInteractions: autoCollectPropositionInteractions
|
|
84
94
|
})), schema.HTML_CONTENT_ITEM, (0, _createProcessHtmlContent.default)({
|
|
85
95
|
modules: domActionsModules,
|
|
86
|
-
logger: logger
|
|
96
|
+
logger: logger,
|
|
97
|
+
storeInteractionMeta: storeInteractionMeta,
|
|
98
|
+
autoCollectPropositionInteractions: autoCollectPropositionInteractions
|
|
87
99
|
})), schema.REDIRECT_ITEM, (0, _createProcessRedirect.default)({
|
|
88
100
|
logger: logger,
|
|
89
101
|
executeRedirect: executeRedirect,
|
|
@@ -110,9 +122,12 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
110
122
|
});
|
|
111
123
|
var onClickHandler = (0, _createOnClickHandler.default)({
|
|
112
124
|
mergeDecisionsMeta: _event.mergeDecisionsMeta,
|
|
125
|
+
collectInteractions: _collectInteractions.default,
|
|
113
126
|
collectClicks: _collectClicks.default,
|
|
127
|
+
getInteractionMetas: getInteractionMetas,
|
|
128
|
+
getClickMetas: getClickMetas,
|
|
114
129
|
getClickSelectors: getClickSelectors,
|
|
115
|
-
|
|
130
|
+
autoCollectPropositionInteractions: autoCollectPropositionInteractions
|
|
116
131
|
});
|
|
117
132
|
var viewChangeHandler = (0, _createViewChangeHandler.default)({
|
|
118
133
|
processPropositions: processPropositions,
|
|
@@ -155,8 +170,12 @@ var createPersonalization = function createPersonalization(_ref) {
|
|
|
155
170
|
});
|
|
156
171
|
};
|
|
157
172
|
createPersonalization.namespace = "Personalization";
|
|
173
|
+
var interactionConfigOptions = _propositionInteractionType.PROPOSITION_INTERACTION_TYPES.map(function (propositionInteractionType) {
|
|
174
|
+
return (0, _index.literal)(propositionInteractionType);
|
|
175
|
+
});
|
|
158
176
|
createPersonalization.configValidators = (0, _index.objectOf)({
|
|
159
177
|
prehidingStyle: (0, _index.string)().nonEmpty(),
|
|
160
|
-
targetMigrationEnabled: (0, _index.boolean)().default(false)
|
|
178
|
+
targetMigrationEnabled: (0, _index.boolean)().default(false),
|
|
179
|
+
autoCollectPropositionInteractions: (0, _index.objectOf)(_defineProperty(_defineProperty({}, _decisionProvider.ADOBE_JOURNEY_OPTIMIZER, (0, _index.anyOf)(interactionConfigOptions).default(_propositionInteractionType.ALWAYS)), _decisionProvider.ADOBE_TARGET, (0, _index.anyOf)(interactionConfigOptions).default(_propositionInteractionType.NEVER))).default(_defineProperty(_defineProperty({}, _decisionProvider.ADOBE_JOURNEY_OPTIMIZER, _propositionInteractionType.ALWAYS), _decisionProvider.ADOBE_TARGET, _propositionInteractionType.NEVER)).noUnknownFields()
|
|
161
180
|
});
|
|
162
181
|
var _default = exports.default = createPersonalization;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.dedupeMetas = exports.cleanMetas = void 0;
|
|
4
|
+
var _excluded = ["trackingLabel", "scopeType"];
|
|
5
|
+
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; }
|
|
6
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
9
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
var cleanMetas = exports.cleanMetas = function cleanMetas(metas) {
|
|
19
|
+
return metas.map(function (meta) {
|
|
20
|
+
var trackingLabel = meta.trackingLabel,
|
|
21
|
+
scopeType = meta.scopeType,
|
|
22
|
+
rest = _objectWithoutProperties(meta, _excluded);
|
|
23
|
+
return rest;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var dedupeMetas = exports.dedupeMetas = function dedupeMetas(metas) {
|
|
27
|
+
return metas.filter(function (meta, index) {
|
|
28
|
+
var stringifiedMeta = JSON.stringify(meta);
|
|
29
|
+
return index === metas.findIndex(function (innerMeta) {
|
|
30
|
+
return JSON.stringify(innerMeta) === stringifiedMeta;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
};
|
|
@@ -21,7 +21,18 @@ var _default = exports.default = function _default(_ref) {
|
|
|
21
21
|
var logger = _ref.logger,
|
|
22
22
|
options = _ref.options;
|
|
23
23
|
var applyPropositionsOptionsValidator = (0, _index.objectOf)({
|
|
24
|
-
propositions: (0, _index.arrayOf)((0, _index.objectOf)(
|
|
24
|
+
propositions: (0, _index.arrayOf)((0, _index.objectOf)({
|
|
25
|
+
id: (0, _index.string)().required(),
|
|
26
|
+
scope: (0, _index.string)().required(),
|
|
27
|
+
scopeDetails: (0, _index.objectOf)({
|
|
28
|
+
decisionProvider: (0, _index.string)().required()
|
|
29
|
+
}).required(),
|
|
30
|
+
items: (0, _index.arrayOf)((0, _index.objectOf)({
|
|
31
|
+
id: (0, _index.string)().required(),
|
|
32
|
+
schema: (0, _index.string)().required(),
|
|
33
|
+
data: (0, _index.anything)().required()
|
|
34
|
+
})).nonEmpty().required()
|
|
35
|
+
}).required()).nonEmpty().required(),
|
|
25
36
|
metadata: (0, _index.objectOf)((0, _index.anything)()),
|
|
26
37
|
viewName: (0, _index.string)()
|
|
27
38
|
}).required();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports.ADOBE_JOURNEY_OPTIMIZER = void 0;
|
|
3
|
+
exports.ADOBE_TARGET = exports.ADOBE_JOURNEY_OPTIMIZER = void 0;
|
|
4
4
|
/*
|
|
5
5
|
Copyright 2023 Adobe. All rights reserved.
|
|
6
6
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -12,4 +12,5 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
12
12
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
13
|
governing permissions and limitations under the License.
|
|
14
14
|
*/
|
|
15
|
-
var ADOBE_JOURNEY_OPTIMIZER = exports.ADOBE_JOURNEY_OPTIMIZER = "AJO";
|
|
15
|
+
var ADOBE_JOURNEY_OPTIMIZER = exports.ADOBE_JOURNEY_OPTIMIZER = "AJO";
|
|
16
|
+
var ADOBE_TARGET = exports.ADOBE_TARGET = "TGT";
|
|
@@ -14,4 +14,4 @@ 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 = exports.default = "2.
|
|
17
|
+
var _default = exports.default = "2.21.0-beta.0";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.PROPOSITION_INTERACTION_TYPES = exports.NEVER = exports.DECORATED_ELEMENTS_ONLY = exports.ALWAYS = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2024 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 ALWAYS = exports.ALWAYS = "always";
|
|
16
|
+
var NEVER = exports.NEVER = "never";
|
|
17
|
+
var DECORATED_ELEMENTS_ONLY = exports.DECORATED_ELEMENTS_ONLY = "decoratedElementsOnly";
|
|
18
|
+
var PROPOSITION_INTERACTION_TYPES = exports.PROPOSITION_INTERACTION_TYPES = [ALWAYS, NEVER, DECORATED_ELEMENTS_ONLY];
|
|
@@ -37,14 +37,18 @@ var canUseMutationObserver = exports.canUseMutationObserver = function canUseMut
|
|
|
37
37
|
};
|
|
38
38
|
var awaitUsingMutationObserver = exports.awaitUsingMutationObserver = function awaitUsingMutationObserver(win, doc, selector, timeout, selectFunc) {
|
|
39
39
|
return createPromise(function (resolve, reject) {
|
|
40
|
+
var timer;
|
|
40
41
|
var mutationObserver = new win[MUTATION_OBSERVER](function () {
|
|
41
42
|
var nodes = selectFunc(selector);
|
|
42
43
|
if ((0, _isNonEmptyArray.default)(nodes)) {
|
|
43
44
|
mutationObserver.disconnect();
|
|
45
|
+
if (timer) {
|
|
46
|
+
clearTimeout(timer);
|
|
47
|
+
}
|
|
44
48
|
resolve(nodes);
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
|
-
setTimeout(function () {
|
|
51
|
+
timer = setTimeout(function () {
|
|
48
52
|
mutationObserver.disconnect();
|
|
49
53
|
reject(createError(selector));
|
|
50
54
|
}, timeout);
|
|
@@ -10,34 +10,49 @@ 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 {
|
|
14
|
-
import { DOM_ACTION, HTML_CONTENT_ITEM, MESSAGE_IN_APP } from "../../constants/schema.js";
|
|
13
|
+
import { defer, isEmptyObject, isNonEmptyArray } from "../../utils/index.js";
|
|
14
|
+
import { DOM_ACTION, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, MESSAGE_IN_APP } from "../../constants/schema.js";
|
|
15
15
|
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope.js";
|
|
16
|
-
|
|
16
|
+
import { DOM_ACTION_COLLECT_INTERACTIONS } from "./dom-actions/initDomActionsModules.js";
|
|
17
|
+
const isInteractionTrackingItem = (schema, actionType) => schema === JSON_CONTENT_ITEM && actionType === DOM_ACTION_COLLECT_INTERACTIONS;
|
|
18
|
+
const SUPPORTED_SCHEMAS = {
|
|
19
|
+
[DOM_ACTION]: () => true,
|
|
20
|
+
[HTML_CONTENT_ITEM]: () => true,
|
|
21
|
+
[JSON_CONTENT_ITEM]: isInteractionTrackingItem,
|
|
22
|
+
[MESSAGE_IN_APP]: () => true
|
|
23
|
+
};
|
|
24
|
+
const filterItemsPredicate = (schema, actionType) => typeof SUPPORTED_SCHEMAS[schema] === "function" && SUPPORTED_SCHEMAS[schema](schema, actionType);
|
|
17
25
|
export default (({
|
|
18
26
|
processPropositions,
|
|
19
27
|
createProposition,
|
|
20
28
|
renderedPropositions,
|
|
21
29
|
viewCache
|
|
22
30
|
}) => {
|
|
23
|
-
const filterItemsPredicate = item => SUPPORTED_SCHEMAS.indexOf(item.schema) > -1;
|
|
24
31
|
const updatePropositionItems = ({
|
|
25
32
|
items,
|
|
26
|
-
metadataForScope
|
|
33
|
+
metadataForScope = {}
|
|
27
34
|
}) => {
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
const {
|
|
36
|
+
actionType,
|
|
37
|
+
selector
|
|
38
|
+
} = metadataForScope;
|
|
39
|
+
return items.filter(item => filterItemsPredicate(item.schema, actionType)).map(item => {
|
|
40
|
+
const {
|
|
41
|
+
schema
|
|
42
|
+
} = item;
|
|
43
|
+
if (schema !== HTML_CONTENT_ITEM && !isInteractionTrackingItem(schema, actionType)) {
|
|
30
44
|
return {
|
|
31
45
|
...item
|
|
32
46
|
};
|
|
33
47
|
}
|
|
34
|
-
if (
|
|
48
|
+
if (!isEmptyObject(metadataForScope)) {
|
|
35
49
|
return {
|
|
36
50
|
...item,
|
|
51
|
+
schema: isInteractionTrackingItem(schema, actionType) ? DOM_ACTION : schema,
|
|
37
52
|
data: {
|
|
38
53
|
...item.data,
|
|
39
|
-
selector
|
|
40
|
-
type:
|
|
54
|
+
selector,
|
|
55
|
+
type: actionType
|
|
41
56
|
}
|
|
42
57
|
};
|
|
43
58
|
}
|