@adobe/alloy 2.19.0-beta.8 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libEs5/components/DataCollector/index.js +3 -0
- package/libEs5/components/DataCollector/validateApplyResponse.js +2 -1
- package/libEs5/components/DataCollector/validateUserEventOptions.js +2 -1
- package/libEs5/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +32 -0
- package/libEs5/components/{Personalization/utils/isPageWideScope.js → DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js} +10 -5
- package/libEs5/components/DecisioningEngine/constants.js +31 -0
- package/libEs5/components/DecisioningEngine/createApplyResponse.js +36 -0
- package/libEs5/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
- package/libEs5/components/DecisioningEngine/createContextProvider.js +93 -0
- package/libEs5/components/DecisioningEngine/createDecisionHistory.js +28 -0
- package/libEs5/components/DecisioningEngine/createDecisionProvider.js +51 -0
- package/libEs5/components/DecisioningEngine/createEvaluableRulesetPayload.js +80 -0
- package/libEs5/components/DecisioningEngine/createEvaluateRulesetsCommand.js +49 -0
- package/libEs5/components/DecisioningEngine/createEventRegistry.js +130 -0
- package/libEs5/components/DecisioningEngine/createOnResponseHandler.js +46 -0
- package/libEs5/components/DecisioningEngine/createSubscribeRulesetItems.js +87 -0
- package/libEs5/components/DecisioningEngine/index.js +119 -0
- package/libEs5/components/DecisioningEngine/utils.js +90 -0
- package/libEs5/components/Personalization/constants/scopeType.js +6 -2
- package/libEs5/components/Personalization/createActionsProvider.js +72 -0
- package/libEs5/components/Personalization/createApplyPropositions.js +2 -2
- package/libEs5/components/Personalization/createClickStorage.js +21 -13
- package/libEs5/components/Personalization/createCollect.js +9 -4
- package/libEs5/components/Personalization/createComponent.js +5 -3
- package/libEs5/components/Personalization/createFetchDataHandler.js +2 -17
- package/libEs5/components/Personalization/createNotificationHandler.js +33 -0
- package/libEs5/components/Personalization/createOnClickHandler.js +9 -8
- package/libEs5/components/Personalization/createOnDecisionHandler.js +44 -0
- package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -5
- package/libEs5/components/Personalization/createPreprocessors.js +21 -0
- package/libEs5/components/Personalization/createViewCacheManager.js +11 -3
- package/libEs5/components/Personalization/dom-actions/clicks/collectClicks.js +43 -23
- package/libEs5/components/Personalization/dom-actions/createRedirect.js +11 -1
- package/libEs5/components/Personalization/event.js +25 -22
- package/libEs5/components/Personalization/handlers/createProcessDomAction.js +7 -1
- package/libEs5/components/Personalization/handlers/createProcessInAppMessage.js +76 -0
- package/libEs5/components/Personalization/handlers/createProcessRedirect.js +6 -3
- package/libEs5/components/Personalization/handlers/injectCreateProposition.js +13 -15
- package/libEs5/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +288 -0
- package/libEs5/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +23 -0
- package/libEs5/components/Personalization/in-app-message-actions/utils.js +53 -0
- package/libEs5/components/Personalization/index.js +20 -7
- package/libEs5/constants/contentType.js +18 -0
- package/libEs5/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +4 -8
- package/libEs5/constants/eventType.js +25 -0
- package/libEs5/{components/Personalization/constants/eventType.js → constants/handle.js} +4 -7
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/constants/propositionEventType.js +33 -0
- package/libEs5/{components/Personalization/constants → constants}/schema.js +9 -1
- package/libEs5/core/componentCreators.js +2 -1
- package/libEs5/core/createEvent.js +26 -1
- package/libEs5/core/createEventManager.js +3 -0
- package/libEs5/core/createLifecycle.js +4 -1
- package/libEs5/utils/createSubscription.js +91 -0
- package/libEs5/utils/debounce.js +30 -0
- package/libEs5/utils/dom/selectNodesWithShadow.js +10 -3
- package/libEs5/utils/flattenArray.js +37 -0
- package/libEs5/utils/flattenObject.js +43 -0
- package/libEs5/utils/index.js +7 -0
- package/libEs5/utils/parseUrl.js +70 -0
- package/libEs6/components/DataCollector/index.js +2 -0
- package/libEs6/components/DataCollector/validateApplyResponse.js +2 -1
- package/libEs6/components/DataCollector/validateUserEventOptions.js +2 -1
- package/libEs6/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +30 -0
- package/libEs6/components/{Personalization/utils/isPageWideScope.js → DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js} +13 -4
- package/libEs6/components/DecisioningEngine/constants.js +25 -0
- package/libEs6/components/DecisioningEngine/createApplyResponse.js +31 -0
- package/libEs6/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
- package/libEs6/components/DecisioningEngine/createContextProvider.js +95 -0
- package/libEs6/components/DecisioningEngine/createDecisionHistory.js +25 -0
- package/libEs6/components/DecisioningEngine/createDecisionProvider.js +41 -0
- package/libEs6/components/DecisioningEngine/createEvaluableRulesetPayload.js +79 -0
- package/libEs6/components/DecisioningEngine/createEvaluateRulesetsCommand.js +45 -0
- package/libEs6/components/DecisioningEngine/createEventRegistry.js +120 -0
- package/libEs6/components/DecisioningEngine/createOnResponseHandler.js +45 -0
- package/libEs6/components/DecisioningEngine/createSubscribeRulesetItems.js +79 -0
- package/libEs6/components/DecisioningEngine/index.js +124 -0
- package/libEs6/components/DecisioningEngine/utils.js +83 -0
- package/libEs6/components/Personalization/constants/scopeType.js +3 -1
- package/libEs6/components/Personalization/createActionsProvider.js +70 -0
- package/libEs6/components/Personalization/createApplyPropositions.js +2 -2
- package/libEs6/components/Personalization/createClickStorage.js +18 -10
- package/libEs6/components/Personalization/createCollect.js +7 -4
- package/libEs6/components/Personalization/createComponent.js +5 -3
- package/libEs6/components/Personalization/createFetchDataHandler.js +3 -18
- package/libEs6/components/Personalization/createNotificationHandler.js +29 -0
- package/libEs6/components/Personalization/createOnClickHandler.js +10 -9
- package/libEs6/components/Personalization/createOnDecisionHandler.js +42 -0
- package/libEs6/components/Personalization/createPersonalizationDetails.js +8 -5
- package/libEs6/components/Personalization/createPreprocessors.js +19 -0
- package/libEs6/components/Personalization/createViewCacheManager.js +14 -4
- package/libEs6/components/Personalization/dom-actions/clicks/collectClicks.js +28 -12
- package/libEs6/components/Personalization/dom-actions/createRedirect.js +10 -1
- package/libEs6/components/Personalization/event.js +14 -9
- package/libEs6/components/Personalization/handlers/createProcessDomAction.js +5 -1
- package/libEs6/components/Personalization/handlers/createProcessInAppMessage.js +77 -0
- package/libEs6/components/Personalization/handlers/createProcessRedirect.js +6 -3
- package/libEs6/components/Personalization/handlers/injectCreateProposition.js +12 -15
- package/libEs6/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +291 -0
- package/libEs6/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +17 -0
- package/libEs6/components/Personalization/in-app-message-actions/utils.js +49 -0
- package/libEs6/components/Personalization/index.js +22 -8
- package/libEs6/{components/Personalization/constants/eventType.js → constants/contentType.js} +3 -4
- package/libEs6/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +2 -6
- package/libEs6/constants/eventType.js +17 -0
- package/libEs6/constants/handle.js +12 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/constants/propositionEventType.js +33 -0
- package/libEs6/{components/Personalization/constants → constants}/schema.js +4 -0
- package/libEs6/core/componentCreators.js +2 -1
- package/libEs6/core/createEvent.js +26 -1
- package/libEs6/core/createEventManager.js +2 -0
- package/libEs6/core/createLifecycle.js +4 -1
- package/libEs6/utils/createSubscription.js +70 -0
- package/libEs6/utils/debounce.js +22 -0
- package/libEs6/utils/dom/selectNodesWithShadow.js +10 -3
- package/libEs6/utils/flattenArray.js +26 -0
- package/libEs6/utils/flattenObject.js +28 -0
- package/libEs6/utils/index.js +1 -0
- package/libEs6/utils/parseUrl.js +62 -0
- package/package.json +6 -2
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const createRestoreStorage = (storage, storageKey) => {
|
|
14
|
+
return defaultValue => {
|
|
15
|
+
const stored = storage.getItem(storageKey);
|
|
16
|
+
if (!stored) {
|
|
17
|
+
return defaultValue;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(stored);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return defaultValue;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export const createSaveStorage = (storage, storageKey, prepareFn = value => value) => {
|
|
27
|
+
return value => {
|
|
28
|
+
storage.setItem(storageKey, JSON.stringify(prepareFn(value)));
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export const getExpirationDate = retentionPeriod => {
|
|
32
|
+
const expirationDate = new Date();
|
|
33
|
+
expirationDate.setDate(expirationDate.getDate() - retentionPeriod);
|
|
34
|
+
return expirationDate;
|
|
35
|
+
};
|
|
36
|
+
export const getActivityId = proposition => {
|
|
37
|
+
const {
|
|
38
|
+
scopeDetails = {}
|
|
39
|
+
} = proposition;
|
|
40
|
+
const {
|
|
41
|
+
activity = {}
|
|
42
|
+
} = scopeDetails;
|
|
43
|
+
const {
|
|
44
|
+
id
|
|
45
|
+
} = activity;
|
|
46
|
+
return id;
|
|
47
|
+
};
|
|
48
|
+
export const createInMemoryStorage = () => {
|
|
49
|
+
const inMemoryStorage = {};
|
|
50
|
+
return {
|
|
51
|
+
getItem: key => {
|
|
52
|
+
return key in inMemoryStorage ? inMemoryStorage[key] : null;
|
|
53
|
+
},
|
|
54
|
+
setItem: (key, value) => {
|
|
55
|
+
inMemoryStorage[key] = value;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export const clearLocalStorage = storage => {
|
|
60
|
+
storage.clear();
|
|
61
|
+
};
|
|
62
|
+
export const hasExperienceData = xdm => {
|
|
63
|
+
const {
|
|
64
|
+
eventType = "",
|
|
65
|
+
_experience
|
|
66
|
+
} = xdm;
|
|
67
|
+
if (!eventType || eventType === "") {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (!_experience || typeof _experience !== "object") {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
};
|
|
75
|
+
export const getDecisionProvider = proposition => {
|
|
76
|
+
const {
|
|
77
|
+
scopeDetails = {}
|
|
78
|
+
} = proposition;
|
|
79
|
+
const {
|
|
80
|
+
decisionProvider
|
|
81
|
+
} = scopeDetails;
|
|
82
|
+
return decisionProvider;
|
|
83
|
+
};
|
|
@@ -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";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import createPreprocessors from "./createPreprocessors";
|
|
13
|
+
import { assign } from "../../utils";
|
|
14
|
+
export default (({
|
|
15
|
+
modules,
|
|
16
|
+
preprocessors = createPreprocessors(),
|
|
17
|
+
logger
|
|
18
|
+
}) => {
|
|
19
|
+
const logActionError = (action, error) => {
|
|
20
|
+
if (logger.enabled) {
|
|
21
|
+
const details = JSON.stringify(action);
|
|
22
|
+
const {
|
|
23
|
+
message,
|
|
24
|
+
stack
|
|
25
|
+
} = error;
|
|
26
|
+
const errorMessage = `Failed to execute action ${details}. ${message} ${stack ? `\n ${stack}` : ""}`;
|
|
27
|
+
logger.warn(errorMessage);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const logActionCompleted = action => {
|
|
31
|
+
if (logger.enabled) {
|
|
32
|
+
const details = JSON.stringify(action);
|
|
33
|
+
logger.info(`Action ${details} executed.`);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const getExecuteAction = (schema, type) => {
|
|
37
|
+
if (!modules[schema] || !modules[schema][type]) {
|
|
38
|
+
return () => Promise.reject(new Error(`Action "${type}" not found for schema "${schema}"`));
|
|
39
|
+
}
|
|
40
|
+
return modules[schema][type];
|
|
41
|
+
};
|
|
42
|
+
const applyPreprocessors = action => {
|
|
43
|
+
const {
|
|
44
|
+
schema
|
|
45
|
+
} = action;
|
|
46
|
+
const preprocessorsList = preprocessors[schema];
|
|
47
|
+
if (!schema || !(preprocessorsList instanceof Array) || preprocessorsList.length === 0) {
|
|
48
|
+
return action;
|
|
49
|
+
}
|
|
50
|
+
return preprocessorsList.reduce((processed, fn) => assign(processed, fn(processed)), action);
|
|
51
|
+
};
|
|
52
|
+
const executeAction = action => {
|
|
53
|
+
const processedAction = applyPreprocessors(action);
|
|
54
|
+
const {
|
|
55
|
+
type,
|
|
56
|
+
schema
|
|
57
|
+
} = processedAction;
|
|
58
|
+
const execute = getExecuteAction(schema, type);
|
|
59
|
+
return execute(processedAction).then(result => {
|
|
60
|
+
logActionCompleted(processedAction);
|
|
61
|
+
return result;
|
|
62
|
+
}).catch(error => {
|
|
63
|
+
logActionError(processedAction, error);
|
|
64
|
+
throw error;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
executeAction
|
|
69
|
+
};
|
|
70
|
+
});
|
|
@@ -11,9 +11,9 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { isNonEmptyArray, isObject, defer } from "../../utils";
|
|
14
|
-
import { DOM_ACTION, HTML_CONTENT_ITEM } from "
|
|
14
|
+
import { DOM_ACTION, HTML_CONTENT_ITEM, MESSAGE_IN_APP } from "../../constants/schema";
|
|
15
15
|
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
|
|
16
|
-
const SUPPORTED_SCHEMAS = [DOM_ACTION, HTML_CONTENT_ITEM];
|
|
16
|
+
const SUPPORTED_SCHEMAS = [DOM_ACTION, HTML_CONTENT_ITEM, MESSAGE_IN_APP];
|
|
17
17
|
export default (({
|
|
18
18
|
processPropositions,
|
|
19
19
|
createProposition,
|
|
@@ -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 = () => {
|
|
@@ -9,8 +9,8 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
9
9
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import { DISPLAY } from "
|
|
13
|
-
import {
|
|
12
|
+
import { DISPLAY } from "../../constants/eventType";
|
|
13
|
+
import { getPropositionEventType } from "../../constants/propositionEventType";
|
|
14
14
|
import { isNonEmptyArray } from "../../utils";
|
|
15
15
|
export default (({
|
|
16
16
|
eventManager,
|
|
@@ -19,12 +19,15 @@ export default (({
|
|
|
19
19
|
// Called when a decision is auto-rendered for the __view__ scope or a SPA view(display and empty display notification)
|
|
20
20
|
return ({
|
|
21
21
|
decisionsMeta = [],
|
|
22
|
+
propositionAction,
|
|
22
23
|
documentMayUnload = false,
|
|
24
|
+
eventType = DISPLAY,
|
|
25
|
+
propositionEventTypes = [getPropositionEventType(eventType)],
|
|
23
26
|
viewName
|
|
24
27
|
}) => {
|
|
25
28
|
const event = eventManager.createEvent();
|
|
26
29
|
const data = {
|
|
27
|
-
eventType
|
|
30
|
+
eventType
|
|
28
31
|
};
|
|
29
32
|
if (viewName) {
|
|
30
33
|
data.web = {
|
|
@@ -34,7 +37,7 @@ export default (({
|
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
if (isNonEmptyArray(decisionsMeta)) {
|
|
37
|
-
mergeDecisionsMeta(event, decisionsMeta,
|
|
40
|
+
mergeDecisionsMeta(event, decisionsMeta, propositionEventTypes, propositionAction);
|
|
38
41
|
}
|
|
39
42
|
event.mergeXdm(data);
|
|
40
43
|
if (documentMayUnload) {
|
|
@@ -13,8 +13,8 @@ governing permissions and limitations under the License.
|
|
|
13
13
|
import { noop, flatMap, isNonEmptyArray } from "../../utils";
|
|
14
14
|
import createPersonalizationDetails from "./createPersonalizationDetails";
|
|
15
15
|
import { AUTHORING_ENABLED } from "./constants/loggerMessage";
|
|
16
|
+
import { PropositionEventType } from "../../constants/propositionEventType";
|
|
16
17
|
import validateApplyPropositionsOptions from "./validateApplyPropositionsOptions";
|
|
17
|
-
import { PropositionEventType } from "./constants/propositionEventType";
|
|
18
18
|
export default (({
|
|
19
19
|
getPageLocation,
|
|
20
20
|
logger,
|
|
@@ -28,10 +28,12 @@ export default (({
|
|
|
28
28
|
applyPropositions,
|
|
29
29
|
setTargetMigration,
|
|
30
30
|
mergeDecisionsMeta,
|
|
31
|
-
renderedPropositions
|
|
31
|
+
renderedPropositions,
|
|
32
|
+
onDecisionHandler
|
|
32
33
|
}) => {
|
|
33
34
|
return {
|
|
34
35
|
lifecycle: {
|
|
36
|
+
onDecision: onDecisionHandler,
|
|
35
37
|
onBeforeRequest({
|
|
36
38
|
request
|
|
37
39
|
}) {
|
|
@@ -100,7 +102,7 @@ export default (({
|
|
|
100
102
|
// from two places: the pending display notifications and the view change handler.
|
|
101
103
|
const decisionsMeta = flatMap(decisionsMetas, dms => dms);
|
|
102
104
|
if (isNonEmptyArray(decisionsMeta)) {
|
|
103
|
-
mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.DISPLAY);
|
|
105
|
+
mergeDecisionsMeta(event, decisionsMeta, [PropositionEventType.DISPLAY]);
|
|
104
106
|
}
|
|
105
107
|
});
|
|
106
108
|
},
|
|
@@ -9,17 +9,16 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
9
9
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import { groupBy } from "../../utils";
|
|
13
13
|
const DECISIONS_HANDLE = "personalization:decisions";
|
|
14
14
|
export default (({
|
|
15
15
|
prehidingStyle,
|
|
16
16
|
showContainers,
|
|
17
17
|
hideContainers,
|
|
18
18
|
mergeQuery,
|
|
19
|
-
collect,
|
|
20
19
|
processPropositions,
|
|
21
20
|
createProposition,
|
|
22
|
-
|
|
21
|
+
notificationHandler
|
|
23
22
|
}) => {
|
|
24
23
|
return ({
|
|
25
24
|
cacheUpdate,
|
|
@@ -33,21 +32,7 @@ export default (({
|
|
|
33
32
|
showContainers();
|
|
34
33
|
}
|
|
35
34
|
mergeQuery(event, personalizationDetails.createQueryDetails());
|
|
36
|
-
|
|
37
|
-
if (personalizationDetails.isSendDisplayEvent()) {
|
|
38
|
-
handleNotifications = decisionsMeta => {
|
|
39
|
-
if (decisionsMeta.length > 0) {
|
|
40
|
-
collect({
|
|
41
|
-
decisionsMeta,
|
|
42
|
-
viewName: personalizationDetails.getViewName()
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
} else {
|
|
47
|
-
const renderedPropositionsDeferred = defer();
|
|
48
|
-
renderedPropositions.concat(renderedPropositionsDeferred.promise);
|
|
49
|
-
handleNotifications = renderedPropositionsDeferred.resolve;
|
|
50
|
-
}
|
|
35
|
+
const handleNotifications = notificationHandler(personalizationDetails.isSendDisplayEvent(), personalizationDetails.getViewName());
|
|
51
36
|
onResponse(({
|
|
52
37
|
response
|
|
53
38
|
}) => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { defer } from "../../utils";
|
|
13
|
+
export default ((collect, renderedPropositions) => {
|
|
14
|
+
return (sendDisplayEvent, viewName) => {
|
|
15
|
+
if (!sendDisplayEvent) {
|
|
16
|
+
const renderedPropositionsDeferred = defer();
|
|
17
|
+
renderedPropositions.concat(renderedPropositionsDeferred.promise);
|
|
18
|
+
return renderedPropositionsDeferred.resolve;
|
|
19
|
+
}
|
|
20
|
+
return decisionsMeta => {
|
|
21
|
+
if (decisionsMeta.length > 0) {
|
|
22
|
+
collect({
|
|
23
|
+
decisionsMeta,
|
|
24
|
+
viewName
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
});
|
|
@@ -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
|
|
14
|
-
import { INTERACT } from "
|
|
15
|
-
import { PropositionEventType } from "
|
|
16
|
-
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
|
|
13
|
+
import { isNonEmptyArray } from "../../utils";
|
|
14
|
+
import { INTERACT } from "../../constants/eventType";
|
|
15
|
+
import { PropositionEventType } from "../../constants/propositionEventType";
|
|
17
16
|
export default (({
|
|
18
17
|
mergeDecisionsMeta,
|
|
19
18
|
collectClicks,
|
|
@@ -29,22 +28,24 @@ 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
|
}
|
|
46
45
|
event.mergeXdm(xdm);
|
|
47
|
-
mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.INTERACT, eventLabel
|
|
46
|
+
mergeDecisionsMeta(event, decisionsMeta, [PropositionEventType.INTERACT], eventLabel ? {
|
|
47
|
+
label: eventLabel
|
|
48
|
+
} : undefined);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default (({
|
|
14
|
+
processPropositions,
|
|
15
|
+
createProposition,
|
|
16
|
+
notificationHandler
|
|
17
|
+
}) => {
|
|
18
|
+
return ({
|
|
19
|
+
renderDecisions,
|
|
20
|
+
propositions,
|
|
21
|
+
event,
|
|
22
|
+
personalization = {}
|
|
23
|
+
}) => {
|
|
24
|
+
if (!renderDecisions) {
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
const {
|
|
28
|
+
sendDisplayEvent = true
|
|
29
|
+
} = personalization;
|
|
30
|
+
const viewName = event ? event.getViewName() : undefined;
|
|
31
|
+
const propositionsToExecute = propositions.map(proposition => createProposition(proposition, true));
|
|
32
|
+
const {
|
|
33
|
+
render,
|
|
34
|
+
returnedPropositions
|
|
35
|
+
} = processPropositions(propositionsToExecute);
|
|
36
|
+
const handleNotifications = notificationHandler(sendDisplayEvent, viewName);
|
|
37
|
+
render().then(handleNotifications);
|
|
38
|
+
return Promise.resolve({
|
|
39
|
+
propositions: returnedPropositions
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
});
|
|
@@ -13,7 +13,7 @@ governing permissions and limitations under the License.
|
|
|
13
13
|
import { includes, isNonEmptyString, isNonEmptyArray } from "../../utils";
|
|
14
14
|
import { buildPageSurface, normalizeSurfaces } from "./utils/surfaceUtils";
|
|
15
15
|
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
|
|
16
|
-
import { DEFAULT_CONTENT_ITEM, DOM_ACTION, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM } from "
|
|
16
|
+
import { DEFAULT_CONTENT_ITEM, DOM_ACTION, HTML_CONTENT_ITEM, MESSAGE_IN_APP, JSON_CONTENT_ITEM, REDIRECT_ITEM, RULESET_ITEM, MESSAGE_FEED_ITEM } from "../../constants/schema";
|
|
17
17
|
const addPageWideScope = scopes => {
|
|
18
18
|
if (!includes(scopes, PAGE_WIDE_SCOPE)) {
|
|
19
19
|
scopes.push(PAGE_WIDE_SCOPE);
|
|
@@ -64,11 +64,11 @@ export default (({
|
|
|
64
64
|
scopes.push(...personalization.decisionScopes);
|
|
65
65
|
}
|
|
66
66
|
const eventSurfaces = normalizeSurfaces(personalization.surfaces, getPageLocation, logger);
|
|
67
|
-
if (
|
|
67
|
+
if (this.shouldRequestDefaultPersonalization()) {
|
|
68
68
|
addPageWideScope(scopes);
|
|
69
69
|
addPageSurface(eventSurfaces, getPageLocation);
|
|
70
70
|
}
|
|
71
|
-
const schemas = [DEFAULT_CONTENT_ITEM, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM];
|
|
71
|
+
const schemas = [DEFAULT_CONTENT_ITEM, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM, RULESET_ITEM, MESSAGE_IN_APP, MESSAGE_FEED_ITEM];
|
|
72
72
|
if (includes(scopes, PAGE_WIDE_SCOPE)) {
|
|
73
73
|
schemas.push(DOM_ACTION);
|
|
74
74
|
}
|
|
@@ -82,10 +82,13 @@ export default (({
|
|
|
82
82
|
return isCacheInitialized;
|
|
83
83
|
},
|
|
84
84
|
shouldFetchData() {
|
|
85
|
-
return this.hasScopes() || this.hasSurfaces() ||
|
|
85
|
+
return this.hasScopes() || this.hasSurfaces() || this.shouldRequestDefaultPersonalization();
|
|
86
86
|
},
|
|
87
87
|
shouldUseCachedData() {
|
|
88
|
-
return this.hasViewName() && this.
|
|
88
|
+
return this.hasViewName() && !this.shouldFetchData();
|
|
89
|
+
},
|
|
90
|
+
shouldRequestDefaultPersonalization() {
|
|
91
|
+
return personalization.defaultPersonalizationEnabled || !this.isCacheInitialized() && personalization.defaultPersonalizationEnabled !== false;
|
|
89
92
|
}
|
|
90
93
|
};
|
|
91
94
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { DOM_ACTION } from "../../constants/schema";
|
|
13
|
+
import remapHeadOffers from "./dom-actions/remapHeadOffers";
|
|
14
|
+
import remapCustomCodeOffers from "./dom-actions/remapCustomCodeOffers";
|
|
15
|
+
export default (() => {
|
|
16
|
+
return {
|
|
17
|
+
[DOM_ACTION]: [remapHeadOffers, remapCustomCodeOffers]
|
|
18
|
+
};
|
|
19
|
+
});
|
|
@@ -10,9 +10,10 @@ 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 { groupBy } from "../../utils";
|
|
13
|
+
import { assign, groupBy } from "../../utils";
|
|
14
14
|
import defer from "../../utils/defer";
|
|
15
|
-
import { DEFAULT_CONTENT_ITEM } from "
|
|
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
|
}) => {
|
|
@@ -27,7 +28,7 @@ export default (({
|
|
|
27
28
|
scope: viewName,
|
|
28
29
|
scopeDetails: {
|
|
29
30
|
characteristics: {
|
|
30
|
-
scopeType:
|
|
31
|
+
scopeType: VIEW_SCOPE_TYPE
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
items: [{
|
|
@@ -41,7 +42,16 @@ export default (({
|
|
|
41
42
|
const createCacheUpdate = viewName => {
|
|
42
43
|
const updateCacheDeferred = defer();
|
|
43
44
|
cacheUpdateCreatedAtLeastOnce = true;
|
|
44
|
-
|
|
45
|
+
|
|
46
|
+
// Additional updates will merge the new view propositions with the old.
|
|
47
|
+
// i.e. if there are new "cart" view propositions they will overwrite the
|
|
48
|
+
// old "cart" view propositions, but if there are no new "cart" view
|
|
49
|
+
// propositions the old "cart" view propositions will remain.
|
|
50
|
+
viewStoragePromise = viewStoragePromise.then(oldViewStorage => {
|
|
51
|
+
return updateCacheDeferred.promise.then(newViewStorage => {
|
|
52
|
+
return assign({}, oldViewStorage, newViewStorage);
|
|
53
|
+
}).catch(() => oldViewStorage);
|
|
54
|
+
});
|
|
45
55
|
return {
|
|
46
56
|
update(viewPropositions) {
|
|
47
57
|
const viewPropositionsWithScope = viewPropositions.filter(proposition => proposition.getScope());
|
|
@@ -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
|
});
|
|
@@ -10,4 +10,13 @@ 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 default (window => url =>
|
|
13
|
+
export default (window => (url, preserveHistory = false) => {
|
|
14
|
+
if (preserveHistory) {
|
|
15
|
+
window.location.href = url;
|
|
16
|
+
} else {
|
|
17
|
+
window.location.replace(url);
|
|
18
|
+
}
|
|
19
|
+
// Return a promise that never resolves because redirects never complete
|
|
20
|
+
// within the current page.
|
|
21
|
+
return new Promise(() => undefined);
|
|
22
|
+
});
|