@adobe/alloy 2.29.0-beta.1 → 2.29.0-beta.14
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/utils/dom/findClickableElement.js +4 -0
- package/libEs5/components/Advertising/createComponent.js +1 -5
- package/libEs5/components/Advertising/handlers/clickThroughHandler.js +2 -1
- package/libEs5/components/Advertising/handlers/sendAdConversion.js +6 -8
- package/libEs5/components/Advertising/handlers/viewThroughHandler.js +4 -3
- package/libEs5/components/Consent/createConsentRequestPayload.js +14 -3
- package/libEs5/components/Consent/types.js +18 -0
- package/libEs5/components/Identity/createComponent.js +5 -4
- package/libEs5/components/Identity/index.js +4 -9
- package/libEs5/components/Personalization/dom-actions/action.js +7 -4
- package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +10 -10
- package/libEs5/components/PushNotifications/helpers/getPushSubscriptionDetails.js +116 -0
- package/libEs5/components/PushNotifications/index.js +96 -0
- package/libEs5/components/PushNotifications/request/createSendPushSubscriptionPayload.js +62 -0
- package/libEs5/components/PushNotifications/request/createSendPushSubscriptionRequest.js +35 -0
- package/libEs5/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +88 -0
- package/libEs5/components/PushNotifications/types.js +14 -0
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/componentCreators.js +8 -1
- package/libEs5/core/consent/createConsent.js +10 -0
- package/libEs5/core/consent/createConsentStateMachine.js +36 -0
- package/libEs5/core/consent/types.js +24 -0
- package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +20 -0
- package/libEs5/core/edgeNetwork/types.js +10 -0
- package/libEs5/core/identity/createIdentity.js +82 -0
- package/libEs5/core/identity/types.js +15 -0
- package/libEs5/core/index.js +8 -0
- package/libEs5/core/injectCreateResponse.js +9 -7
- package/libEs5/core/types.js +101 -11
- package/libEs5/utils/bytes.js +49 -0
- package/libEs5/{components/Identity → utils}/createDecodeKndctrCookie.js +12 -20
- package/libEs5/utils/createLoggingCookieJar.js +14 -1
- package/libEs5/utils/createMerger.js +5 -4
- package/libEs5/utils/index.js +13 -0
- package/libEs5/utils/injectStorage.js +19 -0
- package/libEs5/utils/request/createDataCollectionRequestPayload.js +16 -8
- package/libEs5/utils/request/createRequest.js +28 -1
- package/libEs5/utils/request/createRequestPayload.js +68 -4
- package/libEs5/utils/request/types.js +52 -0
- package/libEs5/utils/types.js +39 -0
- package/libEs6/components/ActivityCollector/utils/dom/findClickableElement.js +4 -0
- package/libEs6/components/Advertising/createComponent.js +1 -5
- package/libEs6/components/Advertising/handlers/clickThroughHandler.js +2 -1
- package/libEs6/components/Advertising/handlers/sendAdConversion.js +6 -8
- package/libEs6/components/Advertising/handlers/viewThroughHandler.js +4 -3
- package/libEs6/components/Consent/createConsentRequestPayload.js +16 -3
- package/libEs6/components/Consent/types.js +15 -0
- package/libEs6/components/Identity/createComponent.js +5 -4
- package/libEs6/components/Identity/index.js +4 -9
- package/libEs6/components/Personalization/dom-actions/action.js +7 -4
- package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +10 -10
- package/libEs6/components/PushNotifications/helpers/getPushSubscriptionDetails.js +114 -0
- package/libEs6/components/PushNotifications/index.js +93 -0
- package/libEs6/components/PushNotifications/request/createSendPushSubscriptionPayload.js +61 -0
- package/libEs6/components/PushNotifications/request/createSendPushSubscriptionRequest.js +34 -0
- package/libEs6/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +84 -0
- package/libEs6/components/PushNotifications/types.js +11 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/componentCreators.js +2 -1
- package/libEs6/core/consent/createConsent.js +12 -0
- package/libEs6/core/consent/createConsentStateMachine.js +36 -0
- package/libEs6/core/consent/types.js +21 -0
- package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +20 -0
- package/libEs6/core/edgeNetwork/types.js +7 -0
- package/libEs6/core/identity/createIdentity.js +81 -0
- package/libEs6/core/identity/types.js +12 -0
- package/libEs6/core/index.js +8 -0
- package/libEs6/core/injectCreateResponse.js +11 -7
- package/libEs6/core/types.js +101 -11
- package/libEs6/utils/bytes.js +44 -0
- package/libEs6/{components/Identity → utils}/createDecodeKndctrCookie.js +11 -19
- package/libEs6/utils/createLoggingCookieJar.js +15 -1
- package/libEs6/utils/createMerger.js +5 -4
- package/libEs6/utils/index.js +1 -0
- package/libEs6/utils/injectStorage.js +20 -0
- package/libEs6/utils/request/createDataCollectionRequestPayload.js +19 -8
- package/libEs6/utils/request/createRequest.js +29 -1
- package/libEs6/utils/request/createRequestPayload.js +67 -4
- package/libEs6/utils/request/types.js +49 -0
- package/libEs6/utils/types.js +36 -0
- package/package.json +30 -30
- package/types/components/ActivityCollector/utils/dom/findClickableElement.d.ts.map +1 -1
- package/types/components/Advertising/createComponent.d.ts +1 -1
- package/types/components/Advertising/createComponent.d.ts.map +1 -1
- package/types/components/Advertising/handlers/sendAdConversion.d.ts.map +1 -1
- package/types/components/Advertising/handlers/viewThroughHandler.d.ts.map +1 -1
- package/types/components/Advertising/index.d.ts +1 -1
- package/types/components/Consent/createConsentRequest.d.ts +1 -11
- package/types/components/Consent/createConsentRequest.d.ts.map +1 -1
- package/types/components/Consent/createConsentRequestPayload.d.ts +2 -9
- package/types/components/Consent/createConsentRequestPayload.d.ts.map +1 -1
- package/types/components/Consent/types.d.ts +28 -0
- package/types/components/Consent/types.d.ts.map +1 -0
- package/types/components/Identity/createComponent.d.ts +2 -2
- package/types/components/Identity/createComponent.d.ts.map +1 -1
- package/types/components/Identity/getIdentity/createIdentityRequest.d.ts +1 -11
- package/types/components/Identity/getIdentity/createIdentityRequest.d.ts.map +1 -1
- package/types/components/Identity/getIdentity/createIdentityRequestPayload.d.ts +1 -9
- package/types/components/Identity/getIdentity/createIdentityRequestPayload.d.ts.map +1 -1
- package/types/components/Identity/index.d.ts +2 -1
- package/types/components/Identity/index.d.ts.map +1 -1
- package/types/components/Personalization/dom-actions/action.d.ts +1 -1
- package/types/components/Personalization/dom-actions/action.d.ts.map +1 -1
- package/types/components/PushNotifications/helpers/getPushSubscriptionDetails.d.ts +30 -0
- package/types/components/PushNotifications/helpers/getPushSubscriptionDetails.d.ts.map +1 -0
- package/types/components/PushNotifications/index.d.ts +43 -0
- package/types/components/PushNotifications/index.d.ts.map +1 -0
- package/types/components/PushNotifications/request/createSendPushSubscriptionPayload.d.ts +10 -0
- package/types/components/PushNotifications/request/createSendPushSubscriptionPayload.d.ts.map +1 -0
- package/types/components/PushNotifications/request/createSendPushSubscriptionRequest.d.ts +7 -0
- package/types/components/PushNotifications/request/createSendPushSubscriptionRequest.d.ts.map +1 -0
- package/types/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts +20 -0
- package/types/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts.map +1 -0
- package/types/components/PushNotifications/types.d.ts +23 -0
- package/types/components/PushNotifications/types.d.ts.map +1 -0
- package/types/components/StreamingMedia/createMediaRequest.d.ts +1 -11
- package/types/components/StreamingMedia/createMediaRequest.d.ts.map +1 -1
- package/types/core/componentCreators.d.ts +1 -0
- package/types/core/consent/createConsent.d.ts +4 -10
- package/types/core/consent/createConsent.d.ts.map +1 -1
- package/types/core/consent/createConsentStateMachine.d.ts +4 -12
- package/types/core/consent/createConsentStateMachine.d.ts.map +1 -1
- package/types/core/consent/types.d.ts +42 -0
- package/types/core/consent/types.d.ts.map +1 -0
- package/types/core/edgeNetwork/injectSendEdgeNetworkRequest.d.ts +15 -13
- package/types/core/edgeNetwork/injectSendEdgeNetworkRequest.d.ts.map +1 -1
- package/types/core/edgeNetwork/types.d.ts +12 -0
- package/types/core/edgeNetwork/types.d.ts.map +1 -0
- package/types/core/identity/createIdentity.d.ts +12 -0
- package/types/core/identity/createIdentity.d.ts.map +1 -0
- package/types/core/identity/types.d.ts +23 -0
- package/types/core/identity/types.d.ts.map +1 -0
- package/types/core/index.d.ts.map +1 -1
- package/types/core/injectCreateResponse.d.ts +3 -27
- package/types/core/injectCreateResponse.d.ts.map +1 -1
- package/types/core/types.d.ts +209 -22
- package/types/core/types.d.ts.map +1 -1
- package/types/utils/bytes.d.ts +5 -0
- package/types/utils/bytes.d.ts.map +1 -0
- package/types/utils/createDecodeKndctrCookie.d.ts.map +1 -0
- package/types/utils/createLoggingCookieJar.d.ts +5 -3
- package/types/utils/createLoggingCookieJar.d.ts.map +1 -1
- package/types/utils/createMerger.d.ts +1 -1
- package/types/utils/createMerger.d.ts.map +1 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/injectStorage.d.ts +2 -40
- package/types/utils/injectStorage.d.ts.map +1 -1
- package/types/utils/request/createDataCollectionRequest.d.ts +1 -11
- package/types/utils/request/createDataCollectionRequest.d.ts.map +1 -1
- package/types/utils/request/createDataCollectionRequestPayload.d.ts +2 -9
- package/types/utils/request/createDataCollectionRequestPayload.d.ts.map +1 -1
- package/types/utils/request/createRequest.d.ts +13 -11
- package/types/utils/request/createRequest.d.ts.map +1 -1
- package/types/utils/request/createRequestPayload.d.ts +7 -9
- package/types/utils/request/createRequestPayload.d.ts.map +1 -1
- package/types/utils/request/types.d.ts +91 -0
- package/types/utils/request/types.d.ts.map +1 -0
- package/types/utils/types.d.ts +91 -0
- package/types/utils/types.d.ts.map +1 -0
- package/types/components/Identity/createDecodeKndctrCookie.d.ts.map +0 -1
- /package/types/{components/Identity → utils}/createDecodeKndctrCookie.d.ts +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.default = exports.decodeVarint = void 0;
|
|
4
|
-
var _index = require("
|
|
4
|
+
var _index = require("./index.js");
|
|
5
|
+
var _bytes = require("./bytes.js");
|
|
5
6
|
/*
|
|
6
7
|
Copyright 2024 Adobe. All rights reserved.
|
|
7
8
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -29,39 +30,39 @@ governing permissions and limitations under the License.
|
|
|
29
30
|
* and https://git.corp.adobe.com/experience-edge/konductor/blob/master/feature-identity/src/main/kotlin/com/adobe/edge/features/identity/data/StoredIdentity.kt#L16
|
|
30
31
|
|
|
31
32
|
* syntax = "proto3";
|
|
32
|
-
*
|
|
33
|
+
*
|
|
33
34
|
* // Device-level identity for Experience Edge
|
|
34
35
|
* message Identity {
|
|
35
36
|
* // The Experience Cloud ID value
|
|
36
37
|
* string ecid = 1;
|
|
37
|
-
*
|
|
38
|
+
*
|
|
38
39
|
* IdentityMetadata metadata = 10;
|
|
39
|
-
*
|
|
40
|
+
*
|
|
40
41
|
* // Used only in the 3rd party domain context.
|
|
41
42
|
* // It stores the UNIX timestamp and some metadata about the last identity sync triggered by Experience Edge.
|
|
42
43
|
* int64 last_sync = 20;
|
|
43
44
|
* int64 sync_hash = 21;
|
|
44
45
|
* int32 id_sync_container_id = 22;
|
|
45
|
-
*
|
|
46
|
+
*
|
|
46
47
|
* // UNIX timestamp when the Identity was last returned in a `state:store` instruction.
|
|
47
48
|
* // The Identity is written at most once every 24h with a large TTL, to ensure it does not expire.
|
|
48
49
|
* int64 write_time = 30;
|
|
49
50
|
* }
|
|
50
|
-
*
|
|
51
|
+
*
|
|
51
52
|
* message IdentityMetadata {
|
|
52
53
|
* // UNIX timestamp when this identity was minted.
|
|
53
54
|
* int64 created_at = 1;
|
|
54
|
-
*
|
|
55
|
+
*
|
|
55
56
|
* // Whether or not the identity is random (new) or based on an existing seed.
|
|
56
57
|
* bool is_new = 2;
|
|
57
|
-
*
|
|
58
|
+
*
|
|
58
59
|
* // Type of device for which the identity was generated.
|
|
59
60
|
* // 0 = UNKNOWN, 1 = BROWSER, 2 = MOBILE
|
|
60
61
|
* int32 device_type = 3;
|
|
61
|
-
*
|
|
62
|
+
*
|
|
62
63
|
* // The Experience Edge region in which the identity was minted.
|
|
63
64
|
* string region = 5;
|
|
64
|
-
*
|
|
65
|
+
*
|
|
65
66
|
* // More details on the source of the ECID identity.
|
|
66
67
|
* // Invariant: when `is_new` = true, the source must be set to `RANDOM`.
|
|
67
68
|
* // 0 = RANDOM, 1 = THIRD_PARTY_ID, 2 = FIRST_PARTY_ID, 3 = RECEIVED_IN_REQUEST
|
|
@@ -224,15 +225,6 @@ const decodeKndctrProtobuf = buffer => {
|
|
|
224
225
|
throw new Error("No ECID found in cookie.");
|
|
225
226
|
};
|
|
226
227
|
|
|
227
|
-
/**
|
|
228
|
-
* takes a base64 string of bytes and returns a Uint8Array
|
|
229
|
-
* @param {string} base64
|
|
230
|
-
* @returns {Uint8Array}
|
|
231
|
-
*/
|
|
232
|
-
const base64ToBytes = base64 => {
|
|
233
|
-
const binString = atob(base64);
|
|
234
|
-
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
235
|
-
};
|
|
236
228
|
// #endregion
|
|
237
229
|
|
|
238
230
|
// #region decode cookie
|
|
@@ -256,7 +248,7 @@ var _default = ({
|
|
|
256
248
|
// cookie is a base64 encoded byte representation of a Identity protobuf message
|
|
257
249
|
// and we need to get it to a Uint8Array in order to decode it
|
|
258
250
|
|
|
259
|
-
const cookieBytes = base64ToBytes(decodedCookie);
|
|
251
|
+
const cookieBytes = (0, _bytes.base64ToBytes)(decodedCookie);
|
|
260
252
|
return decodeKndctrProtobuf(cookieBytes);
|
|
261
253
|
} catch (error) {
|
|
262
254
|
logger.warn("Unable to decode ECID from " + kndctrCookieName + " cookie", error);
|
|
@@ -12,6 +12,19 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
12
12
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
13
|
governing permissions and limitations under the License.
|
|
14
14
|
*/
|
|
15
|
+
/** @import { Logger } from '../core/types.js' */
|
|
16
|
+
/** @import { CookieJar } from './types.js' */
|
|
17
|
+
/**
|
|
18
|
+
* Creates a logging wrapper around a cookie jar that logs cookie operations.
|
|
19
|
+
*
|
|
20
|
+
* @function
|
|
21
|
+
*
|
|
22
|
+
* @param {object} options
|
|
23
|
+
* @param {Logger} options.logger
|
|
24
|
+
* @param {CookieJar} options.cookieJar
|
|
25
|
+
*
|
|
26
|
+
* @returns {CookieJar}
|
|
27
|
+
*/
|
|
15
28
|
var _default = ({
|
|
16
29
|
logger,
|
|
17
30
|
cookieJar
|
|
@@ -24,7 +37,7 @@ var _default = ({
|
|
|
24
37
|
value,
|
|
25
38
|
...options
|
|
26
39
|
});
|
|
27
|
-
cookieJar.set(key, value, options);
|
|
40
|
+
return cookieJar.set(key, value, options);
|
|
28
41
|
}
|
|
29
42
|
};
|
|
30
43
|
};
|
|
@@ -16,10 +16,11 @@ governing permissions and limitations under the License.
|
|
|
16
16
|
/**
|
|
17
17
|
* Creates a function that, when passed an object of updates, will merge
|
|
18
18
|
* the updates onto the current value of a payload property.
|
|
19
|
-
*
|
|
20
|
-
* @param {
|
|
21
|
-
* can be a dot-notation property path.
|
|
22
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* @param {object} content The base object to modify
|
|
21
|
+
* @param {string} key The property to merge updates into. This can be a dot-notation property path.
|
|
22
|
+
*
|
|
23
|
+
* @returns {function(object): void}
|
|
23
24
|
*/
|
|
24
25
|
var _default = (content, key) => updates => {
|
|
25
26
|
const propertyPath = key.split(".");
|
package/libEs5/utils/index.js
CHANGED
|
@@ -6,6 +6,18 @@ Object.defineProperty(exports, "assignConcatArrayValues", {
|
|
|
6
6
|
return _assignConcatArrayValues.default;
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
|
+
Object.defineProperty(exports, "base64ToBytes", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _bytes.base64ToBytes;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "bytesToBase64", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return _bytes.bytesToBase64;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
9
21
|
Object.defineProperty(exports, "clone", {
|
|
10
22
|
enumerable: true,
|
|
11
23
|
get: function () {
|
|
@@ -301,6 +313,7 @@ Object.defineProperty(exports, "validateIdentityMap", {
|
|
|
301
313
|
}
|
|
302
314
|
});
|
|
303
315
|
var _assignConcatArrayValues = require("./assignConcatArrayValues.js");
|
|
316
|
+
var _bytes = require("./bytes.js");
|
|
304
317
|
var _clone = require("./clone.js");
|
|
305
318
|
var _cookieJar = require("./cookieJar.js");
|
|
306
319
|
var _createMerger = require("./createMerger.js");
|
|
@@ -14,6 +14,16 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
/** @import { Storage, StorageCreator } from './types.js' */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates a storage interface for a specific storage type with namespaced keys.
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} context - The context object (typically window) that provides storage APIs.
|
|
23
|
+
* @param {string} storageType - The type of storage to use ('localStorage' or 'sessionStorage').
|
|
24
|
+
* @param {string} namespace - The namespace prefix to prepend to all storage keys.
|
|
25
|
+
* @returns {Storage}
|
|
26
|
+
*/
|
|
17
27
|
const getStorageByType = (context, storageType, namespace) => {
|
|
18
28
|
// When storage is disabled on Safari, the mere act of referencing
|
|
19
29
|
// window.localStorage or window.sessionStorage throws an error.
|
|
@@ -62,6 +72,15 @@ const getStorageByType = (context, storageType, namespace) => {
|
|
|
62
72
|
}
|
|
63
73
|
};
|
|
64
74
|
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Creates a storage factory function that provides access to both session and persistent storage
|
|
78
|
+
* with namespaced keys. This is a higher-order function that returns a function which can be
|
|
79
|
+
* used to create storage instances with additional namespace suffixes.
|
|
80
|
+
*
|
|
81
|
+
* @param {Object} context - The context object (typically window) that provides storage APIs.
|
|
82
|
+
* @returns {StorageCreator}
|
|
83
|
+
*/
|
|
65
84
|
var _default = context => additionalNamespace => {
|
|
66
85
|
const finalNamespace = _namespace.default + additionalNamespace;
|
|
67
86
|
return {
|
|
@@ -15,20 +15,28 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
15
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
16
|
governing permissions and limitations under the License.
|
|
17
17
|
*/
|
|
18
|
+
/** @import { DataCollectionRequestPayload } from './types.js' */
|
|
19
|
+
/**
|
|
20
|
+
* @function
|
|
21
|
+
*
|
|
22
|
+
* @returns {DataCollectionRequestPayload}
|
|
23
|
+
*/
|
|
18
24
|
var _default = () => {
|
|
19
25
|
const content = {};
|
|
20
|
-
const
|
|
26
|
+
const requestPayload = (0, _createRequestPayload.default)({
|
|
21
27
|
content,
|
|
22
28
|
addIdentity: (0, _createAddIdentity.default)(content),
|
|
23
29
|
hasIdentity: (0, _createHasIdentity.default)(content)
|
|
24
30
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
return {
|
|
32
|
+
...requestPayload,
|
|
33
|
+
addEvent: event => {
|
|
34
|
+
content.events = content.events || [];
|
|
35
|
+
content.events.push(event);
|
|
36
|
+
},
|
|
37
|
+
getDocumentMayUnload: () => {
|
|
38
|
+
return (content.events || []).some(event => event.getDocumentMayUnload());
|
|
39
|
+
}
|
|
28
40
|
};
|
|
29
|
-
payload.getDocumentMayUnload = () => {
|
|
30
|
-
return (content.events || []).some(event => event.getDocumentMayUnload());
|
|
31
|
-
};
|
|
32
|
-
return payload;
|
|
33
41
|
};
|
|
34
42
|
exports.default = _default;
|
|
@@ -13,7 +13,34 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
13
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
/** @import { Request, RequestPayload } from './types.js' */
|
|
17
|
+
/**
|
|
18
|
+
* Creates a request object with methods to access and modify request properties.
|
|
19
|
+
*
|
|
20
|
+
* @function
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} options
|
|
23
|
+
* @param {RequestPayload} options.payload
|
|
24
|
+
* @param {function({isIdentityEstablished: boolean}): string} options.getAction
|
|
25
|
+
* @param {function({isIdentityEstablished: boolean}): boolean} options.getUseSendBeacon
|
|
26
|
+
* @param {string} [options.datastreamIdOverride]
|
|
27
|
+
* @param {string} [options.edgeSubPath]
|
|
28
|
+
*
|
|
29
|
+
* @returns {Request}
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const request = createRequest({
|
|
33
|
+
* payload: { event: 'pageView' },
|
|
34
|
+
* getAction: ({ isIdentityEstablished }) => isIdentityEstablished ? 'send' : 'queue',
|
|
35
|
+
* getUseSendBeacon: ({ isIdentityEstablished }) => isIdentityEstablished,
|
|
36
|
+
* datastreamIdOverride: 'custom-datastream-id',
|
|
37
|
+
* edgeSubPath: 'custom/path'
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* console.log(request.getId()); // Returns unique UUID
|
|
41
|
+
* request.setIsIdentityEstablished();
|
|
42
|
+
* console.log(request.getAction()); // Returns action based on identity status
|
|
43
|
+
*/
|
|
17
44
|
var _default = options => {
|
|
18
45
|
const {
|
|
19
46
|
payload,
|
|
@@ -13,20 +13,84 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
13
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
|
|
17
|
+
/** @import { RequestPayload, Identity } from './types.js' */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* createMerger creates a function that does a deep merge. Example:
|
|
21
|
+
* ```js
|
|
22
|
+
* payload.mergeConfigOverride({
|
|
23
|
+
* com_adobe_analytics: {
|
|
24
|
+
* reportSuites: ["reportSuite1"],
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* payload.mergeConfigOverride({
|
|
29
|
+
* com_adobe_analytics: {
|
|
30
|
+
* enabled: false,
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
*
|
|
35
|
+
* // payload.meta.configOverrides is now:
|
|
36
|
+
* // {
|
|
37
|
+
* // com_adobe_analytics: {
|
|
38
|
+
* // enabled: false,
|
|
39
|
+
* // reportSuites: ["reportSuite1"],
|
|
40
|
+
* // },
|
|
41
|
+
* // }
|
|
42
|
+
* ```
|
|
43
|
+
* however, we need the result to be:
|
|
44
|
+
* ```js
|
|
45
|
+
* // {
|
|
46
|
+
* // com_adobe_analytics: {
|
|
47
|
+
* // enabled: false,
|
|
48
|
+
* // },
|
|
49
|
+
* // }
|
|
50
|
+
* ```
|
|
51
|
+
* aka a shallow merge, where the second object overwrites the first.
|
|
52
|
+
* This is because order matters and we don't want to send reportSuites when something is
|
|
53
|
+
* disabled.
|
|
54
|
+
* This function does that.
|
|
55
|
+
*
|
|
56
|
+
* @param {Object} content
|
|
57
|
+
* @param {string} key
|
|
58
|
+
* @returns {(updates: Object) => void}
|
|
59
|
+
*/
|
|
60
|
+
const createMergeConfigOverride = (content, key) => updates => {
|
|
61
|
+
const propertyPath = key.split(".");
|
|
62
|
+
const hostObjectForUpdates = propertyPath.reduce((obj, propertyName) => {
|
|
63
|
+
obj[propertyName] = obj[propertyName] || {};
|
|
64
|
+
return obj[propertyName];
|
|
65
|
+
}, content);
|
|
66
|
+
Object.assign(hostObjectForUpdates, updates);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Creates a request payload object with methods for merging different types of data.
|
|
71
|
+
* This provides the base functionality that all types of request payloads share.
|
|
72
|
+
*
|
|
73
|
+
* @function
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} options
|
|
76
|
+
* @param {Object} options.content
|
|
77
|
+
* @param {function(string, Identity): void} options.addIdentity
|
|
78
|
+
* @param {function(string): boolean} options.hasIdentity
|
|
79
|
+
*
|
|
80
|
+
* @returns {RequestPayload}
|
|
81
|
+
*/
|
|
18
82
|
var _default = options => {
|
|
19
83
|
const {
|
|
20
84
|
content,
|
|
21
85
|
addIdentity,
|
|
22
86
|
hasIdentity
|
|
23
87
|
} = options;
|
|
24
|
-
const
|
|
88
|
+
const mergeConfigOverrides = createMergeConfigOverride(content, "meta.configOverrides");
|
|
25
89
|
return {
|
|
26
90
|
mergeMeta: (0, _index.createMerger)(content, "meta"),
|
|
27
91
|
mergeState: (0, _index.createMerger)(content, "meta.state"),
|
|
28
92
|
mergeQuery: (0, _index.createMerger)(content, "query"),
|
|
29
|
-
mergeConfigOverride: updates =>
|
|
93
|
+
mergeConfigOverride: updates => mergeConfigOverrides((0, _index.prepareConfigOverridesForEdge)(updates)),
|
|
30
94
|
addIdentity,
|
|
31
95
|
hasIdentity,
|
|
32
96
|
toJSON() {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Request object with methods to access and modify request properties.
|
|
6
|
+
*
|
|
7
|
+
* @typedef {Object} Request
|
|
8
|
+
* @property {function(): string} getId
|
|
9
|
+
* @property {function(): RequestPayload} getPayload
|
|
10
|
+
* @property {function({isIdentityEstablished: boolean}): string} getAction
|
|
11
|
+
* @property {function(): string|undefined} getDatastreamIdOverride
|
|
12
|
+
* @property {Function} getUseSendBeacon
|
|
13
|
+
* @property {function(): string|undefined} getEdgeSubPath
|
|
14
|
+
* @property {Function} getUseIdThirdPartyDomain
|
|
15
|
+
* @property {Function} setUseIdThirdPartyDomain
|
|
16
|
+
* @property {Function} setIsIdentityEstablished
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Request payload object with methods for merging different types of data.
|
|
21
|
+
*
|
|
22
|
+
* @typedef {Object} RequestPayload
|
|
23
|
+
* @property {function(object): void} mergeMeta
|
|
24
|
+
* @property {function(object): void} mergeState
|
|
25
|
+
* @property {function(object): void} mergeQuery
|
|
26
|
+
* @property {function(object): void} mergeConfigOverride
|
|
27
|
+
* @property {function(string, Identity): void} options.addIdentity
|
|
28
|
+
* @property {function(string): boolean} options.hasIdentity
|
|
29
|
+
* @property {function(): object} toJSON
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Request payload object with methods for merging different types of data.
|
|
34
|
+
*
|
|
35
|
+
* @typedef {Object} DataCollectionRequestPayload
|
|
36
|
+
* @property {function(object): void} mergeMeta
|
|
37
|
+
* @property {function(object): void} mergeState
|
|
38
|
+
* @property {function(object): void} mergeQuery
|
|
39
|
+
* @property {function(object): void} mergeConfigOverride
|
|
40
|
+
* @property {function(string, Identity): void} options.addIdentity
|
|
41
|
+
* @property {function(string): boolean} options.hasIdentity
|
|
42
|
+
* @property {function(object): void} addEvent
|
|
43
|
+
* @property {function(): boolean} getDocumentMayUnload
|
|
44
|
+
* @property {function(): object} toJSON
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {Object} Identity
|
|
49
|
+
* @property {string} id
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
const Types = exports.Types = {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} Storage
|
|
6
|
+
* @property {function(string): string|null} getItem
|
|
7
|
+
* @property {function(string, string): void} setItem
|
|
8
|
+
* @property {function(): void} clear
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} CookieAttributes
|
|
13
|
+
* @property {number|Date} [expires] - Cookie expiration (number of days or Date object)
|
|
14
|
+
* @property {string} [path] - Cookie path (default: "/")
|
|
15
|
+
* @property {string} [domain] - Cookie domain
|
|
16
|
+
* @property {boolean} [secure] - Requires HTTPS transmission
|
|
17
|
+
* @property {"strict"|"lax"|"none"} [sameSite] - SameSite attribute
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} CookieConverter
|
|
22
|
+
* @property {function(string, string): string} [read] - Custom decoder function
|
|
23
|
+
* @property {function(string, string): string} [write] - Custom encoder function
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {Object} CookieJar
|
|
28
|
+
* @property {function(string): string|undefined} get - Get cookie value by name, or get all cookies as object if no name provided
|
|
29
|
+
* @property {function(): Object<string, string>} get - Get all cookies as key-value object when called with no arguments
|
|
30
|
+
* @property {function(string, string, CookieAttributes=): string|undefined} set - Set cookie with optional attributes
|
|
31
|
+
* @property {function(string, CookieAttributes=): void} remove - Remove cookie with optional attributes (must match set attributes)
|
|
32
|
+
* @property {function(CookieConverter): CookieJar} withConverter - Create new instance with custom encoding/decoding
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {function(string): { session: Storage, persistent: Storage }} StorageCreator
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const Types = exports.Types = {};
|
|
@@ -17,6 +17,10 @@ import isButtonSubmitElement from "./isButtonSubmitElement.js";
|
|
|
17
17
|
export default element => {
|
|
18
18
|
let node = element;
|
|
19
19
|
while (node) {
|
|
20
|
+
// Stop looking when BODY is reached
|
|
21
|
+
if (node.nodeName && node.nodeName === "BODY") {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
20
24
|
if (isSupportedAnchorElement(node) || elementHasClickHandler(node) || isInputSubmitElement(node) || isButtonSubmitElement(node)) {
|
|
21
25
|
return node;
|
|
22
26
|
}
|
|
@@ -21,9 +21,6 @@ export default ({
|
|
|
21
21
|
getBrowser
|
|
22
22
|
}) => {
|
|
23
23
|
const componentConfig = config.advertising;
|
|
24
|
-
const sharedState = {
|
|
25
|
-
processedAdvertisingIds: false
|
|
26
|
-
};
|
|
27
24
|
const sendAdConversionHandler = createSendAdConversion({
|
|
28
25
|
eventManager,
|
|
29
26
|
cookieManager,
|
|
@@ -35,7 +32,7 @@ export default ({
|
|
|
35
32
|
return {
|
|
36
33
|
lifecycle: {
|
|
37
34
|
onComponentsRegistered() {
|
|
38
|
-
sendAdConversionHandler(
|
|
35
|
+
return sendAdConversionHandler();
|
|
39
36
|
},
|
|
40
37
|
onBeforeEvent: ({
|
|
41
38
|
event,
|
|
@@ -44,7 +41,6 @@ export default ({
|
|
|
44
41
|
return handleOnBeforeSendEvent({
|
|
45
42
|
cookieManager,
|
|
46
43
|
logger,
|
|
47
|
-
state: sharedState,
|
|
48
44
|
event,
|
|
49
45
|
componentConfig,
|
|
50
46
|
advertising,
|
|
@@ -62,7 +62,8 @@ export default async function handleClickThrough({
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
eventType: AD_CONVERSION_CLICK_EVENT_TYPE
|
|
65
|
+
eventType: AD_CONVERSION_CLICK_EVENT_TYPE,
|
|
66
|
+
timestamp: new Date().toISOString()
|
|
66
67
|
};
|
|
67
68
|
event.setUserXdm(xdm);
|
|
68
69
|
cookieManager.setValue(LAST_CONVERSION_TIME_KEY);
|
|
@@ -33,11 +33,11 @@ export default ({
|
|
|
33
33
|
skwcid,
|
|
34
34
|
efid
|
|
35
35
|
} = getUrlParams();
|
|
36
|
-
const isClickThru = !!(skwcid
|
|
36
|
+
const isClickThru = !!(skwcid || efid);
|
|
37
37
|
try {
|
|
38
|
-
let result = null;
|
|
39
38
|
if (isClickThru) {
|
|
40
|
-
|
|
39
|
+
// wait for click through to complete
|
|
40
|
+
return handleClickThrough({
|
|
41
41
|
eventManager,
|
|
42
42
|
cookieManager,
|
|
43
43
|
adConversionHandler,
|
|
@@ -45,19 +45,17 @@ export default ({
|
|
|
45
45
|
skwcid,
|
|
46
46
|
efid
|
|
47
47
|
});
|
|
48
|
-
return result;
|
|
49
48
|
} else if (activeAdvertiserIds) {
|
|
50
|
-
|
|
49
|
+
// fire and forget view through
|
|
50
|
+
handleViewThrough({
|
|
51
51
|
eventManager,
|
|
52
52
|
cookieManager,
|
|
53
53
|
logger,
|
|
54
54
|
componentConfig,
|
|
55
55
|
adConversionHandler,
|
|
56
56
|
getBrowser
|
|
57
|
-
});
|
|
58
|
-
return result;
|
|
57
|
+
}).catch(error => logger.error("Error in view through:", error));
|
|
59
58
|
}
|
|
60
|
-
return null;
|
|
61
59
|
} catch (error) {
|
|
62
60
|
logger.error("Error in sendAdConversion:", error);
|
|
63
61
|
}
|
|
@@ -23,7 +23,8 @@ export default async function handleViewThrough({
|
|
|
23
23
|
try {
|
|
24
24
|
const event = appendAdvertisingIdQueryToEvent(resolvedIds, eventManager.createEvent(), cookieManager, componentConfig, true);
|
|
25
25
|
const xdm = {
|
|
26
|
-
eventType: AD_CONVERSION_VIEW_EVENT_TYPE
|
|
26
|
+
eventType: AD_CONVERSION_VIEW_EVENT_TYPE,
|
|
27
|
+
timestamp: new Date().toISOString()
|
|
27
28
|
};
|
|
28
29
|
event.setUserXdm(xdm);
|
|
29
30
|
const result = await adConversionHandler.trackAdConversion({
|
|
@@ -43,11 +44,11 @@ export default async function handleViewThrough({
|
|
|
43
44
|
const identityPromises = Object.entries(identityPromisesMap).map(([idType, idPromise]) => idPromise.then(idValue => {
|
|
44
45
|
if (idValue) {
|
|
45
46
|
resolvedIds[idType] = idValue;
|
|
46
|
-
return triggerConversion();
|
|
47
|
+
return triggerConversion();
|
|
47
48
|
}
|
|
48
49
|
}).catch(error => {
|
|
49
50
|
logger.error(LOG_ERROR_RESOLVING_ID.replace("{0}", idType), error);
|
|
50
51
|
return null;
|
|
51
52
|
}));
|
|
52
|
-
return Promise.allSettled(identityPromises);
|
|
53
|
+
return Promise.allSettled(identityPromises);
|
|
53
54
|
}
|
|
@@ -10,10 +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
|
|
|
13
|
+
/** @import { ConsentRequestPayload } from './types.js' */
|
|
14
|
+
|
|
13
15
|
import { createRequestPayload } from "../../utils/request/index.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @function
|
|
19
|
+
*
|
|
20
|
+
* @returns {ConsentRequestPayload}
|
|
21
|
+
*/
|
|
14
22
|
export default () => {
|
|
15
23
|
const content = {};
|
|
16
|
-
const
|
|
24
|
+
const requestPayload = createRequestPayload({
|
|
17
25
|
content,
|
|
18
26
|
addIdentity: (namespaceCode, identity) => {
|
|
19
27
|
content.identityMap = content.identityMap || {};
|
|
@@ -24,8 +32,13 @@ export default () => {
|
|
|
24
32
|
return (content.identityMap && content.identityMap[namespaceCode]) !== undefined;
|
|
25
33
|
}
|
|
26
34
|
});
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
|
|
36
|
+
/** @type {ConsentRequestPayload} */
|
|
37
|
+
const payload = {
|
|
38
|
+
...requestPayload,
|
|
39
|
+
setConsent: consent => {
|
|
40
|
+
content.consent = consent;
|
|
41
|
+
}
|
|
29
42
|
};
|
|
30
43
|
return payload;
|
|
31
44
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request payload object with methods for merging different types of data.
|
|
3
|
+
*
|
|
4
|
+
* @typedef {Object} ConsentRequestPayload
|
|
5
|
+
* @property {Function} mergeMeta
|
|
6
|
+
* @property {Function} mergeState
|
|
7
|
+
* @property {Function} mergeQuery
|
|
8
|
+
* @property {Function} mergeConfigOverride
|
|
9
|
+
* @property {Function} addIdentity
|
|
10
|
+
* @property {Function} hasIdentity
|
|
11
|
+
* @property {Function} toJSON
|
|
12
|
+
* @property {Function} setConsent
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const Types = {};
|
|
@@ -22,8 +22,8 @@ export default ({
|
|
|
22
22
|
consent,
|
|
23
23
|
appendIdentityToUrl,
|
|
24
24
|
logger,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
identity,
|
|
26
|
+
getIdentityOptionsValidator
|
|
27
27
|
}) => {
|
|
28
28
|
let namespaces;
|
|
29
29
|
let edge = {};
|
|
@@ -65,6 +65,7 @@ export default ({
|
|
|
65
65
|
...edge,
|
|
66
66
|
...response.getEdge()
|
|
67
67
|
};
|
|
68
|
+
identity.setIdentityAcquired();
|
|
68
69
|
return handleResponseForIdSyncs(response);
|
|
69
70
|
}
|
|
70
71
|
},
|
|
@@ -79,7 +80,7 @@ export default ({
|
|
|
79
80
|
if (namespaces) {
|
|
80
81
|
return undefined;
|
|
81
82
|
}
|
|
82
|
-
const ecidFromCookie =
|
|
83
|
+
const ecidFromCookie = identity.getEcidFromCookie();
|
|
83
84
|
if (ecidFromCookie && requestedNamespaces.includes(ecidNamespace)) {
|
|
84
85
|
if (!namespaces) {
|
|
85
86
|
namespaces = {};
|
|
@@ -110,7 +111,7 @@ export default ({
|
|
|
110
111
|
if (namespaces) {
|
|
111
112
|
return undefined;
|
|
112
113
|
}
|
|
113
|
-
const ecidFromCookie =
|
|
114
|
+
const ecidFromCookie = identity.getEcidFromCookie();
|
|
114
115
|
if (ecidFromCookie) {
|
|
115
116
|
if (!namespaces) {
|
|
116
117
|
namespaces = {};
|