@blotoutio/providers-google-analytics-4-sdk 1.21.2 → 1.22.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 (4) hide show
  1. package/index.cjs.js +28 -22
  2. package/index.js +28 -22
  3. package/index.mjs +28 -22
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -450,33 +450,35 @@ const getGoogleConsent = (consent) => {
450
450
  };
451
451
 
452
452
  // eslint-disable-next-line @nx/enforce-module-boundaries
453
- const initGA4 = (ID, advancedConsentMode, consentData, executionContext) => {
453
+ const initGA4 = (ID, advancedConsentMode, consentSkip, consentData, executionContext) => {
454
454
  var _a;
455
455
  window.dataLayer = window.dataLayer || [];
456
456
  window.gtag = function gtag() {
457
457
  // eslint-disable-next-line prefer-rest-params
458
458
  window.dataLayer.push(arguments);
459
459
  };
460
- let isConsentInitialised = false;
461
- for (const otherProvider of ['googleAdsClicks', 'googleAnalytics4']) {
462
- if ((_a = executionContext.get(otherProvider)) === null || _a === void 0 ? void 0 : _a.get('gtag')) {
463
- isConsentInitialised = true;
464
- break;
460
+ if (consentSkip != '1') {
461
+ let isConsentInitialised = false;
462
+ for (const otherProvider of ['googleAdsClicks', 'googleAnalytics4']) {
463
+ if ((_a = executionContext.get(otherProvider)) === null || _a === void 0 ? void 0 : _a.get('gtag')) {
464
+ isConsentInitialised = true;
465
+ break;
466
+ }
467
+ }
468
+ const data = advancedConsentMode === '1'
469
+ ? getGoogleConsentFromCategories(consentData.categories)
470
+ : getGoogleConsent(consentData);
471
+ if (isConsentInitialised) {
472
+ window.gtag('consent', 'update', data);
473
+ }
474
+ else {
475
+ window.gtag('consent', 'default', {
476
+ ...data,
477
+ functional_storage: 'granted',
478
+ personalization_storage: 'granted',
479
+ security_storage: 'granted',
480
+ });
465
481
  }
466
- }
467
- const data = advancedConsentMode === '1'
468
- ? getGoogleConsentFromCategories(consentData.categories)
469
- : getGoogleConsent(consentData);
470
- if (isConsentInitialised) {
471
- window.gtag('consent', 'update', data);
472
- }
473
- else {
474
- window.gtag('consent', 'default', {
475
- ...data,
476
- functional_storage: 'granted',
477
- personalization_storage: 'granted',
478
- security_storage: 'granted',
479
- });
480
482
  }
481
483
  upsert(executionContext, packageName, (providerMap) => providerMap.set('gtag', true), () => new Map());
482
484
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -499,7 +501,7 @@ const init = ({ manifest, userId, executionContext, consentData, }) => {
499
501
  }
500
502
  if (!window.google_tag_manager ||
501
503
  !window.google_tag_manager[manifest.variables['measurementId']]) {
502
- initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], consentData, executionContext);
504
+ initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], manifest.variables['consentSkip'], consentData, executionContext);
503
505
  }
