@naturalcycles/internal-web-lib 1.6.0 → 1.7.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 (51) hide show
  1. package/bundle/analyticsClient.js +50 -63
  2. package/bundle/analyticsClient.js.map +1 -1
  3. package/bundle/conversionClient.js +22 -45
  4. package/bundle/conversionClient.js.map +1 -1
  5. package/bundle/cookieMonster.js +105 -101
  6. package/bundle/cookieMonster.js.map +1 -1
  7. package/dist/analytics/analyticsClient.d.ts +12 -0
  8. package/dist/analytics/analyticsClient.js +36 -12
  9. package/dist/conversion/conversion.util.js +1 -2
  10. package/dist/conversion/conversionClient.js +1 -2
  11. package/dist/cookie-monster/components/setting-dropdown/setting-dropdown.component.js +2 -3
  12. package/dist/cookie-monster/components/setting-dropdown/setting-dropdown2.component.js +1 -2
  13. package/dist/cookie-monster/components/themed-button/themed-button.component.js +2 -3
  14. package/dist/cookie-monster/components/themed-button/themed-button2.component.js +1 -2
  15. package/dist/cookie-monster/consent/consent.service.js +3 -4
  16. package/dist/cookie-monster/consent/consentLogStorage.service.js +1 -2
  17. package/dist/cookie-monster/const/cookieMonster.const.js +0 -1
  18. package/dist/cookie-monster/cookie-monster-element.d.ts +2 -2
  19. package/dist/cookie-monster/cookie-monster-element.js +11 -8
  20. package/dist/cookie-monster/cookieMonsterService.d.ts +3 -0
  21. package/dist/cookie-monster/cookieMonsterService.js +16 -9
  22. package/dist/cookie-monster/css/fonts.js +1 -2
  23. package/dist/cookie-monster/css/general.js +1 -2
  24. package/dist/cookie-monster/css/shared-sheets.js +2 -3
  25. package/dist/cookie-monster/css/variants.js +3 -0
  26. package/dist/cookie-monster/icons/chevron.js +1 -2
  27. package/dist/cookie-monster/index.js +2 -2
  28. package/dist/cookie-monster/lang/da-DK.js +1 -2
  29. package/dist/cookie-monster/lang/de-DE.js +1 -2
  30. package/dist/cookie-monster/lang/en-GB.js +1 -2
  31. package/dist/cookie-monster/lang/en-US.js +1 -2
  32. package/dist/cookie-monster/lang/es-US.js +1 -2
  33. package/dist/cookie-monster/lang/fi-FI.js +1 -2
  34. package/dist/cookie-monster/lang/fr-FR.js +1 -2
  35. package/dist/cookie-monster/lang/it-IT.js +1 -2
  36. package/dist/cookie-monster/lang/no-NO.js +1 -2
  37. package/dist/cookie-monster/lang/pt-BR.js +1 -2
  38. package/dist/cookie-monster/lang/sv-SE.js +1 -2
  39. package/dist/cookie-monster/types/CookieMonster.types.d.ts +5 -0
  40. package/dist/cookie-monster/types/CookieMonster.types.js +7 -3
  41. package/dist/cookie-monster/utils/createButton.js +1 -2
  42. package/dist/cookie-monster/utils/getCookieMonsterEvent.js +1 -2
  43. package/dist/cookie-monster/utils/handleRootClick.js +1 -2
  44. package/dist/cookie-monster/utils/linkify.js +1 -2
  45. package/dist/cookie-monster/utils/translationsService.js +1 -2
  46. package/dist/cookie-monster/views/main.view.js +3 -4
  47. package/dist/cookie-monster/views/settings.view.js +3 -5
  48. package/dist/cookie-monster/views/views.js +2 -3
  49. package/dist/{node_modules/.pnpm/@naturalcycles_ncuikit@1.17.0_react@19.3.1_undici@8.12.1/node_modules/@naturalcycles/ncuikit → ncuikit}/dist/styles/_palette.js +1 -2
  50. package/package.json +3 -2
  51. package/dist/cookie-monster/icons/back.js +0 -4
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/is.util.js
1
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/is.util.js
2
2
  var e = (e) => !!e;
3
3
  function t(e) {
4
4
  return typeof e == "object" && !!e && !Array.isArray(e) || !1;
@@ -7,8 +7,7 @@ function n(e) {
7
7
  for (let t in e) if (Object.hasOwn(e, t)) return !1;
8
8
  return !0;
9
9
  }
10
- //#endregion
11
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/abort.js
10
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/abort.js
12
11
  function r(e) {
13
12
  return e ? i(e) : void 0;
14
13
  }
@@ -37,8 +36,7 @@ function c(e) {
37
36
  });
