@braze/web-sdk 4.8.3 → 4.9.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 (154) hide show
  1. package/index.d.ts +121 -6
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +7 -7
  4. package/shared-lib/encoding-utils.js +4 -4
  5. package/shared-lib/event-types.js +22 -21
  6. package/shared-lib/guid.js +7 -7
  7. package/shared-lib/indexed-db-adapter.js +172 -135
  8. package/shared-lib/logger.js +26 -26
  9. package/shared-lib/supported-options.js +15 -15
  10. package/shared-lib/types.js +1 -0
  11. package/src/Card/card-manager-factory.js +1 -1
  12. package/src/Card/card-manager.js +2 -2
  13. package/src/Card/display/card-display.js +5 -4
  14. package/src/Card/models/banner.js +10 -10
  15. package/src/Card/models/captioned-image.js +7 -7
  16. package/src/Card/models/card.js +37 -36
  17. package/src/Card/models/classic-card.js +7 -7
  18. package/src/Card/models/control-card.js +3 -3
  19. package/src/Card/models/image-only.js +32 -0
  20. package/src/Card/models/index.js +1 -0
  21. package/src/Card/util/card-factory.js +16 -16
  22. package/src/ContentCards/content-cards-provider-factory.js +1 -1
  23. package/src/ContentCards/content-cards-provider.js +102 -102
  24. package/src/ContentCards/get-cached-content-cards.js +1 -1
  25. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  26. package/src/ContentCards/subscribe-to-content-cards-updates.js +4 -4
  27. package/src/ContentCards/ui/show-content-cards.js +15 -12
  28. package/src/Core/add-sdk-metadata.js +2 -2
  29. package/src/Core/braze-sdk-metadata.js +1 -1
  30. package/src/Core/change-user.js +1 -1
  31. package/src/Core/device-properties.js +1 -1
  32. package/src/Core/disable-sdk.js +10 -7
  33. package/src/Core/enable-sdk.js +5 -2
  34. package/src/Core/get-device-id.js +3 -3
  35. package/src/Core/get-user.js +1 -1
  36. package/src/Core/handle-braze-action.js +14 -14
  37. package/src/Core/is-disabled.js +1 -1
  38. package/src/Core/log-custom-event.js +4 -4
  39. package/src/Core/log-purchase.js +9 -9
  40. package/src/Core/open-session.js +10 -10
  41. package/src/FeatureFlags/feature-flag-factory.js +5 -3
  42. package/src/FeatureFlags/feature-flag.js +17 -14
  43. package/src/FeatureFlags/feature-flags-provider-factory.js +1 -1
  44. package/src/FeatureFlags/feature-flags-provider.js +56 -43
  45. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  46. package/src/FeatureFlags/get-feature-flag.js +2 -2
  47. package/src/FeatureFlags/index.js +1 -0
  48. package/src/FeatureFlags/log-feature-flag-impression.js +23 -0
  49. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  50. package/src/Feed/feed-provider-factory.js +1 -1
  51. package/src/Feed/feed-provider.js +20 -20
  52. package/src/Feed/get-cached-feed.js +1 -1
  53. package/src/Feed/log-feed-displayed.js +1 -1
  54. package/src/Feed/request-feed-refresh.js +1 -1
  55. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  56. package/src/Feed/ui/show-feed.js +13 -10
  57. package/src/InAppMessage/defer-in-app-message.js +13 -0
  58. package/src/InAppMessage/display/get-animation-effect.js +1 -1
  59. package/src/InAppMessage/display/html-message-to-html.js +47 -47
  60. package/src/InAppMessage/display/in-app-message-to-html.js +92 -91
  61. package/src/InAppMessage/display/modal-utils.js +16 -16
  62. package/src/InAppMessage/get-deferred-in-app-message.js +5 -0
  63. package/src/InAppMessage/in-app-message-factory.js +77 -57
  64. package/src/InAppMessage/in-app-message-manager-factory.js +6 -6
  65. package/src/InAppMessage/in-app-message-manager.js +121 -82
  66. package/src/InAppMessage/index.js +2 -0
  67. package/src/InAppMessage/log-in-app-message-button-click.js +17 -9
  68. package/src/InAppMessage/log-in-app-message-click.js +4 -4
  69. package/src/InAppMessage/log-in-app-message-html-click.js +6 -6
  70. package/src/InAppMessage/log-in-app-message-impression.js +3 -3
  71. package/src/InAppMessage/models/full-screen-message.js +65 -29
  72. package/src/InAppMessage/models/html-message.js +32 -13
  73. package/src/InAppMessage/models/in-app-message-button.js +7 -7
  74. package/src/InAppMessage/models/in-app-message.js +203 -134
  75. package/src/InAppMessage/models/modal-message.js +64 -29
  76. package/src/InAppMessage/models/slide-up-message.js +52 -24
  77. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  78. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  79. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +6 -6
  80. package/src/InAppMessage/ui/show-in-app-message.js +49 -47
  81. package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
  82. package/src/Push/is-push-blocked.js +2 -2
  83. package/src/Push/is-push-permission-granted.js +2 -2
  84. package/src/Push/is-push-supported.js +2 -2
  85. package/src/Push/push-manager-factory.js +19 -19
  86. package/src/Push/push-manager.js +131 -131
  87. package/src/Push/request-push-permission.js +2 -2
  88. package/src/Push/unregister-push.js +2 -2
  89. package/src/Push/utils/push-utils.js +12 -10
  90. package/src/User/user-manager.js +4 -4
  91. package/src/User/user.js +57 -57
  92. package/src/common/base-feed.js +1 -1
  93. package/src/common/constants.js +1 -0
  94. package/src/common/event-logger.js +6 -6
  95. package/src/common/feed-display.js +34 -34
  96. package/src/common/translations.js +33 -33
  97. package/src/l10n/l10n-manager-factory.js +8 -8
  98. package/src/l10n/l10n-manager.js +6 -2
  99. package/src/l10n/types.js +1 -0
  100. package/src/managers/auth-manager.js +29 -29
  101. package/src/managers/braze-instance.js +125 -125
  102. package/src/managers/device-manager.js +20 -20
  103. package/src/managers/network-manager.js +100 -98
  104. package/src/managers/server-config-manager.js +23 -23
  105. package/src/managers/session-manager.js +5 -5
  106. package/src/managers/storage-manager-factory.js +9 -9
  107. package/src/managers/storage-manager.js +132 -129
  108. package/src/managers/subscription-manager.js +8 -8
  109. package/src/models/backend-errors.js +6 -6
  110. package/src/models/braze-event.js +11 -11
  111. package/src/models/braze-sdk-metadata.js +1 -1
  112. package/src/models/device.js +2 -2
  113. package/src/models/identifier.js +1 -1
  114. package/src/models/push-token.js +5 -5
  115. package/src/models/server-config.js +7 -7
  116. package/src/request-controller.js +191 -178
  117. package/src/triggers/models/custom-event-data.js +4 -4
  118. package/src/triggers/models/custom-event-property-data.js +7 -7
  119. package/src/triggers/models/filter-set.js +5 -5
  120. package/src/triggers/models/filter.js +64 -60
  121. package/src/triggers/models/in-app-message-click-data.js +9 -9
  122. package/src/triggers/models/purchase-data.js +4 -4
  123. package/src/triggers/models/purchase-property-data.js +6 -6
  124. package/src/triggers/models/push-click-data.js +6 -6
  125. package/src/triggers/models/trigger-condition.js +55 -59
  126. package/src/triggers/models/trigger-events.js +3 -3
  127. package/src/triggers/models/trigger.js +47 -35
  128. package/src/triggers/triggers-provider-factory.js +10 -6
  129. package/src/triggers/triggers-provider.js +203 -185
  130. package/src/triggers/types.js +1 -0
  131. package/src/ui/js/attach-css.js +5 -4
  132. package/src/ui/js/feed-css.js +5 -5
  133. package/src/ui/js/iam-css.js +5 -5
  134. package/src/ui/js/load-font-awesome.js +1 -1
  135. package/src/util/base-device-parser.js +1 -1
  136. package/src/util/braze-actions.js +35 -30
  137. package/src/util/browser-detector.js +30 -31
  138. package/src/util/client-hints-parser.js +30 -24
  139. package/src/util/code-utils.js +22 -21
  140. package/src/util/color-utils.js +19 -13
  141. package/src/util/component-utils.js +4 -4
  142. package/src/util/date-utils.js +4 -3
  143. package/src/util/device-constants.js +10 -10
  144. package/src/util/dom-utils.js +32 -28
  145. package/src/util/error-utils.js +1 -1
  146. package/src/util/key-codes.js +1 -1
  147. package/src/util/net.js +53 -57
  148. package/src/util/request-header-utils.js +34 -11
  149. package/src/util/string-utils.js +14 -14
  150. package/src/util/types.js +1 -0
  151. package/src/util/url-utils.js +1 -4
  152. package/src/util/user-agent-parser.js +39 -39
  153. package/src/util/validation-utils.js +32 -32
  154. package/src/util/window-utils.js +11 -12
