@adobe/alloy 2.28.1 → 2.29.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.
Files changed (80) hide show
  1. package/libEs5/components/Advertising/configValidators.js +26 -0
  2. package/libEs5/components/Advertising/constants/index.js +78 -0
  3. package/libEs5/components/Advertising/createComponent.js +59 -0
  4. package/libEs5/components/Advertising/handlers/clickThroughHandler.js +81 -0
  5. package/libEs5/components/Advertising/handlers/createAdConversionHandler.js +55 -0
  6. package/libEs5/components/Advertising/handlers/onBeforeSendEventHandler.js +69 -0
  7. package/libEs5/components/Advertising/handlers/sendAdConversion.js +67 -0
  8. package/libEs5/components/Advertising/handlers/viewThroughHandler.js +56 -0
  9. package/libEs5/components/Advertising/identities/collectAllIdentities.js +34 -0
  10. package/libEs5/components/Advertising/identities/collectID5Id.js +112 -0
  11. package/libEs5/components/Advertising/identities/collectRampId.js +183 -0
  12. package/libEs5/components/Advertising/identities/collectSurferId.js +146 -0
  13. package/libEs5/components/Advertising/index.js +52 -0
  14. package/libEs5/components/Advertising/utils/advertisingCookieManager.js +80 -0
  15. package/libEs5/components/Advertising/utils/helpers.js +123 -0
  16. package/libEs5/components/DataCollector/validateUserEventOptions.js +5 -1
  17. package/libEs5/constants/consentStatus.js +5 -2
  18. package/libEs5/constants/libraryVersion.js +1 -1
  19. package/libEs5/core/componentCreators.js +8 -1
  20. package/libEs5/utils/dom/index.js +7 -0
  21. package/libEs5/utils/dom/loadScript.js +93 -0
  22. package/libEs6/components/Advertising/configValidators.js +24 -0
  23. package/libEs6/components/Advertising/constants/index.js +75 -0
  24. package/libEs6/components/Advertising/createComponent.js +56 -0
  25. package/libEs6/components/Advertising/handlers/clickThroughHandler.js +79 -0
  26. package/libEs6/components/Advertising/handlers/createAdConversionHandler.js +52 -0
  27. package/libEs6/components/Advertising/handlers/onBeforeSendEventHandler.js +66 -0
  28. package/libEs6/components/Advertising/handlers/sendAdConversion.js +65 -0
  29. package/libEs6/components/Advertising/handlers/viewThroughHandler.js +53 -0
  30. package/libEs6/components/Advertising/identities/collectAllIdentities.js +31 -0
  31. package/libEs6/components/Advertising/identities/collectID5Id.js +108 -0
  32. package/libEs6/components/Advertising/identities/collectRampId.js +179 -0
  33. package/libEs6/components/Advertising/identities/collectSurferId.js +143 -0
  34. package/libEs6/components/Advertising/index.js +49 -0
  35. package/libEs6/components/Advertising/utils/advertisingCookieManager.js +77 -0
  36. package/libEs6/components/Advertising/utils/helpers.js +113 -0
  37. package/libEs6/components/DataCollector/validateUserEventOptions.js +6 -2
  38. package/libEs6/constants/consentStatus.js +4 -1
  39. package/libEs6/constants/libraryVersion.js +1 -1
  40. package/libEs6/core/componentCreators.js +2 -1
  41. package/libEs6/utils/dom/index.js +1 -0
  42. package/libEs6/utils/dom/loadScript.js +90 -0
  43. package/package.json +2 -2
  44. package/types/components/Advertising/configValidators.d.ts +3 -0
  45. package/types/components/Advertising/configValidators.d.ts.map +1 -0
  46. package/types/components/Advertising/constants/index.d.ts +46 -0
  47. package/types/components/Advertising/constants/index.d.ts.map +1 -0
  48. package/types/components/Advertising/createComponent.d.ts +18 -0
  49. package/types/components/Advertising/createComponent.d.ts.map +1 -0
  50. package/types/components/Advertising/handlers/clickThroughHandler.d.ts +22 -0
  51. package/types/components/Advertising/handlers/clickThroughHandler.d.ts.map +1 -0
  52. package/types/components/Advertising/handlers/createAdConversionHandler.d.ts +13 -0
  53. package/types/components/Advertising/handlers/createAdConversionHandler.d.ts.map +1 -0
  54. package/types/components/Advertising/handlers/onBeforeSendEventHandler.d.ts +21 -0
  55. package/types/components/Advertising/handlers/onBeforeSendEventHandler.d.ts.map +1 -0
  56. package/types/components/Advertising/handlers/sendAdConversion.d.ts +10 -0
  57. package/types/components/Advertising/handlers/sendAdConversion.d.ts.map +1 -0
  58. package/types/components/Advertising/handlers/viewThroughHandler.d.ts +9 -0
  59. package/types/components/Advertising/handlers/viewThroughHandler.d.ts.map +1 -0
  60. package/types/components/Advertising/identities/collectAllIdentities.d.ts +7 -0
  61. package/types/components/Advertising/identities/collectAllIdentities.d.ts.map +1 -0
  62. package/types/components/Advertising/identities/collectID5Id.d.ts +3 -0
  63. package/types/components/Advertising/identities/collectID5Id.d.ts.map +1 -0
  64. package/types/components/Advertising/identities/collectRampId.d.ts +3 -0
  65. package/types/components/Advertising/identities/collectRampId.d.ts.map +1 -0
  66. package/types/components/Advertising/identities/collectSurferId.d.ts +3 -0
  67. package/types/components/Advertising/identities/collectSurferId.d.ts.map +1 -0
  68. package/types/components/Advertising/index.d.ts +23 -0
  69. package/types/components/Advertising/index.d.ts.map +1 -0
  70. package/types/components/Advertising/utils/advertisingCookieManager.d.ts +9 -0
  71. package/types/components/Advertising/utils/advertisingCookieManager.d.ts.map +1 -0
  72. package/types/components/Advertising/utils/helpers.d.ts +23 -0
  73. package/types/components/Advertising/utils/helpers.d.ts.map +1 -0
  74. package/types/components/DataCollector/validateUserEventOptions.d.ts.map +1 -1
  75. package/types/constants/consentStatus.d.ts +3 -0
  76. package/types/constants/consentStatus.d.ts.map +1 -1
  77. package/types/core/componentCreators.d.ts +1 -0
  78. package/types/utils/dom/index.d.ts +1 -0
  79. package/types/utils/dom/loadScript.d.ts +17 -0
  80. package/types/utils/dom/loadScript.d.ts.map +1 -0
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _index = require("../../utils/validation/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
+ var _default = exports.default = (0, _index.objectOf)({
17
+ advertising: (0, _index.objectOf)({
18
+ id5PartnerId: (0, _index.string)(),
19
+ rampIdJSPath: (0, _index.string)(),
20
+ dspEnabled: (0, _index.boolean)(),
21
+ advertiserSettings: (0, _index.arrayOf)((0, _index.objectOf)({
22
+ advertiserId: (0, _index.string)().required(),
23
+ enabled: (0, _index.boolean)().required()
24
+ }).noUnknownFields())
25
+ }).noUnknownFields()
26
+ });
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ exports.XDM_AD_STITCH_DATA = exports.XDM_AD_CLOUD_PATH = exports.XDM_AD_ASSET_REFERENCE = exports.XDM_AD_ASSET_DATA = exports.XDM_ADVERTISER = exports.UNKNOWN_ADVERTISER = exports.TRACKING_IDENTITIES = exports.TRACKING_CODE = exports.SURFER_USER_ID = exports.SURFER_TRUSTED_ORIGIN = exports.SURFER_TIMEOUT_MS = exports.SURFER_PIXEL_HOST = exports.SURFER_PARAM_KEY = exports.SURFER_ID_COOKIE_KEY = exports.SURFER_ID = exports.SKWCID_PARAM = exports.RAMP_ID_EXPIRES = exports.RAMP_ID_COOKIE_KEY = exports.RAMP_ID = exports.LOG_SENDING_CONVERSION = exports.LOG_ID_RESOLVED = exports.LOG_ID_CONVERSION_SUCCESS = exports.LOG_ERROR_RESOLVING_ID = exports.LOG_COOKIE_WRITTEN = exports.LOG_CONVERSION_TIME_UPDATED = exports.LOG_ALL_IDS_USED = exports.LOG_ALL_IDS_THROTTLED = exports.LOG_AD_CONVERSION_START = exports.LOG_AD_CONVERSION_FAILED = exports.LAST_CONVERSION_TIME_KEY_EXPIRES = exports.LAST_CONVERSION_TIME_KEY = exports.LAST_CLICK_COOKIE_KEY = exports.ID5_SCRIPT_URL = exports.ID5_ID = exports.ID5_COOKIE_KEY = exports.ERROR_RAMP_ID_MAX_RETRIES = exports.ERROR_ID5_PARTNER_ID_REQUIRED = exports.EFID_PARAM = exports.DISPLAY_CLICK_COOKIE_KEY_EXPIRES = exports.DISPLAY_CLICK_COOKIE_KEY = exports.DEFAULT_THROTTLE_MINUTES = exports.DEFAULT_COOKIE_EXPIRATION_MINUTES = exports.AD_CONVERSION_VIEW_EVENT_TYPE = exports.AD_CONVERSION_CLICK_EVENT_TYPE = exports.ADVERTISING_COOKIE_KEY = void 0;
4
+ /*
5
+ Copyright 2025 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
15
+
16
+ // Cookie Keys
17
+ const ADVERTISING_COOKIE_KEY = exports.ADVERTISING_COOKIE_KEY = "advertising";
18
+ const SURFER_ID_COOKIE_KEY = exports.SURFER_ID_COOKIE_KEY = "surfer_id";
19
+ const RAMP_ID_COOKIE_KEY = exports.RAMP_ID_COOKIE_KEY = "ramp_id";
20
+ const ID5_COOKIE_KEY = exports.ID5_COOKIE_KEY = "id5_id";
21
+ const LAST_CLICK_COOKIE_KEY = exports.LAST_CLICK_COOKIE_KEY = "_les_lsc";
22
+ const LAST_CONVERSION_TIME_KEY = exports.LAST_CONVERSION_TIME_KEY = "lastConversionTime";
23
+ const DISPLAY_CLICK_COOKIE_KEY_EXPIRES = exports.DISPLAY_CLICK_COOKIE_KEY_EXPIRES = "displayClickCookieExpires";
24
+ const RAMP_ID_EXPIRES = exports.RAMP_ID_EXPIRES = "rampIdExpires";
25
+ const LAST_CONVERSION_TIME_KEY_EXPIRES = exports.LAST_CONVERSION_TIME_KEY_EXPIRES = "lastConversionTimeExpires";
26
+ // URL Parameters
27
+ const SKWCID_PARAM = exports.SKWCID_PARAM = "s_kwcid";
28
+ const EFID_PARAM = exports.EFID_PARAM = "ef_id";
29
+
30
+ // Identity Types
31
+ const SURFER_ID = exports.SURFER_ID = "surferId";
32
+ const RAMP_ID = exports.RAMP_ID = "rampId";
33
+ const ID5_ID = exports.ID5_ID = "id5Id";
34
+
35
+ // Default Values
36
+ const UNKNOWN_ADVERTISER = exports.UNKNOWN_ADVERTISER = "";
37
+ const DEFAULT_THROTTLE_MINUTES = exports.DEFAULT_THROTTLE_MINUTES = 30;
38
+ const DEFAULT_COOKIE_EXPIRATION_MINUTES = exports.DEFAULT_COOKIE_EXPIRATION_MINUTES = 527040; // 365 days
39
+
40
+ // Event Types
41
+ const AD_CONVERSION_CLICK_EVENT_TYPE = exports.AD_CONVERSION_CLICK_EVENT_TYPE = "advertising.enrichment_ct";
42
+ const AD_CONVERSION_VIEW_EVENT_TYPE = exports.AD_CONVERSION_VIEW_EVENT_TYPE = "advertising.enrichment";
43
+
44
+ // XDM Paths
45
+ const XDM_AD_CLOUD_PATH = exports.XDM_AD_CLOUD_PATH = "_experience.adloud";
46
+ const XDM_AD_ASSET_REFERENCE = exports.XDM_AD_ASSET_REFERENCE = "adAssetReference";
47
+ const XDM_AD_STITCH_DATA = exports.XDM_AD_STITCH_DATA = "adStitchData";
48
+ const XDM_AD_ASSET_DATA = exports.XDM_AD_ASSET_DATA = "adAssetData";
49
+ const XDM_ADVERTISER = exports.XDM_ADVERTISER = "advertiser";
50
+ const TRACKING_CODE = exports.TRACKING_CODE = "trackingCode";
51
+ const TRACKING_IDENTITIES = exports.TRACKING_IDENTITIES = "trackingIdentities";
52
+
53
+ // Script URLs
54
+ const ID5_SCRIPT_URL = exports.ID5_SCRIPT_URL = "https://www.everestjs.net/static/id5-api.js";
55
+
56
+ // Surfer ID Configuration
57
+ const SURFER_PIXEL_HOST = exports.SURFER_PIXEL_HOST = "pixel.everesttech.net";
58
+ const SURFER_USER_ID = exports.SURFER_USER_ID = "1";
59
+ const SURFER_TIMEOUT_MS = exports.SURFER_TIMEOUT_MS = 5000;
60
+ const SURFER_TRUSTED_ORIGIN = exports.SURFER_TRUSTED_ORIGIN = "www.everestjs.net";
61
+ const SURFER_PARAM_KEY = exports.SURFER_PARAM_KEY = "gsurfer";
62
+
63
+ // Error Messages
64
+ const ERROR_ID5_PARTNER_ID_REQUIRED = exports.ERROR_ID5_PARTNER_ID_REQUIRED = "ID5 partner ID is required";
65
+ const ERROR_RAMP_ID_MAX_RETRIES = exports.ERROR_RAMP_ID_MAX_RETRIES = "Failed to retrieve RampID after maximum retries";
66
+
67
+ // Log Messages
68
+ const LOG_AD_CONVERSION_START = exports.LOG_AD_CONVERSION_START = "Processing ad conversion";
69
+ const LOG_COOKIE_WRITTEN = exports.LOG_COOKIE_WRITTEN = "Ad tracking data saved";
70
+ const LOG_CONVERSION_TIME_UPDATED = exports.LOG_CONVERSION_TIME_UPDATED = "Conversion timing recorded";
71
+ const LOG_SENDING_CONVERSION = exports.LOG_SENDING_CONVERSION = "Submitting ad conversion data";
72
+ const LOG_ALL_IDS_THROTTLED = exports.LOG_ALL_IDS_THROTTLED = "Ad conversion paused to prevent duplicate submissions";
73
+ const LOG_ALL_IDS_USED = exports.LOG_ALL_IDS_USED = "Ad conversion already processed";
74
+ const LOG_ID_RESOLVED = exports.LOG_ID_RESOLVED = "Ad identity available";
75
+ const LOG_ERROR_RESOLVING_ID = exports.LOG_ERROR_RESOLVING_ID = "Unable to obtain ad identity";
76
+ const LOG_ID_CONVERSION_SUCCESS = exports.LOG_ID_CONVERSION_SUCCESS = "Ad conversion submitted successfully";
77
+ const LOG_AD_CONVERSION_FAILED = exports.LOG_AD_CONVERSION_FAILED = "Ad conversion submission failed";
78
+ const DISPLAY_CLICK_COOKIE_KEY = exports.DISPLAY_CLICK_COOKIE_KEY = "ev_lcc";
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _sendAdConversion = require("./handlers/sendAdConversion.js");
5
+ var _onBeforeSendEventHandler = require("./handlers/onBeforeSendEventHandler.js");
6
+ /*
7
+ Copyright 2023 Adobe. All rights reserved.
8
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License. You may obtain a copy
10
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software distributed under
13
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ OF ANY KIND, either express or implied. See the License for the specific language
15
+ governing permissions and limitations under the License.
16
+ */
17
+ var _default = ({
18
+ logger,
19
+ config,
20
+ eventManager,
21
+ cookieManager,
22
+ adConversionHandler,
23
+ getBrowser
24
+ }) => {
25
+ const componentConfig = config.advertising;
26
+ const sharedState = {
27
+ processedAdvertisingIds: false
28
+ };
29
+ const sendAdConversionHandler = (0, _sendAdConversion.default)({
30
+ eventManager,
31
+ cookieManager,
32
+ adConversionHandler,
33
+ logger,
34
+ componentConfig,
35
+ getBrowser
36
+ });
37
+ return {
38
+ lifecycle: {
39
+ onComponentsRegistered() {
40
+ sendAdConversionHandler(sharedState);
41
+ },
42
+ onBeforeEvent: ({
43
+ event,
44
+ advertising = {}
45
+ }) => {
46
+ return (0, _onBeforeSendEventHandler.default)({
47
+ cookieManager,
48
+ logger,
49
+ state: sharedState,
50
+ event,
51
+ componentConfig,
52
+ advertising,
53
+ getBrowser
54
+ });
55
+ }
56
+ }
57
+ };
58
+ };
59
+ exports.default = _default;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ exports.default = handleClickThrough;
4
+ var _index = require("../constants/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
+
17
+ /**
18
+ * Handles click-through ad conversions
19
+ * @param {Object} params - All required parameters
20
+ * @param {Object} params.eventManager - Event manager for creating events
21
+ * @param {Object} params.cookieManager - Session manager for cookie operations
22
+ * @param {Object} params.adConversionHandler - Handler for sending ad conversion events
23
+ * @param {Object} params.logger - Logger instance
24
+ * @param {string} params.skwcid - Search keyword click ID
25
+ * @param {string} params.efid - EF ID parameter
26
+ * @param {Object} params.optionsFromCommand - Additional options from command
27
+ * @returns {Promise} Result of the ad conversion tracking
28
+ */
29
+ async function handleClickThrough({
30
+ eventManager,
31
+ cookieManager,
32
+ adConversionHandler,
33
+ logger,
34
+ skwcid,
35
+ efid
36
+ }) {
37
+ logger.info(_index.LOG_AD_CONVERSION_START, {
38
+ skwcid,
39
+ efid
40
+ });
41
+ const event = eventManager.createEvent();
42
+ if (typeof skwcid !== "undefined" && typeof efid !== "undefined" && skwcid.startsWith("AL!")) {
43
+ const clickData = {
44
+ click_time: Date.now(),
45
+ ...(typeof skwcid !== "undefined" && {
46
+ skwcid
47
+ }),
48
+ ...(typeof efid !== "undefined" && {
49
+ efid
50
+ })
51
+ };
52
+ cookieManager.setValue(_index.LAST_CLICK_COOKIE_KEY, clickData);
53
+ }
54
+ const xdm = {
55
+ _experience: {
56
+ adcloud: {
57
+ conversionDetails: {
58
+ ...(typeof skwcid !== "undefined" && {
59
+ [_index.TRACKING_CODE]: skwcid
60
+ }),
61
+ ...(typeof efid !== "undefined" && {
62
+ [_index.TRACKING_IDENTITIES]: efid
63
+ })
64
+ }
65
+ }
66
+ },
67
+ eventType: _index.AD_CONVERSION_CLICK_EVENT_TYPE
68
+ };
69
+ event.setUserXdm(xdm);
70
+ cookieManager.setValue(_index.LAST_CONVERSION_TIME_KEY);
71
+ cookieManager.setValue(_index.LAST_CONVERSION_TIME_KEY_EXPIRES, Date.now() + 91 * 24 * 60 * 60 * 1000); //expires in 91 days
72
+
73
+ try {
74
+ return await adConversionHandler.trackAdConversion({
75
+ event
76
+ });
77
+ } catch (error) {
78
+ logger.error(_index.LOG_AD_CONVERSION_FAILED, error);
79
+ throw error;
80
+ }
81
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ /*
5
+ Copyright 2023 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
15
+ /**
16
+ * Creates a specialized handler for ad conversion events.
17
+ * This follows a similar pattern to the media event handling in the StreamingMedia component.
18
+ */
19
+ var _default = ({
20
+ sendEdgeNetworkRequest,
21
+ consent,
22
+ createDataCollectionRequest,
23
+ createDataCollectionRequestPayload,
24
+ logger
25
+ }) => {
26
+ /**
27
+ * Tracks an ad conversion event by sending it directly to the Edge Network
28
+ */
29
+ const trackAdConversion = ({
30
+ event
31
+ }) => {
32
+ const dataCollectionRequestPayload = createDataCollectionRequestPayload();
33
+ dataCollectionRequestPayload.addEvent(event);
34
+ event.finalize();
35
+ const request = createDataCollectionRequest({
36
+ payload: dataCollectionRequestPayload
37
+ });
38
+ return consent.awaitConsent().then(() => {
39
+ return sendEdgeNetworkRequest({
40
+ request
41
+ }).then(() => {
42
+ return {
43
+ success: true
44
+ };
45
+ }).catch(error => {
46
+ logger.error("Failed to send ad conversion event", error);
47
+ throw error;
48
+ });
49
+ });
50
+ };
51
+ return {
52
+ trackAdConversion
53
+ };
54
+ };
55
+ exports.default = _default;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ exports.default = handleOnBeforeSendEvent;
4
+ var _collectSurferId = require("../identities/collectSurferId.js");
5
+ var _collectID5Id = require("../identities/collectID5Id.js");
6
+ var _collectRampId = require("../identities/collectRampId.js");
7
+ var _helpers = require("../utils/helpers.js");
8
+ var _index = require("../constants/index.js");
9
+ var _consentStatus = require("../../../constants/consentStatus.js");
10
+ /*
11
+ Copyright 2023 Adobe. All rights reserved.
12
+ Licensed under the Apache License, Version 2.0.
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+ */
15
+
16
+ const isAdvertisingDisabled = advertising => {
17
+ return ![_consentStatus.AUTO, _consentStatus.WAIT].includes(advertising?.handleAdvertisingData);
18
+ };
19
+ const waitForAdvertisingId = advertising => {
20
+ return advertising?.handleAdvertisingData === _consentStatus.WAIT;
21
+ };
22
+
23
+ /**
24
+ * Appends advertising identity IDs to AEP event query if not already added.
25
+ * @param {Object} params
26
+ * @param {Object} params.cookieManager
27
+ * @param {Object} params.logger
28
+ * @param {Object} params.state
29
+ * @param {Object} params.event
30
+ * @param {Object} params.componentConfig
31
+ * @param {Object} params.advertising
32
+ * @param {Function} params.getBrowser
33
+ */
34
+ async function handleOnBeforeSendEvent({
35
+ cookieManager,
36
+ logger,
37
+ event,
38
+ componentConfig,
39
+ advertising,
40
+ getBrowser
41
+ }) {
42
+ const {
43
+ skwcid,
44
+ efid
45
+ } = (0, _helpers.getUrlParams)();
46
+ const isClickThru = !!(skwcid && efid);
47
+ if (isAdvertisingDisabled(advertising) || isClickThru || (0, _helpers.isThrottled)(_index.SURFER_ID, cookieManager) && (0, _helpers.isThrottled)(_index.ID5_ID, cookieManager) && (0, _helpers.isThrottled)(_index.RAMP_ID, cookieManager)) return;
48
+ try {
49
+ const useShortTimeout = waitForAdvertisingId(advertising);
50
+ const [surferIdResult, id5IdResult, rampIdResult] = await Promise.allSettled([(0, _collectSurferId.default)(cookieManager, getBrowser, useShortTimeout), (0, _collectID5Id.getID5Id)(logger, componentConfig.id5PartnerId, useShortTimeout, useShortTimeout), (0, _collectRampId.getRampId)(logger, componentConfig.rampIdJSPath, cookieManager, useShortTimeout, useShortTimeout)]);
51
+ const availableIds = {};
52
+ if (surferIdResult.status === "fulfilled" && surferIdResult.value && !(0, _helpers.isThrottled)(_index.SURFER_ID, cookieManager)) {
53
+ availableIds.surferId = surferIdResult.value;
54
+ }
55
+ if (id5IdResult.status === "fulfilled" && id5IdResult.value && !(0, _helpers.isThrottled)(_index.ID5_ID, cookieManager)) {
56
+ availableIds.id5Id = id5IdResult.value;
57
+ }
58
+ if (rampIdResult.status === "fulfilled" && rampIdResult.value && !(0, _helpers.isThrottled)(_index.RAMP_ID, cookieManager)) {
59
+ availableIds.rampId = rampIdResult.value;
60
+ }
61
+ // If no IDs are available and any ID is throttled, return , because we dont have new info to send
62
+ if (Object.keys(availableIds).length === 0 && ((0, _helpers.isThrottled)(_index.SURFER_ID, cookieManager) || (0, _helpers.isThrottled)(_index.ID5_ID, cookieManager) || (0, _helpers.isThrottled)(_index.RAMP_ID, cookieManager))) {
63
+ return;
64
+ }
65
+ (0, _helpers.appendAdvertisingIdQueryToEvent)(availableIds, event, cookieManager, componentConfig);
66
+ } catch (error) {
67
+ logger.error("Error in onBeforeSendEvent hook:", error);
68
+ }
69
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _clickThroughHandler = require("./clickThroughHandler.js");
5
+ var _viewThroughHandler = require("./viewThroughHandler.js");
6
+ var _helpers = require("../utils/helpers.js");
7
+ /*
8
+ Copyright 2023 Adobe. All rights reserved.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
17
+ */
18
+ /**
19
+ * Creates a handler for sending ad conversions.
20
+ * Handles both click-through and view-through conversions.
21
+ * This is a workaround to avoid the full lifecycle of the eventManager.sendEvent
22
+ */
23
+ var _default = ({
24
+ eventManager,
25
+ cookieManager,
26
+ adConversionHandler,
27
+ logger,
28
+ componentConfig,
29
+ getBrowser
30
+ }) => {
31
+ const activeAdvertiserIds = componentConfig?.advertiserSettings ? (0, _helpers.normalizeAdvertiser)(componentConfig.advertiserSettings) : "";
32
+ return async () => {
33
+ const {
34
+ skwcid,
35
+ efid
36
+ } = (0, _helpers.getUrlParams)();
37
+ const isClickThru = !!(skwcid && efid);
38
+ try {
39
+ let result = null;
40
+ if (isClickThru) {
41
+ result = await (0, _clickThroughHandler.default)({
42
+ eventManager,
43
+ cookieManager,
44
+ adConversionHandler,
45
+ logger,
46
+ skwcid,
47
+ efid
48
+ });
49
+ return result;
50
+ } else if (activeAdvertiserIds) {
51
+ result = await (0, _viewThroughHandler.default)({
52
+ eventManager,
53
+ cookieManager,
54
+ logger,
55
+ componentConfig,
56
+ adConversionHandler,
57
+ getBrowser
58
+ });
59
+ return result;
60
+ }
61
+ return null;
62
+ } catch (error) {
63
+ logger.error("Error in sendAdConversion:", error);
64
+ }
65
+ };
66
+ };
67
+ exports.default = _default;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ exports.default = handleViewThrough;
4
+ var _collectAllIdentities = require("../identities/collectAllIdentities.js");
5
+ var _index = require("../constants/index.js");
6
+ var _helpers = require("../utils/helpers.js");
7
+ /*
8
+ Copyright 2025 Adobe. All rights reserved.
9
+ Licensed under the Apache License, Version 2.0.
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+ */
12
+
13
+ async function handleViewThrough({
14
+ eventManager,
15
+ cookieManager,
16
+ logger,
17
+ componentConfig,
18
+ adConversionHandler,
19
+ getBrowser
20
+ }) {
21
+ const resolvedIds = {};
22
+ const usedIdTracker = {};
23
+ const triggerConversion = async () => {
24
+ if (!(0, _helpers.isAnyIdUnused)(resolvedIds, usedIdTracker)) return null;
25
+ const idTypesToUse = Object.keys(resolvedIds);
26
+ try {
27
+ const event = (0, _helpers.appendAdvertisingIdQueryToEvent)(resolvedIds, eventManager.createEvent(), cookieManager, componentConfig, true);
28
+ const xdm = {
29
+ eventType: _index.AD_CONVERSION_VIEW_EVENT_TYPE
30
+ };
31
+ event.setUserXdm(xdm);
32
+ const result = await adConversionHandler.trackAdConversion({
33
+ event
34
+ });
35
+ (0, _helpers.markIdsAsConverted)(idTypesToUse, usedIdTracker, cookieManager, logger);
36
+ return result;
37
+ } catch (error) {
38
+ logger.error(_index.LOG_AD_CONVERSION_FAILED, error);
39
+ return null;
40
+ }
41
+ };
42
+ const identityPromisesMap = (0, _collectAllIdentities.default)(logger, componentConfig, cookieManager, getBrowser);
43
+ if (Object.keys(identityPromisesMap).length === 0) {
44
+ return [];
45
+ }
46
+ const identityPromises = Object.entries(identityPromisesMap).map(([idType, idPromise]) => idPromise.then(idValue => {
47
+ if (idValue) {
48
+ resolvedIds[idType] = idValue;
49
+ return triggerConversion(); // Return the promise directly
50
+ }
51
+ }).catch(error => {
52
+ logger.error(_index.LOG_ERROR_RESOLVING_ID.replace("{0}", idType), error);
53
+ return null;
54
+ }));
55
+ return Promise.allSettled(identityPromises); // Remove the separate conversionTasks handling
56
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _collectSurferId = require("./collectSurferId.js");
5
+ var _collectRampId = require("./collectRampId.js");
6
+ var _collectID5Id = require("./collectID5Id.js");
7
+ var _index = require("../constants/index.js");
8
+ var _helpers = require("../utils/helpers.js");
9
+ /*
10
+ Copyright 2025 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
+
21
+ const collectAllIdentities = (logger, componentConfig, cookieManager, getBrowser) => {
22
+ const promises = {};
23
+ if (!(0, _helpers.isThrottled)(_index.SURFER_ID, cookieManager)) {
24
+ promises.surferId = (0, _collectSurferId.default)(cookieManager, getBrowser, true).catch(() => null);
25
+ }
26
+ if (componentConfig.id5PartnerId && componentConfig.dspEnabled && !(0, _helpers.isThrottled)(_index.ID5_ID, cookieManager)) {
27
+ promises.id5Id = (0, _collectID5Id.getID5Id)(logger, componentConfig.id5PartnerId).catch(() => null);
28
+ }
29
+ if (componentConfig.rampIdJSPath && componentConfig.dspEnabled && !(0, _helpers.isThrottled)(_index.RAMP_ID, cookieManager)) {
30
+ promises.rampId = (0, _collectRampId.getRampId)(logger, componentConfig.rampIdJSPath, cookieManager, true).catch(() => null);
31
+ }
32
+ return promises;
33
+ };
34
+ var _default = exports.default = collectAllIdentities;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ exports.initiateID5Call = exports.getID5Id = void 0;
4
+ var _index = require("../../../utils/dom/index.js");
5
+ var _index2 = require("../constants/index.js");
6
+ /*
7
+ Copyright 2025 Adobe. All rights reserved.
8
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License. You may obtain a copy
10
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software distributed under
13
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ OF ANY KIND, either express or implied. See the License for the specific language
15
+ governing permissions and limitations under the License.
16
+ */
17
+
18
+ let id5Id = "";
19
+ let inProgressId5Promise = null;
20
+ const SHORT_TIMEOUT_MS = 5000;
21
+ const DEFAULT_TIMEOUT_MS = 30000;
22
+ const initiateID5Call = (partnerId, useShortTimeout, logger) => {
23
+ partnerId = Math.floor(Number(partnerId));
24
+ if (inProgressId5Promise) {
25
+ return inProgressId5Promise;
26
+ }
27
+ const timeoutMs = useShortTimeout ? SHORT_TIMEOUT_MS : DEFAULT_TIMEOUT_MS;
28
+ let iD5TimedOut = false;
29
+ const id5ResolutionPromise = new Promise((resolve, reject) => {
30
+ if (!partnerId) {
31
+ logger.error("Missing partner ID");
32
+ reject(new Error("ID5 partner ID is required"));
33
+ return;
34
+ }
35
+ const handleId5 = () => {
36
+ try {
37
+ if (typeof window.ID5 === "undefined") {
38
+ reject(new Error("ID5 object not available after script load"));
39
+ return;
40
+ }
41
+ const id5Instance = window.ID5.init({
42
+ partnerId
43
+ });
44
+ id5Id = id5Instance.getUserId();
45
+ const safeResolve = val => {
46
+ if (!iD5TimedOut) resolve(val);
47
+ };
48
+ if (!id5Id) {
49
+ window.ID5.init({
50
+ partnerId
51
+ }).onAvailable(function firstRetry(retryStatus) {
52
+ id5Id = retryStatus.getUserId();
53
+ if (id5Id) {
54
+ safeResolve(id5Id);
55
+ } else {
56
+ window.ID5.init({
57
+ partnerId
58
+ }).onAvailable(function secondRetry(secondRetryStatus) {
59
+ id5Id = secondRetryStatus.getUserId();
60
+ if (id5Id) {
61
+ safeResolve(id5Id);
62
+ } else {
63
+ logger.error("Failed to get ID5 ID after all retries");
64
+ safeResolve(null);
65
+ }
66
+ });
67
+ }
68
+ }, 1000);
69
+ } else {
70
+ safeResolve(id5Id);
71
+ }
72
+ } catch (error) {
73
+ logger.error("Error during ID5 initialization", error);
74
+ reject(error);
75
+ }
76
+ };
77
+ if (typeof window.ID5 !== "undefined") {
78
+ handleId5();
79
+ } else {
80
+ (0, _index.loadScript)(_index2.ID5_SCRIPT_URL, {
81
+ onLoad: handleId5,
82
+ onError: error => {
83
+ logger.error("Script loading failed", error);
84
+ reject(error);
85
+ }
86
+ });
87
+ }
88
+ });
89
+ const timeoutPromise = new Promise(resolve => {
90
+ setTimeout(() => {
91
+ iD5TimedOut = true;
92
+ resolve(null);
93
+ }, timeoutMs);
94
+ });
95
+ inProgressId5Promise = Promise.race([id5ResolutionPromise, timeoutPromise]).finally(() => {
96
+ inProgressId5Promise = null;
97
+ });
98
+ return inProgressId5Promise;
99
+ };
100
+ exports.initiateID5Call = initiateID5Call;
101
+ const getID5Id = exports.getID5Id = function getID5Id(logger, partnerId, resolveId5IfNotAvailable = true, useShortTimeout = false) {
102
+ if (id5Id && id5Id !== "") {
103
+ return Promise.resolve(id5Id);
104
+ }
105
+ if (!resolveId5IfNotAvailable) {
106
+ return Promise.resolve(null);
107
+ }
108
+ return initiateID5Call(partnerId, useShortTimeout, logger).then(resolvedId => resolvedId).catch(error => {
109
+ logger.error("Failed to get ID5 ID", error);
110
+ throw error;
111
+ });
112
+ };