@blotoutio/edgetag-sdk-js 0.62.1 → 0.63.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.
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) {
@@ -561,7 +562,7 @@ const getStandardPayload = (destination, payload) => {
561
562
  referrer: getReferrer(destination),
562
563
  search: getSearch(destination),
563
564
  locale: getLocale(),
564
- sdkVersion: "0.62.1" ,
565
+ sdkVersion: "0.63.1" ,
565
566
  ...(payload || {}),
566
567
  };
567
568
  let storage = {};
@@ -843,11 +844,11 @@ const handleData = (data, providers, options) => {
843
844
 
844
845
  const handleConsent = (consent, options) => {
845
846
  if (options === null || options === void 0 ? void 0 : options.destination) {
846
- processConsent(options.destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
847
+ processConsent(options.destination, consent, options);
847
848
  return;
848
849
  }
849
850
  getInstances().forEach((destination) => {
850
- processConsent(destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
851
+ processConsent(destination, consent, options);
851
852
  });
852
853
  };
853
854
  const saveConsent = (destination, consent) => {
@@ -856,16 +857,23 @@ const saveConsent = (destination, consent) => {
856
857
  });
857
858
  savePerKey(destination, 'local', tagStorage, consent, consentKey);
858
859
  };
859
- const processConsent = (destination, consent, localSave) => {
860
+ const processConsent = (destination, consent, options) => {
860
861
  const existingConsent = getConsent$1(destination);
861
862
  if (areEqual(existingConsent, consent)) {
862
863
  return;
863
864
  }
865
+ if (!getSetting(destination, 'initialized')) {
866
+ addStub(destination, {
867
+ name: 'consent',
868
+ arguments: [consent, options],
869
+ });
870
+ return;
871
+ }
864
872
  const payload = {
865
873
  consentString: consent,
866
874
  };
867
875
  saveConsent(destination, consent);
868
- if (!localSave) {
876
+ if (!(options === null || options === void 0 ? void 0 : options.localSave)) {
869
877
  postRequest(getConsentURL(destination), payload).catch(error);
870
878
  }
871
879
  const userId = getUserId$1(destination);
@@ -1174,7 +1182,11 @@ const handleInit = (preferences) => {
1174
1182
  userId: result.userId,
1175
1183
  manifest: result.result,
1176
1184
  browserPackages: Object.values(providers),
1185
+ storageId: result.storageId,
1177
1186
  });
1187
+ if (result.storageId != null) {
1188
+ savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
1189
+ }
1178
1190
  handleManifest(preferences.edgeURL, result);
1179
1191
  try {
1180
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) {
@@ -559,7 +560,7 @@ const getStandardPayload = (destination, payload) => {
559
560
  referrer: getReferrer(destination),
560
561
  search: getSearch(destination),
561
562
  locale: getLocale(),
562
- sdkVersion: "0.62.1" ,
563
+ sdkVersion: "0.63.1" ,
563
564
  ...(payload || {}),
564
565
  };
565
566
  let storage = {};
@@ -841,11 +842,11 @@ const handleData = (data, providers, options) => {
841
842
 
842
843
  const handleConsent = (consent, options) => {
843
844
  if (options === null || options === void 0 ? void 0 : options.destination) {
844
- processConsent(options.destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
845
+ processConsent(options.destination, consent, options);
845
846
  return;
846
847
  }
847
848
  getInstances().forEach((destination) => {
848
- processConsent(destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
849
+ processConsent(destination, consent, options);
849
850
  });
850
851
  };
851
852
  const saveConsent = (destination, consent) => {
@@ -854,16 +855,23 @@ const saveConsent = (destination, consent) => {
854
855
  });
855
856
  savePerKey(destination, 'local', tagStorage, consent, consentKey);
856
857
  };
857
- const processConsent = (destination, consent, localSave) => {
858
+ const processConsent = (destination, consent, options) => {
858
859
  const existingConsent = getConsent$1(destination);
859
860
  if (areEqual(existingConsent, consent)) {
860
861
  return;
861
862
  }
863
+ if (!getSetting(destination, 'initialized')) {
864
+ addStub(destination, {
865
+ name: 'consent',
866
+ arguments: [consent, options],
867
+ });
868
+ return;
869
+ }
862
870
  const payload = {
863
871
  consentString: consent,
864
872
  };
865
873
  saveConsent(destination, consent);
866
- if (!localSave) {
874
+ if (!(options === null || options === void 0 ? void 0 : options.localSave)) {
867
875
  postRequest(getConsentURL(destination), payload).catch(error);
868
876
  }
869
877
  const userId = getUserId$1(destination);
@@ -1172,7 +1180,11 @@ const handleInit = (preferences) => {
1172
1180
  userId: result.userId,
1173
1181
  manifest: result.result,
1174
1182
  browserPackages: Object.values(providers),
1183
+ storageId: result.storageId,
1175
1184
  });
1185
+ if (result.storageId != null) {
1186
+ savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
1187
+ }
1176
1188
  handleManifest(preferences.edgeURL, result);
1177
1189
  try {
1178
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.1",
3
+ "version": "0.63.1",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",