@adobe/alloy 2.19.0-beta.1 → 2.19.0-beta.11
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 +6 -2
- package/libEs5/components/Personalization/createClickStorage.js +21 -13
- package/libEs5/components/Personalization/createComponent.js +21 -10
- package/libEs5/components/Personalization/createFetchDataHandler.js +13 -12
- 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/createViewChangeHandler.js +1 -6
- package/libEs5/components/Personalization/dom-actions/clicks/collectClicks.js +43 -23
- package/libEs5/components/Personalization/{utils/isPageWideScope.js → dom-actions/createRedirect.js} +10 -5
- package/libEs5/components/Personalization/handlers/createProcessDomAction.js +19 -4
- package/libEs5/components/Personalization/handlers/createProcessHtmlContent.js +8 -2
- package/libEs5/components/Personalization/handlers/createProcessPropositions.js +2 -2
- package/libEs5/components/Personalization/handlers/createProcessRedirect.js +7 -3
- package/libEs5/components/Personalization/handlers/injectCreateProposition.js +13 -15
- package/libEs5/components/Personalization/index.js +8 -13
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/createEvent.js +1 -1
- package/libEs5/core/createEventManager.js +19 -26
- package/libEs5/utils/dom/selectNodesWithShadow.js +10 -3
- 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 +7 -3
- package/libEs6/components/Personalization/createClickStorage.js +18 -10
- package/libEs6/components/Personalization/createComponent.js +20 -11
- package/libEs6/components/Personalization/createFetchDataHandler.js +13 -12
- 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/createViewChangeHandler.js +0 -5
- package/libEs6/components/Personalization/dom-actions/clicks/collectClicks.js +28 -12
- package/libEs6/components/Personalization/{utils/isPageWideScope.js → dom-actions/createRedirect.js} +7 -4
- package/libEs6/components/Personalization/handlers/createProcessDomAction.js +17 -4
- package/libEs6/components/Personalization/handlers/createProcessHtmlContent.js +8 -2
- package/libEs6/components/Personalization/handlers/createProcessPropositions.js +2 -2
- package/libEs6/components/Personalization/handlers/createProcessRedirect.js +7 -3
- package/libEs6/components/Personalization/handlers/injectCreateProposition.js +12 -15
- package/libEs6/components/Personalization/index.js +8 -11
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/createEvent.js +1 -1
- package/libEs6/core/createEventManager.js +9 -19
- package/libEs6/utils/dom/selectNodesWithShadow.js +10 -3
- package/package.json +3 -3
- package/libEs5/components/Personalization/createPendingNotificationsHandler.js +0 -26
- package/libEs6/components/Personalization/createPendingNotificationsHandler.js +0 -22
|
@@ -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,
|
|
@@ -29,10 +29,12 @@ export default (({
|
|
|
29
29
|
}) => {
|
|
30
30
|
if (personalizationDetails.isRenderDecisions()) {
|
|
31
31
|
hideContainers(prehidingStyle);
|
|
32
|
+
} else {
|
|
33
|
+
showContainers();
|
|
32
34
|
}
|
|
33
35
|
mergeQuery(event, personalizationDetails.createQueryDetails());
|
|
34
36
|
let handleNotifications;
|
|
35
|
-
if (personalizationDetails.
|
|
37
|
+
if (personalizationDetails.isSendDisplayEvent()) {
|
|
36
38
|
handleNotifications = decisionsMeta => {
|
|
37
39
|
if (decisionsMeta.length > 0) {
|
|
38
40
|
collect({
|
|
@@ -42,9 +44,9 @@ export default (({
|
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
46
|
} else {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
handleNotifications =
|
|
47
|
+
const renderedPropositionsDeferred = defer();
|
|
48
|
+
renderedPropositions.concat(renderedPropositionsDeferred.promise);
|
|
49
|
+
handleNotifications = renderedPropositionsDeferred.resolve;
|
|
48
50
|
}
|
|
49
51
|
onResponse(({
|
|
50
52
|
response
|
|
@@ -66,13 +68,12 @@ export default (({
|
|
|
66
68
|
returnedPropositions,
|
|
67
69
|
returnedDecisions
|
|
68
70
|
} = processPropositions([...pagePropositions, ...currentViewPropositions], nonRenderedPropositions));
|
|
69
|
-
render().then(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
71
|
+
render().then(handleNotifications);
|
|
72
|
+
|
|
73
|
+
// Render could take a long time especially if one of the renders
|
|
74
|
+
// is waiting for html to appear on the page. We show the containers
|
|
75
|
+
// immediately, and whatever renders quickly will not have flicker.
|
|
76
|
+
showContainers();
|
|
76
77
|
} else {
|
|
77
78
|
({
|
|
78
79
|
returnedPropositions,
|
|
@@ -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;
|
|
@@ -10,15 +10,12 @@ 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 { PropositionEventType } from "./constants/propositionEventType";
|
|
14
13
|
export default (({
|
|
15
|
-
mergeDecisionsMeta,
|
|
16
14
|
processPropositions,
|
|
17
15
|
viewCache
|
|
18
16
|
}) => {
|
|
19
17
|
return ({
|
|
20
18
|
personalizationDetails,
|
|
21
|
-
event,
|
|
22
19
|
onResponse
|
|
23
20
|
}) => {
|
|
24
21
|
let returnedPropositions;
|
|
@@ -45,8 +42,6 @@ export default (({
|
|
|
45
42
|
returnedDecisions
|
|
46
43
|
} = processPropositions([], propositions));
|
|
47
44
|
return [];
|
|
48
|
-
}).then(decisionsMeta => {
|
|
49
|
-
mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY);
|
|
50
45
|
});
|
|
51
46
|
};
|
|
52
47
|
});
|
|
@@ -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
|
});
|
package/libEs6/components/Personalization/{utils/isPageWideScope.js → dom-actions/createRedirect.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
2
|
+
Copyright 2019 Adobe. All rights reserved.
|
|
3
3
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -10,6 +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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export default (window => url => {
|
|
14
|
+
window.location.replace(url);
|
|
15
|
+
// Return a promise that never resolves because redirects never complete
|
|
16
|
+
// within the current page.
|
|
17
|
+
return new Promise(() => undefined);
|
|
18
|
+
});
|
|
@@ -20,16 +20,26 @@ export default (({
|
|
|
20
20
|
} = item.getData() || {};
|
|
21
21
|
if (!type) {
|
|
22
22
|
logger.warn("Invalid DOM action data: missing type.", item.getData());
|
|
23
|
-
return {
|
|
23
|
+
return {
|
|
24
|
+
setRenderAttempted: false,
|
|
25
|
+
includeInNotification: false
|
|
26
|
+
};
|
|
24
27
|
}
|
|
25
28
|
if (type === "click") {
|
|
26
29
|
if (!selector) {
|
|
27
30
|
logger.warn("Invalid DOM action data: missing selector.", item.getData());
|
|
28
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
setRenderAttempted: false,
|
|
33
|
+
includeInNotification: false
|
|
34
|
+
};
|
|
29
35
|
}
|
|
30
36
|
storeClickMetrics({
|
|
31
37
|
selector,
|
|
32
|
-
meta:
|
|
38
|
+
meta: {
|
|
39
|
+
...item.getProposition().getNotification(),
|
|
40
|
+
trackingLabel: item.getTrackingLabel(),
|
|
41
|
+
scopeType: item.getProposition().getScopeType()
|
|
42
|
+
}
|
|
33
43
|
});
|
|
34
44
|
return {
|
|
35
45
|
setRenderAttempted: true,
|
|
@@ -38,7 +48,10 @@ export default (({
|
|
|
38
48
|
}
|
|
39
49
|
if (!modules[type]) {
|
|
40
50
|
logger.warn("Invalid DOM action data: unknown type.", item.getData());
|
|
41
|
-
return {
|
|
51
|
+
return {
|
|
52
|
+
setRenderAttempted: false,
|
|
53
|
+
includeInNotification: false
|
|
54
|
+
};
|
|
42
55
|
}
|
|
43
56
|
return {
|
|
44
57
|
render: () => modules[type](item.getData()),
|
|
@@ -18,11 +18,17 @@ export default (({
|
|
|
18
18
|
selector
|
|
19
19
|
} = item.getData() || {};
|
|
20
20
|
if (!selector || !type) {
|
|
21
|
-
return {
|
|
21
|
+
return {
|
|
22
|
+
setRenderAttempted: false,
|
|
23
|
+
includeInNotification: false
|
|
24
|
+
};
|
|
22
25
|
}
|
|
23
26
|
if (!modules[type]) {
|
|
24
27
|
logger.warn("Invalid HTML content data", item.getData());
|
|
25
|
-
return {
|
|
28
|
+
return {
|
|
29
|
+
setRenderAttempted: false,
|
|
30
|
+
includeInNotification: false
|
|
31
|
+
};
|
|
26
32
|
}
|
|
27
33
|
return {
|
|
28
34
|
render: () => {
|
|
@@ -26,8 +26,8 @@ export default (({
|
|
|
26
26
|
message,
|
|
27
27
|
stack
|
|
28
28
|
} = error;
|
|
29
|
-
const
|
|
30
|
-
logger.
|
|
29
|
+
const warning = `Failed to execute action ${item.toString()}. ${message} ${stack}`;
|
|
30
|
+
logger.warn(warning);
|
|
31
31
|
}
|
|
32
32
|
return false;
|
|
33
33
|
});
|
|
@@ -23,10 +23,14 @@ export default (({
|
|
|
23
23
|
}
|
|
24
24
|
const render = () => {
|
|
25
25
|
return collect({
|
|
26
|
-
decisionsMeta: [item.
|
|
26
|
+
decisionsMeta: [item.getProposition().getNotification()],
|
|
27
|
+
documentMayUnload: true
|
|
27
28
|
}).then(() => {
|
|
28
|
-
executeRedirect(content);
|
|
29
|
-
//
|
|
29
|
+
return executeRedirect(content);
|
|
30
|
+
// Execute redirect will never resolve. If there are bottom of page events that are waiting
|
|
31
|
+
// for display notifications from this request, they will never run because this promise will
|
|
32
|
+
// not resolve. This is intentional because we don't want to run bottom of page events if
|
|
33
|
+
// there is a redirect.
|
|
30
34
|
});
|
|
31
35
|
};
|
|
32
36
|
|
|
@@ -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 {
|
|
@@ -31,7 +31,6 @@ import remapHeadOffers from "./dom-actions/remapHeadOffers";
|
|
|
31
31
|
import createPreprocess from "./dom-actions/createPreprocess";
|
|
32
32
|
import injectCreateProposition from "./handlers/injectCreateProposition";
|
|
33
33
|
import createAsyncArray from "./utils/createAsyncArray";
|
|
34
|
-
import createPendingNotificationsHandler from "./createPendingNotificationsHandler";
|
|
35
34
|
import * as schema from "./constants/schema";
|
|
36
35
|
import processDefaultContent from "./handlers/processDefaultContent";
|
|
37
36
|
import { isPageWideSurface } from "./utils/surfaceUtils";
|
|
@@ -39,6 +38,7 @@ import createProcessDomAction from "./handlers/createProcessDomAction";
|
|
|
39
38
|
import createProcessHtmlContent from "./handlers/createProcessHtmlContent";
|
|
40
39
|
import createProcessRedirect from "./handlers/createProcessRedirect";
|
|
41
40
|
import createProcessPropositions from "./handlers/createProcessPropositions";
|
|
41
|
+
import createRedirect from "./dom-actions/createRedirect";
|
|
42
42
|
const createPersonalization = ({
|
|
43
43
|
config,
|
|
44
44
|
logger,
|
|
@@ -69,6 +69,7 @@ const createPersonalization = ({
|
|
|
69
69
|
const viewCache = createViewCacheManager({
|
|
70
70
|
createProposition
|
|
71
71
|
});
|
|
72
|
+
const executeRedirect = createRedirect(window);
|
|
72
73
|
const schemaProcessors = {
|
|
73
74
|
[schema.DEFAULT_CONTENT_ITEM]: processDefaultContent,
|
|
74
75
|
[schema.DOM_ACTION]: createProcessDomAction({
|
|
@@ -82,7 +83,7 @@ const createPersonalization = ({
|
|
|
82
83
|
}),
|
|
83
84
|
[schema.REDIRECT_ITEM]: createProcessRedirect({
|
|
84
85
|
logger,
|
|
85
|
-
executeRedirect
|
|
86
|
+
executeRedirect,
|
|
86
87
|
collect
|
|
87
88
|
})
|
|
88
89
|
};
|
|
@@ -90,11 +91,7 @@ const createPersonalization = ({
|
|
|
90
91
|
schemaProcessors,
|
|
91
92
|
logger
|
|
92
93
|
});
|
|
93
|
-
const
|
|
94
|
-
const pendingNotificationsHandler = createPendingNotificationsHandler({
|
|
95
|
-
pendingDisplayNotifications,
|
|
96
|
-
mergeDecisionsMeta
|
|
97
|
-
});
|
|
94
|
+
const renderedPropositions = createAsyncArray();
|
|
98
95
|
const fetchDataHandler = createFetchDataHandler({
|
|
99
96
|
prehidingStyle,
|
|
100
97
|
showContainers,
|
|
@@ -103,7 +100,7 @@ const createPersonalization = ({
|
|
|
103
100
|
collect,
|
|
104
101
|
processPropositions,
|
|
105
102
|
createProposition,
|
|
106
|
-
|
|
103
|
+
renderedPropositions
|
|
107
104
|
});
|
|
108
105
|
const onClickHandler = createOnClickHandler({
|
|
109
106
|
mergeDecisionsMeta,
|
|
@@ -112,14 +109,13 @@ const createPersonalization = ({
|
|
|
112
109
|
getClickMetasBySelector
|
|
113
110
|
});
|
|
114
111
|
const viewChangeHandler = createViewChangeHandler({
|
|
115
|
-
mergeDecisionsMeta,
|
|
116
112
|
processPropositions,
|
|
117
113
|
viewCache
|
|
118
114
|
});
|
|
119
115
|
const applyPropositions = createApplyPropositions({
|
|
120
116
|
processPropositions,
|
|
121
117
|
createProposition,
|
|
122
|
-
|
|
118
|
+
renderedPropositions,
|
|
123
119
|
viewCache
|
|
124
120
|
});
|
|
125
121
|
const setTargetMigration = createSetTargetMigration({
|
|
@@ -137,7 +133,8 @@ const createPersonalization = ({
|
|
|
137
133
|
showContainers,
|
|
138
134
|
applyPropositions,
|
|
139
135
|
setTargetMigration,
|
|
140
|
-
|
|
136
|
+
mergeDecisionsMeta,
|
|
137
|
+
renderedPropositions
|
|
141
138
|
});
|
|
142
139
|
};
|
|
143
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(() => {
|
|
@@ -17,7 +17,7 @@ const splitWithShadow = selector => {
|
|
|
17
17
|
return selector.split(SHADOW_SEPARATOR);
|
|
18
18
|
};
|
|
19
19
|
const transformPrefix = (parent, selector) => {
|
|
20
|
-
const result = selector
|
|
20
|
+
const result = selector;
|
|
21
21
|
const hasChildCombinatorPrefix = startsWith(result, ">");
|
|
22
22
|
if (!hasChildCombinatorPrefix) {
|
|
23
23
|
return result;
|
|
@@ -45,8 +45,15 @@ export default ((context, selector) => {
|
|
|
45
45
|
// find each subselector element based on the previously selected node's shadowRoot
|
|
46
46
|
let parent = context;
|
|
47
47
|
for (let i = 0; i < parts.length; i += 1) {
|
|
48
|
-
const part =
|
|
49
|
-
|
|
48
|
+
const part = parts[i].trim();
|
|
49
|
+
// if part is empty, it means there's a chained :eq:shadow selector
|
|
50
|
+
if (part === "" && parent.shadowRoot) {
|
|
51
|
+
parent = parent.shadowRoot;
|
|
52
|
+
// eslint-disable-next-line no-continue
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const prefixed = transformPrefix(parent, part);
|
|
56
|
+
const partNode = querySelectorAll(parent, prefixed);
|
|
50
57
|
if (partNode.length === 0 || !partNode[0] || !partNode[0].shadowRoot) {
|
|
51
58
|
return partNode;
|
|
52
59
|
}
|
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.11",
|
|
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.10",
|
|
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",
|