@braze/web-sdk 5.6.1 → 5.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 (137) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +15 -5
  3. package/package.json +1 -1
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +23 -23
  6. package/shared-lib/indexed-db-adapter.js +20 -20
  7. package/shared-lib/logger.js +2 -2
  8. package/shared-lib/supported-options.js +17 -17
  9. package/src/Banner/banner-provider.js +53 -50
  10. package/src/Banner/banner.js +1 -1
  11. package/src/Banner/get-all-banners.js +3 -4
  12. package/src/Banner/get-banner.js +11 -11
  13. package/src/Banner/log-banner-click.js +1 -1
  14. package/src/Banner/log-banner-impressions.js +4 -4
  15. package/src/Banner/request-banners-refresh.js +21 -13
  16. package/src/Banner/subscribe-to-banners-updates.js +14 -13
  17. package/src/Banner/ui/insert-banner.js +11 -9
  18. package/src/Card/card-manager.js +10 -10
  19. package/src/Card/log-card-impressions.js +2 -2
  20. package/src/Card/models/captioned-image.js +1 -1
  21. package/src/Card/models/card.js +3 -3
  22. package/src/Card/models/classic-card.js +1 -1
  23. package/src/Card/models/control-card.js +1 -1
  24. package/src/Card/models/image-only.js +1 -1
  25. package/src/ContentCards/content-cards-provider-factory.js +1 -1
  26. package/src/ContentCards/content-cards-provider.js +139 -180
  27. package/src/ContentCards/content-cards.js +3 -3
  28. package/src/ContentCards/get-cached-content-cards.js +1 -1
  29. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  30. package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
  31. package/src/ContentCards/ui/show-content-cards.js +8 -8
  32. package/src/Core/add-sdk-metadata.js +2 -2
  33. package/src/Core/change-user.js +3 -3
  34. package/src/Core/disable-sdk.js +7 -7
  35. package/src/Core/enable-sdk.js +5 -5
  36. package/src/Core/get-device-id.js +2 -2
  37. package/src/Core/get-user.js +1 -1
  38. package/src/Core/is-disabled.js +1 -1
  39. package/src/Core/log-custom-event.js +3 -3
  40. package/src/Core/log-purchase.js +1 -1
  41. package/src/Core/open-session.js +9 -9
  42. package/src/Core/wipe-data.js +5 -5
  43. package/src/FeatureFlags/feature-flag-factory.js +4 -4
  44. package/src/FeatureFlags/feature-flag.js +18 -18
  45. package/src/FeatureFlags/feature-flags-provider.js +81 -78
  46. package/src/FeatureFlags/get-all-feature-flags.js +6 -7
  47. package/src/FeatureFlags/get-feature-flag.js +5 -6
  48. package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
  49. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  50. package/src/Feed/feed-provider.js +34 -34
  51. package/src/Feed/feed.js +2 -2
  52. package/src/Feed/get-cached-feed.js +1 -1
  53. package/src/Feed/request-feed-refresh.js +1 -1
  54. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  55. package/src/Feed/ui/show-feed.js +5 -5
  56. package/src/InAppMessage/defer-in-app-message.js +1 -1
  57. package/src/InAppMessage/display/html-message-to-html.js +10 -10
  58. package/src/InAppMessage/display/in-app-message-to-html.js +21 -21
  59. package/src/InAppMessage/display/modal-utils.js +6 -6
  60. package/src/InAppMessage/in-app-message-factory.js +4 -4
  61. package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
  62. package/src/InAppMessage/in-app-message-manager.js +115 -91
  63. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  64. package/src/InAppMessage/log-in-app-message-click.js +3 -3
  65. package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
  66. package/src/InAppMessage/log-in-app-message-impression.js +2 -2
  67. package/src/InAppMessage/models/control-message.js +1 -1
  68. package/src/InAppMessage/models/full-screen-message.js +5 -5
  69. package/src/InAppMessage/models/html-message.js +10 -10
  70. package/src/InAppMessage/models/in-app-message-button.js +5 -5
  71. package/src/InAppMessage/models/in-app-message.js +42 -42
  72. package/src/InAppMessage/models/modal-message.js +5 -5
  73. package/src/InAppMessage/models/slide-up-message.js +8 -8
  74. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  75. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  76. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  77. package/src/InAppMessage/ui/show-in-app-message.js +24 -24
  78. package/src/Push/is-push-blocked.js +2 -2
  79. package/src/Push/is-push-permission-granted.js +2 -2
  80. package/src/Push/is-push-supported.js +2 -2
  81. package/src/Push/push-manager-factory.js +8 -8
  82. package/src/Push/push-manager.js +90 -90
  83. package/src/Push/utils/push-utils.js +12 -12
  84. package/src/User/user-manager.js +12 -12
  85. package/src/User/user.js +48 -36
  86. package/src/common/base-feed.js +3 -3
  87. package/src/common/constants.js +1 -1
  88. package/src/common/event-logger.js +4 -4
  89. package/src/common/feed-display.js +14 -14
  90. package/src/l10n/l10n-manager-factory.js +2 -2
  91. package/src/l10n/l10n-manager.js +1 -1
  92. package/src/managers/auth-manager.js +10 -10
  93. package/src/managers/braze-instance.js +128 -128
  94. package/src/managers/device-manager.js +18 -18
  95. package/src/managers/network-manager.js +184 -147
  96. package/src/managers/server-config-manager.js +63 -63
  97. package/src/managers/session-manager.js +27 -27
  98. package/src/managers/storage-manager-factory.js +10 -10
  99. package/src/managers/storage-manager.js +146 -146
  100. package/src/managers/subscription-manager.js +8 -8
  101. package/src/managers/utils.js +1 -1
  102. package/src/models/backend-errors.js +4 -4
  103. package/src/models/braze-event.js +8 -8
  104. package/src/models/device.js +2 -2
  105. package/src/models/identifier.js +12 -12
  106. package/src/models/push-token.js +8 -8
  107. package/src/models/server-config.js +31 -31
  108. package/src/request-controller.js +163 -151
  109. package/src/triggers/models/custom-event-data.js +5 -5
  110. package/src/triggers/models/custom-event-property-data.js +6 -6
  111. package/src/triggers/models/filter-set.js +8 -8
  112. package/src/triggers/models/filter.js +16 -16
  113. package/src/triggers/models/in-app-message-click-data.js +2 -2
  114. package/src/triggers/models/purchase-data.js +2 -2
  115. package/src/triggers/models/purchase-property-data.js +4 -4
  116. package/src/triggers/models/push-click-data.js +2 -2
  117. package/src/triggers/models/trigger-condition.js +37 -37
  118. package/src/triggers/models/trigger-events.js +2 -2
  119. package/src/triggers/models/trigger.js +11 -11
  120. package/src/triggers/triggers-provider-factory.js +3 -3
  121. package/src/triggers/triggers-provider.js +39 -39
  122. package/src/ui/js/attach-css.js +3 -3
  123. package/src/ui/js/iam-css.js +1 -1
  124. package/src/ui/js/load-font-awesome.js +2 -2
  125. package/src/util/base-device-parser.js +3 -3
  126. package/src/util/braze-actions.js +4 -4
  127. package/src/util/browser-detector.js +6 -6
  128. package/src/util/client-hints-parser.js +1 -1
  129. package/src/util/component-utils.js +2 -2
  130. package/src/util/dom-utils.js +6 -6
  131. package/src/util/html-display-utils.js +1 -0
  132. package/src/util/key-codes.js +1 -1
  133. package/src/util/net.js +22 -23
  134. package/src/util/request-header-utils.js +25 -22
  135. package/src/util/user-agent-parser.js +1 -1
  136. package/src/util/validation-utils.js +17 -17
  137. package/src/util/window-utils.js +2 -2