@@ -3,13 +3,13 @@ import { BRAZE_MUST_BE_INITIALIZED_ERROR as P } from "../common/constants.js";
3
3
  import e from "../managers/braze-instance.js";
4
4
  import {
5
5
  BRAZE_ACTIONS as _,
6
- getDecodedBrazeAction as Q
6
+ getDecodedBrazeAction as Q,
7
7
  } from "../util/braze-actions.js";
8
8
  import V from "../util/browser-detector.js";
9
9
  import { OperatingSystems as W } from "../util/device-constants.js";
10
10
  import {
11
11
  BRAZE_ACTION_URI_REGEX as X,
12
- isValidBrazeActionJson as Y
12
+ isValidBrazeActionJson as Y,
13
13
  } from "../util/validation-utils.js";
14
14
  import { WindowUtils as Z } from "../util/window-utils.js";
15
15
  import { getUser as ee } from "./get-user.js";
@@ -18,20 +18,20 @@ export function _handleBrazeAction(o, s, t) {
18
18
  if (X.test(o)) {
19
19
  const s = Q(o);
20
20
  if (!s) return;
21
- const t = o => {
21
+ const t = (o) => {
22
22
  if (!Y(o))
23
23
  return void r.j.error(
24
24
  `Decoded Braze Action json is invalid: ${JSON.stringify(
25
25
  o,
26
26
  null,
27
- 2
28
- )}`
27
+ 2,
28
+ )}`,
29
29
  );
30
30
  const s = _.properties.type,
31
- i = _.properties.ce,
32
- n = _.properties.me,
31
+ i = _.properties.me,
32
+ n = _.properties.le,
33
33
  a = o[s];
34
- if (a === _.types.le) {
34
+ if (a === _.types.ue) {
35
35
  const e = o[i];
36
36
  for (const o of e) t(o);
37
37
  } else {
@@ -41,22 +41,22 @@ export function _handleBrazeAction(o, s, t) {
41
41
  case _.types.logCustomEvent:
42
42
  import("./log-custom-event.js").then(
43
43
  ({ logCustomEvent: logCustomEvent }) => {
44
- e.ue()
44
+ e.fe()
45
45
  ? ((i = Array.prototype.slice.call(s)),
46
46
  logCustomEvent(...i))
47
47
  : r.j.error(P);
48
- }
48
+ },
49
49
  );
50
50
  break;
51
51
  case _.types.requestPushPermission:
52
52
  import("../Push/request-push-permission.js").then(
53
53
  ({ requestPushPermission: requestPushPermission }) => {
54
- e.ue()
55
- ? "Safari" === V.browser && V.OS === W.fe
54
+ e.fe()
55
+ ? "Safari" === V.browser && V.OS === W.de
56
56
  ? window.navigator.standalone && requestPushPermission()
57
57
  : requestPushPermission()
58
58
  : r.j.error(P);
59
- }
59
+ },
60
60
  );
61
61
  break;
62
62
  case _.types.setEmailNotificationSubscriptionType:
@@ -70,8 +70,8 @@ export function _handleBrazeAction(o, s, t) {
70
70
  t[a](...Array.prototype.slice.call(s));
71
71
  }
72
72
  break;
73
- case _.types.de:
74
73
  case _.types.pe:
74
+ case _.types.je:
75
75
  (i = Array.prototype.slice.call(s)), Z.openUri(...i);
76
76
  break;
77
77
  default:
@@ -1,4 +1,4 @@
1
1
  import O, { STORAGE_KEYS as i } from "../managers/storage-manager.js";
2
2
  export function isDisabled() {
3
- return !!new O.ee(null, !0).wr(i.ne);
3
+ return !!new O.ee(null, !0).jr(i.re);
4
4
  }
@@ -5,7 +5,7 @@ import tt from "../triggers/models/trigger-events.js";
5
5
  import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
6
6
  import {
7
7
  validateCustomProperties as rt,
8
- validateCustomString as ot
8
+ validateCustomString as ot,
9
9
  } from "../util/validation-utils.js";
10
10
  import { LOG_CUSTOM_EVENT_STRING as nt } from "../common/constants.js";
11
11
  export function logCustomEvent(t, o) {
@@ -13,7 +13,7 @@ export function logCustomEvent(t, o) {
13
13
  if (null == t || t.length <= 0)
14
14
  return (
15
15
  r.j.error(
16
- `logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`
16
+ `logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`,
17
17
  ),
18
18
  !1
19
19
  );
@@ -23,7 +23,7 @@ export function logCustomEvent(t, o) {
23
23
  nt,
24
24
  "eventProperties",
25
25
  `log custom event "${t}"`,
26
- "event"
26
+ "event",
27
27
  );
28
28
  if (!n) return !1;
29
29
  const m = e.tr();
@@ -32,7 +32,7 @@ export function logCustomEvent(t, o) {
32
32
  const g = s.N(r.q.CustomEvent, { n: t, p: i });
33
33
  if (g.O) {
34
34
  r.j.info(`Logged custom event "${t}".`);
35
- for (const e of g.ve) et.er().je(tt.be, [t, o], e);
35
+ for (const e of g.ve) et.er().be(tt.$e, [t, o], e);
36
36
  }
37
37
  return g.O;
38
38
  }
@@ -5,7 +5,7 @@ import tt from "../triggers/models/trigger-events.js";
5
5
  import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
6
6
  import {
7
7
  validateCustomProperties as rt,
8
- validateCustomString as ot
8
+ validateCustomString as ot,
9
9
  } from "../util/validation-utils.js";
10
10
  import s from "../common/event-logger.js";
11
11
  export function logPurchase(o, i, n, t, D) {
@@ -15,7 +15,7 @@ export function logPurchase(o, i, n, t, D) {
15
15
  )
16
16
  return (
17
17
  r.j.error(
18
- `logPurchase requires a non-empty productId, got "${o}", ignoring.`
18
+ `logPurchase requires a non-empty productId, got "${o}", ignoring.`,
19
19
  ),
20
20
  !1
21
21
  );
@@ -28,7 +28,7 @@ export function logPurchase(o, i, n, t, D) {
28
28
  if (null == t || isNaN(parseInt(t.toString())))
29
29
  return (
30
30
  r.j.error(
31
- `logPurchase requires an integer quantity, got ${t}, ignoring.`
31
+ `logPurchase requires an integer quantity, got ${t}, ignoring.`,
32
32
  ),
33
33
  !1
34
34
  );
@@ -36,7 +36,7 @@ export function logPurchase(o, i, n, t, D) {
36
36
  if (u < 1 || u > rr)
37
37
  return (
38
38
  r.j.error(
39
- `logPurchase requires a quantity >1 and <${rr}, got ${u}, ignoring.`
39
+ `logPurchase requires a quantity >1 and <${rr}, got ${u}, ignoring.`,
40
40
  ),
41
41
  !1
42
42
  );
@@ -214,12 +214,12 @@ export function logPurchase(o, i, n, t, D) {
214
214
  "ZAR",
215
215
  "ZMK",
216
216
  "ZMW",
217
- "ZWL"
217
+ "ZWL",
218
218
  ].indexOf(n)
219
219
  )
220
220
  return (
221
221
  r.j.error(
222
- `logPurchase requires a valid currencyCode, got ${n}, ignoring.`
222
+ `logPurchase requires a valid currencyCode, got ${n}, ignoring.`,
223
223
  ),
224
224
  !1
225
225
  );
@@ -228,7 +228,7 @@ export function logPurchase(o, i, n, t, D) {
228
228
  "logPurchase",
229
229
  "purchaseProperties",
230
230
  `log purchase "${o}"`,
231
- "purchase"
231
+ "purchase",
232
232
  );
233
233
  if (!g) return !1;
234
234
  const R = e.tr();
@@ -237,9 +237,9 @@ export function logPurchase(o, i, n, t, D) {
237
237
  const c = s.N(r.q.Pr, { pid: o, c: n, p: a, q: u, pr: P });
238
238
  if (c.O) {
239
239
  r.j.info(
240
- `Logged ${u} purchase${u > 1 ? "s" : ""} of "${o}" for ${n} ${a}.`
240
+ `Logged ${u} purchase${u > 1 ? "s" : ""} of "${o}" for ${n} ${a}.`,
241
241
  );
242
- for (const r of c.ve) et.er().je(tt.Rr, [o, D], r);
242
+ for (const r of c.ve) et.er().be(tt.Rr, [o, D], r);
243
243
  }
244
244
  return c.O;
245
245
  }
@@ -9,17 +9,17 @@ export function openSession() {
9
9
  i.openSession();
10
10
  const t = r.zt.Ft,
11
11
  o = new r.xt(t, r.j);
12
- o.hr(t.Jt.kr, function(n, e) {
13
- const s = e.lastClick,
14
- c = e.trackingString;
15
- r.j.info(`Firing push click trigger from ${c} push click at ${s}`);
16
- const f = i.vr(s, c),
17
- g = function() {
18
- et.er().je(tt.zr, [c], f);
12
+ o.hr(t.Jt.kr, (e, s) => {
13
+ const n = s.lastClick,
14
+ c = s.trackingString;
15
+ r.j.info(`Firing push click trigger from ${c} push click at ${n}`);
16
+ const g = i.vr(n, c),
17
+ f = function () {
18
+ et.er().be(tt.zr, [c], g);
19
19
  };
20
- i.$r(g, g), o.br(t.Jt.kr, n);
20
+ i.$r(f, f), o.oe(t.Jt.kr, e);
21
21
  }),
22
- o.Mt(t.Jt.yr, function(r) {
23
- i.Fr(r);
22
+ o.Mt(t.Jt.wr, function (r) {
23
+ i.yr(r);
24
24
  });
25
25
  }
@@ -5,7 +5,8 @@ export function newFeatureFlagFromJson(e) {
5
5
  return new FeatureFlag(
6
6
  e[FeatureFlag.Tt.ns],
7
7
  e[FeatureFlag.Tt.Fe],
8
- e[FeatureFlag.Tt.we]
8
+ e[FeatureFlag.Tt.we],
9
+ e[FeatureFlag.Tt.ze],
9
10
  );
10
11
  r.j.info(`Unable to create feature flag from ${JSON.stringify(e, null, 2)}`);
11
12
  }
@@ -14,9 +15,10 @@ export function newFeatureFlagFromSerializedValue(e) {
14
15
  return new FeatureFlag(
15
16
  e[FeatureFlag.hs.ns],
16
17
  e[FeatureFlag.hs.Fe],
17
- e[FeatureFlag.hs.we]
18
+ e[FeatureFlag.hs.we],
19
+ e[FeatureFlag.hs.ze],
18
20
  );
19
21
  r.j.info(
20
- `Unable to deserialize feature flag from ${JSON.stringify(e, null, 2)}`
22
+ `Unable to deserialize feature flag from ${JSON.stringify(e, null, 2)}`,
21
23
  );
22
24
  }
@@ -1,36 +1,38 @@
1
1
  import r from "../../shared-lib/braze-shared-lib.js";
2
2
  export default class FeatureFlag {
3
- constructor(t, r = !1, e = {}) {
3
+ constructor(t, r = !1, e = {}, s) {
4
4
  (this.id = t),
5
5
  (this.enabled = r),
6
6
  (this.properties = e),
7
+ (this.trackingString = s),
7
8
  (this.id = t),
8
9
  (this.enabled = r),
9
- (this.properties = e);
10
+ (this.properties = e),
11
+ (this.trackingString = s);
10
12
  }
11
13
  getStringProperty(t) {
12
14
  const r = this.properties[t];
13
15
  return null == r
14
16
  ? (this.Er(t), null)
15
- : this.Br(r)
17
+ : this.Ir(r)
16
18
  ? r.value
17
- : (this.Ir("string"), null);
19
+ : (this.Nr("string"), null);
18
20
  }
19
21
  getNumberProperty(t) {
20
22
  const r = this.properties[t];
21
23
  return null == r
22
24
  ? (this.Er(t), null)
23
- : this.Nr(r)
25
+ : this.Tr(r)
24
26
  ? r.value
25
- : (this.Ir("number"), null);
27
+ : (this.Nr("number"), null);
26
28
  }
27
29
  getBooleanProperty(t) {
28
30
  const r = this.properties[t];
29
31
  return null == r
30
32
  ? (this.Er(t), null)
31
- : this.Tr(r)
33
+ : this.Ar(r)
32
34
  ? r.value
33
- : (this.Ir("boolean"), null);
35
+ : (this.Nr("boolean"), null);
34
36
  }
35
37
  ss() {
36
38
  const t = {};
@@ -38,24 +40,25 @@ export default class FeatureFlag {
38
40
  (t[FeatureFlag.hs.ns] = this.id),
39
41
  (t[FeatureFlag.hs.Fe] = this.enabled),
40
42
  (t[FeatureFlag.hs.we] = this.properties),
43
+ (t[FeatureFlag.hs.ze] = this.trackingString),
41
44
  t
42
45
  );
43
46
  }
44
- Ir(t) {
47
+ Nr(t) {
45
48
  r.j.info(`Property is not of type ${t}.`);
46
49
  }
47
50
  Er(t) {
48
51
  r.j.info(`${t} not found in feature flag properties.`);
49
52
  }
50
- Br(t) {
53
+ Ir(t) {
51
54
  return "string" === t.type && "string" == typeof t.value;
52
55
  }
53
- Nr(t) {
56
+ Tr(t) {
54
57
  return "number" === t.type && "number" == typeof t.value;
55
58
  }
56
- Tr(t) {
59
+ Ar(t) {
57
60
  return "boolean" === t.type && "boolean" == typeof t.value;
58
61
  }
59
62
  }
60
- (FeatureFlag.hs = { ns: "id", Fe: "e", we: "pr" }),
61
- (FeatureFlag.Tt = { ns: "id", Fe: "enabled", we: "properties" });
63
+ (FeatureFlag.hs = { ns: "id", Fe: "e", we: "pr", ze: "fts" }),
64
+ (FeatureFlag.Tt = { ns: "id", Fe: "enabled", we: "properties", ze: "fts" });
@@ -14,6 +14,6 @@ const ir = {
14
14
  },
15
15
  destroy: () => {
16
16
  (ir.provider = null), (ir.t = !1);
17
- }
17
+ },
18
18
  };
19
19
  export default ir;
@@ -7,7 +7,7 @@ import { randomInclusive as D } from "../util/math.js";
7
7
  import C from "../util/net.js";
8
8
  import {
9
9
  newFeatureFlagFromJson as st,
10
- newFeatureFlagFromSerializedValue as it
10
+ newFeatureFlagFromSerializedValue as it,
11
11
  } from "./feature-flag-factory.js";
12
12
  import T from "../util/request-header-utils.js";
13
13
  export default class er extends y {
@@ -16,31 +16,31 @@ export default class er extends y {
16
16
  (this.wt = t),
17
17
  (this.gt = s),
18
18
  (this.u = i),
19
- (this.mi = []),
20
- (this.pi = 0),
19
+ (this.pi = []),
20
+ (this.gi = 0),
21
21
  (this.wt = t),
22
22
  (this.gt = s),
23
23
  (this.u = i),
24
- (this.gi = null),
24
+ (this.Fi = null),
25
25
  (this.wi = new E()),
26
26
  (this.yi = 10),
27
- (this.Fi = null),
28
27
  (this.ji = null),
28
+ (this.bi = null),
29
29
  e.jt(this.wi);
30
30
  }
31
31
  Ts(t) {
32
- if ((!this.wt || this.wt.bi()) && null != t && t.feature_flags) {
33
- this.mi = [];
32
+ if ((!this.wt || this.wt.vi()) && null != t && t.feature_flags) {
33
+ this.pi = [];
34
34
  for (const s of t.feature_flags) {
35
35
  const t = st(s);
36
- t && this.mi.push(t);
36
+ t && this.pi.push(t);
37
37
  }
38
- (this.pi = new Date().getTime()), this.vi(), this.wi.Et(this.mi);
38
+ (this.gi = new Date().getTime()), this.Ti(), this.wi.Et(this.pi);
39
39
  }
40
40
  }
41
- Ti() {
41
+ Di() {
42
42
  let t = {};
43
- this.u && (t = this.u.v(i.k.Di));
43
+ this.u && (t = this.u.v(i.k.Ri));
44
44
  const s = {};
45
45
  for (const i in t) {
46
46
  const e = it(t[i]);
@@ -48,69 +48,82 @@ export default class er extends y {
48
48
  }
49
49
  return s;
50
50
  }
51
- hi(t) {
51
+ Ni() {
52
+ var t;
53
+ return (null === (t = this.u) || void 0 === t ? void 0 : t.v(i.k.qi)) || {};
54
+ }
55
+ xi(t) {
56
+ this.u && this.u.D(i.k.qi, t);
57
+ }
58
+ ri(t) {
52
59
  return this.wi.lt(t);
53
60
  }
54
61
  refreshFeatureFlags(t, s, i = !1, e = !0) {
55
- if (!this.Ri(i))
62
+ if (!this.zi(i))
56
63
  return (
57
- !this.gi &&
64
+ !this.Fi &&
58
65
  this.wt &&
59
- (this.gi = this.wt.Ni(() => {
66
+ (this.Fi = this.wt.Ci(() => {
60
67
  this.refreshFeatureFlags(t, s);
61
68
  })),
62
69
  void ("function" == typeof s && s())
63
70
  );
64
- if ((e && this.qi(), !this.gt)) return void ("function" == typeof s && s());
65
- const r = this.gt.Gs({}, !0),
66
- h = this.gt.Ks(r, T.Qs.xi);
71
+ if ((e && this.Ii(), !this.gt)) return void ("function" == typeof s && s());
72
+ const r = this.gt.Bs({}, !0),
73
+ h = this.gt.Hs(r, T.Os.Si);
67
74
  let o = !1;
68
- this.gt.Vs(r, () => {
75
+ this.gt.Qs(r, () => {
69
76
  this.gt
70
- ? (T.Xs(this.u, T.Qs.xi, new Date().valueOf()),
71
- C.Ys({
72
- url: `${this.gt.Zs()}/feature_flags/sync`,
77
+ ? (T.Ws(this.u, T.Os.Si, new Date().valueOf()),
78
+ C.Xs({
79
+ url: `${this.gt.Ys()}/feature_flags/sync`,
73
80
  headers: h,
74
81
  data: r,
75
- O: i => {
76
- if (!this.gt.ti(r, i, h))
82
+ O: (i) => {
83
+ if (!this.gt.Zs(r, i, h))
77
84
  return (o = !0), void ("function" == typeof s && s());
78
- this.gt.si(), this.Ts(i), (o = !1), "function" == typeof t && t();
85
+ this.gt.ti(),
86
+ this.Ts(i),
87
+ (o = !1),
88
+ T.si(this.u, T.Os.Si, 1),
89
+ "function" == typeof t && t();
79
90
  },
80
- error: t => {
91
+ error: (t) => {
81
92
  this.gt.ii(t, "retrieving feature flags"),
82
93
  (o = !0),
83
94
  "function" == typeof s && s();
84
95
  },
85
96
  ei: () => {
86
- if (e && o && !this.ji) {
87
- let e = this.Fi;
97
+ if (e && o && !this.bi) {
98
+ T.hi(this.u, T.Os.Si);
99
+ let e = this.ji;
88
100
  (null == e || e < 1e3 * this.yi) && (e = 1e3 * this.yi),
89
- this.zi(Math.min(3e5, D(1e3 * this.yi, 3 * e)), t, s, i);
101
+ this.$i(Math.min(3e5, D(1e3 * this.yi, 3 * e)), t, s, i);
90
102
  }
91
- }
103
+ },
92
104
  }))
93
105
  : "function" == typeof s && s();
94
106
  });
95
107
  }
96
- qi() {
97
- null != this.ji && (clearTimeout(this.ji), (this.ji = null));
108
+ Ii() {
109
+ null != this.bi && (clearTimeout(this.bi), (this.bi = null));
98
110
  }
99
- zi(t = 1e3 * this.yi, s, i, e = !1) {
100
- this.qi(),
101
- (this.ji = window.setTimeout(() => {
111
+ $i(t = 1e3 * this.yi, s, i, e = !1) {
112
+ this.Ii(),
113
+ (this.bi = window.setTimeout(() => {
102
114
  this.refreshFeatureFlags(s, i, e);
103
115
  }, t)),
104
- (this.Fi = t);
116
+ (this.ji = t);
105
117
  }
106
- Ri(t) {
118
+ zi(t) {
107
119
  if (!this.wt) return !1;
108
120
  if (!t) {
109
- const t = this.wt.Si();
121
+ const t = this.wt.Mi();
122
+ if (null == t) return !1;
110
123
  let s = !1;
111
124
  if (!isNaN(t)) {
112
125
  if (-1 === t) return r.j.info("Feature flag refreshes not allowed"), !1;
113
- s = new Date().getTime() >= (this.pi || 0) + 1e3 * t;
126
+ s = new Date().getTime() >= (this.gi || 0) + 1e3 * t;
114
127
  }
115
128
  if (!s)
116
129
  return (
@@ -118,15 +131,15 @@ export default class er extends y {
118
131
  !1
119
132
  );
120
133
  }
121
- return this.wt.bi();
134
+ return this.wt.vi();
122
135
  }
123
- vi() {
136
+ Ti() {
124
137
  if (!this.u) return;
125
138
  const t = {};
126
- for (const s of this.mi) {
139
+ for (const s of this.pi) {
127
140
  const i = s.ss();
128
141
  t[s.id] = i;
129
142
  }
130
- this.u.D(i.k.Di, t), this.u.D(i.k.$i, this.pi);
143
+ this.u.D(i.k.Ri, t), this.u.D(i.k.Ui, this.gi);
131
144
  }
132
145
  }
@@ -5,8 +5,8 @@ export function getAllFeatureFlags() {
5
5
  if (!e.rr()) return;
6
6
  const t = [],
7
7
  a = e.tr();
8
- if (a && !a.bi()) return r.j.info("Feature flags are not enabled."), t;
9
- const o = ir.er().Ti();
8
+ if (a && !a.vi()) return r.j.info("Feature flags are not enabled."), t;
9
+ const o = ir.er().Di();
10
10
  for (const r in o) t.push(o[r]);
11
11
  return t;
12
12
  }
@@ -5,8 +5,8 @@ import ir from "./feature-flags-provider-factory.js";
5
5
  export function getFeatureFlag(t) {
6
6
  if (!e.rr()) return;
7
7
  const a = e.tr();
8
- if (a && !a.bi())
8
+ if (a && !a.vi())
9
9
  return r.j.info("Feature flags are not enabled."), new FeatureFlag(t);
10
- const o = ir.er().Ti();
10
+ const o = ir.er().Di();
11
11
  return o[t] ? o[t] : new FeatureFlag(t);
12
12
  }
@@ -3,3 +3,4 @@ export { refreshFeatureFlags } from "./refresh-feature-flags.js";
3
3
  export { getFeatureFlag } from "./get-feature-flag.js";
4
4
  export { subscribeToFeatureFlagsUpdates } from "./subscribe-to-feature-flags-updates.js";
5
5
  export { getAllFeatureFlags } from "./get-all-feature-flags.js";
6
+ export { logFeatureFlagImpression } from "./log-feature-flag-impression.js";
@@ -0,0 +1,23 @@
1
+ import r from "../../shared-lib/braze-shared-lib.js";
2
+ import s from "../common/event-logger.js";
3
+ import e from "../managers/braze-instance.js";
4
+ import ir from "./feature-flags-provider-factory.js";
5
+ export function logFeatureFlagImpression(t) {
6
+ if (!e.rr()) return;
7
+ if (!t) return !1;
8
+ const o = ir.er().Di();
9
+ if (!o[t]) return !1;
10
+ const n = o[t].trackingString;
11
+ if (!n)
12
+ return (
13
+ r.j.info(
14
+ "Not logging a feature flag impression. The feature flag was not part of any matching campaign.",
15
+ ),
16
+ !1
17
+ );
18
+ const a = ir.er().Ni();
19
+ if (a[n]) return !1;
20
+ (a[n] = !0), ir.er().xi(a);
21
+ const i = { fid: t, fts: n };
22
+ return s.N(r.q.Fr, i).O;
23
+ }
@@ -5,5 +5,5 @@ export function subscribeToFeatureFlagsUpdates(r) {
5
5
  if (!e.rr()) return;
6
6
  const t = getAllFeatureFlags();
7
7
  t && "function" == typeof r && r(t);
8
- return ir.er().hi(r);
8
+ return ir.er().ri(r);
9
9
  }
@@ -13,6 +13,6 @@ const ie = {
13
13
  },
14
14
  destroy: () => {
15
15
  (ie.provider = null), (ie.t = !1);
16
- }
16
+ },
17
17
  };
18
18
  export default ie;