@adobe/alloy 2.29.0-beta.0 → 2.29.0-beta.13
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 +112 -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 +38 -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 +110 -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 +33 -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 +3 -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
|
@@ -19,6 +19,10 @@ governing permissions and limitations under the License.
|
|
|
19
19
|
var _default = element => {
|
|
20
20
|
let node = element;
|
|
21
21
|
while (node) {
|
|
22
|
+
// Stop looking when BODY is reached
|
|
23
|
+
if (node.nodeName && node.nodeName === "BODY") {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
22
26
|
if ((0, _isSupportedAnchorElement.default)(node) || (0, _elementHasClickHandler.default)(node) || (0, _isInputSubmitElement.default)(node) || (0, _isButtonSubmitElement.default)(node)) {
|
|
23
27
|
return node;
|
|
24
28
|
}
|
|
@@ -23,9 +23,6 @@ var _default = ({
|
|
|
23
23
|
getBrowser
|
|
24
24
|
}) => {
|
|
25
25
|
const componentConfig = config.advertising;
|
|
26
|
-
const sharedState = {
|
|
27
|
-
processedAdvertisingIds: false
|
|
28
|
-
};
|
|
29
26
|
const sendAdConversionHandler = (0, _sendAdConversion.default)({
|
|
30
27
|
eventManager,
|
|
31
28
|
cookieManager,
|
|
@@ -37,7 +34,7 @@ var _default = ({
|
|
|
37
34
|
return {
|
|
38
35
|
lifecycle: {
|
|
39
36
|
onComponentsRegistered() {
|
|
40
|
-
sendAdConversionHandler(
|
|
37
|
+
return sendAdConversionHandler();
|
|
41
38
|
},
|
|
42
39
|
onBeforeEvent: ({
|
|
43
40
|
event,
|
|
@@ -46,7 +43,6 @@ var _default = ({
|
|
|
46
43
|
return (0, _onBeforeSendEventHandler.default)({
|
|
47
44
|
cookieManager,
|
|
48
45
|
logger,
|
|
49
|
-
state: sharedState,
|
|
50
46
|
event,
|
|
51
47
|
componentConfig,
|
|
52
48
|
advertising,
|
|
@@ -64,7 +64,8 @@ async function handleClickThrough({
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
eventType: _index.AD_CONVERSION_CLICK_EVENT_TYPE
|
|
67
|
+
eventType: _index.AD_CONVERSION_CLICK_EVENT_TYPE,
|
|
68
|
+
timestamp: new Date().toISOString()
|
|
68
69
|
};
|
|
69
70
|
event.setUserXdm(xdm);
|
|
70
71
|
cookieManager.setValue(_index.LAST_CONVERSION_TIME_KEY);
|
|
@@ -34,11 +34,11 @@ var _default = ({
|
|
|
34
34
|
skwcid,
|
|
35
35
|
efid
|
|
36
36
|
} = (0, _helpers.getUrlParams)();
|
|
37
|
-
const isClickThru = !!(skwcid
|
|
37
|
+
const isClickThru = !!(skwcid || efid);
|
|
38
38
|
try {
|
|
39
|
-
let result = null;
|
|
40
39
|
if (isClickThru) {
|
|
41
|
-
|
|
40
|
+
// wait for click through to complete
|
|
41
|
+
return (0, _clickThroughHandler.default)({
|
|
42
42
|
eventManager,
|
|
43
43
|
cookieManager,
|
|
44
44
|
adConversionHandler,
|
|
@@ -46,19 +46,17 @@ var _default = ({
|
|
|
46
46
|
skwcid,
|
|
47
47
|
efid
|
|
48
48
|
});
|
|
49
|
-
return result;
|
|
50
49
|
} else if (activeAdvertiserIds) {
|
|
51
|
-
|
|
50
|
+
// fire and forget view through
|
|
51
|
+
(0, _viewThroughHandler.default)({
|
|
52
52
|
eventManager,
|
|
53
53
|
cookieManager,
|
|
54
54
|
logger,
|
|
55
55
|
componentConfig,
|
|
56
56
|
adConversionHandler,
|
|
57
57
|
getBrowser
|
|
58
|
-
});
|
|
59
|
-
return result;
|
|
58
|
+
}).catch(error => logger.error("Error in view through:", error));
|
|
60
59
|
}
|
|
61
|
-
return null;
|
|
62
60
|
} catch (error) {
|
|
63
61
|
logger.error("Error in sendAdConversion:", error);
|
|
64
62
|
}
|
|
@@ -26,7 +26,8 @@ async function handleViewThrough({
|
|
|
26
26
|
try {
|
|
27
27
|
const event = (0, _helpers.appendAdvertisingIdQueryToEvent)(resolvedIds, eventManager.createEvent(), cookieManager, componentConfig, true);
|
|
28
28
|
const xdm = {
|
|
29
|
-
eventType: _index.AD_CONVERSION_VIEW_EVENT_TYPE
|
|
29
|
+
eventType: _index.AD_CONVERSION_VIEW_EVENT_TYPE,
|
|
30
|
+
timestamp: new Date().toISOString()
|
|
30
31
|
};
|
|
31
32
|
event.setUserXdm(xdm);
|
|
32
33
|
const result = await adConversionHandler.trackAdConversion({
|
|
@@ -46,11 +47,11 @@ async function handleViewThrough({
|
|
|
46
47
|
const identityPromises = Object.entries(identityPromisesMap).map(([idType, idPromise]) => idPromise.then(idValue => {
|
|
47
48
|
if (idValue) {
|
|
48
49
|
resolvedIds[idType] = idValue;
|
|
49
|
-
return triggerConversion();
|
|
50
|
+
return triggerConversion();
|
|
50
51
|
}
|
|
51
52
|
}).catch(error => {
|
|
52
53
|
logger.error(_index.LOG_ERROR_RESOLVING_ID.replace("{0}", idType), error);
|
|
53
54
|
return null;
|
|
54
55
|
}));
|
|
55
|
-
return Promise.allSettled(identityPromises);
|
|
56
|
+
return Promise.allSettled(identityPromises);
|
|
56
57
|
}
|
|
@@ -13,9 +13,15 @@ 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
|
+
/** @import { ConsentRequestPayload } from './types.js' */
|
|
17
|
+
/**
|
|
18
|
+
* @function
|
|
19
|
+
*
|
|
20
|
+
* @returns {ConsentRequestPayload}
|
|
21
|
+
*/
|
|
16
22
|
var _default = () => {
|
|
17
23
|
const content = {};
|
|
18
|
-
const
|
|
24
|
+
const requestPayload = (0, _index.createRequestPayload)({
|
|
19
25
|
content,
|
|
20
26
|
addIdentity: (namespaceCode, identity) => {
|
|
21
27
|
content.identityMap = content.identityMap || {};
|
|
@@ -26,8 +32,13 @@ var _default = () => {
|
|
|
26
32
|
return (content.identityMap && content.identityMap[namespaceCode]) !== undefined;
|
|
27
33
|
}
|
|
28
34
|
});
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
|
|
36
|
+
/** @type {ConsentRequestPayload} */
|
|
37
|
+
const payload = {
|
|
38
|
+
...requestPayload,
|
|
39
|
+
setConsent: consent => {
|
|
40
|
+
content.consent = consent;
|
|
41
|
+
}
|
|
31
42
|
};
|
|
32
43
|
return payload;
|
|
33
44
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Request payload object with methods for merging different types of data.
|
|
6
|
+
*
|
|
7
|
+
* @typedef {Object} ConsentRequestPayload
|
|
8
|
+
* @property {Function} mergeMeta
|
|
9
|
+
* @property {Function} mergeState
|
|
10
|
+
* @property {Function} mergeQuery
|
|
11
|
+
* @property {Function} mergeConfigOverride
|
|
12
|
+
* @property {Function} addIdentity
|
|
13
|
+
* @property {Function} hasIdentity
|
|
14
|
+
* @property {Function} toJSON
|
|
15
|
+
* @property {Function} setConsent
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const Types = exports.Types = {};
|
|
@@ -25,8 +25,8 @@ var _default = ({
|
|
|
25
25
|
consent,
|
|
26
26
|
appendIdentityToUrl,
|
|
27
27
|
logger,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
identity,
|
|
29
|
+
getIdentityOptionsValidator
|
|
30
30
|
}) => {
|
|
31
31
|
let namespaces;
|
|
32
32
|
let edge = {};
|
|
@@ -68,6 +68,7 @@ var _default = ({
|
|
|
68
68
|
...edge,
|
|
69
69
|
...response.getEdge()
|
|
70
70
|
};
|
|
71
|
+
identity.setIdentityAcquired();
|
|
71
72
|
return handleResponseForIdSyncs(response);
|
|
72
73
|
}
|
|
73
74
|
},
|
|
@@ -82,7 +83,7 @@ var _default = ({
|
|
|
82
83
|
if (namespaces) {
|
|
83
84
|
return undefined;
|
|
84
85
|
}
|
|
85
|
-
const ecidFromCookie =
|
|
86
|
+
const ecidFromCookie = identity.getEcidFromCookie();
|
|
86
87
|
if (ecidFromCookie && requestedNamespaces.includes(_ecidNamespace.default)) {
|
|
87
88
|
if (!namespaces) {
|
|
88
89
|
namespaces = {};
|
|
@@ -113,7 +114,7 @@ var _default = ({
|
|
|
113
114
|
if (namespaces) {
|
|
114
115
|
return undefined;
|
|
115
116
|
}
|
|
116
|
-
const ecidFromCookie =
|
|
117
|
+
const ecidFromCookie = identity.getEcidFromCookie();
|
|
117
118
|
if (ecidFromCookie) {
|
|
118
119
|
if (!namespaces) {
|
|
119
120
|
namespaces = {};
|
|
@@ -22,7 +22,6 @@ var _createIdentityRequest = require("./getIdentity/createIdentityRequest.js");
|
|
|
22
22
|
var _createIdentityRequestPayload = require("./getIdentity/createIdentityRequestPayload.js");
|
|
23
23
|
var _injectAppendIdentityToUrl = require("./appendIdentityToUrl/injectAppendIdentityToUrl.js");
|
|
24
24
|
var _createGetIdentityOptionsValidator = require("./getIdentity/createGetIdentityOptionsValidator.js");
|
|
25
|
-
var _createDecodeKndctrCookie = require("./createDecodeKndctrCookie.js");
|
|
26
25
|
/*
|
|
27
26
|
Copyright 2019 Adobe. All rights reserved.
|
|
28
27
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -42,7 +41,8 @@ const createIdentity = ({
|
|
|
42
41
|
fireReferrerHideableImage,
|
|
43
42
|
sendEdgeNetworkRequest,
|
|
44
43
|
apexDomain,
|
|
45
|
-
getBrowser
|
|
44
|
+
getBrowser,
|
|
45
|
+
identity
|
|
46
46
|
}) => {
|
|
47
47
|
const {
|
|
48
48
|
orgId,
|
|
@@ -122,11 +122,6 @@ const createIdentity = ({
|
|
|
122
122
|
thirdPartyCookiesEnabled,
|
|
123
123
|
areThirdPartyCookiesSupportedByDefault
|
|
124
124
|
});
|
|
125
|
-
const decodeKndctrCookie = (0, _createDecodeKndctrCookie.default)({
|
|
126
|
-
orgId,
|
|
127
|
-
cookieJar: loggingCookieJar,
|
|
128
|
-
logger
|
|
129
|
-
});
|
|
130
125
|
return (0, _createComponent.default)({
|
|
131
126
|
addEcidQueryToPayload,
|
|
132
127
|
addQueryStringIdentityToPayload,
|
|
@@ -136,11 +131,11 @@ const createIdentity = ({
|
|
|
136
131
|
getNamespacesFromResponse: _getNamespacesFromResponse.default,
|
|
137
132
|
getIdentity,
|
|
138
133
|
consent,
|
|
134
|
+
identity,
|
|
139
135
|
appendIdentityToUrl,
|
|
140
136
|
logger,
|
|
141
137
|
config,
|
|
142
|
-
getIdentityOptionsValidator
|
|
143
|
-
decodeKndctrCookie
|
|
138
|
+
getIdentityOptionsValidator
|
|
144
139
|
});
|
|
145
140
|
};
|
|
146
141
|
createIdentity.namespace = "Identity";
|
|
@@ -108,9 +108,10 @@ const renderContent = ({
|
|
|
108
108
|
content,
|
|
109
109
|
decorateProposition,
|
|
110
110
|
renderFunc,
|
|
111
|
-
renderStatusHandler
|
|
111
|
+
renderStatusHandler,
|
|
112
|
+
alwaysRender
|
|
112
113
|
}) => {
|
|
113
|
-
const executions = containers.filter(renderStatusHandler.shouldRender).map(async container => {
|
|
114
|
+
const executions = containers.filter(element => alwaysRender || renderStatusHandler.shouldRender(element)).map(async container => {
|
|
114
115
|
await renderFunc(container, content, decorateProposition);
|
|
115
116
|
renderStatusHandler.markAsRendered(container);
|
|
116
117
|
});
|
|
@@ -121,8 +122,9 @@ const renderContent = ({
|
|
|
121
122
|
* Creates an action function that renders content into a container element.
|
|
122
123
|
*
|
|
123
124
|
* @param {Function} renderFunc - The function that performs the rendering.
|
|
125
|
+
* @param {boolean} alwaysRender - Whether to always render the content, even if it has already been rendered.
|
|
124
126
|
*/
|
|
125
|
-
const createAction = renderFunc => {
|
|
127
|
+
const createAction = (renderFunc, alwaysRender = false) => {
|
|
126
128
|
/**
|
|
127
129
|
* Renders content into a container element.
|
|
128
130
|
*
|
|
@@ -144,7 +146,8 @@ const createAction = renderFunc => {
|
|
|
144
146
|
content,
|
|
145
147
|
decorateProposition,
|
|
146
148
|
renderFunc,
|
|
147
|
-
renderStatusHandler
|
|
149
|
+
renderStatusHandler,
|
|
150
|
+
alwaysRender
|
|
148
151
|
});
|
|
149
152
|
} finally {
|
|
150
153
|
(0, _index2.showElements)(prehidingSelector);
|
|
@@ -48,22 +48,22 @@ const DOM_ACTION_CLICK = exports.DOM_ACTION_CLICK = "click";
|
|
|
48
48
|
const DOM_ACTION_COLLECT_INTERACTIONS = exports.DOM_ACTION_COLLECT_INTERACTIONS = "collectInteractions";
|
|
49
49
|
var _default = () => {
|
|
50
50
|
return {
|
|
51
|
-
[DOM_ACTION_SET_HTML]: (0, _action.createAction)(_setHtml.default),
|
|
51
|
+
[DOM_ACTION_SET_HTML]: (0, _action.createAction)(_setHtml.default, true),
|
|
52
52
|
[DOM_ACTION_CUSTOM_CODE]: (0, _action.createAction)(_prependHtml.default),
|
|
53
|
-
[DOM_ACTION_SET_TEXT]: (0, _action.createAction)(_setText.default),
|
|
54
|
-
[DOM_ACTION_SET_ATTRIBUTE]: (0, _action.createAction)(_setAttributes.default),
|
|
55
|
-
[DOM_ACTION_SET_IMAGE_SOURCE]: (0, _action.createAction)(_swapImage.default),
|
|
56
|
-
[DOM_ACTION_SET_STYLE]: (0, _action.createAction)(_setStyles.default),
|
|
57
|
-
[DOM_ACTION_MOVE]: (0, _action.createAction)(_move.default),
|
|
58
|
-
[DOM_ACTION_RESIZE]: (0, _action.createAction)(_resize.default),
|
|
53
|
+
[DOM_ACTION_SET_TEXT]: (0, _action.createAction)(_setText.default, true),
|
|
54
|
+
[DOM_ACTION_SET_ATTRIBUTE]: (0, _action.createAction)(_setAttributes.default, true),
|
|
55
|
+
[DOM_ACTION_SET_IMAGE_SOURCE]: (0, _action.createAction)(_swapImage.default, true),
|
|
56
|
+
[DOM_ACTION_SET_STYLE]: (0, _action.createAction)(_setStyles.default, true),
|
|
57
|
+
[DOM_ACTION_MOVE]: (0, _action.createAction)(_move.default, true),
|
|
58
|
+
[DOM_ACTION_RESIZE]: (0, _action.createAction)(_resize.default, true),
|
|
59
59
|
[DOM_ACTION_REARRANGE]: (0, _action.createAction)(_rearrangeChildren.default),
|
|
60
|
-
[DOM_ACTION_REMOVE]: (0, _action.createAction)(_index.removeNode),
|
|
60
|
+
[DOM_ACTION_REMOVE]: (0, _action.createAction)(_index.removeNode, true),
|
|
61
61
|
[DOM_ACTION_INSERT_AFTER]: (0, _action.createAction)(_insertHtmlAfter.default),
|
|
62
62
|
[DOM_ACTION_INSERT_BEFORE]: (0, _action.createAction)(_insertHtmlBefore.default),
|
|
63
|
-
[DOM_ACTION_REPLACE_HTML]: (0, _action.createAction)(_replaceHtml.default),
|
|
63
|
+
[DOM_ACTION_REPLACE_HTML]: (0, _action.createAction)(_replaceHtml.default, true),
|
|
64
64
|
[DOM_ACTION_PREPEND_HTML]: (0, _action.createAction)(_prependHtml.default),
|
|
65
65
|
[DOM_ACTION_APPEND_HTML]: (0, _action.createAction)(_appendHtml.default),
|
|
66
|
-
[DOM_ACTION_COLLECT_INTERACTIONS]: (0, _action.createAction)(_collectInteractions.default)
|
|
66
|
+
[DOM_ACTION_COLLECT_INTERACTIONS]: (0, _action.createAction)(_collectInteractions.default, true)
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
69
|
exports.default = _default;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _index = require("../../../utils/index.js");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2025 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
|
+
/** @import { PushSubscription } from '../types.js' */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Gets push subscription details for the current browser.
|
|
21
|
+
*
|
|
22
|
+
* @async
|
|
23
|
+
* @function
|
|
24
|
+
*
|
|
25
|
+
* @param {object} options
|
|
26
|
+
* @param {string} options.vapidPublicKey - The VAPID public key in base64 format used for push notification authentication.
|
|
27
|
+
* @param {Window} options.window
|
|
28
|
+
*
|
|
29
|
+
* @returns {Promise<PushSubscription>} A promise that resolves to an object containing the push subscription details.
|
|
30
|
+
|
|
31
|
+
* @throws {Error} Throws an error if service workers are not supported in the browser.
|
|
32
|
+
* @throws {Error} Throws an error if user didn't approve push notifications for the domain.
|
|
33
|
+
* @throws {Error} Throws an error if push notifications are not supported in the browser.
|
|
34
|
+
* @throws {Error} Throws an error if no VAPID public key was provided.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Get subscription details with VAPID key
|
|
38
|
+
* const vapidKey = "BEl62iUYgUivxIkv69yViEuiBIa40HI5hmjHbKPlXO...";
|
|
39
|
+
* const subscription = await getPushSubscriptionDetails(vapidKey);
|
|
40
|
+
* console.log(subscription.endpoint); // "https://fcm.googleapis.com/fcm/send/..."
|
|
41
|
+
*/
|
|
42
|
+
const getPushSubscriptionDetails = async ({
|
|
43
|
+
vapidPublicKey,
|
|
44
|
+
window
|
|
45
|
+
}) => {
|
|
46
|
+
if (!("serviceWorker" in window.navigator)) {
|
|
47
|
+
throw new Error("Service workers are not supported in this browser.");
|
|
48
|
+
}
|
|
49
|
+
if (!("PushManager" in window) || !("Notification" in window)) {
|
|
50
|
+
throw new Error("Push notifications are not supported in this browser.");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @type {object} */
|
|
54
|
+
const notification = window.Notification;
|
|
55
|
+
if (notification.permission !== "granted") {
|
|
56
|
+
throw new Error("The user has not given permission to send push notifications.");
|
|
57
|
+
}
|
|
58
|
+
const serviceWorkerRegistration =
|
|
59
|
+
// eslint-disable-next-line compat/compat
|
|
60
|
+
await window.navigator.serviceWorker.getRegistration();
|
|
61
|
+
if (!serviceWorkerRegistration) {
|
|
62
|
+
throw new Error("No service worker registration was found.");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Even `applicationServerKey` is not required in the spec, some browsers like Chrome are requiring it.
|
|
66
|
+
if (!vapidPublicKey) {
|
|
67
|
+
throw new Error("No VAPID public key was provided.");
|
|
68
|
+
}
|
|
69
|
+
const subscriptionOptions = {
|
|
70
|
+
userVisibleOnly: true,
|
|
71
|
+
applicationServerKey: (0, _index.base64ToBytes)(vapidPublicKey)
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Push subscription handling strategy:
|
|
75
|
+
//
|
|
76
|
+
// 1. We always call subscribe() to either get the current subscription or create a new one.
|
|
77
|
+
// - If called with the same VAPID key as an existing subscription, it returns that subscription
|
|
78
|
+
// - If called with a different VAPID key when a subscription exists, it throws an error
|
|
79
|
+
//
|
|
80
|
+
// 2. Error handling approach:
|
|
81
|
+
// - Browser error messages vary and don't clearly indicate VAPID key conflicts
|
|
82
|
+
// - When subscribe() fails, we assume it's likely due to a VAPID key mismatch
|
|
83
|
+
// - We attempt recovery by unsubscribing the existing subscription and retrying
|
|
84
|
+
// - If the retry also fails, we re-throw the original error
|
|
85
|
+
//
|
|
86
|
+
// This strategy ensures we can handle both new subscriptions and VAPID key changes
|
|
87
|
+
// while gracefully falling back to error reporting when recovery isn't possible.
|
|
88
|
+
try {
|
|
89
|
+
const subscription = await serviceWorkerRegistration.pushManager.subscribe(subscriptionOptions);
|
|
90
|
+
return {
|
|
91
|
+
endpoint: subscription.endpoint,
|
|
92
|
+
keys: {
|
|
93
|
+
p256dh: (0, _index.bytesToBase64)(new Uint8Array(subscription.getKey("p256dh"))),
|
|
94
|
+
auth: (0, _index.bytesToBase64)(new Uint8Array(subscription.getKey("auth")))
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
} catch (e) {
|
|
98
|
+
const subscription = await serviceWorkerRegistration.pushManager.getSubscription();
|
|
99
|
+
if (!subscription) {
|
|
100
|
+
throw e;
|
|
101
|
+
}
|
|
102
|
+
const unsubscribeResult = await subscription.unsubscribe();
|
|
103
|
+
if (!unsubscribeResult) {
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
return getPushSubscriptionDetails({
|
|
107
|
+
vapidPublicKey,
|
|
108
|
+
window
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var _default = exports.default = getPushSubscriptionDetails;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _index = require("../../utils/validation/index.js");
|
|
5
|
+
var _index2 = require("../../utils/index.js");
|
|
6
|
+
var _makeSendPushSubscriptionRequest = require("./request/makeSendPushSubscriptionRequest.js");
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2025 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
|
+
|
|
19
|
+
/** @import { StorageCreator } from '../../utils/types.js' */
|
|
20
|
+
/** @import { EventManager, Logger } from '../../core/types.js' */
|
|
21
|
+
/** @import { IdentityManager } from '../../core/identity/types.js' */
|
|
22
|
+
/** @import { ConsentManager } from '../../core/consent/types.js' */
|
|
23
|
+
/** @import { EdgeRequestExecutor } from '../../core/edgeNetwork/types.js' */
|
|
24
|
+
|
|
25
|
+
const isComponentConfigured = ({
|
|
26
|
+
orgId,
|
|
27
|
+
pushNotifications: {
|
|
28
|
+
vapidPublicKey
|
|
29
|
+
} = {
|
|
30
|
+
vapidPublicKey: undefined
|
|
31
|
+
}
|
|
32
|
+
}) => orgId && vapidPublicKey;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @function
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} options
|
|
38
|
+
* @param {{ orgId: string, pushNotifications: { vapidPublicKey: string }}} options.config
|
|
39
|
+
* @param {StorageCreator} options.createNamespacedStorage
|
|
40
|
+
* @param {EventManager} options.eventManager
|
|
41
|
+
* @param {Logger} options.logger
|
|
42
|
+
* @param {ConsentManager} options.consent
|
|
43
|
+
* @param {IdentityManager} options.identity
|
|
44
|
+
* @param {EdgeRequestExecutor} options.sendEdgeNetworkRequest
|
|
45
|
+
* @returns {{ commands: { sendPushSubscription: object } }}
|
|
46
|
+
*/
|
|
47
|
+
const createPushNotifications = ({
|
|
48
|
+
createNamespacedStorage,
|
|
49
|
+
eventManager,
|
|
50
|
+
config,
|
|
51
|
+
logger,
|
|
52
|
+
consent,
|
|
53
|
+
identity,
|
|
54
|
+
sendEdgeNetworkRequest
|
|
55
|
+
}) => {
|
|
56
|
+
return {
|
|
57
|
+
commands: {
|
|
58
|
+
sendPushSubscription: {
|
|
59
|
+
run: async () => {
|
|
60
|
+
if (!isComponentConfigured(config)) {
|
|
61
|
+
throw new Error("Push notifications module is not configured. No VAPID public key was provided.");
|
|
62
|
+
}
|
|
63
|
+
const {
|
|
64
|
+
orgId,
|
|
65
|
+
pushNotifications: {
|
|
66
|
+
vapidPublicKey
|
|
67
|
+
} = {
|
|
68
|
+
vapidPublicKey: undefined
|
|
69
|
+
}
|
|
70
|
+
} = config || {};
|
|
71
|
+
const storage = createNamespacedStorage((0, _index2.sanitizeOrgIdForCookieName)(orgId) + ".pushNotifications.");
|
|
72
|
+
return (0, _makeSendPushSubscriptionRequest.default)({
|
|
73
|
+
config: {
|
|
74
|
+
vapidPublicKey
|
|
75
|
+
},
|
|
76
|
+
storage: storage.persistent,
|
|
77
|
+
logger,
|
|
78
|
+
sendEdgeNetworkRequest,
|
|
79
|
+
consent,
|
|
80
|
+
eventManager,
|
|
81
|
+
identity,
|
|
82
|
+
window
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
optionsValidator: (0, _index.objectOf)({}).noUnknownFields()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
createPushNotifications.namespace = "Push Notifications";
|
|
91
|
+
createPushNotifications.configValidators = (0, _index.objectOf)({
|
|
92
|
+
pushNotifications: (0, _index.objectOf)({
|
|
93
|
+
vapidPublicKey: (0, _index.string)().required()
|
|
94
|
+
}).noUnknownFields()
|
|
95
|
+
});
|
|
96
|
+
var _default = exports.default = createPushNotifications;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _createDataCollectionRequestPayload = require("../../../utils/request/createDataCollectionRequestPayload.js");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2025 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
|
+
/** @import { EventManager } from "../../../core/types.js" */
|
|
17
|
+
/** @import { DataCollectionRequestPayload } from "../../../utils/request/types.js" */
|
|
18
|
+
/**
|
|
19
|
+
* Creates a data collection request payload for sending push subscription details to Adobe Experience Platform.
|
|
20
|
+
*
|
|
21
|
+
* This function constructs an event containing push notification subscription information,
|
|
22
|
+
* including the subscription details, platform information, and identity data. The event
|
|
23
|
+
* is then packaged into a data collection request payload for transmission to the edge network.
|
|
24
|
+
*
|
|
25
|
+
* @async
|
|
26
|
+
* @function
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} options
|
|
29
|
+
* @param {string} options.ecid
|
|
30
|
+
* @param {EventManager} options.eventManager
|
|
31
|
+
* @param {string} options.serializedPushSubscriptionDetails
|
|
32
|
+
* @param {Window} options.window
|
|
33
|
+
*
|
|
34
|
+
* @returns {Promise<DataCollectionRequestPayload>}
|
|
35
|
+
*/
|
|
36
|
+
var _default = async ({
|
|
37
|
+
ecid,
|
|
38
|
+
eventManager,
|
|
39
|
+
serializedPushSubscriptionDetails,
|
|
40
|
+
window
|
|
41
|
+
}) => {
|
|
42
|
+
const event = eventManager.createEvent();
|
|
43
|
+
event.setUserData({
|
|
44
|
+
pushNotificationDetails: [{
|
|
45
|
+
appID: window.location.host,
|
|
46
|
+
token: serializedPushSubscriptionDetails,
|
|
47
|
+
platform: "web",
|
|
48
|
+
denylisted: false,
|
|
49
|
+
identity: {
|
|
50
|
+
namespace: {
|
|
51
|
+
code: "ECID"
|
|
52
|
+
},
|
|
53
|
+
id: ecid
|
|
54
|
+
}
|
|
55
|
+
}]
|
|
56
|
+
});
|
|
57
|
+
event.finalize();
|
|
58
|
+
const payload = (0, _createDataCollectionRequestPayload.default)();
|
|
59
|
+
payload.addEvent(event);
|
|
60
|
+
return payload;
|
|
61
|
+
};
|
|
62
|
+
exports.default = _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _index = require("../../../utils/request/index.js");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 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
|
+
/** @import { DataCollectionRequestPayload, Request } from '../../../utils/request/types.js' */
|
|
17
|
+
/**
|
|
18
|
+
* @function
|
|
19
|
+
*
|
|
20
|
+
* @param {{ payload: DataCollectionRequestPayload }} options
|
|
21
|
+
*
|
|
22
|
+
* @returns {Request}
|
|
23
|
+
*/
|
|
24
|
+
var _default = ({
|
|
25
|
+
payload
|
|
26
|
+
}) => (0, _index.createRequest)({
|
|
27
|
+
payload,
|
|
28
|
+
getAction() {
|
|
29
|
+
return "interact";
|
|
30
|
+
},
|
|
31
|
+
getUseSendBeacon() {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
exports.default = _default;
|