504
506
  if (window.gtag) {
505
507
  window.gtag('config', manifest.variables['measurementId'], {
@@ -772,7 +774,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
772
774
  }
773
775
  return {
774
776
  loaded: isLoaded,
775
- sdkVersion: "1.21.2" ,
777
+ sdkVersion: "1.22.0" ,
776
778
  };
777
779
  };
778
780
 
@@ -780,6 +782,10 @@ const consent = ({ consentData, variables }) => {
780
782
  if (!(window === null || window === void 0 ? void 0 : window.gtag)) {
781
783
  return;
782
784
  }
785
+ const shouldSkipConsent = variables.some((v) => { var _a; return ((_a = v.variableSet) === null || _a === void 0 ? void 0 : _a['consentSkip']) == '1'; });
786
+ if (shouldSkipConsent) {
787
+ return;
788
+ }
783
789
  const isAdvancedConsentModeEnabled = variables.some((variable) => { var _a; return ((_a = variable.variableSet) === null || _a === void 0 ? void 0 : _a['advancedConsentMode']) === '1'; });
784
790
  const data = isAdvancedConsentModeEnabled
785
791
  ? getGoogleConsentFromCategories(consentData.categories)
package/index.js CHANGED
@@ -451,33 +451,35 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
451
451
  };
452
452
 
453
453
  // eslint-disable-next-line @nx/enforce-module-boundaries
454
- const initGA4 = (ID, advancedConsentMode, consentData, executionContext) => {
454
+ const initGA4 = (ID, advancedConsentMode, consentSkip, consentData, executionContext) => {
455
455
  var _a;
456
456
  window.dataLayer = window.dataLayer || [];
457
457
  window.gtag = function gtag() {
458
458
  // eslint-disable-next-line prefer-rest-params
459
459
  window.dataLayer.push(arguments);
460
460
  };
461
- let isConsentInitialised = false;
462
- for (const otherProvider of ['googleAdsClicks', 'googleAnalytics4']) {
463
- if ((_a = executionContext.get(otherProvider)) === null || _a === void 0 ? void 0 : _a.get('gtag')) {
464
- isConsentInitialised = true;
465
- break;
461
+ if (consentSkip != '1') {
462
+ let isConsentInitialised = false;
463
+ for (const otherProvider of ['googleAdsClicks', 'googleAnalytics4']) {
464
+ if ((_a = executionContext.get(otherProvider)) === null || _a === void 0 ? void 0 : _a.get('gtag')) {
465
+ isConsentInitialised = true;
466
+ break;
467
+ }
468
+ }
469
+ const data = advancedConsentMode === '1'
470
+ ? getGoogleConsentFromCategories(consentData.categories)
471
+ : getGoogleConsent(consentData);
472
+ if (isConsentInitialised) {
473
+ window.gtag('consent', 'update', data);
474
+ }
475
+ else {
476
+ window.gtag('consent', 'default', {
477
+ ...data,
478
+ functional_storage: 'granted',
479
+ personalization_storage: 'granted',
480
+ security_storage: 'granted',
481
+ });
466
482
  }
467
- }
468
- const data = advancedConsentMode === '1'
469
- ? getGoogleConsentFromCategories(consentData.categories)
470
- : getGoogleConsent(consentData);
471
- if (isConsentInitialised) {
472
- window.gtag('consent', 'update', data);
473
- }
474
- else {
475
- window.gtag('consent', 'default', {
476
- ...data,
477
- functional_storage: 'granted',
478
- personalization_storage: 'granted',
479
- security_storage: 'granted',
480
- });
481
483
  }
482
484
  upsert(executionContext, packageName, (providerMap) => providerMap.set('gtag', true), () => new Map());
483
485
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -500,7 +502,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
500
502
  }
501
503
  if (!window.google_tag_manager ||
502
504
  !window.google_tag_manager[manifest.variables['measurementId']]) {
503
- initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], consentData, executionContext);
505
+ initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], manifest.variables['consentSkip'], consentData, executionContext);
504
506
  }
