@blotoutio/providers-google-ads-clicks-sdk 1.15.0 → 1.16.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 +52 -69
  2. package/index.js +52 -69
  3. package/index.mjs +52 -69
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -443,7 +443,7 @@ const init = ({ manifest, consentData, executionContext }) => {
443
443
  var _a, _b;
444
444
  if (!window ||
445
445
  !((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['tagId']) ||
446
- manifest.variables['flowType'] === 'server') {
446
+ manifest.variables['loadSDK'] !== '1') {
447
447
  return;
448
448
  }
449
449
  const customConfig = {
@@ -461,6 +461,42 @@ const init = ({ manifest, consentData, executionContext }) => {
461
461
  }
462
462
  };
463
463
 
464
+ const getCookieValue = (key) => {
465
+ var _a;
466
+ try {
467
+ if (!document || !document.cookie) {
468
+ return '';
469
+ }
470
+ const cookies = parseCookies(document.cookie);
471
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
472
+ }
473
+ catch {
474
+ return '';
475
+ }
476
+ };
477
+ const parseCookies = (cookie) => {
478
+ return Object.fromEntries(cookie
479
+ .split(/;\s+/)
480
+ .map((r) => r.split('=').map((str) => str.trim()))
481
+ .map(([cookieKey, ...cookieValues]) => {
482
+ const cookieValue = cookieValues.join('=');
483
+ if (!cookieKey) {
484
+ return [];
485
+ }
486
+ let decodedValue = '';
487
+ if (cookieValue) {
488
+ try {
489
+ decodedValue = decodeURIComponent(cookieValue);
490
+ }
491
+ catch (e) {
492
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
493
+ decodedValue = cookieValue;
494
+ }
495
+ }
496
+ return [cookieKey, decodedValue];
497
+ }));
498
+ };
499
+
464
500
  const getIdentifierValue = (identifier, contentItem) => {
465
501
  let identifierValue = identifier.trim();
466
502
  if (!contentItem) {
@@ -480,8 +516,7 @@ const getConversionLabel = (eventName, manifestVariables) => {
480
516
  mappings = manifestVariables['conversionMappings'];
481
517
  }
482
518
  catch (e) {
483
- mappings = [];
484
- console.log(e);
519
+ // do nothing
485
520
  }
486
521
  const mapping = mappings.find((mappingItem) => mappingItem.eventName === eventName);
487
522
  return mapping === null || mapping === void 0 ? void 0 : mapping.browserConversionLabel;
@@ -529,8 +564,7 @@ const getUserData = (destination) => {
529
564
  (_c = (_b = (_a = JSON.parse(window.sessionStorage.getItem('_workerStoreMultiple') || '{}')) === null || _a === void 0 ? void 0 : _a[destination]) === null || _b === void 0 ? void 0 : _b['kv']) !== null && _c !== void 0 ? _c : {};
530
565
  }
531
566
  catch (e) {
532
- console.error('Unable to get user data from session storage');
533
- kv = {};
567
+ // do nothing
534
568
  }
535
569
  if (kv['email']) {
536
570
  userData['email'] = kv['email'];
@@ -555,16 +589,23 @@ const getUserData = (destination) => {
555
589
  }
556
590
  return userData;
557
591
  };
558
- const handleTag = ({ data, eventName, manifestVariables, destination, }) => {
592
+ const tag = ({ data, eventName, manifestVariables, destination, }) => {
559
593
  if (!eventName ||
560
594
  !window.gtag ||
561
595
  !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId']) ||
562
- manifestVariables['flowType'] === 'server') {
563
- return;
596
+ (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) !== '1' ||
597
+ !getCookieValue('_gcl_au')) {
598
+ return {
599
+ isFired: false,
600
+ sdkVersion: "1.16.1" ,
601
+ };
564
602
  }
565
603
  const conversionLabel = getConversionLabel(eventName, manifestVariables);
566
604
  if (!conversionLabel) {
567
- return;
605
+ return {
606
+ isFired: false,
607
+ sdkVersion: "1.16.1" ,
608
+ };
568
609
  }
569
610
  if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
570
611
  destination) {
@@ -578,67 +619,9 @@ const handleTag = ({ data, eventName, manifestVariables, destination, }) => {
578
619
  ...cartData,
579
620
  app: 'blotout',
580
621
  });
581
- };
582
-
583
- const getCookieValue = (key) => {
584
- var _a;
585
- try {
586
- if (!document || !document.cookie) {
587
- return '';
588
- }
589
- const cookies = parseCookies(document.cookie);
590
- return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
591
- }
592
- catch {
593
- return '';
594
- }
595
- };
596
- const parseCookies = (cookie) => {
597
- return Object.fromEntries(cookie
598
- .split(/;\s+/)
599
- .map((r) => r.split('=').map((str) => str.trim()))
600
- .map(([cookieKey, ...cookieValues]) => {
601
- const cookieValue = cookieValues.join('=');
602
- if (!cookieKey) {
603
- return [];
604
- }
605
- let decodedValue = '';
606
- if (cookieValue) {
607
- try {
608
- decodedValue = decodeURIComponent(cookieValue);
609
- }
610
- catch (e) {
611
- console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
612
- decodedValue = cookieValue;
613
- }
614
- }
615
- return [cookieKey, decodedValue];
616
- }));
617
- };
618
-
619
- const tag = ({ data, eventName, manifestVariables, eventId, destination, }) => {
620
- let isLoaded;
621
- if (manifestVariables['flowType'] === 'browser') {
622
- isLoaded = true;
623
- }
624
- else if (manifestVariables['flowType'] === 'server') {
625
- isLoaded = false;
626
- }
627
- else {
628
- isLoaded = window && window.gtag && !!getCookieValue('_gcl_au');
629
- }
630
- if (isLoaded) {
631
- handleTag({
632
- data,
633
- eventName,
634
- manifestVariables,
635
- eventId,
636
- destination,
637
- });
638
- }
639
622
  return {
640
- loaded: isLoaded,
641
- sdkVersion: "1.15.0" ,
623
+ isFired: true,
624
+ sdkVersion: "1.16.1" ,
642
625
  };
643
626
  };
644
627
 
package/index.js CHANGED
@@ -444,7 +444,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
444
444
  var _a, _b;
445
445
  if (!window ||
446
446
  !((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['tagId']) ||
447
- manifest.variables['flowType'] === 'server') {
447
+ manifest.variables['loadSDK'] !== '1') {
448
448
  return;
449
449
  }
450
450
  const customConfig = {
@@ -462,6 +462,42 @@ var ProvidersGoogleAdsClicksSdk = (function () {
462
462
  }
463
463
  };
464
464
 
465
+ const getCookieValue = (key) => {
466
+ var _a;
467
+ try {
468
+ if (!document || !document.cookie) {
469
+ return '';
470
+ }
471
+ const cookies = parseCookies(document.cookie);
472
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
473
+ }
474
+ catch {
475
+ return '';
476
+ }
477
+ };
478
+ const parseCookies = (cookie) => {
479
+ return Object.fromEntries(cookie
480
+ .split(/;\s+/)
481
+ .map((r) => r.split('=').map((str) => str.trim()))
482
+ .map(([cookieKey, ...cookieValues]) => {
483
+ const cookieValue = cookieValues.join('=');
484
+ if (!cookieKey) {
485
+ return [];
486
+ }
487
+ let decodedValue = '';
488
+ if (cookieValue) {
489
+ try {
490
+ decodedValue = decodeURIComponent(cookieValue);
491
+ }
492
+ catch (e) {
493
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
494
+ decodedValue = cookieValue;
495
+ }
496
+ }
497
+ return [cookieKey, decodedValue];
498
+ }));
499
+ };
500
+
465
501
  const getIdentifierValue = (identifier, contentItem) => {
466
502
  let identifierValue = identifier.trim();
467
503
  if (!contentItem) {
@@ -481,8 +517,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
481
517
  mappings = manifestVariables['conversionMappings'];
482
518
  }
483
519
  catch (e) {
484
- mappings = [];
485
- console.log(e);
520
+ // do nothing
486
521
  }
487
522
  const mapping = mappings.find((mappingItem) => mappingItem.eventName === eventName);
488
523
  return mapping === null || mapping === void 0 ? void 0 : mapping.browserConversionLabel;
@@ -530,8 +565,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
530
565
  (_c = (_b = (_a = JSON.parse(window.sessionStorage.getItem('_workerStoreMultiple') || '{}')) === null || _a === void 0 ? void 0 : _a[destination]) === null || _b === void 0 ? void 0 : _b['kv']) !== null && _c !== void 0 ? _c : {};
531
566
  }
532
567
  catch (e) {
533
- console.error('Unable to get user data from session storage');
534
- kv = {};
568
+ // do nothing
535
569
  }
536
570
  if (kv['email']) {
537
571
  userData['email'] = kv['email'];
@@ -556,16 +590,23 @@ var ProvidersGoogleAdsClicksSdk = (function () {
556
590
  }
557
591
  return userData;
558
592
  };
559
- const handleTag = ({ data, eventName, manifestVariables, destination, }) => {
593
+ const tag = ({ data, eventName, manifestVariables, destination, }) => {
560
594
  if (!eventName ||
561
595
  !window.gtag ||
562
596
  !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId']) ||
563
- manifestVariables['flowType'] === 'server') {
564
- return;
597
+ (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) !== '1' ||
598
+ !getCookieValue('_gcl_au')) {
599
+ return {
600
+ isFired: false,
601
+ sdkVersion: "1.16.1" ,
602
+ };
565
603
  }
566
604
  const conversionLabel = getConversionLabel(eventName, manifestVariables);
567
605
  if (!conversionLabel) {
568
- return;
606
+ return {
607
+ isFired: false,
608
+ sdkVersion: "1.16.1" ,
609
+ };
569
610
  }
570
611
  if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
571
612
  destination) {
@@ -579,67 +620,9 @@ var ProvidersGoogleAdsClicksSdk = (function () {
579
620
  ...cartData,
580
621
  app: 'blotout',
581
622
  });
582
- };
583
-
584
- const getCookieValue = (key) => {
585
- var _a;
586
- try {
587
- if (!document || !document.cookie) {
588
- return '';
589
- }
590
- const cookies = parseCookies(document.cookie);
591
- return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
592
- }
593
- catch {
594
- return '';
595
- }
596
- };
597
- const parseCookies = (cookie) => {
598
- return Object.fromEntries(cookie
599
- .split(/;\s+/)
600
- .map((r) => r.split('=').map((str) => str.trim()))
601
- .map(([cookieKey, ...cookieValues]) => {
602
- const cookieValue = cookieValues.join('=');
603
- if (!cookieKey) {
604
- return [];
605
- }
606
- let decodedValue = '';
607
- if (cookieValue) {
608
- try {
609
- decodedValue = decodeURIComponent(cookieValue);
610
- }
611
- catch (e) {
612
- console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
613
- decodedValue = cookieValue;
614
- }
615
- }
616
- return [cookieKey, decodedValue];
617
- }));
618
- };
619
-
620
- const tag = ({ data, eventName, manifestVariables, eventId, destination, }) => {
621
- let isLoaded;
622
- if (manifestVariables['flowType'] === 'browser') {
623
- isLoaded = true;
624
- }
625
- else if (manifestVariables['flowType'] === 'server') {
626
- isLoaded = false;
627
- }
628
- else {
629
- isLoaded = window && window.gtag && !!getCookieValue('_gcl_au');
630
- }
631
- if (isLoaded) {
632
- handleTag({
633
- data,
634
- eventName,
635
- manifestVariables,
636
- eventId,
637
- destination,
638
- });
639
- }
640
623
  return {
641
- loaded: isLoaded,
642
- sdkVersion: "1.15.0" ,
624
+ isFired: true,
625
+ sdkVersion: "1.16.1" ,
643
626
  };
644
627
  };
645
628
 
package/index.mjs CHANGED
@@ -441,7 +441,7 @@ const init = ({ manifest, consentData, executionContext }) => {
441
441
  var _a, _b;
442
442
  if (!window ||
443
443
  !((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['tagId']) ||
444
- manifest.variables['flowType'] === 'server') {
444
+ manifest.variables['loadSDK'] !== '1') {
445
445
  return;
446
446
  }
447
447
  const customConfig = {
@@ -459,6 +459,42 @@ const init = ({ manifest, consentData, executionContext }) => {
459
459
  }
460
460
  };
461
461
 
462
+ const getCookieValue = (key) => {
463
+ var _a;
464
+ try {
465
+ if (!document || !document.cookie) {
466
+ return '';
467
+ }
468
+ const cookies = parseCookies(document.cookie);
469
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
470
+ }
471
+ catch {
472
+ return '';
473
+ }
474
+ };
475
+ const parseCookies = (cookie) => {
476
+ return Object.fromEntries(cookie
477
+ .split(/;\s+/)
478
+ .map((r) => r.split('=').map((str) => str.trim()))
479
+ .map(([cookieKey, ...cookieValues]) => {
480
+ const cookieValue = cookieValues.join('=');
481
+ if (!cookieKey) {
482
+ return [];
483
+ }
484
+ let decodedValue = '';
485
+ if (cookieValue) {
486
+ try {
487
+ decodedValue = decodeURIComponent(cookieValue);
488
+ }
489
+ catch (e) {
490
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
491
+ decodedValue = cookieValue;
492
+ }
493
+ }
494
+ return [cookieKey, decodedValue];
495
+ }));
496
+ };
497
+
462
498
  const getIdentifierValue = (identifier, contentItem) => {
463
499
  let identifierValue = identifier.trim();
464
500
  if (!contentItem) {
@@ -478,8 +514,7 @@ const getConversionLabel = (eventName, manifestVariables) => {
478
514
  mappings = manifestVariables['conversionMappings'];
479
515
  }
480
516
  catch (e) {
481
- mappings = [];
482
- console.log(e);
517
+ // do nothing
483
518
  }
484
519
  const mapping = mappings.find((mappingItem) => mappingItem.eventName === eventName);
485
520
  return mapping === null || mapping === void 0 ? void 0 : mapping.browserConversionLabel;
@@ -527,8 +562,7 @@ const getUserData = (destination) => {
527
562
  (_c = (_b = (_a = JSON.parse(window.sessionStorage.getItem('_workerStoreMultiple') || '{}')) === null || _a === void 0 ? void 0 : _a[destination]) === null || _b === void 0 ? void 0 : _b['kv']) !== null && _c !== void 0 ? _c : {};
528
563
  }
529
564
  catch (e) {
530
- console.error('Unable to get user data from session storage');
531
- kv = {};
565
+ // do nothing
532
566
  }
533
567
  if (kv['email']) {
534
568
  userData['email'] = kv['email'];
@@ -553,16 +587,23 @@ const getUserData = (destination) => {
553
587
  }
554
588
  return userData;
555
589
  };
556
- const handleTag = ({ data, eventName, manifestVariables, destination, }) => {
590
+ const tag = ({ data, eventName, manifestVariables, destination, }) => {
557
591
  if (!eventName ||
558
592
  !window.gtag ||
559
593
  !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId']) ||
560
- manifestVariables['flowType'] === 'server') {
561
- return;
594
+ (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) !== '1' ||
595
+ !getCookieValue('_gcl_au')) {
596
+ return {
597
+ isFired: false,
598
+ sdkVersion: "1.16.1" ,
599
+ };
562
600
  }
563
601
  const conversionLabel = getConversionLabel(eventName, manifestVariables);
564
602
  if (!conversionLabel) {
565
- return;
603
+ return {
604
+ isFired: false,
605
+ sdkVersion: "1.16.1" ,
606
+ };
566
607
  }
567
608
  if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
568
609
  destination) {
@@ -576,67 +617,9 @@ const handleTag = ({ data, eventName, manifestVariables, destination, }) => {
576
617
  ...cartData,
577
618
  app: 'blotout',
578
619
  });
579
- };
580
-
581
- const getCookieValue = (key) => {
582
- var _a;
583
- try {
584
- if (!document || !document.cookie) {
585
- return '';
586
- }
587
- const cookies = parseCookies(document.cookie);
588
- return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
589
- }
590
- catch {
591
- return '';
592
- }
593
- };
594
- const parseCookies = (cookie) => {
595
- return Object.fromEntries(cookie
596
- .split(/;\s+/)
597
- .map((r) => r.split('=').map((str) => str.trim()))
598
- .map(([cookieKey, ...cookieValues]) => {
599
- const cookieValue = cookieValues.join('=');
600
- if (!cookieKey) {
601
- return [];
602
- }
603
- let decodedValue = '';
604
- if (cookieValue) {
605
- try {
606
- decodedValue = decodeURIComponent(cookieValue);
607
- }
608
- catch (e) {
609
- console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
610
- decodedValue = cookieValue;
611
- }
612
- }
613
- return [cookieKey, decodedValue];
614
- }));
615
- };
616
-
617
- const tag = ({ data, eventName, manifestVariables, eventId, destination, }) => {
618
- let isLoaded;
619
- if (manifestVariables['flowType'] === 'browser') {
620
- isLoaded = true;
621
- }
622
- else if (manifestVariables['flowType'] === 'server') {
623
- isLoaded = false;
624
- }
625
- else {
626
- isLoaded = window && window.gtag && !!getCookieValue('_gcl_au');
627
- }
628
- if (isLoaded) {
629
- handleTag({
630
- data,
631
- eventName,
632
- manifestVariables,
633
- eventId,
634
- destination,
635
- });
636
- }
637
620
  return {
638
- loaded: isLoaded,
639
- sdkVersion: "1.15.0" ,
621
+ isFired: true,
622
+ sdkVersion: "1.16.1" ,
640
623
  };
641
624
  };
642
625
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-ads-clicks-sdk",
3
- "version": "1.15.0",
3
+ "version": "1.16.1",
4
4
  "description": "Google Ads Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",