@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,183 @@
1
+ "use strict";
2
+
3
+ exports.initiateRampIDCall = exports.getRampId = 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
+ const RETRY_CONFIG = {
19
+ MAX_COUNT: 15,
20
+ MAX_TIME_MS: 30000,
21
+ DELAY_BASE_MS: 500,
22
+ MAX_DELAY_MS: 5000,
23
+ SHORT_TIMEOUT_MS: 5000
24
+ };
25
+ const state = {
26
+ rampIdEnv: undefined,
27
+ rampIdCallInitiated: false,
28
+ inProgressRampIdPromise: null,
29
+ scriptLoadingInitiated: false,
30
+ envelopeRetrievalInProgress: false
31
+ };
32
+ const processEnvelope = (envelope, resolve, cookieManager, logger) => {
33
+ let parsedEnvelope;
34
+ try {
35
+ parsedEnvelope = JSON.parse(envelope).envelope;
36
+ } catch {
37
+ parsedEnvelope = envelope;
38
+ }
39
+ if (parsedEnvelope && !state.rampIdCallInitiated) {
40
+ state.rampIdCallInitiated = true;
41
+ state.rampIdEnv = parsedEnvelope;
42
+ state.envelopeRetrievalInProgress = false;
43
+ state.inProgressRampIdPromise = null;
44
+ cookieManager.setValue(_index2.RAMP_ID, state.rampIdEnv);
45
+ cookieManager.setValue(_index2.RAMP_ID_EXPIRES, Date.now() + 48 * 60 * 60 * 1000); //expires in 48 hours
46
+ resolve(state.rampIdEnv);
47
+ } else {
48
+ logger.warn("Invalid RampID envelope received", {
49
+ envelope: parsedEnvelope
50
+ });
51
+ state.envelopeRetrievalInProgress = false;
52
+ }
53
+ };
54
+ const retrieveEnvelopeWithRetries = (resolve, reject, cookieManager, logger) => {
55
+ let retryCount = RETRY_CONFIG.MAX_COUNT;
56
+ let timerMultiplier = 1;
57
+ let totalElapsedTime = 0;
58
+ const tryToRetrieve = () => {
59
+ if (state.rampIdEnv) return;
60
+ if (totalElapsedTime > RETRY_CONFIG.MAX_TIME_MS) {
61
+ logger.error("Maximum retry time exceeded");
62
+ state.envelopeRetrievalInProgress = false;
63
+ reject(new Error("Failed to retrieve RampID - timeout"));
64
+ state.inProgressRampIdPromise = null;
65
+ return;
66
+ }
67
+ if (retryCount === 0) {
68
+ logger.error("Maximum retries exceeded");
69
+ state.envelopeRetrievalInProgress = false;
70
+ reject(new Error("Failed to retrieve RampID after maximum retries"));
71
+ state.inProgressRampIdPromise = null;
72
+ return;
73
+ }
74
+ const delay = Math.min(RETRY_CONFIG.DELAY_BASE_MS * timerMultiplier, RETRY_CONFIG.MAX_DELAY_MS);
75
+ setTimeout(() => {
76
+ totalElapsedTime += delay;
77
+ retryCount -= 1;
78
+ timerMultiplier += 1;
79
+ if (typeof window.ats !== "undefined" && window.ats !== null && !state.rampIdEnv && !state.envelopeRetrievalInProgress) {
80
+ state.envelopeRetrievalInProgress = true;
81
+ window.ats.retrieveEnvelope().then(rampIdResponse => {
82
+ processEnvelope(rampIdResponse, resolve, cookieManager, logger);
83
+ if (!state.rampIdEnv) tryToRetrieve();
84
+ }, () => {
85
+ logger.warn("Failed to retrieve envelope");
86
+ state.envelopeRetrievalInProgress = false;
87
+ tryToRetrieve();
88
+ });
89
+ } else {
90
+ tryToRetrieve();
91
+ }
92
+ }, delay);
93
+ };
94
+ tryToRetrieve();
95
+ };
96
+ const initiateRampIDCall = (rampIdScriptPath, cookieManager, logger, useShortTimeout = false) => {
97
+ if (state.inProgressRampIdPromise) {
98
+ return state.inProgressRampIdPromise;
99
+ }
100
+ const timeoutMs = useShortTimeout ? RETRY_CONFIG.SHORT_TIMEOUT_MS : RETRY_CONFIG.MAX_TIME_MS;
101
+ let timedOut = false;
102
+ const mainPromise = new Promise((resolve, reject) => {
103
+ (0, _index.loadScript)(rampIdScriptPath, {
104
+ onLoad: () => {
105
+ if (typeof window.ats !== "undefined" && !state.envelopeRetrievalInProgress) {
106
+ state.envelopeRetrievalInProgress = true;
107
+ window.ats.retrieveEnvelope().then(envelopeResponse => {
108
+ if (envelopeResponse) {
109
+ if (!timedOut) {
110
+ processEnvelope(envelopeResponse, resolve, cookieManager, logger);
111
+ }
112
+ } else {
113
+ state.envelopeRetrievalInProgress = false;
114
+ window.addEventListener("lrEnvelopePresent", () => {
115
+ if (state.envelopeRetrievalInProgress || timedOut) return;
116
+ state.envelopeRetrievalInProgress = true;
117
+ window.ats.retrieveEnvelope().then(envelopeResult => {
118
+ if (!timedOut) {
119
+ processEnvelope(envelopeResult, resolve, cookieManager, logger);
120
+ }
121
+ }, error => {
122
+ if (!timedOut) {
123
+ logger.error("Failed to retrieve envelope after event", error);
124
+ state.envelopeRetrievalInProgress = false;
125
+ reject(error);
126
+ state.inProgressRampIdPromise = null;
127
+ }
128
+ });
129
+ });
130
+ }
131
+ }).catch(error => {
132
+ if (!timedOut) {
133
+ logger.error("Error retrieving envelope", error);
134
+ state.envelopeRetrievalInProgress = false;
135
+ reject(error);
136
+ state.inProgressRampIdPromise = null;
137
+ }
138
+ });
139
+ }
140
+ retrieveEnvelopeWithRetries(val => {
141
+ if (!timedOut) resolve(val);
142
+ }, err => {
143
+ if (!timedOut) reject(err);
144
+ }, cookieManager, logger);
145
+ },
146
+ onError: error => {
147
+ if (!timedOut) {
148
+ reject(error);
149
+ }
150
+ state.inProgressRampIdPromise = null;
151
+ }
152
+ });
153
+ });
154
+ const timeoutPromise = new Promise(resolve => {
155
+ setTimeout(() => {
156
+ timedOut = true;
157
+ resolve(null);
158
+ }, timeoutMs);
159
+ });
160
+ state.inProgressRampIdPromise = Promise.race([mainPromise, timeoutPromise]).finally(() => {
161
+ state.inProgressRampIdPromise = null;
162
+ });
163
+ return state.inProgressRampIdPromise;
164
+ };
165
+ exports.initiateRampIDCall = initiateRampIDCall;
166
+ const getRampId = (logger, rampIdScriptPath, cookieManager, resolveRampIdIfNotAvailable = true, useShortTimeout = false) => {
167
+ if (state.rampIdEnv) {
168
+ return Promise.resolve(state.rampIdEnv);
169
+ }
170
+ if (cookieManager) {
171
+ const rampIdFromCookie = cookieManager.getValue(_index2.RAMP_ID);
172
+ const rampIdExpires = cookieManager.getValue(_index2.RAMP_ID_EXPIRES);
173
+ if (rampIdFromCookie && rampIdExpires && rampIdExpires > Date.now()) {
174
+ state.rampIdEnv = rampIdFromCookie;
175
+ return Promise.resolve(rampIdFromCookie);
176
+ }
177
+ }
178
+ if (!resolveRampIdIfNotAvailable || rampIdScriptPath == null) {
179
+ return Promise.resolve(null);
180
+ }
181
+ return initiateRampIDCall(rampIdScriptPath, cookieManager, logger, useShortTimeout);
182
+ };
183
+ exports.getRampId = getRampId;
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _index = require("../constants/index.js");
5
+ var _createNode = require("../../../utils/dom/createNode.js");
6
+ var _index2 = require("../../../utils/index.js");
7
+ /*
8
+ Copyright 2025 Adobe. All rights reserved.
9
+ This file is licensed under the Apache License, Version 2.0.
10
+ */
11
+
12
+ let surferId = "";
13
+ let displayClickCookie = "";
14
+ let inProgressSurferPromise = null;
15
+ const addToDom = element => {
16
+ if (document.body) {
17
+ document.body.appendChild(element);
18
+ } else {
19
+ window.addEventListener("load", () => {
20
+ document.body.appendChild(element);
21
+ }, false);
22
+ }
23
+ };
24
+ const getInvisibleIframeElement = url => (0, _createNode.default)("iframe", {
25
+ src: url
26
+ }, {
27
+ height: 0,
28
+ width: 0,
29
+ frameBorder: 0,
30
+ style: {
31
+ display: "none"
32
+ }
33
+ }, []);
34
+ const addListener = fn => window.addEventListener("message", fn, false);
35
+ const removeListener = fn => window.removeEventListener("message", fn, false);
36
+ const initiateAdvertisingIdentityCall = () => {
37
+ if (inProgressSurferPromise) {
38
+ return inProgressSurferPromise;
39
+ }
40
+ inProgressSurferPromise = new Promise((resolve, reject) => {
41
+ setTimeout(() => {
42
+ const scheme = document.location.protocol === "https:" ? "https:" : "http:";
43
+ const nestedParams = new URLSearchParams({
44
+ google: "__EFGCK__",
45
+ gsurfer: "__EFGSURFER__",
46
+ imsId: "__EFIMSORGID__",
47
+ is_fb_cookie_synced: "__EFFB__",
48
+ optout: "__EFOPTOUT__",
49
+ throttleCookie: "__EFSYNC__",
50
+ time: "__EFTIME__",
51
+ ev_lcc: "__LCC__"
52
+ });
53
+ const nestedUrl = scheme + "//www.everestjs.net/static/pixel_details.html#" + nestedParams.toString();
54
+ const mainParams = new URLSearchParams({
55
+ ev_gb: "0",
56
+ url: nestedUrl
57
+ });
58
+ const pixelDetailsUrl = scheme + "//" + _index.SURFER_PIXEL_HOST + "/" + _index.SURFER_USER_ID + "/gr?" + mainParams.toString();
59
+ const iframeElement = getInvisibleIframeElement(pixelDetailsUrl);
60
+ addToDom(iframeElement);
61
+ const pixelDetailsReceiver = function pixelDetailsReceiver(message) {
62
+ if (!message.origin.includes(_index.SURFER_TRUSTED_ORIGIN)) {
63
+ return;
64
+ }
65
+ try {
66
+ const pixelRedirectUri = message.data;
67
+ const hashIndex = pixelRedirectUri.indexOf("#");
68
+ if (hashIndex === -1) {
69
+ resolve({
70
+ surferId: null,
71
+ displayClickCookie: null
72
+ });
73
+ return;
74
+ }
75
+ const hashParams = new URLSearchParams(pixelRedirectUri.substring(hashIndex + 1));
76
+ let resolvedSurferId;
77
+ let resolvedDisplayClickCookie;
78
+ const surferValue = hashParams.get(_index.SURFER_PARAM_KEY);
79
+ if (surferValue) {
80
+ resolvedSurferId = surferValue;
81
+ }
82
+ const displayClickValue = hashParams.get(_index.DISPLAY_CLICK_COOKIE_KEY);
83
+ if (displayClickValue && displayClickValue !== "__LCC__") {
84
+ resolvedDisplayClickCookie = displayClickValue;
85
+ }
86
+ removeListener(pixelDetailsReceiver);
87
+ if (resolvedSurferId) {
88
+ surferId = resolvedSurferId;
89
+ displayClickCookie = resolvedDisplayClickCookie;
90
+ resolve({
91
+ surferId,
92
+ displayClickCookie
93
+ });
94
+ } else {
95
+ resolve({
96
+ surferId: null,
97
+ displayClickCookie: null
98
+ });
99
+ }
100
+ } catch (err) {
101
+ reject(err);
102
+ } finally {
103
+ inProgressSurferPromise = null;
104
+ }
105
+ };
106
+ addListener(pixelDetailsReceiver);
107
+ }, _index.SURFER_TIMEOUT_MS);
108
+ });
109
+ return inProgressSurferPromise;
110
+ };
111
+ const collectSurferId = function collectSurferId(cookieManager, getBrowser, resolveSurferIdIfNotAvailable = true) {
112
+ if (getBrowser) {
113
+ const areThirdPartyCookiesSupportedByDefault = (0, _index2.injectAreThirdPartyCookiesSupportedByDefault)({
114
+ getBrowser
115
+ });
116
+ if (!areThirdPartyCookiesSupportedByDefault()) {
117
+ return Promise.resolve(null);
118
+ }
119
+ }
120
+ if (surferId && surferId !== "") {
121
+ return Promise.resolve(surferId);
122
+ }
123
+ if (cookieManager) {
124
+ const cookieSurferId = cookieManager.getValue(_index.SURFER_ID);
125
+ if (cookieSurferId) {
126
+ surferId = cookieSurferId;
127
+ return Promise.resolve(cookieSurferId);
128
+ }
129
+ }
130
+ if (resolveSurferIdIfNotAvailable) {
131
+ return initiateAdvertisingIdentityCall().then(resolvedId => {
132
+ if (cookieManager && resolvedId) {
133
+ if (resolvedId.surferId) {
134
+ cookieManager.setValue(_index.SURFER_ID, resolvedId.surferId);
135
+ }
136
+ if (resolvedId.displayClickCookie) {
137
+ cookieManager.setValue(_index.DISPLAY_CLICK_COOKIE_KEY, resolvedId.displayClickCookie);
138
+ cookieManager.setValue(_index.DISPLAY_CLICK_COOKIE_KEY_EXPIRES, Date.now() + 15 * 60 * 1000);
139
+ }
140
+ }
141
+ return resolvedId.surferId;
142
+ });
143
+ }
144
+ return Promise.resolve(null);
145
+ };
146
+ var _default = exports.default = collectSurferId;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _createComponent = require("./createComponent.js");
5
+ var _configValidators = require("./configValidators.js");
6
+ var _index = require("../../utils/request/index.js");
7
+ var _createAdConversionHandler = require("./handlers/createAdConversionHandler.js");
8
+ var _advertisingCookieManager = require("./utils/advertisingCookieManager.js");
9
+ /*
10
+ Copyright 2023 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 createAdvertising = ({
22
+ logger,
23
+ config,
24
+ eventManager,
25
+ sendEdgeNetworkRequest,
26
+ consent,
27
+ getBrowser
28
+ }) => {
29
+ const cookieManager = (0, _advertisingCookieManager.default)({
30
+ orgId: config.orgId,
31
+ logger
32
+ });
33
+ const adConversionHandler = (0, _createAdConversionHandler.default)({
34
+ eventManager,
35
+ sendEdgeNetworkRequest,
36
+ consent,
37
+ createDataCollectionRequest: _index.createDataCollectionRequest,
38
+ createDataCollectionRequestPayload: _index.createDataCollectionRequestPayload,
39
+ logger
40
+ });
41
+ return (0, _createComponent.default)({
42
+ logger,
43
+ config,
44
+ eventManager,
45
+ cookieManager,
46
+ adConversionHandler,
47
+ getBrowser
48
+ });
49
+ };
50
+ createAdvertising.namespace = "Advertising";
51
+ createAdvertising.configValidators = _configValidators.default;
52
+ var _default = exports.default = createAdvertising;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _index = require("../../../utils/index.js");
5
+ var _createLoggingCookieJar = require("../../../utils/createLoggingCookieJar.js");
6
+ var _index2 = require("../constants/index.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
+ var _default = ({
19
+ orgId,
20
+ logger
21
+ }) => {
22
+ const loggingCookieJar = (0, _createLoggingCookieJar.default)({
23
+ logger,
24
+ cookieJar: _index.cookieJar
25
+ });
26
+ const getCookieName = (key, useNamespace = true) => useNamespace ? (0, _index.getNamespacedCookieName)(orgId, key) : key;
27
+ const getDefaultExpiration = (minutes = _index2.DEFAULT_THROTTLE_MINUTES) => new Date(Date.now() + minutes * 60 * 1000);
28
+ const safeJsonParse = value => {
29
+ try {
30
+ if (value?.startsWith("%7B") || value?.startsWith("{")) {
31
+ return JSON.parse(decodeURIComponent(value));
32
+ }
33
+ } catch {
34
+ // pass
35
+ }
36
+ return value;
37
+ };
38
+ const safeJsonStringify = value => typeof value === "object" && value !== null ? encodeURIComponent(JSON.stringify(value)) : value;
39
+ const readCookie = (key, useNamespace = true) => {
40
+ try {
41
+ const name = getCookieName(key, useNamespace);
42
+ const value = loggingCookieJar.get(name);
43
+ return value ? safeJsonParse(value) : null;
44
+ } catch (error) {
45
+ logger.error("Error reading cookie: " + key, error);
46
+ return null;
47
+ }
48
+ };
49
+ const writeCookie = (key, value, options = {}, useNamespace = true) => {
50
+ try {
51
+ const name = getCookieName(key, useNamespace);
52
+ const storedValue = safeJsonStringify(value);
53
+ loggingCookieJar.set(name, storedValue, options);
54
+ return true;
55
+ } catch (error) {
56
+ logger.error("Error writing cookie: " + key, error);
57
+ return false;
58
+ }
59
+ };
60
+ const setValue = (key, value, options = {}) => {
61
+ const existing = readCookie(_index2.ADVERTISING_COOKIE_KEY) || {};
62
+ const updated = {
63
+ ...existing,
64
+ [key]: value
65
+ };
66
+ return writeCookie(_index2.ADVERTISING_COOKIE_KEY, updated, {
67
+ expires: getDefaultExpiration(_index2.DEFAULT_COOKIE_EXPIRATION_MINUTES),
68
+ ...options
69
+ });
70
+ };
71
+ const getValue = key => {
72
+ const data = readCookie(_index2.ADVERTISING_COOKIE_KEY) || {};
73
+ return data[key];
74
+ };
75
+ return {
76
+ setValue,
77
+ getValue
78
+ };
79
+ };
80
+ exports.default = _default;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ exports.shouldThrottle = exports.normalizeAdvertiser = exports.markIdsAsConverted = exports.isThrottled = exports.isAnyIdUnused = exports.getUrlParams = exports.createManagedAsyncOperation = exports.appendAdvertisingIdQueryToEvent = void 0;
4
+ var _index = require("../constants/index.js");
5
+ var _index2 = require("../../../utils/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
+ const getUrlParams = () => {
19
+ const parsedParams = _index2.queryString.parse(window.location.search);
20
+ return {
21
+ skwcid: parsedParams[_index.SKWCID_PARAM],
22
+ // "s_kwcid"
23
+ efid: parsedParams[_index.EFID_PARAM] // "ef_id"
24
+ };
25
+ };
26
+
27
+ /**
28
+ * Manages a single, ongoing asynchronous operation to prevent redundant calls.
29
+ * @param {string} operationName - A name for the operation for logging purposes.
30
+ * @param {Function} workerFn - A function that returns a Promise to be executed.
31
+ * @returns {Function} A function that, when called, will either start the worker or return the in-progress promise.
32
+ */
33
+ exports.getUrlParams = getUrlParams;
34
+ const createManagedAsyncOperation = (operationName, workerFn) => {
35
+ let inProgressPromise = null;
36
+ return (...args) => {
37
+ if (inProgressPromise) {
38
+ return inProgressPromise;
39
+ }
40
+ inProgressPromise = workerFn(...args).finally(() => {
41
+ inProgressPromise = null;
42
+ });
43
+ return inProgressPromise;
44
+ };
45
+ };
46
+
47
+ /**
48
+ * Normalizes advertiser settings - extracts enabled advertiser IDs
49
+ * @param {Object[]} advertiserSettings - Array of advertiserSettings objects with advertiserId and enabled properties
50
+ * @returns {string} Comma-separated string of enabled advertiser IDs
51
+ */
52
+ exports.createManagedAsyncOperation = createManagedAsyncOperation;
53
+ const normalizeAdvertiser = advertiserSettings => {
54
+ if (!advertiserSettings || !Array.isArray(advertiserSettings)) {
55
+ return _index.UNKNOWN_ADVERTISER;
56
+ }
57
+ return advertiserSettings.filter(item => item && item.enabled === true && item.advertiserId).map(item => item.advertiserId).join(", ");
58
+ };
59
+ exports.normalizeAdvertiser = normalizeAdvertiser;
60
+ const appendAdvertisingIdQueryToEvent = (idsToInclude, event, cookieManager, componentConfig, addEventType = false) => {
61
+ const searchClickData = cookieManager.getValue(_index.LAST_CLICK_COOKIE_KEY);
62
+ let displayClickCookie = null;
63
+ const displayClickCookieExpires = cookieManager.getValue(_index.DISPLAY_CLICK_COOKIE_KEY_EXPIRES);
64
+ if (displayClickCookieExpires && displayClickCookieExpires > Date.now()) {
65
+ displayClickCookie = cookieManager.getValue(_index.DISPLAY_CLICK_COOKIE_KEY);
66
+ }
67
+ const query = {
68
+ advertising: {
69
+ ...(searchClickData?.click_time && {
70
+ lastSearchClick: searchClickData.click_time
71
+ }),
72
+ ...(displayClickCookie && {
73
+ lastDisplayClick: displayClickCookie
74
+ }),
75
+ stitchIds: {
76
+ ...(idsToInclude[_index.SURFER_ID] && {
77
+ surferId: idsToInclude[_index.SURFER_ID]
78
+ }),
79
+ ...(idsToInclude[_index.ID5_ID] && {
80
+ id5: idsToInclude[_index.ID5_ID]
81
+ }),
82
+ ...(idsToInclude[_index.RAMP_ID] && {
83
+ rampIdEnv: idsToInclude[_index.RAMP_ID]
84
+ }),
85
+ ipAddress: "DUMMY_IP_ADDRESS"
86
+ },
87
+ advIds: normalizeAdvertiser(componentConfig.advertiserSettings),
88
+ ...(addEventType && {
89
+ eventType: _index.AD_CONVERSION_VIEW_EVENT_TYPE
90
+ })
91
+ }
92
+ };
93
+ event.mergeQuery(query);
94
+ return event;
95
+ };
96
+ exports.appendAdvertisingIdQueryToEvent = appendAdvertisingIdQueryToEvent;
97
+ const isAnyIdUnused = (availableIds, conversionCalled) => {
98
+ return Object.entries(availableIds).some(([idType]) => {
99
+ return !conversionCalled[idType];
100
+ });
101
+ };
102
+ exports.isAnyIdUnused = isAnyIdUnused;
103
+ const markIdsAsConverted = (idTypes, conversionCalled, cookieManager, logger) => {
104
+ const now = Date.now();
105
+ idTypes.forEach(idType => {
106
+ conversionCalled[idType] = true;
107
+ cookieManager.setValue(idType + "_last_conversion", now);
108
+ logger.info(_index.LOG_ID_CONVERSION_SUCCESS.replace("{0}", idType));
109
+ });
110
+ cookieManager.setValue(_index.LAST_CONVERSION_TIME_KEY, now);
111
+ };
112
+ exports.markIdsAsConverted = markIdsAsConverted;
113
+ const isThrottled = (idType, cookieManager) => {
114
+ const now = Date.now();
115
+ const THROTTLE_WINDOW = 30 * 60 * 1000; // 30 minutes
116
+ const lastSuccessfulConversion = cookieManager.getValue(idType + "_last_conversion");
117
+ return Boolean(lastSuccessfulConversion && now - lastSuccessfulConversion < THROTTLE_WINDOW);
118
+ };
119
+ exports.isThrottled = isThrottled;
120
+ const shouldThrottle = (idType, cookieManager) => {
121
+ return isThrottled(idType, cookieManager);
122
+ };
123
+ exports.shouldThrottle = shouldThrottle;
@@ -3,6 +3,7 @@
3
3
  exports.default = void 0;
