@blotoutio/edgetag-sdk-js 0.62.0 → 0.63.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.
package/index.cjs.js CHANGED
@@ -278,6 +278,7 @@ const consentKey = 'consent';
278
278
  const keyPrefix = `_worker`;
279
279
  const cookieKey = 'tag_user_id';
280
280
  const fallbackSessionKey = 'fallback_tag_user_id';
281
+ const storageIdKey = 'storageId';
281
282
 
282
283
  const getMessage = (error) => {
283
284
  if (error instanceof Error) {
@@ -484,7 +485,8 @@ const parseCookies = (cookie) => {
484
485
  return Object.fromEntries(cookie
485
486
  .split(/;\s+/)
486
487
  .map((r) => r.split('=').map((str) => str.trim()))
487
- .map(([cookieKey, cookieValue]) => {
488
+ .map(([cookieKey, ...cookieValues]) => {
489
+ const cookieValue = cookieValues.join('=');
488
490
  if (!cookieKey) {
489
491
  return [];
490
492
  }
@@ -560,7 +562,7 @@ const getStandardPayload = (destination, payload) => {
560
562
  referrer: getReferrer(destination),
561
563
  search: getSearch(destination),
562
564
  locale: getLocale(),
563
- sdkVersion: "0.62.0" ,
565
+ sdkVersion: "0.63.0" ,
564
566
  ...(payload || {}),
565
567
  };
566
568
  let storage = {};
@@ -842,11 +844,11 @@ const handleData = (data, providers, options) => {
842
844
 
843
845
  const handleConsent = (consent, options) => {
844
846
  if (options === null || options === void 0 ? void 0 : options.destination) {
845
- processConsent(options.destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
847
+ processConsent(options.destination, consent, options);
846
848
  return;
847
849
  }
848
850
  getInstances().forEach((destination) => {
849
- processConsent(destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
851
+ processConsent(destination, consent, options);
850
852
  });
851
853
  };
852
854
  const saveConsent = (destination, consent) => {
@@ -855,16 +857,23 @@ const saveConsent = (destination, consent) => {
855
857
  });
856
858
  savePerKey(destination, 'local', tagStorage, consent, consentKey);
857
859
  };
858
- const processConsent = (destination, consent, localSave) => {
860
+ const processConsent = (destination, consent, options) => {
859
861
  const existingConsent = getConsent$1(destination);
860
862
  if (areEqual(existingConsent, consent)) {
861
863
  return;
862
864
  }
865
+ if (!getSetting(destination, 'initialized')) {
866
+ addStub(destination, {
867
+ name: 'consent',
868
+ arguments: [consent, options],
869
+ });
870
+ return;
871
+ }
863
872
  const payload = {
864
873
  consentString: consent,
865
874
  };
866
875
  saveConsent(destination, consent);
867
- if (!localSave) {
876
+ if (!(options === null || options === void 0 ? void 0 : options.localSave)) {
868
877
  postRequest(getConsentURL(destination), payload).catch(error);
869
878
  }
870
879
  const userId = getUserId$1(destination);
@@ -1173,7 +1182,11 @@ const handleInit = (preferences) => {
1173
1182
  userId: result.userId,
1174
1183
  manifest: result.result,
1175
1184
  browserPackages: Object.values(providers),
1185
+ storageId: result.storageId,
1176
1186
  });
1187
+ if (result.storageId != null) {
1188
+ savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
1189
+ }
1177
1190
  handleManifest(preferences.edgeURL, result);
1178
1191
  try {
1179
1192
  window.dispatchEvent(new CustomEvent('edgetag-initialized', {
package/index.mjs CHANGED
@@ -276,6 +276,7 @@ const consentKey = 'consent';
276
276
  const keyPrefix = `_worker`;
277
277
  const cookieKey = 'tag_user_id';
278
278
  const fallbackSessionKey = 'fallback_tag_user_id';
279
+ const storageIdKey = 'storageId';
279
280
 
280
281
  const getMessage = (error) => {
281
282
  if (error instanceof Error) {
@@ -482,7 +483,8 @@ const parseCookies = (cookie) => {
482
483
  return Object.fromEntries(cookie
483
484
  .split(/;\s+/)
484
485
  .map((r) => r.split('=').map((str) => str.trim()))
485
- .map(([cookieKey, cookieValue]) => {
486
+ .map(([cookieKey, ...cookieValues]) => {
487
+ const cookieValue = cookieValues.join('=');
486
488
  if (!cookieKey) {
487
489
  return [];
488
490
  }
@@ -558,7 +560,7 @@ const getStandardPayload = (destination, payload) => {
558
560
  referrer: getReferrer(destination),
559
561
  search: getSearch(destination),
560
562
  locale: getLocale(),
561
- sdkVersion: "0.62.0" ,
563
+ sdkVersion: "0.63.0" ,
562
564
  ...(payload || {}),
563
565
  };
564
566
  let storage = {};
@@ -840,11 +842,11 @@ const handleData = (data, providers, options) => {
840
842
 
841
843
  const handleConsent = (consent, options) => {
842
844
  if (options === null || options === void 0 ? void 0 : options.destination) {
843
- processConsent(options.destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
845
+ processConsent(options.destination, consent, options);
844
846
  return;
845
847
  }
846
848
  getInstances().forEach((destination) => {
847
- processConsent(destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
849
+ processConsent(destination, consent, options);
848
850
  });
849
851
  };
850
852
  const saveConsent = (destination, consent) => {
@@ -853,16 +855,23 @@ const saveConsent = (destination, consent) => {
853
855
  });
854
856
  savePerKey(destination, 'local', tagStorage, consent, consentKey);
855
857
  };
856
- const processConsent = (destination, consent, localSave) => {
858
+ const processConsent = (destination, consent, options) => {
857
859
  const existingConsent = getConsent$1(destination);
858
860
  if (areEqual(existingConsent, consent)) {
859
861
  return;
860
862
  }
863
+ if (!getSetting(destination, 'initialized')) {
864
+ addStub(destination, {
865
+ name: 'consent',
866
+ arguments: [consent, options],
867
+ });
868
+ return;
869
+ }
861
870
  const payload = {
862
871
  consentString: consent,
863
872
  };
864
873
  saveConsent(destination, consent);
865
- if (!localSave) {
874
+ if (!(options === null || options === void 0 ? void 0 : options.localSave)) {
866
875
  postRequest(getConsentURL(destination), payload).catch(error);
867
876
  }
868
877
  const userId = getUserId$1(destination);
@@ -1171,7 +1180,11 @@ const handleInit = (preferences) => {
1171
1180
  userId: result.userId,
1172
1181
  manifest: result.result,
1173
1182
  browserPackages: Object.values(providers),
1183
+ storageId: result.storageId,
1174
1184
  });
1185
+ if (result.storageId != null) {
1186
+ savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
1187
+ }
1175
1188
  handleManifest(preferences.edgeURL, result);
1176
1189
  try {
1177
1190
  window.dispatchEvent(new CustomEvent('edgetag-initialized', {
package/internal.d.ts CHANGED
@@ -49,6 +49,7 @@ type PostPayload = {
49
49
  type InitResponse = {
50
50
  result: Manifest[]
51
51
  userId?: string
52
+ storageId?: number
52
53
  consent: UserConsent
53
54
  consentSetting: ConsentSetting
54
55
  isNewUser?: boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-js",
3
- "version": "0.62.0",
3
+ "version": "0.63.0",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",