@braze/web-sdk 4.8.0 → 4.8.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 (72) hide show
  1. package/index.d.ts +6 -3
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -1
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +11 -11
  6. package/shared-lib/indexed-db-adapter.js +67 -67
  7. package/shared-lib/logger.js +7 -7
  8. package/src/Card/card-manager.js +1 -1
  9. package/src/ContentCards/ui/show-content-cards.js +1 -1
  10. package/src/Core/disable-sdk.js +5 -4
  11. package/src/Core/enable-sdk.js +1 -1
  12. package/src/Core/is-disabled.js +1 -1
  13. package/src/FeatureFlags/feature-flags-provider.js +12 -12
  14. package/src/Feed/ui/show-feed.js +1 -1
  15. package/src/InAppMessage/in-app-message-manager.js +40 -34
  16. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  17. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  18. package/src/InAppMessage/log-in-app-message-html-click.js +1 -1
  19. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  20. package/src/InAppMessage/models/in-app-message.js +13 -13
  21. package/src/InAppMessage/models/slide-up-message.js +2 -2
  22. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  23. package/src/InAppMessage/ui/show-in-app-message.js +2 -2
  24. package/src/Push/push-manager.js +82 -81
  25. package/src/Push/utils/push-utils.js +4 -4
  26. package/src/User/user-manager.js +4 -4
  27. package/src/User/user.js +5 -5
  28. package/src/common/feed-display.js +82 -72
  29. package/src/l10n/l10n-manager-factory.js +7 -7
  30. package/src/managers/auth-manager.js +18 -15
  31. package/src/managers/braze-instance.js +125 -109
  32. package/src/managers/device-manager.js +40 -35
  33. package/src/managers/network-manager.js +90 -81
  34. package/src/managers/server-config-manager.js +36 -34
  35. package/src/managers/session-manager.js +44 -37
  36. package/src/managers/storage-manager-factory.js +23 -16
  37. package/src/managers/storage-manager.js +251 -239
  38. package/src/managers/subscription-manager.js +10 -7
  39. package/src/managers/types.js +1 -0
  40. package/src/models/backend-errors.js +5 -5
  41. package/src/models/braze-event.js +10 -4
  42. package/src/models/device.js +10 -18
  43. package/src/models/identifier.js +10 -11
  44. package/src/models/push-token.js +14 -9
  45. package/src/models/request-result.js +2 -2
  46. package/src/models/server-config.js +32 -16
  47. package/src/models/types.js +1 -0
  48. package/src/request-controller.js +109 -109
  49. package/src/triggers/models/custom-event-data.js +6 -6
  50. package/src/triggers/models/custom-event-property-data.js +9 -9
  51. package/src/triggers/models/filter-set.js +9 -9
  52. package/src/triggers/models/filter.js +60 -60
  53. package/src/triggers/models/in-app-message-click-data.js +9 -9
  54. package/src/triggers/models/purchase-data.js +3 -3
  55. package/src/triggers/models/purchase-property-data.js +7 -7
  56. package/src/triggers/models/push-click-data.js +6 -6
  57. package/src/triggers/models/trigger-condition.js +46 -46
  58. package/src/triggers/models/trigger-events.js +1 -1
  59. package/src/triggers/models/trigger.js +27 -27
  60. package/src/triggers/triggers-provider.js +126 -126
  61. package/src/ui/js/attach-css.js +1 -1
  62. package/src/util/base-device-parser.js +2 -2
  63. package/src/util/braze-actions.js +4 -4
  64. package/src/util/browser-detector.js +18 -18
  65. package/src/util/client-hints-parser.js +6 -6
  66. package/src/util/device-constants.js +6 -6
  67. package/src/util/dom-utils.js +5 -5
  68. package/src/util/error-utils.js +2 -0
  69. package/src/util/net.js +1 -1
  70. package/src/util/request-header-utils.js +9 -9
  71. package/src/util/user-agent-parser.js +21 -21
  72. package/src/util/window-utils.js +1 -1
@@ -11,40 +11,51 @@ import { STORAGE_KEYS as i } from "./storage-manager.js";
11
11
  import T from "../util/request-header-utils.js";
12
12
  import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Ht } from "../common/constants.js";