4
4
  var _index = require("../../utils/validation/index.js");
5
5
  var _index2 = require("../../utils/index.js");
6
+ var _consentStatus = require("../../constants/consentStatus.js");
6
7
  /*
7
8
  Copyright 2020 Adobe. All rights reserved.
8
9
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -44,7 +45,10 @@ var _default = ({
44
45
  }),
45
46
  datasetId: (0, _index.string)(),
46
47
  mergeId: (0, _index.string)(),
47
- edgeConfigOverrides: _index2.validateConfigOverride
48
+ edgeConfigOverrides: _index2.validateConfigOverride,
49
+ advertising: (0, _index.objectOf)({
50
+ handleAdvertisingData: (0, _index.enumOf)(_consentStatus.DISABLED, _consentStatus.WAIT, _consentStatus.AUTO).default(_consentStatus.DISABLED)
51
+ })
48
52
  }).required().noUnknownFields();
49
53
  return eventOptionsValidator(options);
50
54
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- exports.PENDING = exports.OUT = exports.IN = void 0;
3
+ exports.WAIT = exports.PENDING = exports.OUT = exports.IN = exports.DISABLED = exports.AUTO = void 0;
4
4
  /*
5
5
  Copyright 2020 Adobe. All rights reserved.
6
6
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -15,4 +15,7 @@ governing permissions and limitations under the License.
15
15
 
16
16
  const IN = exports.IN = "in";
17
17
  const OUT = exports.OUT = "out";
18
- const PENDING = exports.PENDING = "pending";
18
+ const PENDING = exports.PENDING = "pending";
19
+ const DISABLED = exports.DISABLED = "disabled";
20
+ const WAIT = exports.WAIT = "wait";
21
+ const AUTO = exports.AUTO = "auto";
@@ -14,4 +14,4 @@ governing permissions and limitations under the License.
14
14
  */
