@adobe/alloy 2.17.0 → 2.18.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/ActivityCollector/configValidators.js +9 -5
- package/libEs5/components/ActivityCollector/utils.js +22 -3
- package/libEs5/components/Audiences/index.js +0 -1
- package/libEs5/components/Context/index.js +2 -2
- package/libEs5/components/DataCollector/index.js +1 -2
- package/libEs5/components/EventMerge/index.js +0 -1
- package/libEs5/components/Identity/configValidators.js +2 -2
- package/libEs5/components/Identity/getIdentity/createGetIdentity.js +8 -5
- package/libEs5/components/Identity/getIdentity/createIdentityRequest.js +5 -2
- package/libEs5/components/MachineLearning/index.js +0 -1
- package/libEs5/components/Personalization/index.js +2 -2
- package/libEs5/components/Privacy/createConsentRequest.js +5 -2
- package/libEs5/components/Privacy/injectSendSetConsentRequest.js +10 -6
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/buildAndValidateConfig.js +79 -26
- package/libEs5/core/config/createCoreConfigs.js +3 -3
- package/libEs5/core/createEventManager.js +15 -6
- package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
- package/libEs5/utils/request/createDataCollectionRequest.js +10 -6
- package/libEs5/utils/request/createRequest.js +5 -1
- package/libEs5/utils/request/createRequestParams.js +53 -0
- package/libEs5/utils/request/index.js +8 -0
- package/libEs5/utils/validation/booleanValidator.js +2 -2
- package/libEs5/utils/validation/callbackValidator.js +2 -2
- package/libEs5/utils/validation/createAnyOfValidator.js +8 -5
- package/libEs5/utils/validation/createArrayOfValidator.js +6 -4
- package/libEs5/utils/validation/createDeprecatedValidator.js +53 -0
- package/libEs5/utils/validation/createLiteralValidator.js +2 -2
- package/libEs5/utils/validation/createMapOfValuesValidator.js +6 -4
- package/libEs5/utils/validation/createMinimumValidator.js +2 -2
- package/libEs5/utils/validation/createNonEmptyValidator.js +3 -3
- package/libEs5/utils/validation/createObjectOfValidator.js +6 -4
- package/libEs5/utils/validation/createUniqueItemsValidator.js +2 -2
- package/libEs5/utils/validation/createUniqueValidator.js +2 -2
- package/libEs5/utils/validation/domainValidator.js +2 -2
- package/libEs5/utils/validation/index.js +54 -45
- package/libEs5/utils/validation/integerValidator.js +2 -2
- package/libEs5/utils/validation/numberValidator.js +2 -2
- package/libEs5/utils/validation/regexpValidator.js +2 -2
- package/libEs5/utils/validation/stringValidator.js +2 -2
- package/libEs5/utils/validation/utils.js +155 -0
- package/libEs6/components/ActivityCollector/configValidators.js +6 -5
- package/libEs6/components/ActivityCollector/utils.js +20 -3
- package/libEs6/components/Audiences/index.js +0 -1
- package/libEs6/components/Context/index.js +3 -3
- package/libEs6/components/DataCollector/index.js +1 -2
- package/libEs6/components/EventMerge/index.js +0 -1
- package/libEs6/components/Identity/configValidators.js +3 -3
- package/libEs6/components/Identity/getIdentity/createGetIdentity.js +7 -5
- package/libEs6/components/Identity/getIdentity/createIdentityRequest.js +6 -2
- package/libEs6/components/MachineLearning/index.js +0 -1
- package/libEs6/components/Personalization/index.js +3 -3
- package/libEs6/components/Privacy/createConsentRequest.js +6 -2
- package/libEs6/components/Privacy/injectSendSetConsentRequest.js +9 -6
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/buildAndValidateConfig.js +48 -19
- package/libEs6/core/config/createCoreConfigs.js +4 -4
- package/libEs6/core/createEventManager.js +14 -6
- package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
- package/libEs6/utils/request/createDataCollectionRequest.js +6 -2
- package/libEs6/utils/request/createRequest.js +6 -1
- package/libEs6/utils/request/createRequestParams.js +43 -0
- package/libEs6/utils/request/index.js +1 -0
- package/libEs6/utils/validation/booleanValidator.js +1 -1
- package/libEs6/utils/validation/callbackValidator.js +1 -1
- package/libEs6/utils/validation/createAnyOfValidator.js +5 -4
- package/libEs6/utils/validation/createArrayOfValidator.js +3 -3
- package/libEs6/utils/validation/createDeprecatedValidator.js +41 -0
- package/libEs6/utils/validation/createLiteralValidator.js +1 -1
- package/libEs6/utils/validation/createMapOfValuesValidator.js +3 -3
- package/libEs6/utils/validation/createMinimumValidator.js +1 -1
- package/libEs6/utils/validation/createNonEmptyValidator.js +1 -1
- package/libEs6/utils/validation/createObjectOfValidator.js +3 -3
- package/libEs6/utils/validation/createUniqueItemsValidator.js +1 -1
- package/libEs6/utils/validation/createUniqueValidator.js +1 -1
- package/libEs6/utils/validation/domainValidator.js +1 -1
- package/libEs6/utils/validation/index.js +84 -13
- package/libEs6/utils/validation/integerValidator.js +1 -1
- package/libEs6/utils/validation/numberValidator.js +1 -1
- package/libEs6/utils/validation/regexpValidator.js +1 -1
- package/libEs6/utils/validation/stringValidator.js +1 -1
- package/libEs6/utils/validation/utils.js +131 -0
- package/package.json +6 -4
- package/libEs5/utils/validation/assertValid.js +0 -22
- package/libEs5/utils/validation/chain.js +0 -76
- package/libEs5/utils/validation/nullSafeChain.js +0 -41
- package/libEs6/utils/validation/assertValid.js +0 -16
- package/libEs6/utils/validation/chain.js +0 -67
- package/libEs6/utils/validation/nullSafeChain.js +0 -32
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.reverseNullSafeChainJoinErrors = exports.nullSafeChain = exports.chain = exports.assertValid = void 0;
|
|
4
|
+
|
|
5
|
+
var _assign = require("../assign");
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2023 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
|
+
// This is used to add methods onto a function.
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Wraps a validator returning the value if it is null or undefined, otherwise
|
|
22
|
+
* it will call the original validator and return the result.
|
|
23
|
+
*
|
|
24
|
+
* @param {function} validator - the validator to call if the value is not null
|
|
25
|
+
*/
|
|
26
|
+
var skipIfNull = function skipIfNull(validator) {
|
|
27
|
+
return function skipIfNullValidator(value, path) {
|
|
28
|
+
return value == null ? value : validator.call(this, value, path);
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Returns a new validator that calls the first validator and then calls the second
|
|
33
|
+
* validator with the result of the first validator. The result of the second validator
|
|
34
|
+
* is returned.
|
|
35
|
+
*
|
|
36
|
+
* @param {function} firstValidator - validator to call first
|
|
37
|
+
* @param {function} secondValidator - validator to call second
|
|
38
|
+
* @returns {function} - a new validator that calls the first and second validators
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
var callSequentially = function callSequentially(firstValidator, secondValidator) {
|
|
43
|
+
return function callSequentiallyValidator(value, path) {
|
|
44
|
+
return secondValidator.call(this, firstValidator.call(this, value, path), path);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Just like callSequentially, but if either validator throws an error, the errors
|
|
49
|
+
* are collected and thrown at the end.
|
|
50
|
+
*
|
|
51
|
+
* @param {function} firstValidator
|
|
52
|
+
* @param {function} secondValidator
|
|
53
|
+
* @returns {function}
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
var callSequentiallyJoinErrors = function callSequentiallyJoinErrors(firstValidator, secondValidator) {
|
|
58
|
+
return function callSequentiallyJoinErrorsValidator(value, path) {
|
|
59
|
+
var _this = this;
|
|
60
|
+
|
|
61
|
+
var errors = [];
|
|
62
|
+
var newValue = [firstValidator, secondValidator].reduce(function (memo, validator) {
|
|
63
|
+
try {
|
|
64
|
+
return validator.call(_this, memo, path);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
errors.push(e);
|
|
67
|
+
return memo;
|
|
68
|
+
}
|
|
69
|
+
}, value);
|
|
70
|
+
|
|
71
|
+
if (errors.length) {
|
|
72
|
+
throw new Error(errors.join("\n"));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return newValue;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Chains two validators together. In addition to calling the validators in
|
|
80
|
+
* sequence, this will also copy over methods from the base validator to the
|
|
81
|
+
* resulting validator and include any additional methods.
|
|
82
|
+
*
|
|
83
|
+
* @param {function} baseValidator - This validator will be called first, and its
|
|
84
|
+
* methods will be copied over to the returned validator.
|
|
85
|
+
* @param {function} newValidator - This validator will be called second.
|
|
86
|
+
* @param {object} additionalMethods - Additional methods to include on the returned
|
|
87
|
+
* validator.
|
|
88
|
+
* @returns {function}
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var chain = function chain(baseValidator, newValidator, additionalMethods) {
|
|
93
|
+
return (0, _assign.default)(callSequentially(baseValidator, newValidator), baseValidator, additionalMethods);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Chains two validators together, but skips the second validator if the value
|
|
97
|
+
* is null. In addition to calling the validators in sequence, this will also
|
|
98
|
+
* copy over methods from the base validator to the resulting validator and
|
|
99
|
+
* include any additional methods.
|
|
100
|
+
*
|
|
101
|
+
* @param {function} baseValidator - This validator will be called first, and its
|
|
102
|
+
* methods will be copied over to the returned validator.
|
|
103
|
+
* @param {function} newValidator - This validator will be called second. If the value
|
|
104
|
+
* is null after the first validator is called, this validator will not be
|
|
105
|
+
* called.
|
|
106
|
+
* @param {object} additionalMethods - Additional methods to include on the returned
|
|
107
|
+
* validator.
|
|
108
|
+
* @returns {function}
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
exports.chain = chain;
|
|
113
|
+
|
|
114
|
+
var nullSafeChain = function nullSafeChain(baseValidator, newValidator, additionalMethods) {
|
|
115
|
+
return (0, _assign.default)(callSequentially(baseValidator, skipIfNull(newValidator)), baseValidator, additionalMethods);
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Same as nullSafeChain, but calls the new validator first.
|
|
119
|
+
*
|
|
120
|
+
* @param {function} baseValidator - This validator will be called second, and its
|
|
121
|
+
* methods will be copied over to the returned validator.
|
|
122
|
+
* @param {function} newValidator - This validator will be called first. If the value
|
|
123
|
+
* is null, this validator will not be called.
|
|
124
|
+
* @param {function} additionalMethods - Additional methods to include on the returned
|
|
125
|
+
* validator.
|
|
126
|
+
* @returns {function}
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
exports.nullSafeChain = nullSafeChain;
|
|
131
|
+
|
|
132
|
+
var reverseNullSafeChainJoinErrors = function reverseNullSafeChainJoinErrors(baseValidator, newValidator, additionalMethods) {
|
|
133
|
+
return (0, _assign.default)(callSequentiallyJoinErrors(skipIfNull(newValidator), baseValidator), baseValidator, additionalMethods);
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Throws an error if the value is not valid.
|
|
137
|
+
*
|
|
138
|
+
* @param {boolean} isValid - Whether or not the value is valid.
|
|
139
|
+
* @param {*} value - The value to validate.
|
|
140
|
+
* @param {string} path - The path to the value.
|
|
141
|
+
* @param {string} message - The expected part of the error message.
|
|
142
|
+
* @throws {Error} - Throws an error if the value is not valid.
|
|
143
|
+
* @returns {void}
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
exports.reverseNullSafeChainJoinErrors = reverseNullSafeChainJoinErrors;
|
|
148
|
+
|
|
149
|
+
var assertValid = function assertValid(isValid, value, path, message) {
|
|
150
|
+
if (!isValid) {
|
|
151
|
+
throw new Error("'" + path + "': Expected " + message + ", but got " + JSON.stringify(value) + ".");
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
exports.assertValid = assertValid;
|
|
@@ -9,9 +9,10 @@ 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 {
|
|
13
|
-
export default
|
|
12
|
+
import { boolean, callback, objectOf, string } from "../../utils/validation";
|
|
13
|
+
export const downloadLinkQualifier = string().regexp().default("\\.(exe|zip|wav|mp3|mov|mpg|avi|wmv|pdf|doc|docx|xls|xlsx|ppt|pptx)$");
|
|
14
|
+
export default objectOf({
|
|
14
15
|
clickCollectionEnabled: boolean().default(true),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
16
|
+
onBeforeLinkClickSend: callback(),
|
|
17
|
+
downloadLinkQualifier
|
|
18
|
+
});
|
|
@@ -54,15 +54,32 @@ const isSupportedAnchorElement = element => {
|
|
|
54
54
|
return false;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
const trimQueryFromUrl = url => {
|
|
58
|
+
const questionMarkIndex = url.indexOf("?");
|
|
59
|
+
const hashIndex = url.indexOf("#");
|
|
60
|
+
|
|
61
|
+
if (questionMarkIndex >= 0 && (questionMarkIndex < hashIndex || hashIndex < 0)) {
|
|
62
|
+
return url.substring(0, questionMarkIndex);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (hashIndex >= 0) {
|
|
66
|
+
return url.substring(0, hashIndex);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return url;
|
|
70
|
+
};
|
|
71
|
+
|
|
57
72
|
const isDownloadLink = (downloadLinkQualifier, linkUrl, clickedObj) => {
|
|
58
73
|
const re = new RegExp(downloadLinkQualifier);
|
|
59
|
-
|
|
74
|
+
const trimmedLinkUrl = trimQueryFromUrl(linkUrl).toLowerCase();
|
|
75
|
+
return clickedObj.download ? true : re.test(trimmedLinkUrl);
|
|
60
76
|
};
|
|
61
77
|
|
|
62
78
|
const isExitLink = (window, linkUrl) => {
|
|
63
79
|
const currentHostname = window.location.hostname.toLowerCase();
|
|
80
|
+
const trimmedLinkUrl = trimQueryFromUrl(linkUrl).toLowerCase();
|
|
64
81
|
|
|
65
|
-
if (
|
|
82
|
+
if (trimmedLinkUrl.indexOf(currentHostname) >= 0) {
|
|
66
83
|
return false;
|
|
67
84
|
}
|
|
68
85
|
|
|
@@ -111,4 +128,4 @@ const findSupportedAnchorElement = targetElement => {
|
|
|
111
128
|
return null;
|
|
112
129
|
};
|
|
113
130
|
|
|
114
|
-
export { urlStartsWithScheme, getAbsoluteUrlFromAnchorElement, isSupportedAnchorElement, isDownloadLink, isEmptyString, isExitLink, truncateWhiteSpace, findSupportedAnchorElement, determineLinkType };
|
|
131
|
+
export { urlStartsWithScheme, getAbsoluteUrlFromAnchorElement, isSupportedAnchorElement, isDownloadLink, isEmptyString, isExitLink, trimQueryFromUrl, truncateWhiteSpace, findSupportedAnchorElement, determineLinkType };
|
|
@@ -17,7 +17,7 @@ import injectTimestamp from "./injectTimestamp";
|
|
|
17
17
|
import implementationDetails from "./implementationDetails";
|
|
18
18
|
import createComponent from "./createComponent";
|
|
19
19
|
import injectHighEntropyUserAgentHints from "./injectHighEntropyUserAgentHints";
|
|
20
|
-
import { arrayOf, string } from "../../utils/validation";
|
|
20
|
+
import { arrayOf, objectOf, string } from "../../utils/validation";
|
|
21
21
|
const web = injectWeb(window);
|
|
22
22
|
const device = injectDevice(window);
|
|
23
23
|
const environment = injectEnvironment(window);
|
|
@@ -46,7 +46,7 @@ const createContext = ({
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
createContext.namespace = "Context";
|
|
49
|
-
createContext.configValidators = {
|
|
49
|
+
createContext.configValidators = objectOf({
|
|
50
50
|
context: arrayOf(string()).default(Object.keys(defaultEnabledContexts))
|
|
51
|
-
};
|
|
51
|
+
});
|
|
52
52
|
export default createContext;
|
|
@@ -72,7 +72,7 @@ const createDataCollector = ({
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (datasetId) {
|
|
75
|
-
logger.warn("The 'datasetId' option has been deprecated. Please use 'edgeConfigOverrides.
|
|
75
|
+
logger.warn("The 'datasetId' option has been deprecated. Please use 'edgeConfigOverrides.com_adobe_experience_platform.datasets.event.datasetId' instead.");
|
|
76
76
|
sendEventOptions.edgeConfigOverrides = edgeConfigOverrides || {};
|
|
77
77
|
deepAssign(sendEventOptions.edgeConfigOverrides, {
|
|
78
78
|
com_adobe_experience_platform: {
|
|
@@ -116,5 +116,4 @@ const createDataCollector = ({
|
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
createDataCollector.namespace = "DataCollector";
|
|
119
|
-
createDataCollector.configValidators = {};
|
|
120
119
|
export default createDataCollector;
|
|
@@ -9,9 +9,9 @@ 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 { boolean } from "../../utils/validation";
|
|
13
|
-
const configValidators = {
|
|
12
|
+
import { boolean, objectOf } from "../../utils/validation";
|
|
13
|
+
const configValidators = objectOf({
|
|
14
14
|
thirdPartyCookiesEnabled: boolean().default(true),
|
|
15
15
|
idMigrationEnabled: boolean().default(true)
|
|
16
|
-
};
|
|
16
|
+
});
|
|
17
17
|
export default configValidators;
|
|
@@ -9,6 +9,7 @@ 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 { createRequestParams } from "../../../utils/request";
|
|
12
13
|
export default (({
|
|
13
14
|
sendEdgeNetworkRequest,
|
|
14
15
|
createIdentityRequestPayload,
|
|
@@ -19,11 +20,12 @@ export default (({
|
|
|
19
20
|
namespaces,
|
|
20
21
|
edgeConfigOverrides: localConfigOverrides
|
|
21
22
|
} = {}) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const requestParams = createRequestParams({
|
|
24
|
+
payload: createIdentityRequestPayload(namespaces),
|
|
25
|
+
globalConfigOverrides,
|
|
26
|
+
localConfigOverrides
|
|
27
|
+
});
|
|
28
|
+
const request = createIdentityRequest(requestParams);
|
|
27
29
|
return sendEdgeNetworkRequest({
|
|
28
30
|
request
|
|
29
31
|
});
|
|
@@ -10,9 +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
|
import { createRequest } from "../../../utils/request";
|
|
13
|
-
export default (
|
|
13
|
+
export default (({
|
|
14
|
+
payload,
|
|
15
|
+
datastreamIdOverride
|
|
16
|
+
}) => {
|
|
14
17
|
return createRequest({
|
|
15
|
-
payload
|
|
18
|
+
payload,
|
|
19
|
+
datastreamIdOverride,
|
|
16
20
|
|
|
17
21
|
getAction() {
|
|
18
22
|
return "identity/acquire";
|
|
@@ -9,7 +9,7 @@ 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 { string, boolean } from "../../utils/validation";
|
|
12
|
+
import { string, boolean, objectOf } from "../../utils/validation";
|
|
13
13
|
import createComponent from "./createComponent";
|
|
14
14
|
import { initDomActionsModules, executeActions } from "./dom-actions";
|
|
15
15
|
import createCollect from "./createCollect";
|
|
@@ -122,8 +122,8 @@ const createPersonalization = ({
|
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
createPersonalization.namespace = "Personalization";
|
|
125
|
-
createPersonalization.configValidators = {
|
|
125
|
+
createPersonalization.configValidators = objectOf({
|
|
126
126
|
prehidingStyle: string().nonEmpty(),
|
|
127
127
|
targetMigrationEnabled: boolean().default(false)
|
|
128
|
-
};
|
|
128
|
+
});
|
|
129
129
|
export default createPersonalization;
|
|
@@ -10,9 +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
|
import { createRequest } from "../../utils/request";
|
|
13
|
-
export default (
|
|
13
|
+
export default (({
|
|
14
|
+
payload,
|
|
15
|
+
datastreamIdOverride
|
|
16
|
+
}) => {
|
|
14
17
|
return createRequest({
|
|
15
|
-
payload
|
|
18
|
+
payload,
|
|
19
|
+
datastreamIdOverride,
|
|
16
20
|
|
|
17
21
|
getAction() {
|
|
18
22
|
return "privacy/set-consent";
|
|
@@ -10,6 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
import { isObject } from "../../utils";
|
|
13
|
+
import { createRequestParams } from "../../utils/request";
|
|
13
14
|
export default (({
|
|
14
15
|
createConsentRequestPayload,
|
|
15
16
|
createConsentRequest,
|
|
@@ -20,20 +21,22 @@ export default (({
|
|
|
20
21
|
identityMap,
|
|
21
22
|
edgeConfigOverrides: localConfigOverrides
|
|
22
23
|
}) => {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const requestParams = createRequestParams({
|
|
25
|
+
payload: createConsentRequestPayload(),
|
|
26
|
+
globalConfigOverrides,
|
|
27
|
+
localConfigOverrides
|
|
28
|
+
});
|
|
29
|
+
requestParams.payload.setConsent(consentOptions);
|
|
27
30
|
|
|
28
31
|
if (isObject(identityMap)) {
|
|
29
32
|
Object.keys(identityMap).forEach(key => {
|
|
30
33
|
identityMap[key].forEach(identity => {
|
|
31
|
-
payload.addIdentity(key, identity);
|
|
34
|
+
requestParams.payload.addIdentity(key, identity);
|
|
32
35
|
});
|
|
33
36
|
});
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
const request = createConsentRequest(
|
|
39
|
+
const request = createConsentRequest(requestParams);
|
|
37
40
|
return sendEdgeNetworkRequest({
|
|
38
41
|
request
|
|
39
42
|
}).then(() => {// Don't let response data disseminate beyond this
|
|
@@ -10,25 +10,18 @@ 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
|
import { assign } from "../utils";
|
|
13
|
-
import { objectOf } from "../utils/validation";
|
|
14
13
|
const CONFIG_DOC_URI = "https://adobe.ly/3sHh553";
|
|
15
14
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
configValidators
|
|
22
|
-
} = createComponent;
|
|
23
|
-
assign(schema, configValidators);
|
|
24
|
-
});
|
|
25
|
-
return schema;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const transformOptions = (schema, options) => {
|
|
15
|
+
const transformOptions = ({
|
|
16
|
+
combinedConfigValidator,
|
|
17
|
+
options,
|
|
18
|
+
logger
|
|
19
|
+
}) => {
|
|
29
20
|
try {
|
|
30
|
-
const validator =
|
|
31
|
-
return validator(
|
|
21
|
+
const validator = combinedConfigValidator.noUnknownFields().required();
|
|
22
|
+
return validator.call({
|
|
23
|
+
logger
|
|
24
|
+
}, options);
|
|
32
25
|
} catch (e) {
|
|
33
26
|
throw new Error(`Resolve these configuration problems:\n\t - ${e.message.split("\n").join("\n\t - ")}\nFor configuration documentation see: ${CONFIG_DOC_URI}`);
|
|
34
27
|
}
|
|
@@ -49,6 +42,32 @@ const buildAllOnInstanceConfiguredExtraParams = (config, logger, componentCreato
|
|
|
49
42
|
}, {});
|
|
50
43
|
};
|
|
51
44
|
|
|
45
|
+
const wrapLoggerInQueue = logger => {
|
|
46
|
+
const queue = [];
|
|
47
|
+
const queuedLogger = {
|
|
48
|
+
get enabled() {
|
|
49
|
+
return logger.enabled;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
flush() {
|
|
53
|
+
queue.forEach(({
|
|
54
|
+
method,
|
|
55
|
+
args
|
|
56
|
+
}) => logger[method](...args));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
};
|
|
60
|
+
Object.keys(logger).filter(key => typeof logger[key] === "function").forEach(method => {
|
|
61
|
+
queuedLogger[method] = (...args) => {
|
|
62
|
+
queue.push({
|
|
63
|
+
method,
|
|
64
|
+
args
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
return queuedLogger;
|
|
69
|
+
};
|
|
70
|
+
|
|
52
71
|
export default (({
|
|
53
72
|
options,
|
|
54
73
|
componentCreators,
|
|
@@ -57,11 +76,21 @@ export default (({
|
|
|
57
76
|
logger,
|
|
58
77
|
setDebugEnabled
|
|
59
78
|
}) => {
|
|
60
|
-
|
|
61
|
-
|
|
79
|
+
// We wrap the logger in a queue in case debugEnabled is set in the config
|
|
80
|
+
// but we need to log something before the config is created.
|
|
81
|
+
const queuedLogger = wrapLoggerInQueue(logger);
|
|
82
|
+
const combinedConfigValidator = componentCreators.map(({
|
|
83
|
+
configValidators
|
|
84
|
+
}) => configValidators).filter(configValidators => configValidators).reduce((validator, configValidators) => validator.concat(configValidators), coreConfigValidators);
|
|
85
|
+
const config = createConfig(transformOptions({
|
|
86
|
+
combinedConfigValidator,
|
|
87
|
+
options,
|
|
88
|
+
logger: queuedLogger
|
|
89
|
+
}));
|
|
62
90
|
setDebugEnabled(config.debugEnabled, {
|
|
63
91
|
fromConfig: true
|
|
64
|
-
});
|
|
92
|
+
});
|
|
93
|
+
queuedLogger.flush(); // eslint-disable-next-line no-underscore-dangle
|
|
65
94
|
|
|
66
95
|
const extraParams = buildAllOnInstanceConfiguredExtraParams(config, logger, componentCreators);
|
|
67
96
|
logger.logOnInstanceConfigured({ ...extraParams,
|
|
@@ -9,18 +9,18 @@ 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 { boolean, string, callback, enumOf } from "../../utils/validation";
|
|
12
|
+
import { boolean, string, callback, enumOf, objectOf } from "../../utils/validation";
|
|
13
13
|
import { noop, validateConfigOverride } from "../../utils";
|
|
14
14
|
import { EDGE as EDGE_DOMAIN } from "../../constants/domain";
|
|
15
15
|
import EDGE_BASE_PATH from "../../constants/edgeBasePath";
|
|
16
16
|
import { IN, OUT, PENDING } from "../../constants/consentStatus";
|
|
17
|
-
export default (() => ({
|
|
17
|
+
export default (() => objectOf({
|
|
18
18
|
debugEnabled: boolean().default(false),
|
|
19
19
|
defaultConsent: enumOf(IN, OUT, PENDING).default(IN),
|
|
20
|
-
|
|
20
|
+
datastreamId: string().unique().required(),
|
|
21
21
|
edgeDomain: string().domain().default(EDGE_DOMAIN),
|
|
22
22
|
edgeBasePath: string().nonEmpty().default(EDGE_BASE_PATH),
|
|
23
23
|
orgId: string().unique().required(),
|
|
24
24
|
onBeforeEventSend: callback().default(noop),
|
|
25
25
|
edgeConfigOverrides: validateConfigOverride
|
|
26
|
-
}));
|
|
26
|
+
}).deprecated("edgeConfigId", string().unique(), "datastreamId"));
|
|
@@ -11,6 +11,7 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
import PAGE_WIDE_SCOPE from "../constants/pageWideScope";
|
|
13
13
|
import { createCallbackAggregator, noop } from "../utils";
|
|
14
|
+
import { createRequestParams } from "../utils/request";
|
|
14
15
|
const EVENT_CANCELLATION_MESSAGE = "Event was canceled because the onBeforeEventSend callback returned false.";
|
|
15
16
|
export default (({
|
|
16
17
|
config,
|
|
@@ -44,6 +45,9 @@ export default (({
|
|
|
44
45
|
* @param {Object} [options.serverState]
|
|
45
46
|
* This will be passed to components
|
|
46
47
|
* so they can take appropriate action.
|
|
48
|
+
* @param {Object} [options.edgeConfigOverrides] Settings that take
|
|
49
|
+
* precedence over the global datastream configuration, including which
|
|
50
|
+
* datastream to use.
|
|
47
51
|
* @returns {*}
|
|
48
52
|
*/
|
|
49
53
|
sendEvent(event, options = {}) {
|
|
@@ -53,12 +57,14 @@ export default (({
|
|
|
53
57
|
edgeConfigOverrides: localConfigOverrides,
|
|
54
58
|
personalization
|
|
55
59
|
} = options;
|
|
56
|
-
const
|
|
57
|
-
|
|
60
|
+
const requestParams = createRequestParams({
|
|
61
|
+
payload: createDataCollectionRequestPayload(),
|
|
62
|
+
localConfigOverrides,
|
|
63
|
+
globalConfigOverrides
|
|
64
|
+
});
|
|
65
|
+
const request = createDataCollectionRequest(requestParams);
|
|
58
66
|
const onResponseCallbackAggregator = createCallbackAggregator();
|
|
59
67
|
const onRequestFailureCallbackAggregator = createCallbackAggregator();
|
|
60
|
-
payload.mergeConfigOverride(globalConfigOverrides);
|
|
61
|
-
payload.mergeConfigOverride(localConfigOverrides);
|
|
62
68
|
return lifecycle.onBeforeEvent({
|
|
63
69
|
event,
|
|
64
70
|
renderDecisions,
|
|
@@ -67,7 +73,7 @@ export default (({
|
|
|
67
73
|
onResponse: onResponseCallbackAggregator.add,
|
|
68
74
|
onRequestFailure: onRequestFailureCallbackAggregator.add
|
|
69
75
|
}).then(() => {
|
|
70
|
-
payload.addEvent(event);
|
|
76
|
+
requestParams.payload.addEvent(event);
|
|
71
77
|
return consent.awaitConsent();
|
|
72
78
|
}).then(() => {
|
|
73
79
|
try {
|
|
@@ -113,7 +119,9 @@ export default (({
|
|
|
113
119
|
}
|
|
114
120
|
} = options;
|
|
115
121
|
const payload = createDataCollectionRequestPayload();
|
|
116
|
-
const request = createDataCollectionRequest(
|
|
122
|
+
const request = createDataCollectionRequest({
|
|
123
|
+
payload
|
|
124
|
+
});
|
|
117
125
|
const onResponseCallbackAggregator = createCallbackAggregator();
|
|
118
126
|
return lifecycle.onBeforeEvent({
|
|
119
127
|
event,
|
|
@@ -27,7 +27,7 @@ export default (({
|
|
|
27
27
|
const {
|
|
28
28
|
edgeDomain,
|
|
29
29
|
edgeBasePath,
|
|
30
|
-
|
|
30
|
+
datastreamId
|
|
31
31
|
} = config;
|
|
32
32
|
/**
|
|
33
33
|
* Sends a network request that is aware of payload interfaces,
|
|
@@ -53,7 +53,8 @@ export default (({
|
|
|
53
53
|
const endpointDomain = request.getUseIdThirdPartyDomain() ? ID_THIRD_PARTY_DOMAIN : edgeDomain;
|
|
54
54
|
const locationHint = getLocationHint();
|
|
55
55
|
const edgeBasePathWithLocationHint = locationHint ? `${edgeBasePath}/${locationHint}` : edgeBasePath;
|
|
56
|
-
const
|
|
56
|
+
const configId = request.getDatastreamIdOverride() || datastreamId;
|
|
57
|
+
const url = `https://${endpointDomain}/${edgeBasePathWithLocationHint}/${apiVersion}/${request.getAction()}?configId=${configId}&requestId=${request.getId()}${getAssuranceValidationTokenParams()}`;
|
|
57
58
|
cookieTransfer.cookiesToPayload(request.getPayload(), endpointDomain);
|
|
58
59
|
return sendNetworkRequest({
|
|
59
60
|
requestId: request.getId(),
|
|
@@ -10,7 +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
|
import createRequest from "./createRequest";
|
|
13
|
-
export default (
|
|
13
|
+
export default (({
|
|
14
|
+
payload: dataCollectionRequestPayload,
|
|
15
|
+
datastreamIdOverride
|
|
16
|
+
}) => {
|
|
14
17
|
const getUseSendBeacon = ({
|
|
15
18
|
isIdentityEstablished
|
|
16
19
|
}) => {
|
|
@@ -62,6 +65,7 @@ export default (dataCollectionRequestPayload => {
|
|
|
62
65
|
}) ? "collect" : "interact";
|
|
63
66
|
},
|
|
64
67
|
|
|
65
|
-
getUseSendBeacon
|
|
68
|
+
getUseSendBeacon,
|
|
69
|
+
datastreamIdOverride
|
|
66
70
|
});
|
|
67
71
|
});
|
|
@@ -15,7 +15,8 @@ export default (options => {
|
|
|
15
15
|
const {
|
|
16
16
|
payload,
|
|
17
17
|
getAction,
|
|
18
|
-
getUseSendBeacon
|
|
18
|
+
getUseSendBeacon,
|
|
19
|
+
datastreamIdOverride
|
|
19
20
|
} = options;
|
|
20
21
|
const id = uuid();
|
|
21
22
|
let shouldUseThirdPartyDomain = false;
|
|
@@ -35,6 +36,10 @@ export default (options => {
|
|
|
35
36
|
});
|
|
36
37
|
},
|
|
37
38
|
|
|
39
|
+
getDatastreamIdOverride() {
|
|
40
|
+
return datastreamIdOverride;
|
|
41
|
+
},
|
|
42
|
+
|
|
38
43
|
getUseSendBeacon() {
|
|
39
44
|
return getUseSendBeacon({
|
|
40
45
|
isIdentityEstablished
|