@adobe/alloy 2.12.0-beta.0 → 2.13.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/attachClickActivityCollector.js +4 -9
- package/libEs5/components/ActivityCollector/createLinkClick.js +7 -1
- package/libEs5/components/Context/createComponent.js +7 -6
- package/libEs5/components/Context/index.js +17 -13
- package/libEs5/components/Context/injectHighEntropyUserAgentHints.js +55 -0
- package/libEs5/components/DataCollector/index.js +26 -0
- package/libEs5/components/DataCollector/validateApplyResponse.js +22 -0
- package/libEs5/components/DataCollector/validateUserEventOptions.js +5 -3
- package/libEs5/components/Identity/getIdentity/getIdentityOptionsValidator.js +1 -1
- package/libEs5/components/Personalization/constants/propositionEventType.js +20 -0
- package/libEs5/components/Personalization/createCollect.js +3 -1
- package/libEs5/components/Personalization/createComponent.js +19 -13
- package/libEs5/components/Personalization/createFetchDataHandler.js +1 -2
- package/libEs5/components/Personalization/createOnClickHandler.js +3 -1
- package/libEs5/components/Personalization/createSetTargetMigration.js +34 -0
- package/libEs5/components/Personalization/createViewChangeHandler.js +3 -1
- package/libEs5/components/Personalization/event.js +5 -2
- package/libEs5/components/Personalization/index.js +12 -3
- package/libEs5/constants/cookieNameKey.js +4 -2
- package/libEs5/constants/highEntropyUserAgentClientHints.js +17 -0
- package/libEs5/constants/legacyCookies.js +21 -0
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/createCookieTransfer.js +2 -9
- package/libEs5/core/createEventManager.js +32 -1
- package/libEs5/core/edgeNetwork/handleRequestFailure.js +20 -0
- package/libEs5/core/edgeNetwork/injectApplyResponse.js +62 -0
- package/libEs5/core/edgeNetwork/injectGetLocationHint.js +18 -1
- package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +14 -29
- package/libEs5/core/edgeNetwork/mergeLifecycleResponses.js +28 -0
- package/libEs5/core/index.js +19 -3
- package/libEs5/core/injectShouldTransferCookie.js +33 -0
- package/libEs5/utils/isUnique.js +38 -0
- package/libEs5/utils/request/createRequestPayload.js +1 -0
- package/libEs5/utils/validateIdentityMap.js +1 -1
- package/libEs5/utils/validation/createUniqueItemsValidator.js +26 -0
- package/libEs5/utils/validation/index.js +8 -1
- package/libEs6/components/ActivityCollector/attachClickActivityCollector.js +3 -8
- package/libEs6/components/ActivityCollector/createLinkClick.js +7 -1
- package/libEs6/components/Context/createComponent.js +4 -5
- package/libEs6/components/Context/index.js +10 -2
- package/libEs6/components/Context/injectHighEntropyUserAgentHints.js +46 -0
- package/libEs6/components/DataCollector/index.js +24 -0
- package/libEs6/components/DataCollector/validateApplyResponse.js +16 -0
- package/libEs6/components/DataCollector/validateUserEventOptions.js +5 -3
- package/libEs6/components/Identity/getIdentity/getIdentityOptionsValidator.js +1 -1
- package/libEs6/components/Personalization/constants/propositionEventType.js +15 -0
- package/libEs6/components/Personalization/createCollect.js +2 -1
- package/libEs6/components/Personalization/createComponent.js +9 -1
- package/libEs6/components/Personalization/createFetchDataHandler.js +1 -5
- package/libEs6/components/Personalization/createOnClickHandler.js +2 -1
- package/libEs6/components/Personalization/createSetTargetMigration.js +27 -0
- package/libEs6/components/Personalization/createViewChangeHandler.js +2 -1
- package/libEs6/components/Personalization/event.js +6 -2
- package/libEs6/components/Personalization/index.js +14 -4
- package/libEs6/constants/cookieNameKey.js +2 -1
- package/libEs6/constants/highEntropyUserAgentClientHints.js +12 -0
- package/libEs6/constants/legacyCookies.js +14 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/createCookieTransfer.js +3 -10
- package/libEs6/core/createEventManager.js +32 -2
- package/libEs6/core/edgeNetwork/handleRequestFailure.js +14 -0
- package/libEs6/core/edgeNetwork/injectApplyResponse.js +48 -0
- package/libEs6/core/edgeNetwork/injectGetLocationHint.js +17 -1
- package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +5 -21
- package/libEs6/core/edgeNetwork/mergeLifecycleResponses.js +9 -0
- package/libEs6/core/index.js +17 -3
- package/libEs6/core/injectShouldTransferCookie.js +24 -0
- package/libEs6/utils/isUnique.js +32 -0
- package/libEs6/utils/request/createRequestPayload.js +1 -0
- package/libEs6/utils/validateIdentityMap.js +1 -1
- package/libEs6/utils/validation/createUniqueItemsValidator.js +18 -0
- package/libEs6/utils/validation/index.js +7 -1
- package/package.json +4 -3
|
@@ -25,7 +25,8 @@ var _default = function _default(_ref) {
|
|
|
25
25
|
createEvent = _ref.createEvent,
|
|
26
26
|
createDataCollectionRequestPayload = _ref.createDataCollectionRequestPayload,
|
|
27
27
|
createDataCollectionRequest = _ref.createDataCollectionRequest,
|
|
28
|
-
sendEdgeNetworkRequest = _ref.sendEdgeNetworkRequest
|
|
28
|
+
sendEdgeNetworkRequest = _ref.sendEdgeNetworkRequest,
|
|
29
|
+
_applyResponse = _ref.applyResponse;
|
|
29
30
|
var onBeforeEventSend = config.onBeforeEventSend;
|
|
30
31
|
return {
|
|
31
32
|
createEvent: createEvent,
|
|
@@ -39,6 +40,7 @@ var _default = function _default(_ref) {
|
|
|
39
40
|
* @param {Object} [options]
|
|
40
41
|
* @param {boolean} [options.renderDecisions=false]
|
|
41
42
|
* @param {Array} [options.decisionScopes]
|
|
43
|
+
* @param {Object} [options.serverState]
|
|
42
44
|
* This will be passed to components
|
|
43
45
|
* so they can take appropriate action.
|
|
44
46
|
* @returns {*}
|
|
@@ -94,6 +96,35 @@ var _default = function _default(_ref) {
|
|
|
94
96
|
runOnRequestFailureCallbacks: onRequestFailureCallbackAggregator.call
|
|
95
97
|
});
|
|
96
98
|
});
|
|
99
|
+
},
|
|
100
|
+
applyResponse: function applyResponse(event) {
|
|
101
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
102
|
+
var _options$renderDecisi2 = options.renderDecisions,
|
|
103
|
+
renderDecisions = _options$renderDecisi2 === void 0 ? false : _options$renderDecisi2,
|
|
104
|
+
_options$responseHead = options.responseHeaders,
|
|
105
|
+
responseHeaders = _options$responseHead === void 0 ? {} : _options$responseHead,
|
|
106
|
+
_options$responseBody = options.responseBody,
|
|
107
|
+
responseBody = _options$responseBody === void 0 ? {
|
|
108
|
+
handle: []
|
|
109
|
+
} : _options$responseBody;
|
|
110
|
+
var payload = createDataCollectionRequestPayload();
|
|
111
|
+
var request = createDataCollectionRequest(payload);
|
|
112
|
+
var onResponseCallbackAggregator = (0, _utils.createCallbackAggregator)();
|
|
113
|
+
return lifecycle.onBeforeEvent({
|
|
114
|
+
event: event,
|
|
115
|
+
renderDecisions: renderDecisions,
|
|
116
|
+
decisionScopes: [],
|
|
117
|
+
onResponse: onResponseCallbackAggregator.add,
|
|
118
|
+
onRequestFailure: _utils.noop
|
|
119
|
+
}).then(function () {
|
|
120
|
+
payload.addEvent(event);
|
|
121
|
+
return _applyResponse({
|
|
122
|
+
request: request,
|
|
123
|
+
responseHeaders: responseHeaders,
|
|
124
|
+
responseBody: responseBody,
|
|
125
|
+
runOnResponseCallbacks: onResponseCallbackAggregator.call
|
|
126
|
+
});
|
|
127
|
+
});
|
|
97
128
|
}
|
|
98
129
|
};
|
|
99
130
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _default = function _default(onRequestFailureCallbackAggregator) {
|
|
6
|
+
return function (error) {
|
|
7
|
+
// Regardless of whether the network call failed, an unexpected status
|
|
8
|
+
// code was returned, or the response body was malformed, we want to call
|
|
9
|
+
// the onRequestFailure callbacks, but still throw the exception.
|
|
10
|
+
var throwError = function throwError() {
|
|
11
|
+
throw error;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return onRequestFailureCallbackAggregator.call({
|
|
15
|
+
error: error
|
|
16
|
+
}).then(throwError, throwError);
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.default = _default;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _utils = require("../../utils");
|
|
6
|
+
|
|
7
|
+
var _mergeLifecycleResponses = require("./mergeLifecycleResponses");
|
|
8
|
+
|
|
9
|
+
var _handleRequestFailure = require("./handleRequestFailure");
|
|
10
|
+
|
|
11
|
+
var HTTP_STATUS_OK = 200;
|
|
12
|
+
|
|
13
|
+
var _default = function _default(_ref) {
|
|
14
|
+
var cookieTransfer = _ref.cookieTransfer,
|
|
15
|
+
lifecycle = _ref.lifecycle,
|
|
16
|
+
createResponse = _ref.createResponse,
|
|
17
|
+
processWarningsAndErrors = _ref.processWarningsAndErrors;
|
|
18
|
+
return function (_ref2) {
|
|
19
|
+
var request = _ref2.request,
|
|
20
|
+
responseHeaders = _ref2.responseHeaders,
|
|
21
|
+
responseBody = _ref2.responseBody,
|
|
22
|
+
_ref2$runOnResponseCa = _ref2.runOnResponseCallbacks,
|
|
23
|
+
runOnResponseCallbacks = _ref2$runOnResponseCa === void 0 ? _utils.noop : _ref2$runOnResponseCa,
|
|
24
|
+
_ref2$runOnRequestFai = _ref2.runOnRequestFailureCallbacks,
|
|
25
|
+
runOnRequestFailureCallbacks = _ref2$runOnRequestFai === void 0 ? _utils.noop : _ref2$runOnRequestFai;
|
|
26
|
+
var onResponseCallbackAggregator = (0, _utils.createCallbackAggregator)();
|
|
27
|
+
onResponseCallbackAggregator.add(lifecycle.onResponse);
|
|
28
|
+
onResponseCallbackAggregator.add(runOnResponseCallbacks);
|
|
29
|
+
var onRequestFailureCallbackAggregator = (0, _utils.createCallbackAggregator)();
|
|
30
|
+
onRequestFailureCallbackAggregator.add(lifecycle.onRequestFailure);
|
|
31
|
+
onRequestFailureCallbackAggregator.add(runOnRequestFailureCallbacks);
|
|
32
|
+
|
|
33
|
+
var getHeader = function getHeader(key) {
|
|
34
|
+
return responseHeaders[key];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return lifecycle.onBeforeRequest({
|
|
38
|
+
request: request,
|
|
39
|
+
onResponse: onResponseCallbackAggregator.add,
|
|
40
|
+
onRequestFailure: onRequestFailureCallbackAggregator.add
|
|
41
|
+
}).then(function () {
|
|
42
|
+
return processWarningsAndErrors({
|
|
43
|
+
statusCode: HTTP_STATUS_OK,
|
|
44
|
+
getHeader: getHeader,
|
|
45
|
+
body: JSON.stringify(responseBody),
|
|
46
|
+
parsedBody: responseBody
|
|
47
|
+
});
|
|
48
|
+
}).catch((0, _handleRequestFailure.default)(onRequestFailureCallbackAggregator)).then(function () {
|
|
49
|
+
var response = createResponse({
|
|
50
|
+
content: responseBody,
|
|
51
|
+
getHeader: getHeader
|
|
52
|
+
}); // This will clobber any cookies set via HTTP from the server. So care should be given to remove any state:store handles if that is not desirable
|
|
53
|
+
|
|
54
|
+
cookieTransfer.responseToCookies(response);
|
|
55
|
+
return onResponseCallbackAggregator.call({
|
|
56
|
+
response: response
|
|
57
|
+
}).then(_mergeLifecycleResponses.default);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
exports.default = _default;
|
|
@@ -6,6 +6,8 @@ var _utils = require("../../utils");
|
|
|
6
6
|
|
|
7
7
|
var _cookieNameKey = require("../../constants/cookieNameKey");
|
|
8
8
|
|
|
9
|
+
var _legacyCookies = require("../../constants/legacyCookies");
|
|
10
|
+
|
|
9
11
|
/*
|
|
10
12
|
Copyright 2022 Adobe. All rights reserved.
|
|
11
13
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -21,9 +23,24 @@ var _default = function _default(_ref) {
|
|
|
21
23
|
var orgId = _ref.orgId,
|
|
22
24
|
cookieJar = _ref.cookieJar;
|
|
23
25
|
var clusterCookieName = (0, _utils.getNamespacedCookieName)(orgId, _cookieNameKey.CLUSTER);
|
|
24
|
-
|
|
26
|
+
|
|
27
|
+
var fromClusterCookie = function fromClusterCookie() {
|
|
25
28
|
return cookieJar.get(clusterCookieName);
|
|
26
29
|
};
|
|
30
|
+
|
|
31
|
+
var fromTarget = function fromTarget() {
|
|
32
|
+
var mboxEdgeCluster = cookieJar.get(_legacyCookies.MBOX_EDGE_CLUSTER);
|
|
33
|
+
|
|
34
|
+
if (mboxEdgeCluster) {
|
|
35
|
+
return "t" + mboxEdgeCluster;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return undefined;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return function () {
|
|
42
|
+
return fromClusterCookie() || fromTarget();
|
|
43
|
+
};
|
|
27
44
|
};
|
|
28
45
|
|
|
29
46
|
exports.default = _default;
|
|
@@ -8,18 +8,21 @@ var _apiVersion = require("../../constants/apiVersion");
|
|
|
8
8
|
|
|
9
9
|
var _utils = require("../../utils");
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
var _mergeLifecycleResponses = require("./mergeLifecycleResponses");
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
var _handleRequestFailure = require("./handleRequestFailure");
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
+
/*
|
|
16
|
+
Copyright 2019 Adobe. All rights reserved.
|
|
17
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
19
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
20
|
|
|
21
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
22
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
23
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
24
|
+
governing permissions and limitations under the License.
|
|
25
|
+
*/
|
|
23
26
|
var _default = function _default(_ref) {
|
|
24
27
|
var config = _ref.config,
|
|
25
28
|
lifecycle = _ref.lifecycle,
|
|
@@ -67,18 +70,7 @@ var _default = function _default(_ref) {
|
|
|
67
70
|
}).then(function (networkResponse) {
|
|
68
71
|
processWarningsAndErrors(networkResponse);
|
|
69
72
|
return networkResponse;
|
|
70
|
-
}).catch(function (
|
|
71
|
-
// Regardless of whether the network call failed, an unexpected status
|
|
72
|
-
// code was returned, or the response body was malformed, we want to call
|
|
73
|
-
// the onRequestFailure callbacks, but still throw the exception.
|
|
74
|
-
var throwError = function throwError() {
|
|
75
|
-
throw error;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return onRequestFailureCallbackAggregator.call({
|
|
79
|
-
error: error
|
|
80
|
-
}).then(throwError, throwError);
|
|
81
|
-
}).then(function (_ref3) {
|
|
73
|
+
}).catch((0, _handleRequestFailure.default)(onRequestFailureCallbackAggregator)).then(function (_ref3) {
|
|
82
74
|
var parsedBody = _ref3.parsedBody,
|
|
83
75
|
getHeader = _ref3.getHeader;
|
|
84
76
|
// Note that networkResponse.parsedBody may be undefined if it was a
|
|
@@ -94,14 +86,7 @@ var _default = function _default(_ref) {
|
|
|
94
86
|
|
|
95
87
|
return onResponseCallbackAggregator.call({
|
|
96
88
|
response: response
|
|
97
|
-
}).then(
|
|
98
|
-
// Merges all returned objects from all `onResponse` callbacks into
|
|
99
|
-
// a single object that can later be returned to the customer.
|
|
100
|
-
var lifecycleOnResponseReturnValues = returnValues.shift() || [];
|
|
101
|
-
var consumerOnResponseReturnValues = returnValues.shift() || [];
|
|
102
|
-
var lifecycleOnBeforeRequestReturnValues = returnValues;
|
|
103
|
-
return _utils.assign.apply(void 0, [{}].concat(_toConsumableArray(lifecycleOnResponseReturnValues), _toConsumableArray(consumerOnResponseReturnValues), _toConsumableArray(lifecycleOnBeforeRequestReturnValues)));
|
|
104
|
-
});
|
|
89
|
+
}).then(_mergeLifecycleResponses.default);
|
|
105
90
|
});
|
|
106
91
|
};
|
|
107
92
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _utils = require("../../utils");
|
|
6
|
+
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
+
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
|
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
18
|
+
|
|
19
|
+
var _default = function _default(returnValues) {
|
|
20
|
+
// Merges all returned objects from all `onResponse` callbacks into
|
|
21
|
+
// a single object that can later be returned to the customer.
|
|
22
|
+
var lifecycleOnResponseReturnValues = returnValues.shift() || [];
|
|
23
|
+
var consumerOnResponseReturnValues = returnValues.shift() || [];
|
|
24
|
+
var lifecycleOnBeforeRequestReturnValues = returnValues;
|
|
25
|
+
return _utils.assign.apply(void 0, [{}].concat(_toConsumableArray(lifecycleOnResponseReturnValues), _toConsumableArray(consumerOnResponseReturnValues), _toConsumableArray(lifecycleOnBeforeRequestReturnValues)));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.default = _default;
|
package/libEs5/core/index.js
CHANGED
|
@@ -52,6 +52,8 @@ var _createEventManager = require("./createEventManager");
|
|
|
52
52
|
|
|
53
53
|
var _createCookieTransfer = require("./createCookieTransfer");
|
|
54
54
|
|
|
55
|
+
var _injectShouldTransferCookie = require("./injectShouldTransferCookie");
|
|
56
|
+
|
|
55
57
|
var _request = require("../utils/request");
|
|
56
58
|
|
|
57
59
|
var _injectSendEdgeNetworkRequest = require("./edgeNetwork/injectSendEdgeNetworkRequest");
|
|
@@ -64,6 +66,8 @@ var _isRequestRetryable = require("./network/isRequestRetryable");
|
|
|
64
66
|
|
|
65
67
|
var _getRequestRetryDelay = require("./network/getRequestRetryDelay");
|
|
66
68
|
|
|
69
|
+
var _injectApplyResponse = require("./edgeNetwork/injectApplyResponse");
|
|
70
|
+
|
|
67
71
|
/*
|
|
68
72
|
Copyright 2019 Adobe. All rights reserved.
|
|
69
73
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -125,10 +129,15 @@ var createExecuteCommand = function createExecuteCommand(_ref) {
|
|
|
125
129
|
logger: logger,
|
|
126
130
|
setDebugEnabled: setDebugEnabled
|
|
127
131
|
});
|
|
128
|
-
var orgId = config.orgId
|
|
132
|
+
var orgId = config.orgId,
|
|
133
|
+
targetMigrationEnabled = config.targetMigrationEnabled;
|
|
134
|
+
var shouldTransferCookie = (0, _injectShouldTransferCookie.default)({
|
|
135
|
+
orgId: orgId,
|
|
136
|
+
targetMigrationEnabled: targetMigrationEnabled
|
|
137
|
+
});
|
|
129
138
|
var cookieTransfer = (0, _createCookieTransfer.default)({
|
|
130
139
|
cookieJar: loggingCookieJar,
|
|
131
|
-
|
|
140
|
+
shouldTransferCookie: shouldTransferCookie,
|
|
132
141
|
apexDomain: apexDomain,
|
|
133
142
|
dateProvider: function dateProvider() {
|
|
134
143
|
return new Date();
|
|
@@ -170,6 +179,12 @@ var createExecuteCommand = function createExecuteCommand(_ref) {
|
|
|
170
179
|
processWarningsAndErrors: processWarningsAndErrors,
|
|
171
180
|
getLocationHint: getLocationHint
|
|
172
181
|
});
|
|
182
|
+
var applyResponse = (0, _injectApplyResponse.default)({
|
|
183
|
+
lifecycle: lifecycle,
|
|
184
|
+
cookieTransfer: cookieTransfer,
|
|
185
|
+
createResponse: createResponse,
|
|
186
|
+
processWarningsAndErrors: processWarningsAndErrors
|
|
187
|
+
});
|
|
173
188
|
var generalConsentState = (0, _createConsentStateMachine.default)({
|
|
174
189
|
logger: logger
|
|
175
190
|
});
|
|
@@ -185,7 +200,8 @@ var createExecuteCommand = function createExecuteCommand(_ref) {
|
|
|
185
200
|
createEvent: _createEvent.default,
|
|
186
201
|
createDataCollectionRequestPayload: _request.createDataCollectionRequestPayload,
|
|
187
202
|
createDataCollectionRequest: _request.createDataCollectionRequest,
|
|
188
|
-
sendEdgeNetworkRequest: sendEdgeNetworkRequest
|
|
203
|
+
sendEdgeNetworkRequest: sendEdgeNetworkRequest,
|
|
204
|
+
applyResponse: applyResponse
|
|
189
205
|
});
|
|
190
206
|
return (0, _initializeComponents.default)({
|
|
191
207
|
componentCreators: _componentCreators.default,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _utils = require("../utils");
|
|
6
|
+
|
|
7
|
+
var _legacyCookies = require("../constants/legacyCookies");
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
11
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var _default = function _default(_ref) {
|
|
21
|
+
var orgId = _ref.orgId,
|
|
22
|
+
targetMigrationEnabled = _ref.targetMigrationEnabled;
|
|
23
|
+
return function (name) {
|
|
24
|
+
// We have a contract with the server that we will pass
|
|
25
|
+
// all cookies whose names are namespaced according to the
|
|
26
|
+
// logic in isNamespacedCookieName as well as any legacy
|
|
27
|
+
// cookie names (so that the server can handle migrating
|
|
28
|
+
// identities on websites previously using Visitor.js)
|
|
29
|
+
return (0, _utils.isNamespacedCookieName)(orgId, name) || name === _legacyCookies.AT_QA_MODE || targetMigrationEnabled && name === _legacyCookies.MBOX;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.default = _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns whether an array contains unique values.
|
|
19
|
+
* @param {*} value
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
var _default = function _default(values) {
|
|
23
|
+
var storedVals = Object.create(null);
|
|
24
|
+
|
|
25
|
+
for (var i = 0; i < values.length; i += 1) {
|
|
26
|
+
var item = values[i];
|
|
27
|
+
|
|
28
|
+
if (item in storedVals) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
storedVals[item] = true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.default = _default;
|
|
@@ -22,6 +22,7 @@ var _default = function _default(options) {
|
|
|
22
22
|
addIdentity = options.addIdentity,
|
|
23
23
|
hasIdentity = options.hasIdentity;
|
|
24
24
|
return {
|
|
25
|
+
mergeMeta: (0, _.createMerger)(content, "meta"),
|
|
25
26
|
mergeState: (0, _.createMerger)(content, "meta.state"),
|
|
26
27
|
mergeQuery: (0, _.createMerger)(content, "query"),
|
|
27
28
|
addIdentity: addIdentity,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _assertValid = require("./assertValid");
|
|
6
|
+
|
|
7
|
+
var _isUnique = require("../isUnique");
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
11
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var _default = function _default() {
|
|
21
|
+
return function (value, path) {
|
|
22
|
+
(0, _assertValid.default)((0, _isUnique.default)(value), value, path, "array values to be unique");
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.default = _default;
|
|
@@ -30,6 +30,8 @@ var _createAnyOfValidator = require("./createAnyOfValidator");
|
|
|
30
30
|
|
|
31
31
|
var _createUniqueValidator = require("./createUniqueValidator");
|
|
32
32
|
|
|
33
|
+
var _createUniqueItemsValidator = require("./createUniqueItemsValidator");
|
|
34
|
+
|
|
33
35
|
var _domainValidator = require("./domainValidator");
|
|
34
36
|
|
|
35
37
|
var _integerValidator = require("./integerValidator");
|
|
@@ -106,6 +108,10 @@ var regexp = function regexp() {
|
|
|
106
108
|
|
|
107
109
|
var unique = function createUnique() {
|
|
108
110
|
return (0, _nullSafeChain.default)(this, (0, _createUniqueValidator.default)());
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
var uniqueItems = function createUniqueItems() {
|
|
114
|
+
return (0, _nullSafeChain.default)(this, (0, _createUniqueItemsValidator.default)());
|
|
109
115
|
}; // top-level validators. These are the first functions that are called to create a validator.
|
|
110
116
|
|
|
111
117
|
|
|
@@ -121,7 +127,8 @@ var anything = function anything() {
|
|
|
121
127
|
|
|
122
128
|
var arrayOf = function arrayOf(elementValidator) {
|
|
123
129
|
return (0, _nullSafeChain.default)(this, (0, _createArrayOfValidator.default)(elementValidator), {
|
|
124
|
-
nonEmpty: nonEmptyArray
|
|
130
|
+
nonEmpty: nonEmptyArray,
|
|
131
|
+
uniqueItems: uniqueItems
|
|
125
132
|
});
|
|
126
133
|
};
|
|
127
134
|
|
|
@@ -19,7 +19,9 @@ const createClickHandler = ({
|
|
|
19
19
|
return clickEvent => {
|
|
20
20
|
// TODO: Consider safeguarding from the same object being clicked multiple times in rapid succession?
|
|
21
21
|
const clickedElement = clickEvent.target;
|
|
22
|
-
const event = eventManager.createEvent();
|
|
22
|
+
const event = eventManager.createEvent(); // this is to make sure a exit link personalization metric use send beacon
|
|
23
|
+
|
|
24
|
+
event.documentMayUnload();
|
|
23
25
|
return lifecycle.onClick({
|
|
24
26
|
event,
|
|
25
27
|
clickedElement
|
|
@@ -38,17 +40,10 @@ const createClickHandler = ({
|
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
export default (({
|
|
41
|
-
config,
|
|
42
43
|
eventManager,
|
|
43
44
|
lifecycle,
|
|
44
45
|
handleError
|
|
45
46
|
}) => {
|
|
46
|
-
const enabled = config.clickCollectionEnabled;
|
|
47
|
-
|
|
48
|
-
if (!enabled) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
47
|
const clickHandler = createClickHandler({
|
|
53
48
|
eventManager,
|
|
54
49
|
lifecycle,
|
|
@@ -39,8 +39,14 @@ const findSupportedAnchorElement = targetElement => {
|
|
|
39
39
|
|
|
40
40
|
export default ((window, config) => {
|
|
41
41
|
return (event, targetElement) => {
|
|
42
|
-
|
|
42
|
+
const clickCollectionEnabled = config.clickCollectionEnabled;
|
|
43
|
+
|
|
44
|
+
if (!clickCollectionEnabled) {
|
|
45
|
+
return;
|
|
46
|
+
} // Search parent elements for an anchor element
|
|
43
47
|
// TODO: Replace with generic DOM tool that can fetch configured properties
|
|
48
|
+
|
|
49
|
+
|
|
44
50
|
const anchorElement = findSupportedAnchorElement(targetElement);
|
|
45
51
|
|
|
46
52
|
if (!anchorElement) {
|
|
@@ -10,11 +10,11 @@ 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 { flatMap } from "../../utils";
|
|
13
|
-
export default ((config, logger,
|
|
13
|
+
export default ((config, logger, optionalContexts, requiredContexts) => {
|
|
14
14
|
const configuredContexts = config.context;
|
|
15
15
|
const contexts = flatMap(configuredContexts, (context, i) => {
|
|
16
|
-
if (
|
|
17
|
-
return [
|
|
16
|
+
if (optionalContexts[context]) {
|
|
17
|
+
return [optionalContexts[context]];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
logger.warn(`Invalid context[${i}]: '${context}' is not available.`);
|
|
@@ -27,8 +27,7 @@ export default ((config, logger, availableContexts, requiredContexts) => {
|
|
|
27
27
|
event
|
|
28
28
|
}) {
|
|
29
29
|
const xdm = {};
|
|
30
|
-
contexts.
|
|
31
|
-
event.mergeXdm(xdm);
|
|
30
|
+
return Promise.all(contexts.map(context => Promise.resolve(context(xdm, logger)))).then(() => event.mergeXdm(xdm));
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
}
|
|
@@ -16,18 +16,26 @@ import injectPlaceContext from "./injectPlaceContext";
|
|
|
16
16
|
import injectTimestamp from "./injectTimestamp";
|
|
17
17
|
import implementationDetails from "./implementationDetails";
|
|
18
18
|
import createComponent from "./createComponent";
|
|
19
|
+
import injectHighEntropyUserAgentHints from "./injectHighEntropyUserAgentHints";
|
|
19
20
|
import { arrayOf, string } from "../../utils/validation";
|
|
20
21
|
const web = injectWeb(window);
|
|
21
22
|
const device = injectDevice(window);
|
|
22
23
|
const environment = injectEnvironment(window);
|
|
23
24
|
const placeContext = injectPlaceContext(() => new Date());
|
|
24
25
|
const timestamp = injectTimestamp(() => new Date());
|
|
25
|
-
const
|
|
26
|
+
const highEntropyUserAgentHints = injectHighEntropyUserAgentHints(navigator);
|
|
27
|
+
const defaultEnabledContexts = {
|
|
26
28
|
web,
|
|
27
29
|
device,
|
|
28
30
|
environment,
|
|
29
31
|
placeContext
|
|
30
32
|
};
|
|
33
|
+
const defaultDisabledContexts = {
|
|
34
|
+
highEntropyUserAgentHints
|
|
35
|
+
};
|
|
36
|
+
const optionalContexts = { ...defaultEnabledContexts,
|
|
37
|
+
...defaultDisabledContexts
|
|
38
|
+
};
|
|
31
39
|
const requiredContexts = [timestamp, implementationDetails];
|
|
32
40
|
|
|
33
41
|
const createContext = ({
|
|
@@ -39,6 +47,6 @@ const createContext = ({
|
|
|
39
47
|
|
|
40
48
|
createContext.namespace = "Context";
|
|
41
49
|
createContext.configValidators = {
|
|
42
|
-
context: arrayOf(string()).default(Object.keys(
|
|
50
|
+
context: arrayOf(string()).default(Object.keys(defaultEnabledContexts))
|
|
43
51
|
};
|
|
44
52
|
export default createContext;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 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 { deepAssign, noop } from "../../utils";
|
|
13
|
+
import highEntropyUserAgentHints from "../../constants/highEntropyUserAgentClientHints";
|
|
14
|
+
|
|
15
|
+
const browserSupportsUserAgentClientHints = navigator => {
|
|
16
|
+
return typeof navigator.userAgentData !== "undefined";
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default (navigator => {
|
|
20
|
+
if (!browserSupportsUserAgentClientHints(navigator)) {
|
|
21
|
+
return noop;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (xdm, logger) => {
|
|
25
|
+
try {
|
|
26
|
+
return navigator.userAgentData.getHighEntropyValues(highEntropyUserAgentHints).then(hints => {
|
|
27
|
+
const userAgentClientHints = {};
|
|
28
|
+
highEntropyUserAgentHints.forEach(hint => {
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(hints, hint)) {
|
|
30
|
+
userAgentClientHints[hint] = hints[hint];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
deepAssign(xdm, {
|
|
34
|
+
environment: {
|
|
35
|
+
browserDetails: {
|
|
36
|
+
userAgentClientHints
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
logger.warn(`Unable to collect user-agent client hints. ${error.message}`);
|
|
43
|
+
return noop;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|