@blotoutio/edgetag-sdk-js 0.36.0 → 0.36.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.
Files changed (3) hide show
  1. package/index.cjs.js +46 -13
  2. package/index.mjs +46 -13
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -70,6 +70,33 @@ const getPageTitle = () => {
70
70
  return '';
71
71
  }
72
72
  };
73
+ const areEqual = (a, b) => {
74
+ if (typeof a !== typeof b ||
75
+ Array.isArray(a) !== Array.isArray(b) ||
76
+ isNaN(a) !== isNaN(b)) {
77
+ return false;
78
+ }
79
+ if (typeof a !== 'object' || a === null) {
80
+ return a === b;
81
+ }
82
+ const as = Object.keys(a);
83
+ const bs = Object.keys(b);
84
+ if (as.length !== bs.length)
85
+ return false;
86
+ for (const key of as) {
87
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
88
+ // @ts-ignore
89
+ if (!(key in b)) {
90
+ return false;
91
+ }
92
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
93
+ // @ts-ignore
94
+ if (!areEqual(a[key], b[key])) {
95
+ return false;
96
+ }
97
+ }
98
+ return true;
99
+ };
73
100
 
74
101
  const tagStorage = 'edgeTag';
75
102
  const consentKey = 'consent';
@@ -335,7 +362,7 @@ const getStandardPayload = (payload) => {
335
362
  referrer: getReferrer(),
336
363
  search: getSearch(),
337
364
  locale: getLocale(),
338
- sdkVersion: "0.36.0" ,
365
+ sdkVersion: "0.36.2" ,
339
366
  ...(payload || {}),
340
367
  };
341
368
  let storage = {};
@@ -723,6 +750,10 @@ const saveConsent = (consent) => {
723
750
  savePerKey('local', tagStorage, consent, consentKey);
724
751
  };
725
752
  const handleConsent = (consent, options) => {
753
+ const existingConsent = getConsent$1();
754
+ if (areEqual(existingConsent, consent)) {
755
+ return;
756
+ }
726
757
  const payload = {
727
758
  consentString: consent,
728
759
  };
@@ -901,18 +932,20 @@ const handleManifest = (manifest, consent) => {
901
932
  }
902
933
  });
903
934
  }
904
- /* this defines if the consent is given for a specific instance of a provider */
905
- const hasConsent = hasUserConsent(consent, pkg.name, provider.tagName);
906
- if (pkg && pkg.name && pkg.init && hasConsent) {
907
- pkg.init({
908
- userId,
909
- manifest: provider,
910
- sendTag,
911
- sendEdgeData: handleData,
912
- getEdgeData: handleGetData,
913
- keyName: `${keyPrefix}Store`,
914
- executionContext,
915
- });
935
+ if (pkg && pkg.name && pkg.init) {
936
+ /* this defines if the consent is given for a specific instance of a provider */
937
+ const hasConsent = hasUserConsent(consent, pkg.name, provider.tagName);
938
+ if (hasConsent) {
939
+ pkg.init({
940
+ userId,
941
+ manifest: provider,
942
+ sendTag,
943
+ sendEdgeData: handleData,
944
+ getEdgeData: handleGetData,
945
+ keyName: `${keyPrefix}Store`,
946
+ executionContext,
947
+ });
948
+ }
916
949
  }
917
950
  });
918
951
  setInitialized();
package/index.mjs CHANGED
@@ -68,6 +68,33 @@ const getPageTitle = () => {
68
68
  return '';
69
69
  }
70
70
  };
71
+ const areEqual = (a, b) => {
72
+ if (typeof a !== typeof b ||
73
+ Array.isArray(a) !== Array.isArray(b) ||
74
+ isNaN(a) !== isNaN(b)) {
75
+ return false;
76
+ }
77
+ if (typeof a !== 'object' || a === null) {
78
+ return a === b;
79
+ }
80
+ const as = Object.keys(a);
81
+ const bs = Object.keys(b);
82
+ if (as.length !== bs.length)
83
+ return false;
84
+ for (const key of as) {
85
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
86
+ // @ts-ignore
87
+ if (!(key in b)) {
88
+ return false;
89
+ }
90
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
91
+ // @ts-ignore
92
+ if (!areEqual(a[key], b[key])) {
93
+ return false;
94
+ }
95
+ }
96
+ return true;
97
+ };
71
98
 
72
99
  const tagStorage = 'edgeTag';
73
100
  const consentKey = 'consent';
@@ -333,7 +360,7 @@ const getStandardPayload = (payload) => {
333
360
  referrer: getReferrer(),
334
361
  search: getSearch(),
335
362
  locale: getLocale(),
336
- sdkVersion: "0.36.0" ,
363
+ sdkVersion: "0.36.2" ,
337
364
  ...(payload || {}),
338
365
  };
339
366
  let storage = {};
@@ -721,6 +748,10 @@ const saveConsent = (consent) => {
721
748
  savePerKey('local', tagStorage, consent, consentKey);
722
749
  };
723
750
  const handleConsent = (consent, options) => {
751
+ const existingConsent = getConsent$1();
752
+ if (areEqual(existingConsent, consent)) {
753
+ return;
754
+ }
724
755
  const payload = {
725
756
  consentString: consent,
726
757
  };
@@ -899,18 +930,20 @@ const handleManifest = (manifest, consent) => {
899
930
  }
900
931
  });
901
932
  }
902
- /* this defines if the consent is given for a specific instance of a provider */
903
- const hasConsent = hasUserConsent(consent, pkg.name, provider.tagName);
904
- if (pkg && pkg.name && pkg.init && hasConsent) {
905
- pkg.init({
906
- userId,
907
- manifest: provider,
908
- sendTag,
909
- sendEdgeData: handleData,
910
- getEdgeData: handleGetData,
911
- keyName: `${keyPrefix}Store`,
912
- executionContext,
913
- });
933
+ if (pkg && pkg.name && pkg.init) {
934
+ /* this defines if the consent is given for a specific instance of a provider */
935
+ const hasConsent = hasUserConsent(consent, pkg.name, provider.tagName);
936
+ if (hasConsent) {
937
+ pkg.init({
938
+ userId,
939
+ manifest: provider,
940
+ sendTag,
941
+ sendEdgeData: handleData,
942
+ getEdgeData: handleGetData,
943
+ keyName: `${keyPrefix}Store`,
944
+ executionContext,
945
+ });
946
+ }
914
947
  }
915
948
  });
916
949
  setInitialized();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-js",
3
- "version": "0.36.0",
3
+ "version": "0.36.2",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",