15
15
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
16
16
  // see babel-plugin-version
17
- var _default = exports.default = "2.28.1";
17
+ var _default = exports.default = "2.29.0-beta.0";
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "activityCollector", {
6
6
  return _index.default;
7
7
  }
8
8
  });
9
+ Object.defineProperty(exports, "advertising", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _index9.default;
13
+ }
14
+ });
9
15
  Object.defineProperty(exports, "audiences", {
10
16
  enumerable: true,
11
17
  get: function () {
@@ -55,4 +61,5 @@ var _index4 = require("../components/EventMerge/index.js");
55
61
  var _index5 = require("../components/MediaAnalyticsBridge/index.js");
56
62
  var _index6 = require("../components/Personalization/index.js");
57
63
  var _index7 = require("../components/RulesEngine/index.js");
58
- var _index8 = require("../components/StreamingMedia/index.js");
64
+ var _index8 = require("../components/StreamingMedia/index.js");
65
+ var _index9 = require("../components/Advertising/index.js");
@@ -18,6 +18,12 @@ Object.defineProperty(exports, "createNode", {
18
18
  return _createNode.default;
19
19
  }
20
20
  });
21
+ Object.defineProperty(exports, "loadScript", {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _loadScript.default;
25
+ }
26
+ });
21
27
  Object.defineProperty(exports, "matchesSelector", {
22
28
  enumerable: true,
23
29
  get: function () {
@@ -51,6 +57,7 @@ Object.defineProperty(exports, "selectNodesWithShadow", {
51
57
  var _awaitSelector = require("./awaitSelector.js");
52
58
  var _appendNode = require("./appendNode.js");
53
59
  var _createNode = require("./createNode.js");
60
+ var _loadScript = require("./loadScript.js");
54
61
  var _matchesSelector = require("./matchesSelector.js");
55
62
  var _querySelectorAll = require("./querySelectorAll.js");
56
63
  var _removeNode = require("./removeNode.js");