505
507
  if (window.gtag) {
506
508
  window.gtag('config', manifest.variables['measurementId'], {
@@ -773,7 +775,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
773
775
  }
774
776
  return {
775
777
  loaded: isLoaded,
776
- sdkVersion: "1.21.2" ,
778
+ sdkVersion: "1.22.0" ,
777
779
  };
778
780
  };
779
781
 
@@ -781,6 +783,10 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
781
783
  if (!(window === null || window === void 0 ? void 0 : window.gtag)) {
782
784
  return;
783
785
  }
786
+ const shouldSkipConsent = variables.some((v) => { var _a; return ((_a = v.variableSet) === null || _a === void 0 ? void 0 : _a['consentSkip']) == '1'; });
787
+ if (shouldSkipConsent) {
788
+ return;
789
+ }
784
790
  const isAdvancedConsentModeEnabled = variables.some((variable) => { var _a; return ((_a = variable.variableSet) === null || _a === void 0 ? void 0 : _a['advancedConsentMode']) === '1'; });
785
791
  const data = isAdvancedConsentModeEnabled
786
792
  ? getGoogleConsentFromCategories(consentData.categories)
package/index.mjs CHANGED
@@ -448,33 +448,35 @@ const getGoogleConsent = (consent) => {
448
448
  };
449
449
 
450
450
  // eslint-disable-next-line @nx/enforce-module-boundaries
451
- const initGA4 = (ID, advancedConsentMode, consentData, executionContext) => {
451
+ const initGA4 = (ID, advancedConsentMode, consentSkip, consentData, executionContext) => {
452
452
  var _a;
453
453
  window.dataLayer = window.dataLayer || [];
454
454
  window.gtag = function gtag() {
455
455
  // eslint-disable-next-line prefer-rest-params
456
456
  window.dataLayer.push(arguments);
457
457
  };
458
- let isConsentInitialised = false;
459
- for (const otherProvider of ['googleAdsClicks', 'googleAnalytics4']) {
460
- if ((_a = executionContext.get(otherProvider)) === null || _a === void 0 ? void 0 : _a.get('gtag')) {
461
- isConsentInitialised = true;
462
- break;
458
+ if (consentSkip != '1') {
459
+ let isConsentInitialised = false;
460
+ for (const otherProvider of ['googleAdsClicks', 'googleAnalytics4']) {
461
+ if ((_a = executionContext.get(otherProvider)) === null || _a === void 0 ? void 0 : _a.get('gtag')) {
462
+ isConsentInitialised = true;
463
+ break;
464
+ }
465
+ }
466
+ const data = advancedConsentMode === '1'
467
+ ? getGoogleConsentFromCategories(consentData.categories)
468
+ : getGoogleConsent(consentData);
469
+ if (isConsentInitialised) {
470
+ window.gtag('consent', 'update', data);
471
+ }
472
+ else {
473
+ window.gtag('consent', 'default', {
474
+ ...data,
475
+ functional_storage: 'granted',
476
+ personalization_storage: 'granted',
477
+ security_storage: 'granted',
478
+ });
463
479
  }
464
- }
465
- const data = advancedConsentMode === '1'
466
- ? getGoogleConsentFromCategories(consentData.categories)
467
- : getGoogleConsent(consentData);
468
- if (isConsentInitialised) {
469
- window.gtag('consent', 'update', data);
470
- }
471
- else {
472
- window.gtag('consent', 'default', {
473
- ...data,
474
- functional_storage: 'granted',
475
- personalization_storage: 'granted',
476
- security_storage: 'granted',
477
- });
478
480
  }
479
481
  upsert(executionContext, packageName, (providerMap) => providerMap.set('gtag', true), () => new Map());
480
482
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -497,7 +499,7 @@ const init = ({ manifest, userId, executionContext, consentData, }) => {
497
499
  }
498
500
  if (!window.google_tag_manager ||
499
501
  !window.google_tag_manager[manifest.variables['measurementId']]) {
500
- initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], consentData, executionContext);
502
+ initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], manifest.variables['consentSkip'], consentData, executionContext);
501
503
  }
502
504
  if (window.gtag) {
503
505
  window.gtag('config', manifest.variables['measurementId'], {
@@ -770,7 +772,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
770
772
  }
771
773
  return {
772
774
  loaded: isLoaded,
773
- sdkVersion: "1.21.2" ,
775
+ sdkVersion: "1.22.0" ,
774
776
  };
775
777
  };
776
778
 
@@ -778,6 +780,10 @@ const consent = ({ consentData, variables }) => {
778
780
  if (!(window === null || window === void 0 ? void 0 : window.gtag)) {
779
781
  return;
780
782
  }
783
+ const shouldSkipConsent = variables.some((v) => { var _a; return ((_a = v.variableSet) === null || _a === void 0 ? void 0 : _a['consentSkip']) == '1'; });
784
+ if (shouldSkipConsent) {
785
+ return;
786
+ }
781
787
  const isAdvancedConsentModeEnabled = variables.some((variable) => { var _a; return ((_a = variable.variableSet) === null || _a === void 0 ? void 0 : _a['advancedConsentMode']) === '1'; });
782
788
  const data = isAdvancedConsentModeEnabled
783
789
  ? getGoogleConsentFromCategories(consentData.categories)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-analytics-4-sdk",
3
- "version": "1.21.2",
3
+ "version": "1.22.0",
4
4
  "description": "Google Analytics 4 Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",