@blotoutio/providers-google-ads-clicks-sdk 1.20.1 → 1.21.1

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 (4) hide show
  1. package/index.cjs.js +30 -20
  2. package/index.js +30 -20
  3. package/index.mjs +30 -20
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -8,17 +8,28 @@ const isRecord = (v) => !!v && typeof v == 'object' && !Array.isArray(v);
8
8
  * This function validates user consent for a given provider type, not based on tagName.
9
9
  */
10
10
  const hasUserConsentForProvider = (consent, provider) => {
11
- if (!isRecord(consent)) {
12
- return false;
13
- }
14
- let allowed = isBool(consent.all) ? consent.all : false;
15
- if (provider in consent) {
16
- const providerSpecific = consent[provider];
17
- if (isBool(providerSpecific)) {
18
- allowed = providerSpecific;
11
+ var _a, _b;
12
+ let allowed = false;
13
+ if (isRecord(consent === null || consent === void 0 ? void 0 : consent.consent)) {
14
+ allowed = isBool(consent.consent.all) ? consent.consent.all : false;
15
+ if (provider in consent) {
16
+ const providerSpecific = consent.consent[provider];
17
+ if (isBool(providerSpecific)) {
18
+ allowed = providerSpecific;
19
+ }
20
+ else if (isRecord(providerSpecific)) {
21
+ return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
22
+ }
19
23
  }
20
- else if (isRecord(providerSpecific)) {
21
- return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
24
+ }
25
+ if (isRecord(consent.categories) &&
26
+ isRecord((_a = consent.consentSettings) === null || _a === void 0 ? void 0 : _a.channels)) {
27
+ allowed = isBool(consent.categories.all) ? consent.categories.all : false;
28
+ const category = (_b = Object.entries(consent.consentSettings.channels).find(([, value]) => {
29
+ return value.includes(provider);
30
+ })) === null || _b === void 0 ? void 0 : _b[0];
31
+ if (category && consent.categories[category]) {
32
+ allowed = true;
22
33
  }
23
34
  }
24
35
  return allowed;
@@ -388,9 +399,8 @@ const usStates = new Map([
388
399
  new Set([...isoCountries.keys(), ...usStates.keys()]);
389
400
 
390
401
  // eslint-disable-next-line @nx/enforce-module-boundaries
391
- // TODO: once categories becomes a stable field, we need to remove this and start using categories data for google consent mode.
392
- const getGoogleConsentFromChannels = (consent) => {
393
- const gadsConsent = hasUserConsentForProvider(consent, 'googleAdsClicks');
402
+ const getGoogleConsent = (consentData) => {
403
+ const gadsConsent = hasUserConsentForProvider(consentData, 'googleAdsClicks');
394
404
  return {
395
405
  ad_storage: gadsConsent ? 'granted' : 'denied',
396
406
  ad_user_data: gadsConsent ? 'granted' : 'denied',
@@ -399,7 +409,7 @@ const getGoogleConsentFromChannels = (consent) => {
399
409
  };
400
410
 
401
411
  // eslint-disable-next-line @nx/enforce-module-boundaries
402
- const initGAds = (ID, consent, executionContext) => {
412
+ const initGAds = (ID, consentData, executionContext) => {
403
413
  var _a;
404
414
  window.dataLayer = window.dataLayer || [];
405
415
  window.gtag = function gtag() {
@@ -413,7 +423,7 @@ const initGAds = (ID, consent, executionContext) => {
413
423
  break;
414
424
  }
415
425
  }
416
- const data = getGoogleConsentFromChannels(consent);
426
+ const data = getGoogleConsent(consentData);
417
427
  if (isConsentInitialised) {
418
428
  window.gtag('consent', 'update', data);
419
429
  }
@@ -452,7 +462,7 @@ const init = ({ manifest, consentData, executionContext }) => {
452
462
  }
453
463
  if (!window.google_tag_manager ||
454
464
  !window.google_tag_manager[manifest.variables['tagId']]) {
455
- initGAds(manifest.variables['tagId'], consentData.consent, executionContext);
465
+ initGAds(manifest.variables['tagId'], consentData, executionContext);
456
466
  }
457
467
  if (window.gtag) {
458
468
  window.gtag('config', manifest.variables['tagId'], customConfig);
@@ -595,14 +605,14 @@ const tag = ({ data, eventName, manifestVariables, destination, }) => {
595
605
  !getCookieValue('_gcl_au')) {
596
606
  return {
597
607
  isFired: false,
598
- sdkVersion: "1.20.1" ,
608
+ sdkVersion: "1.21.1" ,
599
609
  };
600
610
  }
601
611
  const conversionLabel = getConversionLabel(eventName, manifestVariables);
602
612
  if (!conversionLabel) {
603
613
  return {
604
614
  isFired: false,
605
- sdkVersion: "1.20.1" ,
615
+ sdkVersion: "1.21.1" ,
606
616
  };
607
617
  }
608
618
  if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
@@ -619,7 +629,7 @@ const tag = ({ data, eventName, manifestVariables, destination, }) => {
619
629
  });
620
630
  return {
621
631
  isFired: true,
622
- sdkVersion: "1.20.1" ,
632
+ sdkVersion: "1.21.1" ,
623
633
  };
624
634
  };
625
635
 
@@ -627,7 +637,7 @@ const consent = ({ consentData }) => {
627
637
  if (!(window === null || window === void 0 ? void 0 : window.gtag)) {
628
638
  return;
629
639
  }
630
- const data = getGoogleConsentFromChannels(consentData.consent);
640
+ const data = getGoogleConsent(consentData);
631
641
  window.gtag('consent', 'update', {
632
642
  ...data,
633
643
  personalization_storage: 'granted',
package/index.js CHANGED
@@ -9,17 +9,28 @@ var ProvidersGoogleAdsClicksSdk = (function () {
9
9
  * This function validates user consent for a given provider type, not based on tagName.
10
10
  */
11
11
  const hasUserConsentForProvider = (consent, provider) => {
12
- if (!isRecord(consent)) {
13
- return false;
14
- }
15
- let allowed = isBool(consent.all) ? consent.all : false;
16
- if (provider in consent) {
17
- const providerSpecific = consent[provider];
18
- if (isBool(providerSpecific)) {
19
- allowed = providerSpecific;
12
+ var _a, _b;
13
+ let allowed = false;
14
+ if (isRecord(consent === null || consent === void 0 ? void 0 : consent.consent)) {
15
+ allowed = isBool(consent.consent.all) ? consent.consent.all : false;
16
+ if (provider in consent) {
17
+ const providerSpecific = consent.consent[provider];
18
+ if (isBool(providerSpecific)) {
19
+ allowed = providerSpecific;
20
+ }
21
+ else if (isRecord(providerSpecific)) {
22
+ return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
23
+ }
20
24
  }
21
- else if (isRecord(providerSpecific)) {
22
- return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
25
+ }
26
+ if (isRecord(consent.categories) &&
27
+ isRecord((_a = consent.consentSettings) === null || _a === void 0 ? void 0 : _a.channels)) {
28
+ allowed = isBool(consent.categories.all) ? consent.categories.all : false;
29
+ const category = (_b = Object.entries(consent.consentSettings.channels).find(([, value]) => {
30
+ return value.includes(provider);
31
+ })) === null || _b === void 0 ? void 0 : _b[0];
32
+ if (category && consent.categories[category]) {
33
+ allowed = true;
23
34
  }
24
35
  }
25
36
  return allowed;
@@ -389,9 +400,8 @@ var ProvidersGoogleAdsClicksSdk = (function () {
389
400
  new Set([...isoCountries.keys(), ...usStates.keys()]);
390
401
 
391
402
  // eslint-disable-next-line @nx/enforce-module-boundaries
392
- // TODO: once categories becomes a stable field, we need to remove this and start using categories data for google consent mode.
393
- const getGoogleConsentFromChannels = (consent) => {
394
- const gadsConsent = hasUserConsentForProvider(consent, 'googleAdsClicks');
403
+ const getGoogleConsent = (consentData) => {
404
+ const gadsConsent = hasUserConsentForProvider(consentData, 'googleAdsClicks');
395
405
  return {
396
406
  ad_storage: gadsConsent ? 'granted' : 'denied',
397
407
  ad_user_data: gadsConsent ? 'granted' : 'denied',
@@ -400,7 +410,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
400
410
  };
401
411
 
402
412
  // eslint-disable-next-line @nx/enforce-module-boundaries
403
- const initGAds = (ID, consent, executionContext) => {
413
+ const initGAds = (ID, consentData, executionContext) => {
404
414
  var _a;
405
415
  window.dataLayer = window.dataLayer || [];
406
416
  window.gtag = function gtag() {
@@ -414,7 +424,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
414
424
  break;
415
425
  }
416
426
  }
417
- const data = getGoogleConsentFromChannels(consent);
427
+ const data = getGoogleConsent(consentData);
418
428
  if (isConsentInitialised) {
419
429
  window.gtag('consent', 'update', data);
420
430
  }
@@ -453,7 +463,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
453
463
  }
454
464
  if (!window.google_tag_manager ||
455
465
  !window.google_tag_manager[manifest.variables['tagId']]) {
456
- initGAds(manifest.variables['tagId'], consentData.consent, executionContext);
466
+ initGAds(manifest.variables['tagId'], consentData, executionContext);
457
467
  }
458
468
  if (window.gtag) {
459
469
  window.gtag('config', manifest.variables['tagId'], customConfig);
@@ -596,14 +606,14 @@ var ProvidersGoogleAdsClicksSdk = (function () {
596
606
  !getCookieValue('_gcl_au')) {
597
607
  return {
598
608
  isFired: false,
599
- sdkVersion: "1.20.1" ,
609
+ sdkVersion: "1.21.1" ,
600
610
  };
601
611
  }
602
612
  const conversionLabel = getConversionLabel(eventName, manifestVariables);
603
613
  if (!conversionLabel) {
604
614
  return {
605
615
  isFired: false,
606
- sdkVersion: "1.20.1" ,
616
+ sdkVersion: "1.21.1" ,
607
617
  };
608
618
  }
609
619
  if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
@@ -620,7 +630,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
620
630
  });
621
631
  return {
622
632
  isFired: true,
623
- sdkVersion: "1.20.1" ,
633
+ sdkVersion: "1.21.1" ,
624
634
  };
625
635
  };
626
636
 
@@ -628,7 +638,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
628
638
  if (!(window === null || window === void 0 ? void 0 : window.gtag)) {
629
639
  return;
630
640
  }
631
- const data = getGoogleConsentFromChannels(consentData.consent);
641
+ const data = getGoogleConsent(consentData);
632
642
  window.gtag('consent', 'update', {
633
643
  ...data,
634
644
  personalization_storage: 'granted',
package/index.mjs CHANGED
@@ -6,17 +6,28 @@ const isRecord = (v) => !!v && typeof v == 'object' && !Array.isArray(v);
6
6
  * This function validates user consent for a given provider type, not based on tagName.
7
7
  */
8
8
  const hasUserConsentForProvider = (consent, provider) => {
9
- if (!isRecord(consent)) {
10
- return false;
11
- }
12
- let allowed = isBool(consent.all) ? consent.all : false;
13
- if (provider in consent) {
14
- const providerSpecific = consent[provider];
15
- if (isBool(providerSpecific)) {
16
- allowed = providerSpecific;
9
+ var _a, _b;
10
+ let allowed = false;
11
+ if (isRecord(consent === null || consent === void 0 ? void 0 : consent.consent)) {
12
+ allowed = isBool(consent.consent.all) ? consent.consent.all : false;
13
+ if (provider in consent) {
14
+ const providerSpecific = consent.consent[provider];
15
+ if (isBool(providerSpecific)) {
16
+ allowed = providerSpecific;
17
+ }
18
+ else if (isRecord(providerSpecific)) {
19
+ return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
20
+ }
17
21
  }
18
- else if (isRecord(providerSpecific)) {
19
- return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
22
+ }
23
+ if (isRecord(consent.categories) &&
24
+ isRecord((_a = consent.consentSettings) === null || _a === void 0 ? void 0 : _a.channels)) {
25
+ allowed = isBool(consent.categories.all) ? consent.categories.all : false;
26
+ const category = (_b = Object.entries(consent.consentSettings.channels).find(([, value]) => {
27
+ return value.includes(provider);
28
+ })) === null || _b === void 0 ? void 0 : _b[0];
29
+ if (category && consent.categories[category]) {
30
+ allowed = true;
20
31
  }
21
32
  }
22
33
  return allowed;
@@ -386,9 +397,8 @@ const usStates = new Map([
386
397
  new Set([...isoCountries.keys(), ...usStates.keys()]);
387
398
 
388
399
  // eslint-disable-next-line @nx/enforce-module-boundaries
389
- // TODO: once categories becomes a stable field, we need to remove this and start using categories data for google consent mode.
390
- const getGoogleConsentFromChannels = (consent) => {
391
- const gadsConsent = hasUserConsentForProvider(consent, 'googleAdsClicks');
400
+ const getGoogleConsent = (consentData) => {
401
+ const gadsConsent = hasUserConsentForProvider(consentData, 'googleAdsClicks');
392
402
  return {
393
403
  ad_storage: gadsConsent ? 'granted' : 'denied',
394
404
  ad_user_data: gadsConsent ? 'granted' : 'denied',
@@ -397,7 +407,7 @@ const getGoogleConsentFromChannels = (consent) => {
397
407
  };
398
408
 
399
409
  // eslint-disable-next-line @nx/enforce-module-boundaries
400
- const initGAds = (ID, consent, executionContext) => {
410
+ const initGAds = (ID, consentData, executionContext) => {
401
411
  var _a;
402
412
  window.dataLayer = window.dataLayer || [];
403
413
  window.gtag = function gtag() {
@@ -411,7 +421,7 @@ const initGAds = (ID, consent, executionContext) => {
411
421
  break;
412
422
  }
413
423
  }
414
- const data = getGoogleConsentFromChannels(consent);
424
+ const data = getGoogleConsent(consentData);
415
425
  if (isConsentInitialised) {
416
426
  window.gtag('consent', 'update', data);
417
427
  }
@@ -450,7 +460,7 @@ const init = ({ manifest, consentData, executionContext }) => {
450
460
  }
451
461
  if (!window.google_tag_manager ||
452
462
  !window.google_tag_manager[manifest.variables['tagId']]) {
453
- initGAds(manifest.variables['tagId'], consentData.consent, executionContext);
463
+ initGAds(manifest.variables['tagId'], consentData, executionContext);
454
464
  }
455
465
  if (window.gtag) {
456
466
  window.gtag('config', manifest.variables['tagId'], customConfig);
@@ -593,14 +603,14 @@ const tag = ({ data, eventName, manifestVariables, destination, }) => {
593
603
  !getCookieValue('_gcl_au')) {
594
604
  return {
595
605
  isFired: false,
596
- sdkVersion: "1.20.1" ,
606
+ sdkVersion: "1.21.1" ,
597
607
  };
598
608
  }
599
609
  const conversionLabel = getConversionLabel(eventName, manifestVariables);
600
610
  if (!conversionLabel) {
601
611
  return {
602
612
  isFired: false,
603
- sdkVersion: "1.20.1" ,
613
+ sdkVersion: "1.21.1" ,
604
614
  };
605
615
  }
606
616
  if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
@@ -617,7 +627,7 @@ const tag = ({ data, eventName, manifestVariables, destination, }) => {
617
627
  });
618
628
  return {
619
629
  isFired: true,
620
- sdkVersion: "1.20.1" ,
630
+ sdkVersion: "1.21.1" ,
621
631
  };
622
632
  };
623
633
 
@@ -625,7 +635,7 @@ const consent = ({ consentData }) => {
625
635
  if (!(window === null || window === void 0 ? void 0 : window.gtag)) {
626
636
  return;
627
637
  }
628
- const data = getGoogleConsentFromChannels(consentData.consent);
638
+ const data = getGoogleConsent(consentData);
629
639
  window.gtag('consent', 'update', {
630
640
  ...data,
631
641
  personalization_storage: 'granted',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-ads-clicks-sdk",
3
- "version": "1.20.1",
3
+ "version": "1.21.1",
4
4
  "description": "Google Ads Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",