@@ -14,11 +14,11 @@ export default class ContentCards extends rr {
14
14
  logCardClick(r) {
15
15
  return logCardClick(r, !0);
16
16
  }
17
- dr() {
17
+ sr() {
18
18
  requestContentCardsRefresh();
19
19
  }
20
- ur() {
20
+ nr() {
21
21
  return !0;
22
22
  }
23
23
  }
24
- ContentCards.ar = 6e4;
24
+ ContentCards.dr = 6e4;
@@ -1,5 +1,5 @@
1
1
  import W from "./content-cards-provider-factory.js";
2
2
  import r from "../managers/braze-instance.js";
3
3
  export function getCachedContentCards() {
4
- if (r.rr()) return W.m().ki(!1);
4
+ if (r.rr()) return W.m().Ri(!1);
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import r from "../managers/braze-instance.js";
2
2
  import W from "./content-cards-provider-factory.js";
3
3
  export function requestContentCardsRefresh(e, t) {
4
- if (r.rr()) return W.m().zi(e, t);
4
+ if (r.rr()) return W.m().Di(e, t, !0);
5
5
  }
@@ -1,17 +1,17 @@
1
1
  import r from "../managers/braze-instance.js";
2
2
  import W from "./content-cards-provider-factory.js";
3
- export function subscribeToContentCardsUpdates(t) {
3
+ export function subscribeToContentCardsUpdates(o) {
4
4
  if (!r.rr()) return;
5
- const n = W.m(),
6
- o = n.Fs(t);
7
- if (!n.Ts()) {
8
- const t = r.nn();
9
- if (t) {
10
- const r = t.rn(() => {
11
- n.zi();
5
+ const t = W.m(),
6
+ n = t.qs(o);
7
+ if (!t.Cs()) {
8
+ const o = r.nn();
9
+ if (o) {
10
+ const r = o.rn(() => {
11
+ t.Di(void 0, void 0, !0);
12
12
  });
13
- r && n.Rs(r);
13
+ r && t.Ts(r);
14
14
  }
15
15
  }
16
- return o;
16
+ return n;
17
17
  }
@@ -1,4 +1,4 @@
1
- import r, { OPTIONS as z } from "../../managers/braze-instance.js";
1
+ import r, { OPTIONS as w } from "../../managers/braze-instance.js";
2
2
  import { ContentCards, subscribeToContentCardsUpdates } from "../index.js";
3
3
  import W from "../content-cards-provider-factory.js";
4
4
  import {
@@ -18,20 +18,20 @@ export function showContentCards(n, t) {
18
18
  fn();
19
19
  let e = !1;
20
20
  null == n && ((n = document.body), (e = !0));
21
- const o = r.sr(z.tn) || r.sr(z.en) || !1,
22
- i = W.m().ki(!1);
21
+ const o = r.ee(w.tn) || r.ee(w.en) || !1,
22
+ i = W.m().Ri(!1);
23
23
  "function" == typeof t && an(i, t(i.cards.slice()), i.lastUpdated, null, o);
24
24
  const a = tn(i, o, e),
25
25
  s = W.m(),
26
- f = s.pi();
26
+ f = s.Zs();
27
27
  (null == i.lastUpdated ||
28
- new Date().valueOf() - i.lastUpdated.valueOf() > ContentCards.ar) &&
29
- (null == f || new Date().valueOf() - f > ContentCards.ar) &&
28
+ new Date().valueOf() - i.lastUpdated.valueOf() > ContentCards.dr) &&
29
+ (null == f || new Date().valueOf() - f > ContentCards.dr) &&
30
30
  (N.info(
31
- `Cached content cards were older than max TTL of ${ContentCards.ar} ms, requesting an update from the server.`,
31
+ `Cached content cards were older than max TTL of ${ContentCards.dr} ms, requesting an update from the server.`,
32
32
  ),
33
33
  on(i, a),
34
- s.vi(new Date().valueOf()));
34
+ s.fi(new Date().valueOf()));
35
35
  const l = new Date().valueOf(),
36
36
  c = subscribeToContentCardsUpdates(function (n) {
37
37
  const e = a.querySelectorAll(".ab-refresh-button")[0];
@@ -1,7 +1,7 @@
1
1
  import aa from "../managers/braze-instance.js";
2
2
  import BrazeSdkMetadata from "./braze-sdk-metadata.js";
3
3
  import {
4
- isArray as w,
4
+ isArray as z,
5
5
  validateValueIsFromEnum as ta,
6
6
  } from "../util/code-utils.js";
7
7
  import { logger as N } from "../../shared-lib/index.js";
@@ -9,7 +9,7 @@ export function addSdkMetadata(a) {
9
9
  if (!aa.rr()) return;
10
10
  const t = aa.g();
11
11
  if (t) {
12
- if (!w(a))
12
+ if (!z(a))
13
13
  return (
14
14
  N.error("Cannot set SDK metadata because metadata is not an array."), !1
15
15
  );
@@ -7,11 +7,11 @@ export function changeUser(e, i) {
7
7
  if (!r.rr()) return;
8
8
  if (null == e || 0 === e.length || e != e)
9
9
  return void N.error("changeUser requires a non-empty userId.");
10
- if (er(e) > User.mr)
10
+ if (er(e) > User.ur)
11
11
  return void N.error(
12
- `Rejected user id "${e}" because it is longer than ${User.mr} bytes.`,
12
+ `Rejected user id "${e}" because it is longer than ${User.ur} bytes.`,
13
13
  );
14
14
  if (null != i && !ir(i, "set signature for new user", "signature")) return;
15
15
  const t = r.nn();
16
- t && t.changeUser(e.toString(), r.lr(), i);
16
+ t && t.changeUser(e.toString(), r.ar(), i);
17
17
  }
@@ -1,15 +1,15 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import { logger as N, IndexedDBAdapter as it } from "../../shared-lib/index.js";
2
+ import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
3
3
  import ne, { STORAGE_KEYS as t } from "../managers/storage-manager.js";
4
4
  export function disableSDK() {
5
5
  const e = r.nn();
6
6
  e && e.requestImmediateDataFlush();
7
- const n = new ne.ne(null, !0),
8
- s = "This-cookie-will-expire-in-" + n.se();
9
- n.store(t.ae, s);
10
- const a = it.Gs._s;
11
- new it(a, N).setItem(a.Os.ie, a.oe, !0),
7
+ const n = new ne.se(null, !0),
8
+ s = "This-cookie-will-expire-in-" + n.ae();
9
+ n.store(t.ie, s);
10
+ const a = tt._s.Xs;
11
+ new tt(a, N).setItem(a.Ks.oe, a.te, !0),
12
12
  N.info("disableSDK was called"),
13
13
  r.destroy(!1),
14
- r.re(!0);
14
+ r.le(!0);
15
15
  }
@@ -1,11 +1,11 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import { logger as N, IndexedDBAdapter as it } from "../../shared-lib/index.js";
2
+ import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
3
3
  import ne, { STORAGE_KEYS as t } from "../managers/storage-manager.js";
4
4
  export function enableSDK() {
5
- new ne.ne(null, !0).remove(t.ae);
6
- const e = it.Gs._s;
7
- new it(e, N).me(e.Os.ie, e.oe),
5
+ new ne.se(null, !0).remove(t.ie);
6
+ const e = tt._s.Xs;
7
+ new tt(e, N).me(e.Ks.oe, e.te),
8
8
  N.info("enableSDK was called"),
9
9
  r.destroy(!1),
10
- r.re(!1);
10
+ r.le(!1);
11
11
  }
@@ -2,9 +2,9 @@ import r from "../managers/braze-instance.js";
2
2
  import { logger as N } from "../../shared-lib/index.js";
3
3
  export function getDeviceId(e) {
4
4
  if (!r.rr()) return;
5
- const t = r.te();
5
+ const t = r.ce();
6
6
  if (!t) return;
7
- const i = t.ce().id;
7
+ const i = t.de().id;
8
8
  if ("function" != typeof e) return i;
9
9
  N.warn(
10
10
  "The callback for getDeviceId is deprecated. You can access its return value directly instead (e.g. `const id = braze.getDeviceId()`)",
@@ -1,4 +1,4 @@
1
1
  import r from "../managers/braze-instance.js";
2
2
  export function getUser() {
3
- if (r.rr()) return r.cr();
3
+ if (r.rr()) return r.mr();
4
4
  }
@@ -1,4 +1,4 @@
1
1
  import ne, { STORAGE_KEYS as t } from "../managers/storage-manager.js";
2
2
  export function isDisabled() {
3
- return !!new ne.ne(null, !0).gr(t.ae);
3
+ return !!new ne.se(null, !0).gr(t.ie);
4
4
  }
@@ -7,7 +7,7 @@ import {
7
7
  validateCustomProperties as rt,
8
8
  validateCustomString as nt,
9
9
  } from "../util/validation-utils.js";
10
- import { LOG_CUSTOM_EVENT_STRING as mt } from "../common/constants.js";
10
+ import { LOG_CUSTOM_EVENT_STRING as it } from "../common/constants.js";
11
11
  export function logCustomEvent(t, e) {
12
12
  if (!r.rr()) return !1;
13
13
  if (null == t || t.length <= 0)
@@ -20,7 +20,7 @@ export function logCustomEvent(t, e) {
20
20
  if (!nt(t, "log custom event", "the event name")) return !1;
21
21
  const [o, n] = rt(
22
22
  e,
23
- mt,
23
+ it,
24
24
  "eventProperties",
25
25
  `log custom event "${t}"`,
26
26
  "event",
@@ -29,7 +29,7 @@ export function logCustomEvent(t, e) {
29
29
  const i = r.v();
30
30
  if (i && i.ge(t))
31
31
  return N.info(`Custom Event "${t}" is blocklisted, ignoring.`), !1;
32
- const s = c.ds(d.CustomEvent, { n: t, p: n });
32
+ const s = c.cs(d.CustomEvent, { n: t, p: n });
33
33
  if (s.ss) {
34
34
  N.info(`Logged custom event "${t}".`);
35
35
  for (const o of s.fe) ot.m().ue(et.ve, [t, e], o);
@@ -230,7 +230,7 @@ export function logPurchase(e, o, i, n, t) {
230
230
  const g = r.v();
231
231
  if (g && g.Dr(e))
232
232
  return N.info(`Purchase "${e}" is blocklisted, ignoring.`), !1;
233
- const P = c.ds(d.Pr, { pid: e, c: i, p: s, q: D, pr: a });
233
+ const P = c.cs(d.Pr, { pid: e, c: i, p: s, q: D, pr: a });
234
234
  if (P.ss) {
235
235
  N.info(`Logged ${D} purchase${D > 1 ? "s" : ""} of "${e}" for ${i} ${s}.`);
236
236
  for (const r of P.fe) ot.m().ue(et.Rr, [e, t], r);
@@ -1,5 +1,5 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import { logger as N, IndexedDBAdapter as it } from "../../shared-lib/index.js";
2
+ import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
3
3
  import et from "../triggers/models/trigger-events.js";
4
4
  import { TriggersProviderFactory as ot } from "../triggers/triggers-provider-factory.js";
5
5
  export function openSession() {
@@ -7,19 +7,19 @@ export function openSession() {
7
7
  const i = r.nn();
8
8
  if (!i) return;
9
9
  i.openSession();
10
- const t = it.Gs._s,
11
- o = new it(t, N);
12
- o.jr(t.Os.hr, (r, n) => {
10
+ const t = tt._s.Xs,
11
+ o = new tt(t, N);
12
+ o.cr(t.Ks.jr, (r, n) => {
13
13
  const e = n.lastClick,
14
14
  s = n.trackingString;
15
15
  N.info(`Firing push click trigger from ${s} push click at ${e}`);
16
- const c = i.br(e, s),
16
+ const c = i.lr(e, s),
17
17
  g = function () {
18
- ot.m().ue(et.kr, [s], c);
18
+ ot.m().ue(et.hr, [s], c);
19
19
  };
20
- i.vr(g, g), o.me(t.Os.hr, r);
20
+ i.br(g, g), o.me(t.Ks.jr, r);
21
21
  }),
22
- o.Hs(t.Os.$r, function (r) {
23
- i.wr(r);
22
+ o.Gs(t.Ks.kr, function (r) {
23
+ i.vr(r);
24
24
  });
25
25
  }
@@ -1,16 +1,16 @@
1
1
  import r from "../managers/braze-instance.js";
2
2
  import { keys as y } from "../util/code-utils.js";
3
- import { logger as N, IndexedDBAdapter as it } from "../../shared-lib/index.js";
3
+ import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
4
4
  import { BRAZE_MUST_BE_INITIALIZED_ERROR as p } from "../common/constants.js";
5
5
  export function wipeData() {
6
6
  const o = r.j();
7
7
  if (null == o) return void N.warn(p);
8
8
  o.clearData();
9
- const t = y(it.Gs);
9
+ const t = y(tt._s);
10
10
  for (let o = 0; o < t.length; o++) {
11
11
  const n = t[o],
12
- r = it.Gs[n];
13
- new it(r, N).clearData();
12
+ r = tt._s[n];
13
+ new tt(r, N).clearData();
14
14
  }
15
- if (r.rr()) for (const o of r.lr()) o.clearData(!0);
15
+ if (r.rr()) for (const o of r.ar()) o.clearData(!0);
16
16
  }
@@ -1,22 +1,22 @@
1
1
  import { logger as N } from "../../shared-lib/index.js";
2
2
  import FeatureFlag from "./feature-flag.js";
3
3
  export function newFeatureFlagFromJson(e) {
4
- if (e[FeatureFlag.li.Et] && "boolean" == typeof e[FeatureFlag.li.le])
4
+ if (e[FeatureFlag.li.Et] && "boolean" == typeof e[FeatureFlag.li.pe])
5
5
  return new FeatureFlag(
6
6
  e[FeatureFlag.li.Et],
7
- e[FeatureFlag.li.le],
8
7
  e[FeatureFlag.li.pe],
9
8
  e[FeatureFlag.li.Fe],
9
+ e[FeatureFlag.li.be],
10
10
  );
11
11
  N.info(`Unable to create feature flag from ${JSON.stringify(e, null, 2)}`);
12
12
  }
13
13
  export function newFeatureFlagFromSerializedValue(e) {
14
- if (e[FeatureFlag.qt.Et] && "boolean" == typeof e[FeatureFlag.qt.le])
14
+ if (e[FeatureFlag.qt.Et] && "boolean" == typeof e[FeatureFlag.qt.pe])
15
15
  return new FeatureFlag(
16
16
  e[FeatureFlag.qt.Et],
17
- e[FeatureFlag.qt.le],
18
17
  e[FeatureFlag.qt.pe],
19
18
  e[FeatureFlag.qt.Fe],
19
+ e[FeatureFlag.qt.be],
20
20
  );
21
21
  N.info(
22
22
  `Unable to deserialize feature flag from ${JSON.stringify(e, null, 2)}`,
@@ -15,30 +15,30 @@ export default class FeatureFlag {
15
15
  return null == i ? (this.ye(t), null) : e(i) ? i.value : (this.Pe(r), null);
16
16
  }
17
17
  getStringProperty(t) {
18
- return this.he(t, this.be, "string");
18
+ return this.he(t, this.Ie, "string");
19
19
  }
20
20
  getNumberProperty(t) {
21
- return this.he(t, this.Ie, "number");
21
+ return this.he(t, this.Te, "number");
22
22
  }
23
23
  getBooleanProperty(t) {
24
- return this.he(t, this.de, "boolean");
24
+ return this.he(t, this.Ee, "boolean");
25
25
  }
26
26
  getImageProperty(t) {
27
- return this.he(t, this.Te, "image");
27
+ return this.he(t, this.Ne, "image");
28
28
  }
29
29
  getJsonProperty(t) {
30
- return this.he(t, this.Ee, "jsonobject");
30
+ return this.he(t, this.Re, "jsonobject");
31
31
  }
32
32
  getTimestampProperty(t) {
33
- return this.he(t, this.Ne, "datetime");
33
+ return this.he(t, this.je, "datetime");
34
34
  }
35
- Bs() {
35
+ bs() {
36
36
  const t = {};
37
37
  return (
38
38
  (t[FeatureFlag.qt.Et] = this.id),
39
- (t[FeatureFlag.qt.le] = this.enabled),
40
- (t[FeatureFlag.qt.pe] = this.properties),
41
- (t[FeatureFlag.qt.Fe] = this.trackingString),
39
+ (t[FeatureFlag.qt.pe] = this.enabled),
40
+ (t[FeatureFlag.qt.Fe] = this.properties),
41
+ (t[FeatureFlag.qt.be] = this.trackingString),
42
42
  t
43
43
  );
44
44
  }
@@ -48,28 +48,28 @@ export default class FeatureFlag {
48
48
  ye(t) {
49
49
  N.info(`${t} not found in feature flag properties.`);
50
50
  }
51
- be(t) {
51
+ Ie(t) {
52
52
  return "string" === t.type && "string" == typeof t.value;
53
53
  }
54
- Ie(t) {
54
+ Te(t) {
55
55
  return "number" === t.type && "number" == typeof t.value;
56
56
  }
57
- de(t) {
57
+ Ee(t) {
58
58
  return "boolean" === t.type && "boolean" == typeof t.value;
59
59
  }
60
- Te(t) {
60
+ Ne(t) {
61
61
  return "image" === t.type && "string" == typeof t.value;
62
62
  }
63
- Ee(t) {
63
+ Re(t) {
64
64
  return (
65
65
  "jsonobject" === t.type &&
66
66
  "object" == typeof t.value &&
67
67
  t.value.constructor == Object
68
68
  );
69
69
  }
70
- Ne(t) {
70
+ je(t) {
71
71
  return "datetime" === t.type && "number" == typeof t.value;
72
72
  }
73
73
  }
74
- (FeatureFlag.qt = { Et: "id", le: "e", pe: "pr", Fe: "fts" }),
75
- (FeatureFlag.li = { Et: "id", le: "enabled", pe: "properties", Fe: "fts" });
74
+ (FeatureFlag.qt = { Et: "id", pe: "e", Fe: "pr", be: "fts" }),
75
+ (FeatureFlag.li = { Et: "id", pe: "enabled", Fe: "properties", be: "fts" });
@@ -6,174 +6,177 @@ import u from "../managers/subscription-manager.js";
6
6
  import { randomInclusive as a } from "../util/math.js";
7
7
  import l from "../util/net.js";
8
8
  import {
9
- newFeatureFlagFromJson as ht,
10
- newFeatureFlagFromSerializedValue as at,
9
+ newFeatureFlagFromJson as st,
10
+ newFeatureFlagFromSerializedValue as ht,
11
11
  } from "./feature-flag-factory.js";
12
12
  import h from "../util/request-header-utils.js";
13
13
  export default class tr extends s {
14
- constructor(t, s, i, e) {
14
+ constructor(t, s, e, i) {
15
15
  super(),
16
16
  (this.B = t),
17
17
  (this.S = s),
18
- (this.C = i),
19
- (this.T = e),
20
- (this.Gi = []),
21
- (this.Hi = 0),
18
+ (this.C = e),
19
+ (this.T = i),
20
+ (this.we = []),
21
+ (this.Ce = 0),
22
22
  (this.B = t),
23
23
  (this.S = s),
24
- (this.C = i),
25
- (this.T = e),
26
- (this.Ki = null),
27
- (this.Oi = new u()),
24
+ (this.C = e),
25
+ (this.T = i),
26
+ (this.De = null),
27
+ (this.Se = new u()),
28
28
  (this.R = 10),
29
29
  (this.I = null),
30
30
  (this.q = null),
31
- r.N(this.Oi);
31
+ r.N(this.Se);
32
32
  }
33
33
  U(t) {
34
34
  var s;
35
35
  if (
36
- (null === (s = this.B) || void 0 === s ? void 0 : s.Qi()) &&
36
+ (null === (s = this.B) || void 0 === s ? void 0 : s.qe()) &&
37
37
  null != t &&
38
38
  t.feature_flags
39
39
  ) {
40
- this.Gi = [];
40
+ this.we = [];
41
41
  for (const s of t.feature_flags) {
42
- const t = ht(s);
43
- t && this.Gi.push(t);
42
+ const t = st(s);
43
+ t && this.we.push(t);
44
44
  }
45
- (this.Hi = new Date().getTime()), this.Vi(), this.Oi.X(this.Gi);
45
+ (this.Ce = new Date().getTime()), this.xe(), this.Se.X(this.we);
46
46
  }
47
47
  }
48
- Wi() {
48
+ ze() {
49
49
  let s = {};
50
- this.C && (s = this.C.ps(t.bs.Yi));
51
- const i = {};
50
+ this.C && (s = this.C.vs(t.gs.$e));
51
+ const e = {};
52
52
  for (const t in s) {
53
- const e = at(s[t]);
54
- e && (i[e.id] = e);
53
+ const i = ht(s[t]);
54
+ i && (e[i.id] = i);
55
55
  }
56
- return i;
56
+ return e;
57
57
  }
58
- Zi() {
58
+ ke() {
59
59
  var s;
60
60
  return (
61
- (null === (s = this.C) || void 0 === s ? void 0 : s.ps(t.bs.we)) || {}
61
+ (null === (s = this.C) || void 0 === s ? void 0 : s.vs(t.gs.Be)) || {}
62
62
  );
63
63
  }
64
- je(s) {
65
- this.C && this.C.js(t.bs.we, s);
64
+ Me(s) {
65
+ this.C && this.C.Bs(t.gs.Be, s);
66
66
  }
67
- Fs(t) {
68
- return this.Oi.Ns(t);
67
+ qs(t) {
68
+ return this.Se.Fs(t);
69
69
  }
70
- refreshFeatureFlags(t, s, i = !1, e = !0) {
70
+ refreshFeatureFlags(t, s, e = !1, i = !0) {
71
71
  const r = () => {
72
- "function" == typeof s && s(), this.Oi.X(this.Gi);
72
+ "function" == typeof s && s(), this.Se.X(this.we);
73
73
  };
74
- if (!this.Ce(i))
74
+ if (!this.Ue(e))
75
75
  return (
76
- !this.Ki &&
76
+ !this.De &&
77
77
  this.B &&
78
- (this.Ki = this.B.Re(() => {
78
+ (this.De = this.B.Xe(() => {
79
79
  this.refreshFeatureFlags(t, s);
80
80
  })),
81
81
  void r()
82
82
  );
83
83
  const o = this.S;
84
84
  if (!o) return void r();
85
- e && this.G();
85
+ i && this.G();
86
86
  const n = o.H({}, !0),
87
- u = o.J(n, h.O.De);
87
+ u = o.J(n, h.O._e);
88
88
  let f = !1;
89
89
  o.V(
90
90
  n,
91
- (o = -1) => {
92
- if (!this.S) return void r();
91
+ (i = -1) => {
92
+ const o = this.S;
93
+ if (!o) return void r();
93
94
  const c = new Date().valueOf();
94
- h.W(this.C, h.O.De, c),
95
- -1 !== o && u.push(["X-Braze-Req-Tokens-Remaining", o.toString()]),
95
+ h.W(this.C, h.O._e, c),
96
+ -1 !== i && u.push(["X-Braze-Req-Tokens-Remaining", i.toString()]),
96
97
  l.Y({
97
- url: `${this.S.Z()}/feature_flags/sync`,
98
+ url: `${o.Z()}/feature_flags/sync`,
98
99
  headers: u,
99
100
  data: n,
100
101
  ss: (s) => {
101
- if (!this.S.ts(n, s, u)) return (f = !0), void r();
102
- this.S.es(),
103
- this.U(s),
104
- (f = !1),
105
- h.ns(this.C, h.O.De, 1),
106
- "function" == typeof t && t();
102
+ if (!o.ts(n, s, u)) return (f = !0), void r();
103
+ o.es(), this.U(s), (f = !1), "function" == typeof t && t();
107
104
  },
108
105
  error: (t) => {
109
- this.S.rs(t, "retrieving feature flags"), (f = !0), r();
106
+ o.ns(t, "retrieving feature flags"), (f = !0), r();
110
107
  },
111
- os: () => {
112
- if (e && f && !this.q) {
113
- h.hs(this.C, h.O.De);
114
- let e = this.I;
115
- (null == e || e < 1e3 * this.R) && (e = 1e3 * this.R),
116
- this.ls(Math.min(3e5, a(1e3 * this.R, 3 * e)), t, s, i);
108
+ rs: (i, r) => {
109
+ let n;
110
+ if (f) {
111
+ let t = this.I;
112
+ (null == t || t < 1e3 * this.R) && (t = 1e3 * this.R),
113
+ (n = Math.min(3e5, a(1e3 * this.R, 3 * t)));
117
114
  }
115
+ o.os(
116
+ r,
117
+ () => {
118
+ this.refreshFeatureFlags(t, s, e, !0);
119
+ },
120
+ h.O._e,
121
+ (t) => this.hs(t),
122
+ () => this.G(),
123
+ n,
124
+ );
118
125
  },
119
126
  });
120
127
  },
121
- h.O.De,
128
+ h.O._e,
122
129
  s,
123
130
  );
124
131
  }
125
132
  G() {
126
133
  null != this.q && (clearTimeout(this.q), (this.q = null));
127
134
  }
128
- ls(t = 1e3 * this.R, s, i, e = !1) {
129
- this.G(),
130
- (this.q = window.setTimeout(() => {
131
- this.refreshFeatureFlags(s, i, e);
132
- }, t)),
133
- (this.I = t);
135
+ hs(t) {
136
+ this.G(), (this.q = t);
134
137
  }
135
- Ce(t) {
138
+ Ue(t) {
136
139
  if (!this.B) return !1;
137
140
  if (!t) {
138
- const t = this.B.Se();
141
+ const t = this.B.Ae();
139
142
  if (null == t) return !1;
140
143
  let s = !1;
141
144
  if (!isNaN(t)) {
142
145
  if (-1 === t) return N.info("Feature flag refreshes not allowed"), !1;
143
- s = new Date().getTime() >= (this.Hi || 0) + 1e3 * t;
146
+ s = new Date().getTime() >= (this.Ce || 0) + 1e3 * t;
144
147
  }
145
148
  if (!s)
146
149
  return (
147
150
  N.info(`Feature flag refreshes were rate limited to ${t} seconds`), !1
148
151
  );
149
152
  }
150
- return this.B.Qi();
153
+ return this.B.qe();
151
154
  }
152
- qe() {
155
+ Ge() {
153
156
  var s;
154
157
  return (
155
- (null === (s = this.C) || void 0 === s ? void 0 : s.ps(t.bs.xe)) || null
158
+ (null === (s = this.C) || void 0 === s ? void 0 : s.vs(t.gs.He)) || null
156
159
  );
157
160
  }
158
- ze() {
159
- var s, i;
161
+ Je() {
162
+ var s, e;
160
163
  null === (s = this.C) ||
161
164
  void 0 === s ||
162
- s.js(t.bs.xe, null === (i = this.T) || void 0 === i ? void 0 : i.Ss());
165
+ s.Bs(t.gs.He, null === (e = this.T) || void 0 === e ? void 0 : e.Ss());
163
166
  }
164
- $e() {
167
+ Ke() {
165
168
  var t;
166
169
  const s = null === (t = this.T) || void 0 === t ? void 0 : t.Ss(),
167
- i = this.qe();
168
- return null == i || s === i;
170
+ e = this.Ge();
171
+ return null == e || s === e;
169
172
  }
170
- Vi() {
173
+ xe() {
171
174
  if (!this.C) return;
172
175
  const s = {};
173
- for (const t of this.Gi) {
174
- const i = t.Bs();
175
- s[t.id] = i;
176
+ for (const t of this.we) {
177
+ const e = t.bs();
178
+ s[t.id] = e;
176
179
  }
177
- this.C.js(t.bs.Yi, s), this.C.js(t.bs.ke, this.Hi), this.ze();
180
+ this.C.Bs(t.gs.$e, s), this.C.Bs(t.gs.Le, this.Ce), this.Je();
178
181
  }
179
182
  }