@blotoutio/providers-blotout-consent-sdk 1.61.0 → 1.61.2

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/index.cjs.js CHANGED
@@ -787,6 +787,7 @@ const createFetchIpv4 = ({ endpoint, fetchImpl = fetch, }) => {
787
787
  };
788
788
 
789
789
  // eslint-disable-next-line @nx/enforce-module-boundaries
790
+ const CONSENT_UPDATE_EVENT = 'ConsentUpdate';
790
791
  /**
791
792
  * Creates a Blotout consent API client for fetching and updating consent preferences.
792
793
  *
@@ -800,7 +801,7 @@ const createFetchIpv4 = ({ endpoint, fetchImpl = fetch, }) => {
800
801
  * getConsentCategories: Fetches consent preferences via GET, returns parsed JSON or null.
801
802
  * update: Sends ConsentAPIPayload via POST with JSON body and credentials.
802
803
  */
803
- const createBlotoutConsentAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, ipv4Capture = false, ipv4Endpoint, }) => {
804
+ const createBlotoutConsentAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, ipv4Capture = false, ipv4Endpoint, sendTag, sendCloudEvents = false, }) => {
804
805
  if (!baseURL) {
805
806
  throw new Error(`baseURL missing`);
806
807
  }
@@ -835,10 +836,31 @@ const createBlotoutConsentAPI = ({ fetch: fetchImpl = window.fetch, baseURL, use
835
836
  return tryParse((_b = (_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a[consentProviderKey]) !== null && _b !== void 0 ? _b : null, null);
836
837
  };
837
838
  const update = async (payload, options) => {
839
+ var _a;
838
840
  const browser_ipv4 = fetchIpv4 ? await fetchIpv4() : undefined;
839
841
  const finalPayload = browser_ipv4
840
842
  ? { ...payload, browser_ipv4 }
841
843
  : payload;
844
+ // Forward the consent update to blotout-cloud only, when the merchant has
845
+ // opted in. Fire-and-forget so it never affects the /update POST below.
846
+ if (sendCloudEvents && sendTag) {
847
+ try {
848
+ sendTag({
849
+ eventName: CONSENT_UPDATE_EVENT,
850
+ eventId: crypto.randomUUID(),
851
+ data: {
852
+ consent_action: payload.consent_action,
853
+ user_preferences: payload.user_preferences,
854
+ tcf_string: (_a = payload.tcf_string) !== null && _a !== void 0 ? _a : '',
855
+ ...(browser_ipv4 ? { browser_ipv4 } : {}),
856
+ },
857
+ providers: { blotoutCloud: { all: true } },
858
+ });
859
+ }
860
+ catch (error) {
861
+ logger.error('Failed to send ConsentUpdate event to blotout-cloud', error);
862
+ }
863
+ }
842
864
  const response = await fetchImpl(getURL('/update'), {
843
865
  method: 'POST',
844
866
  headers: getHeaders(true),
@@ -1303,7 +1325,7 @@ const shouldCollectAnalytics = (variables) => isEnabled(variables);
1303
1325
  * @public
1304
1326
  */
1305
1327
  const init = (params) => {
1306
- var _a, _b, _c, _d, _e, _f, _g, _h;
1328
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1307
1329
  if (typeof window == 'undefined' || typeof document == 'undefined') {
1308
1330
  // if loaded in non-browser SDKs, return early
1309
1331
  return;
@@ -1352,10 +1374,12 @@ const init = (params) => {
1352
1374
  userId: params.userId,
1353
1375
  ipv4Capture: (_b = variables.ipv4Capture) !== null && _b !== void 0 ? _b : false,
1354
1376
  ipv4Endpoint: variables.ipv4Endpoint,
1377
+ sendTag: params.sendTag,
1378
+ sendCloudEvents: (_c = variables.sendCloudEvents) !== null && _c !== void 0 ? _c : false,
1355
1379
  });
1356
1380
  let storeAPI = window[registryKey].storeAPI;
1357
1381
  if (!storeAPI) {
1358
- storeAPI = window[registryKey].storeAPI = (_d = (_c = window[registryKey]).storeAPIFactory) === null || _d === void 0 ? void 0 : _d.call(_c, {});
1382
+ storeAPI = window[registryKey].storeAPI = (_e = (_d = window[registryKey]).storeAPIFactory) === null || _e === void 0 ? void 0 : _e.call(_d, {});
1359
1383
  }
1360
1384
  if (isPreviewMode(variables)) {
1361
1385
  logger.info('Consent banner is in preview mode');
@@ -1398,14 +1422,14 @@ const init = (params) => {
1398
1422
  // banner via the public on-demand API; show() defers until the element
1399
1423
  // has rendered, so it appears even when the display rules would hide it.
1400
1424
  if (forceShow) {
1401
- (_f = (_e = window[registryKey]) === null || _e === void 0 ? void 0 : _e.showBanner) === null || _f === void 0 ? void 0 : _f.call(_e);
1425
+ (_g = (_f = window[registryKey]) === null || _f === void 0 ? void 0 : _f.showBanner) === null || _g === void 0 ? void 0 : _g.call(_f);
1402
1426
  }
1403
1427
  }
1404
1428
  else {
1405
1429
  logger.info('Consent banner is disabled');
1406
1430
  }
1407
1431
  if (shouldCollectAnalytics(variables))
1408
- collectConsentAnalytics(params.baseUrl, (_h = (_g = params.session) === null || _g === void 0 ? void 0 : _g.isNewSession) !== null && _h !== void 0 ? _h : false);
1432
+ collectConsentAnalytics(params.baseUrl, (_j = (_h = params.session) === null || _h === void 0 ? void 0 : _h.isNewSession) !== null && _j !== void 0 ? _j : false);
1409
1433
  notifyReady();
1410
1434
  }
1411
1435
  catch (error) {
package/index.js CHANGED
@@ -786,6 +786,7 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
786
786
  };
787
787
 
788
788
  // eslint-disable-next-line @nx/enforce-module-boundaries
789
+ const CONSENT_UPDATE_EVENT = 'ConsentUpdate';
789
790
  /**
790
791
  * Creates a Blotout consent API client for fetching and updating consent preferences.
791
792
  *
@@ -799,7 +800,7 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
799
800
  * getConsentCategories: Fetches consent preferences via GET, returns parsed JSON or null.
800
801
  * update: Sends ConsentAPIPayload via POST with JSON body and credentials.
801
802
  */
802
- const createBlotoutConsentAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, ipv4Capture = false, ipv4Endpoint, }) => {
803
+ const createBlotoutConsentAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, ipv4Capture = false, ipv4Endpoint, sendTag, sendCloudEvents = false, }) => {
803
804
  if (!baseURL) {
804
805
  throw new Error(`baseURL missing`);
805
806
  }
@@ -834,10 +835,31 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
834
835
  return tryParse((_b = (_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a[consentProviderKey]) !== null && _b !== void 0 ? _b : null, null);
835
836
  };
836
837
  const update = async (payload, options) => {
838
+ var _a;
837
839
  const browser_ipv4 = fetchIpv4 ? await fetchIpv4() : undefined;
838
840
  const finalPayload = browser_ipv4
839
841
  ? { ...payload, browser_ipv4 }
840
842
  : payload;
843
+ // Forward the consent update to blotout-cloud only, when the merchant has
844
+ // opted in. Fire-and-forget so it never affects the /update POST below.
845
+ if (sendCloudEvents && sendTag) {
846
+ try {
847
+ sendTag({
848
+ eventName: CONSENT_UPDATE_EVENT,
849
+ eventId: crypto.randomUUID(),
850
+ data: {
851
+ consent_action: payload.consent_action,
852
+ user_preferences: payload.user_preferences,
853
+ tcf_string: (_a = payload.tcf_string) !== null && _a !== void 0 ? _a : '',
854
+ ...(browser_ipv4 ? { browser_ipv4 } : {}),
855
+ },
856
+ providers: { blotoutCloud: { all: true } },
857
+ });
858
+ }
859
+ catch (error) {
860
+ logger.error('Failed to send ConsentUpdate event to blotout-cloud', error);
861
+ }
862
+ }
841
863
  const response = await fetchImpl(getURL('/update'), {
842
864
  method: 'POST',
843
865
  headers: getHeaders(true),
@@ -1302,7 +1324,7 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
1302
1324
  * @public
1303
1325
  */
1304
1326
  const init = (params) => {
1305
- var _a, _b, _c, _d, _e, _f, _g, _h;
1327
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1306
1328
  if (typeof window == 'undefined' || typeof document == 'undefined') {
1307
1329
  // if loaded in non-browser SDKs, return early
1308
1330
  return;
@@ -1351,10 +1373,12 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
1351
1373
  userId: params.userId,
1352
1374
  ipv4Capture: (_b = variables.ipv4Capture) !== null && _b !== void 0 ? _b : false,
1353
1375
  ipv4Endpoint: variables.ipv4Endpoint,
1376
+ sendTag: params.sendTag,
1377
+ sendCloudEvents: (_c = variables.sendCloudEvents) !== null && _c !== void 0 ? _c : false,
1354
1378
  });
1355
1379
  let storeAPI = window[registryKey].storeAPI;
1356
1380
  if (!storeAPI) {
1357
- storeAPI = window[registryKey].storeAPI = (_d = (_c = window[registryKey]).storeAPIFactory) === null || _d === void 0 ? void 0 : _d.call(_c, {});
1381
+ storeAPI = window[registryKey].storeAPI = (_e = (_d = window[registryKey]).storeAPIFactory) === null || _e === void 0 ? void 0 : _e.call(_d, {});
1358
1382
  }
1359
1383
  if (isPreviewMode(variables)) {
1360
1384
  logger.info('Consent banner is in preview mode');
@@ -1397,14 +1421,14 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
1397
1421
  // banner via the public on-demand API; show() defers until the element
1398
1422
  // has rendered, so it appears even when the display rules would hide it.
1399
1423
  if (forceShow) {
1400
- (_f = (_e = window[registryKey]) === null || _e === void 0 ? void 0 : _e.showBanner) === null || _f === void 0 ? void 0 : _f.call(_e);
1424
+ (_g = (_f = window[registryKey]) === null || _f === void 0 ? void 0 : _f.showBanner) === null || _g === void 0 ? void 0 : _g.call(_f);
1401
1425
  }
1402
1426
  }
1403
1427
  else {
1404
1428
  logger.info('Consent banner is disabled');
1405
1429
  }
1406
1430
  if (shouldCollectAnalytics(variables))
1407
- collectConsentAnalytics(params.baseUrl, (_h = (_g = params.session) === null || _g === void 0 ? void 0 : _g.isNewSession) !== null && _h !== void 0 ? _h : false);
1431
+ collectConsentAnalytics(params.baseUrl, (_j = (_h = params.session) === null || _h === void 0 ? void 0 : _h.isNewSession) !== null && _j !== void 0 ? _j : false);
1408
1432
  notifyReady();
1409
1433
  }
1410
1434
  catch (error) {
package/index.mjs CHANGED
@@ -783,6 +783,7 @@ const createFetchIpv4 = ({ endpoint, fetchImpl = fetch, }) => {
783
783
  };
784
784
 
785
785
  // eslint-disable-next-line @nx/enforce-module-boundaries
786
+ const CONSENT_UPDATE_EVENT = 'ConsentUpdate';
786
787
  /**
787
788
  * Creates a Blotout consent API client for fetching and updating consent preferences.
788
789
  *
@@ -796,7 +797,7 @@ const createFetchIpv4 = ({ endpoint, fetchImpl = fetch, }) => {
796
797
  * getConsentCategories: Fetches consent preferences via GET, returns parsed JSON or null.
797
798
  * update: Sends ConsentAPIPayload via POST with JSON body and credentials.
798
799
  */
799
- const createBlotoutConsentAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, ipv4Capture = false, ipv4Endpoint, }) => {
800
+ const createBlotoutConsentAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, ipv4Capture = false, ipv4Endpoint, sendTag, sendCloudEvents = false, }) => {
800
801
  if (!baseURL) {
801
802
  throw new Error(`baseURL missing`);
802
803
  }
@@ -831,10 +832,31 @@ const createBlotoutConsentAPI = ({ fetch: fetchImpl = window.fetch, baseURL, use
831
832
  return tryParse((_b = (_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a[consentProviderKey]) !== null && _b !== void 0 ? _b : null, null);
832
833
  };
833
834
  const update = async (payload, options) => {
835
+ var _a;
834
836
  const browser_ipv4 = fetchIpv4 ? await fetchIpv4() : undefined;
835
837
  const finalPayload = browser_ipv4
836
838
  ? { ...payload, browser_ipv4 }
837
839
  : payload;
840
+ // Forward the consent update to blotout-cloud only, when the merchant has
841
+ // opted in. Fire-and-forget so it never affects the /update POST below.
842
+ if (sendCloudEvents && sendTag) {
843
+ try {
844
+ sendTag({
845
+ eventName: CONSENT_UPDATE_EVENT,
846
+ eventId: crypto.randomUUID(),
847
+ data: {
848
+ consent_action: payload.consent_action,
849
+ user_preferences: payload.user_preferences,
850
+ tcf_string: (_a = payload.tcf_string) !== null && _a !== void 0 ? _a : '',
851
+ ...(browser_ipv4 ? { browser_ipv4 } : {}),
852
+ },
853
+ providers: { blotoutCloud: { all: true } },
854
+ });
855
+ }
856
+ catch (error) {
857
+ logger.error('Failed to send ConsentUpdate event to blotout-cloud', error);
858
+ }
859
+ }
838
860
  const response = await fetchImpl(getURL('/update'), {
839
861
  method: 'POST',
840
862
  headers: getHeaders(true),
@@ -1299,7 +1321,7 @@ const shouldCollectAnalytics = (variables) => isEnabled(variables);
1299
1321
  * @public
1300
1322
  */
1301
1323
  const init = (params) => {
1302
- var _a, _b, _c, _d, _e, _f, _g, _h;
1324
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1303
1325
  if (typeof window == 'undefined' || typeof document == 'undefined') {
1304
1326
  // if loaded in non-browser SDKs, return early
1305
1327
  return;
@@ -1348,10 +1370,12 @@ const init = (params) => {
1348
1370
  userId: params.userId,
1349
1371
  ipv4Capture: (_b = variables.ipv4Capture) !== null && _b !== void 0 ? _b : false,
1350
1372
  ipv4Endpoint: variables.ipv4Endpoint,
1373
+ sendTag: params.sendTag,
1374
+ sendCloudEvents: (_c = variables.sendCloudEvents) !== null && _c !== void 0 ? _c : false,
1351
1375
  });
1352
1376
  let storeAPI = window[registryKey].storeAPI;
1353
1377
  if (!storeAPI) {
1354
- storeAPI = window[registryKey].storeAPI = (_d = (_c = window[registryKey]).storeAPIFactory) === null || _d === void 0 ? void 0 : _d.call(_c, {});
1378
+ storeAPI = window[registryKey].storeAPI = (_e = (_d = window[registryKey]).storeAPIFactory) === null || _e === void 0 ? void 0 : _e.call(_d, {});
1355
1379
  }
1356
1380
  if (isPreviewMode(variables)) {
1357
1381
  logger.info('Consent banner is in preview mode');
@@ -1394,14 +1418,14 @@ const init = (params) => {
1394
1418
  // banner via the public on-demand API; show() defers until the element
1395
1419
  // has rendered, so it appears even when the display rules would hide it.
1396
1420
  if (forceShow) {
1397
- (_f = (_e = window[registryKey]) === null || _e === void 0 ? void 0 : _e.showBanner) === null || _f === void 0 ? void 0 : _f.call(_e);
1421
+ (_g = (_f = window[registryKey]) === null || _f === void 0 ? void 0 : _f.showBanner) === null || _g === void 0 ? void 0 : _g.call(_f);
1398
1422
  }
1399
1423
  }
1400
1424
  else {
1401
1425
  logger.info('Consent banner is disabled');
1402
1426
  }
1403
1427
  if (shouldCollectAnalytics(variables))
1404
- collectConsentAnalytics(params.baseUrl, (_h = (_g = params.session) === null || _g === void 0 ? void 0 : _g.isNewSession) !== null && _h !== void 0 ? _h : false);
1428
+ collectConsentAnalytics(params.baseUrl, (_j = (_h = params.session) === null || _h === void 0 ? void 0 : _h.isNewSession) !== null && _j !== void 0 ? _j : false);
1405
1429
  notifyReady();
1406
1430
  }
1407
1431
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-blotout-consent-sdk",
3
- "version": "1.61.0",
3
+ "version": "1.61.2",
4
4
  "description": "Blotout Consent Banner SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",