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