13
13
  export default class Pt {
14
- constructor(t, e, s, i, r, o, n, a, u, h, c) {
15
- (this.Xo = t),
16
- (this.Jn = e),
17
- (this.gh = s),
18
- (this.Qo = i),
19
- (this.fh = r),
20
- (this.Zo = o),
21
- (this.Ko = n),
22
- (this.Ho = a),
23
- (this.Vo = u),
24
- (this.Yo = h),
25
- (this.pa = c),
26
- (this.Ra = ["npm"]);
14
+ constructor(t, e, s, i, r, o, n, a, h, u, c) {
15
+ (this.Zr = t),
16
+ (this.u = e),
17
+ (this.jo = s),
18
+ (this.ft = i),
19
+ (this._e = r),
20
+ (this.wt = o),
21
+ (this.Xr = n),
22
+ (this.Do = a),
23
+ (this.Ro = h),
24
+ (this.Mo = u),
25
+ (this.appVersion = c),
26
+ (this.Zr = t),
27
+ (this.u = e),
28
+ (this.jo = s),
29
+ (this.ft = i),
30
+ (this._e = r),
31
+ (this.wt = o),
32
+ (this.Xr = n),
33
+ (this.Do = a),
34
+ (this.Ro = h),
35
+ (this.Mo = u),
36
+ (this.appVersion = c),
37
+ (this.ha = ["npm"]);
27
38
  }
28
- Gs(t, e) {
29
- const s = this.Xo.te(),
30
- r = s.Wi(),
31
- o = this.Jn.v(i.k.ma);
39
+ Gs(t, e = !1) {
40
+ const s = this.Zr.te(),
41
+ r = s.Xi(),
42
+ o = this.u.v(i.k.la);
32
43
  ii(o, r) || (t.device = r),
33
- (t.api_key = this.Ko),
44
+ (t.api_key = this.Xr),
34
45
  (t.time = h(new Date().valueOf(), !0));
35
- const n = this.Jn.v(i.k.ga) || [],
36
- a = this.Jn.v(i.k.qa) || "";
46
+ const n = this.u.v(i.k.ua) || [],
47
+ a = this.u.v(i.k.ma) || "";
37
48
  if (
38
- (this.Ra.length > 0 &&
39
- (!ii(n, this.Ra) || a !== this.fh.ba()) &&
40
- (t.sdk_metadata = this.Ra),
41
- (t.sdk_version = this.Vo),
42
- this.Yo && (t.sdk_flavor = this.Yo),
43
- (t.app_version = this.pa),
49
+ (this.ha.length > 0 &&
50
+ (!ii(n, this.ha) || a !== this._e.pa()) &&
51
+ (t.sdk_metadata = this.ha),
52
+ (t.sdk_version = this.Ro),
53
+ this.Mo && (t.sdk_flavor = this.Mo),
54
+ (t.app_version = this.appVersion),
44
55
  (t.device_id = s.id),
45
56
  e)
46
57
  ) {
47
- const e = this.Qo.getUserId();
58
+ const e = this.ft.getUserId();
48
59
  null != e && (t.user_id = e);
49
60
  }
50
61
  return t;
@@ -55,7 +66,7 @@ export default class Pt {
55
66
  if (!o && !n) return !0;
56
67
  if (o) {
57
68
  let e;
58
- this.gh.pu();
69
+ this.jo.Ch();
59
70
  const s = { errorCode: o.error_code };
60
71
  for (const t of i)
61
72
  p(t) && "X-Braze-Auth-Signature" === t[0] && (s.signature = t[1]);
@@ -67,12 +78,12 @@ export default class Pt {
67
78
  n
68
79
  ? ((s.reason = n), (e = `due to ${n}`))
69
80
  : (e = `with error code ${o.error_code}.`),
70
- this.gh.Zn() ||
81
+ this.jo.Zn() ||
71
82
  (e +=
72
83
  ' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
73
84
  r.j.error(`SDK Authentication failed ${e}`),
74
- this.Aa(t.events, t.attributes),
75
- this.gh.Su(s),
85
+ this.Ra(t.events || [], t.attributes || []),
86
+ this.jo.wh(s),
76
87
  !1
77
88
  );
78
89
  }
@@ -80,120 +91,118 @@ export default class Pt {
80
91
  let i,
81
92
  o = n;
82
93
  switch (o) {
83
- case qt.za:
94
+ case qt.ga:
84
95
  return (
85
96
  (i = "Received successful response with empty body."),
86
97
  s.N(r.q.Is, { e: i }),
87
98
  r.j.info(i),
88
99
  !1
89
100
  );
90
- case qt.Ba:
101
+ case qt.qa:
91
102
  return (
92
103
  (i = "Received successful response with invalid JSON"),
93
104
  s.N(r.q.Is, { e: i + ": " + e.response }),
94
105
  r.j.info(i),
95
106
  !1
96
107
  );
97
- case qt.Da:
98
- o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Ho}`;
108
+ case qt.ba:
109
+ o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Do}`;
99
110
  break;
100
- case qt.Sa:
111
+ case qt.Aa:
101
112
  o =
102
113
  "Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
103
114
  break;
104
- case qt.va:
115
+ case qt.za:
105
116
  o = "No device identifier. Please contact support@braze.com";
106
117
  }
107
118
  r.j.error("Backend error: " + o);
108
119
  }
109
120
  return !1;
110
121
  }
111
- ka(t, e, s, i) {
122
+ Ba(t, e, s, i) {
112
123
  return !!((t && 0 !== t.length) || (e && 0 !== e.length) || s || i);
113
124
  }
114
- Ta(t, e, s, i) {
125
+ Da(t, e, s, i) {
115
126
  const r = [],
116
127
  o = t => t || "",
117
- n = o(this.Qo.getUserId());
118
- let a,
119
- u,
120
- h,
121
- c,
122
- l = this.Vi(t, e);
128
+ n = o(this.ft.getUserId());
129
+ let a = this.Wi(t, e);
130
+ const h = [],
131
+ u = [];
132
+ let c,
133
+ l = null;
123
134
  if (s.length > 0) {
124
135
  const t = [];
125
136
  for (const e of s) {
126
- if (((a = e.Wi()), this.gh.Zn())) {
127
- if (n && !a.user_id) {
128
- c || ((c = {}), (c.events = [])), c.events.push(a);
137
+ if (((c = e.Xi()), this.jo.Zn())) {
138
+ if (n && !c.user_id) {
139
+ l || (l = {}), l.events || (l.events = []), l.events.push(c);
129
140
  continue;
130
141
  }
131
- if (o(a.user_id) !== n) {
132
- u || (u = []), u.push(a);
142
+ if (o(c.user_id) !== n) {
143
+ u.push(c);
133
144
  continue;
134
145
  }
135
146
  }
136
- t.push(a);
147
+ t.push(c);
137
148
  }
138
- t.length > 0 && (l.events = t);
149
+ t.length > 0 && (a.events = t);
139
150
  }
140
151
  if (i.length > 0) {
141
152
  const t = [];
142
153
  for (const e of i)
143
- this.gh.Zn() && o(e.user_id) !== n
144
- ? (h || (h = []), h.push(e))
145
- : t.push(e);
146
- t.length > 0 && (l.attributes = t);
154
+ this.jo.Zn() && o(e.user_id) !== n ? h.push(e) : t.push(e);
155
+ t.length > 0 && (a.attributes = t);
147
156
  }
148
- if ((this.Aa(u, h), (l = this.Gs(l, !0)), c)) {
149
- c = this.Gs(c, !1);
150
- const t = { requestData: c, headers: this.Ks(c, T.Qs.Xa) };
157
+ if ((this.Ra(u, h), (a = this.Gs(a, !0)), l)) {
158
+ l = this.Gs(l, !1);
159
+ const t = { requestData: l, headers: this.Ks(l, T.Qs.Sa) };
151
160
  r.push(t);
152
161
  }
153
- if (l && !this.ka(l.events, l.attributes, t, e)) return c ? r : null;
154
- const f = { requestData: l, headers: this.Ks(l, T.Qs.Xa) };
162
+ if (a && !this.Ba(a.events, a.attributes, t, e)) return l ? r : null;
163
+ const f = { requestData: a, headers: this.Ks(a, T.Qs.Sa) };
155
164
  return r.push(f), r;
156
165
  }
157
- Aa(t, e) {
166
+ Ra(t, e) {
158
167
  if (t) {
159
168
  const e = [];
160
169
  for (const s of t) {
161
170
  const t = ue.fromJson(s);
162
171
  (t.time = Xt(t.time)), e.push(t);
163
172
  }
164
- this.Jn.co(e);
173
+ this.u.co(e);
165
174
  }
166
- if (e) for (const t of e) this.Jn.wa(t);
175
+ if (e) for (const t of e) this.u.va(t);
167
176
  }
168
177
  ii(t, e) {
169
178
  let s = "HTTP error ";
170
179
  null != t && (s += t + " "), (s += e), r.j.error(s);
171
180
  }
172
181
  qr(t) {
173
- return s.N(r.q.ya, { n: t });
182
+ return s.N(r.q.ka, { n: t });
174
183
  }
175
- Vi(t, e, s) {
184
+ Wi(t, e, s) {
176
185
  const i = {};
177
186
  t && (i.feed = !0), e && (i.triggers = !0);
178
- const r = null != s ? s : this.Qo.getUserId();
187
+ const r = null != s ? s : this.ft.getUserId();
179
188
  return (
180
189
  r && (i.user_id = r),
181
- (i.config = { config_time: this.Zo.oi() }),
190
+ (i.config = { config_time: this.wt.oi() }),
182
191
  { respond_with: i }
183
192
  );
184
193
  }
185
- Ca(t) {
194
+ Ta(t) {
186
195
  const e = new Date().valueOf();
187
- let s = Ht.toString(),
188
- i = T.Ea(this.Jn, t);
196
+ let s = Ht.toString();
197
+ const i = T.Xa(this.u, t);
189
198
  if (-1 !== i) {
190
199
  s = (e - i).toString();
191
200
  }
192
201
  return s;
193
202
  }
194
- Ks(t, e, s) {
195
- const r = [["X-Braze-Api-Key", this.Ko]];
196
- let o = this.Ca(e);
203
+ Ks(t, e, s = !1) {
204
+ const r = [["X-Braze-Api-Key", this.Xr]],
205
+ o = this.Ta(e);
197
206
  r.push(["X-Braze-Last-Req-Ms-Ago", o]);
198
207
  let n = !1;
199
208
  if (
@@ -206,8 +215,8 @@ export default class Pt {
206
215
  e === T.Qs.Os)
207
216
  ) {
208
217
  r.push(["X-Braze-ContentCardsRequest", "true"]);
209
- let t = this.Jn.v(i.k.Fs);
210
- (t && s) || ((t = 0), this.Jn.D(i.k.Fs, t)),
218
+ let t = this.u.v(i.k.Fs);
219
+ (t && s) || ((t = 0), this.u.D(i.k.Fs, t)),
211
220
  r.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
212
221
  (n = !0);
213
222
  }
@@ -215,9 +224,9 @@ export default class Pt {
215
224
  (e === T.Qs.xi &&
216
225
  (r.push(["X-Braze-FeatureFlagsRequest", "true"]), (n = !0)),
217
226
  n && r.push(["X-Braze-DataRequest", "true"]),
218
- this.gh.Zn())
227
+ this.jo.Zn())
219
228
  ) {
220
- const t = this.gh.au();
229
+ const t = this.jo.gh();
221
230
  null != t && r.push(["X-Braze-Auth-Signature", t]);
222
231
  }
223
232
  return r;
@@ -231,12 +240,12 @@ export default class Pt {
231
240
  : e();
232
241
  }
233
242
  si() {
234
- this.gh.si();
243
+ this.jo.si();
235
244
  }
236
245
  Zs() {
237
- return this.Ho;
246
+ return this.Do;
238
247
  }
239
248
  addSdkMetadata(t) {
240
- for (const e of t) -1 === this.Ra.indexOf(e) && this.Ra.push(e);
249
+ for (const e of t) -1 === this.ha.indexOf(e) && this.ha.push(e);
241
250
  }
242
251
  }
@@ -4,31 +4,33 @@ import Kt from "../models/server-config.js";
4
4
  import s from "../common/event-logger.js";
5
5
  import r from "../../shared-lib/braze-shared-lib.js";
6
6
  import {
7
- CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as xt,
8
- CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Vt
7
+ CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as Vt,
8
+ CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Gt
9
9
  } from "../common/constants.js";
10
10
  export default class Mt {
11
11
  constructor(t) {
12
- (this.Jn = t),
12
+ (this.u = t),
13
+ (this.u = t),
13
14
  (this.tl = new E()),
14
15
  (this.el = new E()),
15
16
  (this.sl = new E()),
16
- (this.il = null);
17
+ (this.il = null),
18
+ (this.rl = null);
17
19
  }
18
- rl() {
19
- if (null == this.il) {
20
- const t = this.Jn.v(i.k.ll);
21
- this.il = null != t ? Kt.Tn(t) : new Kt();
20
+ ll() {
21
+ if (null == this.rl) {
22
+ const t = this.u.v(i.k.hl);
23
+ this.rl = null != t ? Kt.zn(t) : new Kt();
22
24
  }
23
- return this.il;
25
+ return this.rl;
24
26
  }
25
27
  oi() {
26
- return this.rl().hl;
28
+ return this.ll().ol;
27
29
  }
28
- ol(t) {
30
+ ul(t) {
29
31
  if (null != t && null != t.config) {
30
32
  const e = t.config;
31
- if (e.time > this.rl().hl) {
33
+ if (e.time > this.ll().ol) {
32
34
  const t = new Kt(
33
35
  e.time,
34
36
  e.events_blacklist,
@@ -40,22 +42,22 @@ export default class Mt {
40
42
  e.feature_flags
41
43
  );
42
44
  let s = !1;
43
- null != t.al && this.jn() !== t.al && (s = !0);
45
+ null != t.al && this.Un() !== t.al && (s = !0);
44
46
  let r = !1;
45
- null != t.ul.enabled && this.ni() !== t.ul.enabled && (r = !0);
47
+ null != t.ml.enabled && this.ni() !== t.ml.enabled && (r = !0);
46
48
  let n = !1;
47
49
  null != t.mi.enabled && this.bi() !== t.mi.enabled && (n = !0),
48
- (this.il = t),
49
- this.Jn.D(i.k.ll, t.ss()),
50
+ (this.rl = t),
51
+ this.u.D(i.k.hl, t.ss()),
50
52
  s && this.tl.Et(),
51
53
  r && this.el.Et(),
52
54
  n && this.sl.Et();
53
55
  }
54
56
  }
55
57
  }
56
- Un(t) {
57
- let e = this.tl.lt(t);
58
- return this.ml && this.tl.removeSubscription(this.ml), (this.ml = e), e;
58
+ Wn(t) {
59
+ const e = this.tl.lt(t);
60
+ return this.il && this.tl.removeSubscription(this.il), (this.il = e), e;
59
61
  }
60
62
  $s(t) {
61
63
  return this.el.lt(t);
@@ -64,43 +66,43 @@ export default class Mt {
64
66
  return this.sl.lt(t);
65
67
  }
66
68
  ge(t) {
67
- return -1 !== this.rl().cl.indexOf(t);
69
+ return -1 !== this.ll().cl.indexOf(t);
68
70
  }
69
71
  hu(t) {
70
- return -1 !== this.rl().gl.indexOf(t);
72
+ return -1 !== this.ll().gl.indexOf(t);
71
73
  }
72
74
  Dr(t) {
73
- return -1 !== this.rl().fl.indexOf(t);
75
+ return -1 !== this.ll().fl.indexOf(t);
74
76
  }
75
77
  dl() {
76
- return this.rl().bl;
78
+ return this.ll().bl;
77
79
  }
78
- jn() {
79
- return this.rl().al;
80
+ Un() {
81
+ return this.ll().al;
80
82
  }
81
83
  ni() {
82
- return this.rl().ul.enabled || !1;
84
+ return this.ll().ml.enabled || !1;
83
85
  }
84
86
  _s() {
85
- const t = this.rl().ul.rate_limit;
87
+ const t = this.ll().ml.rate_limit;
86
88
  return !(!t || null == t.enabled) && t.enabled;
87
89
  }
88
90
  fi() {
89
91
  if (!this._s()) return -1;
90
- const t = this.rl().ul.rate_limit;
91
- return null == t.capacity ? xt : t.capacity <= 0 ? -1 : t.capacity;
92
+ const t = this.ll().ml.rate_limit;
93
+ return null == t.capacity ? Vt : t.capacity <= 0 ? -1 : t.capacity;
92
94
  }
93
95
  di() {
94
96
  if (!this._s()) return -1;
95
- const t = this.rl().ul.rate_limit;
96
- return null == t.refill_rate ? Vt : t.refill_rate <= 0 ? -1 : t.refill_rate;
97
+ const t = this.ll().ml.rate_limit;
98
+ return null == t.refill_rate ? Gt : t.refill_rate <= 0 ? -1 : t.refill_rate;
97
99
  }
98
100
  bi() {
99
- return this.rl().mi.enabled && null == this.Si()
101
+ return this.ll().mi.enabled && null == this.Si()
100
102
  ? (s.N(r.q.Is, { e: "Missing feature flag refresh_rate_limit." }), !1)
101
- : this.rl().mi.enabled || !1;
103
+ : this.ll().mi.enabled || !1;
102
104
  }
103
105
  Si() {
104
- return this.rl().mi.refresh_rate_limit;
106
+ return this.ll().mi.refresh_rate_limit;
105
107
  }
106
108
  }
@@ -4,65 +4,72 @@ import _t from "../models/identifier.js";
4
4
  import { convertMsToSeconds as h } from "../util/date-utils.js";
5
5
  import r from "../../shared-lib/braze-shared-lib.js";
6
6
  export default class Dt {
7
- constructor(s, t, e, i) {
8
- (this.Jn = s),
9
- (this.Qo = t),
10
- (this.Zo = e),
11
- (this.jh = 1e3),
12
- (i = parseFloat(i)),
13
- isNaN(i) && (i = 1800),
14
- i < this.jh / 1e3 &&
7
+ constructor(s, t, i, e) {
8
+ (this.u = s),
9
+ (this.ft = t),
10
+ (this.wt = i),
11
+ (this.wl = e),
12
+ (this.u = s),
13
+ (this.ft = t),
14
+ (this.wt = i),
15
+ (this.Sl = 1e3),
16
+ (null == e || isNaN(e)) && (e = 1800),
17
+ e < this.Sl / 1e3 &&
15
18
  (r.j.info(
16
19
  "Specified session timeout of " +
17
- i +
20
+ e +
18
21
  "s is too small, using the minimum session timeout of " +
19
- this.jh / 1e3 +
22
+ this.Sl / 1e3 +
20
23
  "s instead."
21
24
  ),
22
- (i = this.jh / 1e3)),
23
- (this.xh = i);
25
+ (e = this.Sl / 1e3)),
26
+ (this.wl = e);
24
27
  }
25
- Gh(s, t) {
26
- return new ue(this.Qo.getUserId(), r.q.Fh, s, t.iu, { d: h(s - t.Hh) });
28
+ jl(s, t) {
29
+ return new ue(this.ft.getUserId(), r.q.xl, s, t.iu, { d: h(s - t.vl) });
27
30
  }
28
- ba() {
29
- const s = this.Jn.tu(i.eu.Wh);
31
+ pa() {
32
+ const s = this.u.tu(i.eu.Dl);
30
33
  return null == s ? null : s.iu;
31
34
  }
32
- kh() {
35
+ El() {
33
36
  const s = new Date().valueOf(),
34
- t = this.Zo.dl(),
35
- e = this.Jn.v(i.k.qh);
37
+ t = this.wt.dl(),
38
+ e = this.u.v(i.k.zl);
36
39
  if (null != e && null == t) return !1;
37
- const n = null == e || s - e > 1e3 * t;
38
- return n && this.Jn.D(i.k.qh, s), n;
40
+ let n = !1;
41
+ return (
42
+ null == e ? (n = !0) : null != t && (n = s - e > 1e3 * t),
43
+ n && this.u.D(i.k.zl, s),
44
+ n
45
+ );
39
46
  }
40
- yh(s, t) {
41
- return null == t || (!(s - t.Hh < this.jh) && t.Bh < s);
47
+ Cl(s, t) {
48
+ return null == t || null == t.Gl || (!(s - t.vl < this.Sl) && t.Gl < s);
42
49
  }
43
50
  bo() {
44
51
  const s = new Date().valueOf(),
45
- t = s + 1e3 * this.xh,
46
- e = this.Jn.tu(i.eu.Wh);
47
- if (this.yh(s, e)) {
52
+ t = s + 1e3 * this.wl,
53
+ e = this.u.tu(i.eu.Dl);
54
+ if (this.Cl(s, e)) {
48
55
  let n = "Generating session start event with time " + s;
49
56
  if (null != e) {
50
- let s = e.Jh;
51
- s - e.Hh < this.jh && (s = e.Hh + this.Kh),
52
- this.Jn.Qh(this.Gh(s, e)),
57
+ let s = e.Nl;
58
+ s - e.vl < this.Sl && (s = e.vl + this.Sl),
59
+ this.u.Hl(this.jl(s, e)),
53
60
  (n += " (old session ended " + s + ")");
54
61
  }
55
62
  (n += ". Will expire " + t.valueOf()), r.j.info(n);
56
- const o = new _t(r.Z.Y(), t);
57
- this.Jn.Qh(new ue(this.Qo.getUserId(), r.q.Vh, s, o.iu)),
58
- this.Jn.uu(i.eu.Wh, o);
59
- return null == this.Jn.v(i.k.qh) && this.Jn.D(i.k.qh, s), o.iu;
63
+ const l = new _t(r.Z.Y(), t);
64
+ this.u.Hl(new ue(this.ft.getUserId(), r.q.Wl, s, l.iu)),
65
+ this.u.uu(i.eu.Dl, l);
66
+ return null == this.u.v(i.k.zl) && this.u.D(i.k.zl, s), l.iu;
60
67
  }
61
- return (e.Jh = s), (e.Bh = t), this.Jn.uu(i.eu.Wh, e), e.iu;
68
+ if (null != e) return (e.Nl = s), (e.Gl = t), this.u.uu(i.eu.Dl, e), e.iu;
62
69
  }
63
- Xh() {
64
- const s = this.Jn.tu(i.eu.Wh);
70
+ kl() {
71
+ const s = this.u.tu(i.eu.Dl);
65
72
  null != s &&
66
- (this.Jn.Yh(i.eu.Wh), this.Jn.Qh(this.Gh(new Date().valueOf(), s)));
73
+ (this.u.ql(i.eu.Dl), this.u.Hl(this.jl(new Date().valueOf(), s)));
67
74
  }
68
75
  }
@@ -1,19 +1,22 @@
1
1
  import O, { STORAGE_KEYS as i } from "./storage-manager.js";
2
2
  import r from "../../shared-lib/braze-shared-lib.js";
3
3
  const Bt = {
4
- qo: (e, o) => {
4
+ $o: function(e, o = !1) {
5
5
  let t = !1;
6
6
  try {
7
7
  if (localStorage && localStorage.getItem)
8
8
  try {
9
- localStorage.setItem(i.k._a, !0),
10
- localStorage.getItem(i.k._a) &&
11
- (localStorage.removeItem(i.k._a), (t = !0));
9
+ localStorage.setItem(i.k.Ea, "true"),
10
+ localStorage.getItem(i.k.Ea) &&
11
+ (localStorage.removeItem(i.k.Ea), (t = !0));
12
12
  } catch (e) {
13
13
  if (
14
- ("QuotaExceededError" !== e.name &&
15
- "NS_ERROR_DOM_QUOTA_REACHED" !== e.name) ||
16
- !(localStorage.length > 0)
14
+ !(
15
+ e instanceof Error &&
16
+ ("QuotaExceededError" === e.name ||
17
+ "NS_ERROR_DOM_QUOTA_REACHED" === e.name) &&
18
+ localStorage.length > 0
19
+ )
17
20
  )
18
21
  throw e;
19
22
  t = !0;
@@ -21,15 +24,19 @@ const Bt = {
21
24
  } catch (e) {
22
25
  r.j.info("Local Storage not supported!");
23
26
  }
24
- const a = Bt.Oa(),
25
- l = new O.xa(e, a && !o, t);
26
- let c = null;
27
- return (c = t ? new O.Ma(e) : new O.Qa()), new O(l, c);
27
+ const a = Bt.wa(),
28
+ n = new O._a(e, a && !o, t);
29
+ let c;
30
+ return (c = t ? new O.Oa(e) : new O.xa()), new O(n, c);
28
31
  },
29
- Oa: () =>
30
- navigator.cookieEnabled ||
31
- ("cookie" in document &&
32
- (document.cookie.length > 0 ||
33
- (document.cookie = "test").indexOf.call(document.cookie, "test") > -1))
32
+ wa: function() {
33
+ return (
34
+ navigator.cookieEnabled ||
35
+ ("cookie" in document &&
36
+ (document.cookie.length > 0 ||
37
+ (document.cookie = "test").indexOf.call(document.cookie, "test") >
38
+ -1))
39
+ );
40
+ }
34
41
  };
35
42
  export default Bt;