38
37
  return t.signal;
39
38
  }
40
- //#endregion
41
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/log/commonLogger.js
39
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/log/commonLogger.js
42
40
  function l(e, t) {
43
41
  let n = (n, [r, i]) => e({
44
42
  ...t?.(),
@@ -66,8 +64,7 @@ var d = l(({ level: e, msg: t, err: n, ...r }) => {
66
64
  let i = [];
67
65
  t !== void 0 && i.push(t), n !== void 0 && i.push(n), Object.keys(r).length && i.push(r), console[e](...i);
68
66
  }), f = (...e) => void 0, p = Object.entries;
69
- //#endregion
70
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/object/object.util.js
67
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/object/object.util.js
71
68
  function ee(e, t, n = {}) {
72
69
  if (n.mutate) {
73
70
  for (let n of Object.keys(e)) t.includes(n) || delete e[n];
@@ -113,16 +110,14 @@ function y(e, ...n) {
113
110
  for (let r of n) if (t(r)) for (let n of Object.keys(r)) n !== "__proto__" && n !== "constructor" && n !== "prototype" && (t(r[n]) ? (e[n] ||= {}, y(e[n], r[n])) : e[n] = r[n]);
114
111
  return e;
115
112
  }
116
- //#endregion
117
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/env.js
113
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/env.js
118
114
  function b() {
119
115
  return !x();
120
116
  }
121
117
  function x() {
122
118
  return typeof window < "u" && !!window?.document;
123
119
  }
124
- //#endregion
125
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/string/json.util.js
120
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/string/json.util.js
126
121
  var S = /^\s*[{["\-\d]/;
127
122
  function C(e, t) {
128
123
  if (typeof e == "string" && e && S.test(e)) try {
@@ -137,16 +132,14 @@ function ne(e, t) {
137
132
  throw new ae({ text: e });
138
133
  }
139
134
  }
140
- //#endregion
141
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/string/string.util.js
135
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/string/string.util.js
142
136
  function w(e, t, n = "...") {
143
137
  if (!e || e.length <= t) return e;
144
138
  if (t <= n.length) return n;
145
139
  let r = Math.round((t - n.length) / 2), i = e.length - Math.floor((t - n.length) / 2);
146
140
  return e.slice(0, r) + n + e.slice(i);
147
141
  }
148
- //#endregion
149
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/error/error.util.js
142
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/error/error.util.js
150
143
  function T(e, t = Error, n) {
151
144
  let r;
152
145
  return r = e instanceof t ? e : re(E(e), t), n && (r.data ||= {}, Object.assign(r.data, n)), r;
@@ -285,8 +278,7 @@ var M = class e extends Error {
285
278
  super(e || "expected error was not thrown", {}, { name: "UnexpectedPassError" });
286
279
  }
287
280
  };
288
- //#endregion
289
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/string/safeJsonStringify.js
281
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/string/safeJsonStringify.js
290
282
  function P(e, t, n, r) {
291
283
  try {
292
284
  return JSON.stringify(e, t, n);
@@ -304,8 +296,7 @@ function ce(e, t) {
304
296
  return e == null ? a : e.call(this, i, a);
305
297
  };
306
298
  }
307
- //#endregion
308
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/string/stringify.js
299
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/string/stringify.js
309
300
  var le = typeof globalThis.AggregateError == "function", ue = P;
310
301
  function F(e, t = {}) {
311
302
  if (e === void 0) return "undefined";
@@ -342,16 +333,14 @@ function de(e, t) {
342
333
  ...e.errors.map((e, n) => `${n + 1}. ${F(e, t)}`)
343
334
  ].join("\n")), e.cause && n && (r = r + "\nCaused by: " + F(e.cause, t)), r;
344
335
  }
345
- //#endregion
346
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/error/assert.js
336
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/error/assert.js
347
337
  function I(e, t = Error) {
348
338
  if (!(e instanceof t)) throw new ie(`Expected to be instanceof ${t.name}, actual typeof: ${typeof e}`);
349
339
  }
350
340
  function L(e, t) {
351
341
  if (!(e instanceof t)) throw e;
352
342
  }
353
- //#endregion
354
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/promise/pDelay.js
343
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/promise/pDelay.js
355
344
  async function R(e, t) {
356
345
  t?.aborted || await new Promise((n) => {
357
346
  let r = setTimeout(i, e);
@@ -361,8 +350,7 @@ async function R(e, t) {
361
350
  t?.addEventListener("abort", i);
362
351
  });
363
352
  }
364
- //#endregion
365
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/datetime/time.util.js
353
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/datetime/time.util.js
366
354
  function z(e, t = Date.now()) {
367
355
  return B(t - e);
368
356
  }
@@ -372,13 +360,11 @@ function B(e) {
372
360
  let t = Math.floor(e / 1e3) % 60, n = Math.floor(e / 6e4) % 60, r = Math.floor(e / 36e5);
373
361
  return r === 0 ? n === 0 ? `${t} sec` : `${n}m${t}s` : r < 24 ? `${r}h${n}m` : r < 48 ? `${Math.round(r + n / 60)}h` : `${Math.floor(r / 24)} days`;
374
362
  }
375
- //#endregion
376
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/number/number.util.js
363
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/number/number.util.js
377
364
  function V(e, t, n) {
378
365
  return e <= t ? t : e >= n ? n : e;
379
366
  }
380
- //#endregion
381
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/analytics/analytics.model.js
367
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/analytics/analytics.model.js
382
368
  var H = "identify";
383
369
  function U(e) {
384
370
  return e.length <= 255 ? e : Array.from(e).slice(0, 255).join("");
@@ -395,8 +381,7 @@ var W = [
395
381
  "utm_creative_format",
396
382
  "utm_marketing_tactic"
397
383
  ];
398
- //#endregion
399
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/array/array.util.js
384
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/array/array.util.js
400
385
  function fe(e, t) {
401
386
  let n = {};
402
387
  for (let r of e) {
@@ -405,8 +390,7 @@ function fe(e, t) {
405
390
  }
406
391
  return n;
407
392
  }
408
- //#endregion
409
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/promise/pTimeout.js
393
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/promise/pTimeout.js
410
394
  async function pe(e, t) {
411
395
  let n = new AbortController(), { signal: r } = n;
412
396
  if (!t.timeout) return await e(r);
@@ -432,8 +416,7 @@ async function pe(e, t) {
432
416
  }
433
417
  });
434
418
  }
435
- //#endregion
436
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/string/url.util.js
419
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/string/url.util.js
437
420
  function me(e, t) {
438
421
  if (typeof e != "string") return null;
439
422
  try {
@@ -442,8 +425,7 @@ function me(e, t) {
442
425
  return null;
443
426
  }
444
427
  }
445
- //#endregion
446
- //#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.1_undici@8.12.1/node_modules/@naturalcycles/js-lib/dist/http/http.model.js
428
+ // ../../node_modules/.pnpm/@naturalcycles+js-lib@15.98.0_undici@8.12.3/node_modules/@naturalcycles/js-lib/dist/http/http.model.js
447
429
  var he = [
448
430
  "GET",
449
431
  "POST",
@@ -754,9 +736,7 @@ var he = [
754
736
  return this.cfg.logWithSearchParams || (n = n.split("?")[0]), !this.cfg.logWithBaseUrl && t && n.startsWith(t) && (n = n.slice(t.length)), n;
755
737
  }
756
738
  normalizeCfg(t) {
757
- let { debug: n = !1, logger: r = d } = t;
758
- t.baseUrl?.endsWith("/") && (r.warn(`Fetcher: baseUrl should not end with slash: ${t.baseUrl}`), t.baseUrl = t.baseUrl.slice(0, t.baseUrl.length - 1));
759
- let i = y({
739
+ let { debug: n = !1, logger: r = d } = t, i = y({
760
740
  baseUrl: "",
761
741
  name: this.getFetcherName(t),
762
742
  inputUrl: "",
@@ -799,7 +779,7 @@ var he = [
799
779
  "name",
800
780
  "keepalive"
801
781
  ]));
802
- return i.init.headers = v(i.init.headers, (e) => e.toLowerCase()), i;
782
+ return i.init.headers = v(i.init.headers, (e) => e.toLowerCase()), i.baseUrl.endsWith("/") && (r.warn(`Fetcher: baseUrl should not end with slash: ${i.baseUrl}`), i.baseUrl = i.baseUrl.slice(0, -1)), i;
803
783
  }
804
784
  getFetcherName(e) {
805
785
  let { name: t } = e;
@@ -907,8 +887,7 @@ function we(e, t, n) {
907
887
  }
908
888
  };
909
889
  }
910
- //#endregion
911
- //#region src/analytics/analyticsClient.ts
890
+ // src/analytics/analyticsClient.ts
912
891
  var Te = 3800, Ee = "utm_", De = [
913
892
  "dclid",
914
893
  "fbclid",
@@ -944,7 +923,7 @@ var Te = 3800, Ee = "utm_", De = [
944
923
  logger: this.cfg.logger,
945
924
  retryPost: !0,
946
925
  timeoutSeconds: 10
947
- }), !b() && (this.restoreOrphanedQueues(), globalThis.addEventListener("pagehide", this.handlePageHide), document.addEventListener("visibilitychange", this.handleVisibilityChange));
926
+ }), b() || (this.restoreOrphanedQueues(), globalThis.addEventListener("pagehide", this.handlePageHide), document.addEventListener("visibilitychange", this.handleVisibilityChange));
948
927
  }
949
928
  cfg;
950
929
  firstTouchFetcher;
@@ -956,6 +935,7 @@ var Te = 3800, Ee = "utm_", De = [
956
935
  consecutiveFailures = 0;
957
936
  retryAfter = 0;
958
937
  hasUpdatedAcquisitionProps = !1;
938
+ isQueuePersistScheduled = !1;
959
939
  eventListeners = /* @__PURE__ */ new Set();
960
940
  handlePageHide = () => {
961
941
  this.flushNow();
@@ -1019,7 +999,7 @@ var Te = 3800, Ee = "utm_", De = [
1019
999
  },
1020
1000
  userId: this.identity.getDistinctId()
1021
1001
  };
1022
- return this.cfg.debug && this.cfg.logger.log(`[analytics] ${r.name}`, { props: r.props }), this.queue.push(r), this.queue.length > this.cfg.maxQueueSize && (this.queue.shift(), this.cfg.logger.warn("[analytics] queue overflow, dropped the oldest event")), this.persistQueue(), this.queue.length >= this.cfg.maxBatchSize && !this.consecutiveFailures ? this.flush() : this.scheduleFlush(), r;
1002
+ return this.cfg.debug && this.cfg.logger.log(`[analytics] ${r.name}`, { props: r.props }), this.queue.push(r), this.queue.length > this.cfg.maxQueueSize && (this.queue.shift(), this.cfg.logger.warn("[analytics] queue overflow, dropped the oldest event")), this.schedulePersistQueue(), this.queue.length >= this.cfg.maxBatchSize && !this.consecutiveFailures ? this.flush() : this.scheduleFlush(), r;
1023
1003
  }
1024
1004
  canTrack() {
1025
1005
  return !b() && this.cfg.isEnabled();
@@ -1045,7 +1025,7 @@ var Te = 3800, Ee = "utm_", De = [
1045
1025
  }
1046
1026
  flushNow() {
1047
1027
  if (this.queue.length) {
1048
- this.clearFlushTimer();
1028
+ this.persistScheduledQueue(), this.clearFlushTimer();
1049
1029
  for (let e of this.prepareBatches()) this.postBatch(e, !0).catch((e) => {
1050
1030
  this.cfg.logger.warn("[analytics] lifecycle batch failed to send; retained for retry", { err: e });
1051
1031
  });
@@ -1053,7 +1033,7 @@ var Te = 3800, Ee = "utm_", De = [
1053
1033
  }
1054
1034
  }
1055
1035
  destroy() {
1056
- this.clearFlushTimer(), !b() && (globalThis.removeEventListener("pagehide", this.handlePageHide), document.removeEventListener("visibilitychange", this.handleVisibilityChange));
1036
+ this.persistScheduledQueue(), this.clearFlushTimer(), b() || (globalThis.removeEventListener("pagehide", this.handlePageHide), document.removeEventListener("visibilitychange", this.handleVisibilityChange));
1057
1037
  }
1058
1038
  ensureAcquisitionProps() {
1059
1039
  this.hasUpdatedAcquisitionProps || (this.hasUpdatedAcquisitionProps = !0, this.identity.updateAcquisitionProps(), this.sendFirstTouch());
@@ -1130,24 +1110,22 @@ var Te = 3800, Ee = "utm_", De = [
1130
1110
  let e = [], t, n = this.identity.getDistinctId();
1131
1111
  for (let r of this.queue) {
1132
1112
  let i = Y(P(r)), a = t?.events.length === this.cfg.maxBatchSize, o = +!!t?.events.length, s = !!t && t.bodyBytes + o + i > this.cfg.maxBatchBytes;
1133
- t && (a || s) && (e.push(this.finalizeBatch(t)), t = void 0), t ||= this.createPendingBatch(n);
1134
- let c = +!!t.events.length;
1135
- t.events.push(r), t.bodyBytes += c + i;
1113
+ t && (a || s) && (e.push(this.finalizeBatch(t)), t = void 0), t ? (t.events.push(r), t.bodyBytes += o + i) : t = this.createPendingBatch(n, r, i);
1136
1114
  }
1137
- return t?.events.length && e.push(this.finalizeBatch(t)), e;
1115
+ return t && e.push(this.finalizeBatch(t)), e;
1138
1116
  }
1139
- createPendingBatch(e) {
1140
- let t = Date.now(), n = {
1141
- sentAt: t,
1117
+ createPendingBatch(e, t, n) {
1118
+ let r = Date.now(), i = {
1119
+ sentAt: r,
1142
1120
  clientId: this.cfg.clientId,
1143
1121
  userId: e,
1144
1122
  events: []
1145
1123
  };
1146
1124
  return {
1147
- sentAt: t,
1125
+ sentAt: r,
1148
1126
  userId: e,
1149
- events: [],
1150
- bodyBytes: Y(JSON.stringify(n))
1127
+ events: [t],
1128
+ bodyBytes: Y(JSON.stringify(i)) + n
1151
1129
  };
1152
1130
  }
1153
1131
  finalizeBatch(e) {
@@ -1194,10 +1172,19 @@ var Te = 3800, Ee = "utm_", De = [
1194
1172
  let t = new Set(e.map((e) => e.id));
1195
1173
  this.queue = this.queue.filter((e) => !t.has(e.id)), this.persistQueue();
1196
1174
  }
1175
+ schedulePersistQueue() {
1176
+ this.cfg.persistQueue && !this.isQueuePersistScheduled && (this.isQueuePersistScheduled = !0, queueMicrotask(() => this.persistScheduledQueue()));
1177
+ }
1178
+ persistScheduledQueue() {
1179
+ this.isQueuePersistScheduled && this.persistQueue();
1180
+ }
1197
1181
  persistQueue() {
1198
- if (this.cfg.persistQueue) try {
1199
- this.queue.length ? localStorage.setItem(this.queueKey, P(this.queue)) : localStorage.removeItem(this.queueKey);
1200
- } catch {}
1182
+ if (this.cfg.persistQueue) {
1183
+ this.isQueuePersistScheduled = !1;
1184
+ try {
1185
+ this.queue.length ? localStorage.setItem(this.queueKey, P(this.queue)) : localStorage.removeItem(this.queueKey);
1186
+ } catch {}
1187
+ }
1201
1188
  }
1202
1189
  get queueKey() {
1203
1190
  return `${this.cfg.localStorageKeyPrefix}.q.${this.tabId}`;
@@ -1215,6 +1202,7 @@ var Te = 3800, Ee = "utm_", De = [
1215
1202
  }
1216
1203
  cfg;
1217
1204
  memoryEntry = {};
1205
+ memoryEntryRaw;
1218
1206
  hasRefreshedExpiry = !1;
1219
1207
  getDistinctId() {
1220
1208
  return this.ensureIdentity().distinct_id;
@@ -1267,12 +1255,12 @@ var Te = 3800, Ee = "utm_", De = [
1267
1255
  loadEntry() {
1268
1256
  try {
1269
1257
  let e = this.cfg.persistence === "cookie" ? X(this.cfg.persistenceKey) : localStorage.getItem(this.cfg.persistenceKey);
1270
- e && (this.memoryEntry = JSON.parse(e));
1258
+ e && e !== this.memoryEntryRaw && (this.memoryEntry = JSON.parse(e), this.memoryEntryRaw = e);
1271
1259
  } catch {}
1272
1260
  return this.memoryEntry;
1273
1261
  }
1274
1262
  saveEntry(e) {
1275
- this.memoryEntry = e, this.hasRefreshedExpiry = !0;
1263
+ this.memoryEntry = e, this.memoryEntryRaw = void 0, this.hasRefreshedExpiry = !0;
1276
1264
  let t = 0;
1277
1265
  try {
1278
1266
  let n = JSON.stringify(e);
@@ -1351,7 +1339,6 @@ var $ = class extends M {
1351
1339
  super(e, t, { name: "AnalyticsClientError" });
1352
1340
  }
1353
1341
  };
1354
- //#endregion
1355
1342
  export { Oe as AnalyticsClient, $ as AnalyticsClientError, q as AnalyticsIdentity, X as getCookie, Q as setCookie };
1356
1343
 
1357
1344
  //# sourceMappingURL=analyticsClient.js.map