@braze/web-sdk 4.7.2 → 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 (164) hide show
  1. package/index.d.ts +32 -26
  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 +25 -25
  6. package/shared-lib/guid.js +3 -3
  7. package/shared-lib/indexed-db-adapter.js +74 -74
  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 +48 -42
  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 +36 -34
  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 +8 -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 +41 -37
  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 +130 -110
  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 +193 -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 +95 -85
  109. package/src/common/types.js +1 -0
  110. package/src/l10n/l10n-manager-factory.js +10 -10
  111. package/src/l10n/l10n-manager.js +1 -1
  112. package/src/managers/auth-manager.js +37 -34
  113. package/src/managers/braze-instance.js +209 -193
  114. package/src/managers/device-manager.js +43 -38
  115. package/src/managers/network-manager.js +119 -96
  116. package/src/managers/server-config-manager.js +68 -48
  117. package/src/managers/session-manager.js +52 -45
  118. package/src/managers/storage-manager-factory.js +29 -22
  119. package/src/managers/storage-manager.js +288 -273
  120. package/src/managers/subscription-manager.js +9 -6
  121. package/src/managers/types.js +1 -0
  122. package/src/models/backend-errors.js +5 -5
  123. package/src/models/braze-event.js +14 -8
  124. package/src/models/device.js +10 -18
  125. package/src/models/identifier.js +10 -11
  126. package/src/models/push-token.js +17 -12
  127. package/src/models/request-result.js +4 -4
  128. package/src/models/server-config.js +36 -20
  129. package/src/models/types.js +1 -0
  130. package/src/request-controller.js +176 -174
  131. package/src/triggers/models/custom-event-data.js +6 -6
  132. package/src/triggers/models/custom-event-property-data.js +9 -9
  133. package/src/triggers/models/filter-set.js +9 -9
  134. package/src/triggers/models/filter.js +64 -64
  135. package/src/triggers/models/in-app-message-click-data.js +12 -12
  136. package/src/triggers/models/purchase-data.js +3 -3
  137. package/src/triggers/models/purchase-property-data.js +9 -9
  138. package/src/triggers/models/push-click-data.js +7 -7
  139. package/src/triggers/models/trigger-condition.js +57 -57
  140. package/src/triggers/models/trigger-events.js +2 -2
  141. package/src/triggers/models/trigger.js +42 -42
  142. package/src/triggers/triggers-provider-factory.js +8 -8
  143. package/src/triggers/triggers-provider.js +173 -170
  144. package/src/types.js +1 -0
  145. package/src/ui/js/attach-css.js +3 -3
  146. package/src/ui/js/load-font-awesome.js +2 -2
  147. package/src/util/base-device-parser.js +2 -2
  148. package/src/util/braze-actions.js +20 -20
  149. package/src/util/browser-detector.js +22 -22
  150. package/src/util/client-hints-parser.js +7 -7
  151. package/src/util/code-utils.js +1 -1
  152. package/src/util/color-utils.js +2 -2
  153. package/src/util/component-utils.js +2 -2
  154. package/src/util/deprecation-utils.js +1 -1
  155. package/src/util/device-constants.js +3 -3
  156. package/src/util/dom-utils.js +7 -7
  157. package/src/util/error-utils.js +2 -0
  158. package/src/util/key-codes.js +1 -1
  159. package/src/util/net.js +11 -11
  160. package/src/util/request-header-utils.js +23 -0
  161. package/src/util/string-utils.js +1 -1
  162. package/src/util/user-agent-parser.js +21 -21
  163. package/src/util/validation-utils.js +44 -44
  164. package/src/util/window-utils.js +3 -3
@@ -1,294 +1,310 @@
1
- import kt from "./auth-manager.js";
1
+ import jt from "./auth-manager.js";
2
2
  import y from "../common/base-provider.js";
3
- import ot from "../util/browser-detector.js";
3
+ import V from "../util/browser-detector.js";
4
4
  import Ot from "./device-manager.js";
5
5
  import DeviceProperties from "../Core/device-properties.js";
6
6
  import {
7
7
  isArray as p,
8
- keys as or,
9
- validateValueIsFromEnum as F,
8
+ keys as oo,
9
+ validateValueIsFromEnum as H,
10
10
  values as Lt
11
11
  } from "../util/code-utils.js";
12
- import { logDeprecationWarning as D } from "../util/deprecation-utils.js";
12
+ import { logDeprecationWarning as z } from "../util/deprecation-utils.js";
13
13
  import Pt from "./network-manager.js";
14
14
  import Rt from "../request-controller.js";
15
15
  import Mt from "./server-config-manager.js";
16
- import jt from "./session-manager.js";
16
+ import Dt from "./session-manager.js";
17
17
  import r from "../../shared-lib/braze-shared-lib.js";
18
- import G, { STORAGE_KEYS as o } from "./storage-manager.js";
19
- import Dt from "./storage-manager-factory.js";
20
- import u from "./subscription-manager.js";
21
- import { TriggersProviderFactory as W } from "../triggers/triggers-provider-factory.js";
18
+ import O, { STORAGE_KEYS as i } from "./storage-manager.js";
19
+ import Bt from "./storage-manager-factory.js";
20
+ import E from "./subscription-manager.js";
21
+ import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
22
22
  import bt from "../User/user-manager.js";
23
23
  import { User } from "../User/index.js";
24
- import { parseQueryStringKeyValues as ut } from "../util/url-utils.js";
25
- import { WindowUtils as H } from "../util/window-utils.js";
26
- const T = {
27
- Yn: "allowCrawlerActivity",
28
- Xn: "baseUrl",
29
- Zn: "noCookies",
30
- ho: "devicePropertyAllowlist",
24
+ import { parseQueryStringKeyValues as ct } from "../util/url-utils.js";
25
+ import { WindowUtils as Z } from "../util/window-utils.js";
26
+ import { BRAZE_MUST_BE_INITIALIZED_ERROR as P } from "../common/constants.js";
27
+ const L = {
28
+ ho: "allowCrawlerActivity",
29
+ Eo: "baseUrl",
30
+ _o: "noCookies",
31
+ Io: "devicePropertyAllowlist",
31
32
  ia: "disablePushTokenMaintenance",
32
- po: "enableLogging",
33
- Eo: "enableSdkAuthentication",
33
+ Ao: "enableLogging",
34
+ So: "enableSdkAuthentication",
34
35
  ta: "manageServiceWorkerExternally",
35
- _o: "minimumIntervalBetweenTriggerActionsInSeconds",
36
- Io: "sessionTimeoutInSeconds",
37
- Ao: "appVersion",
36
+ No: "minimumIntervalBetweenTriggerActionsInSeconds",
37
+ wo: "sessionTimeoutInSeconds",
38
+ To: "appVersion",
38
39
  na: "serviceWorkerLocation",
39
40
  ra: "safariWebsitePushId",
40
- jn: "localization",
41
- ao: "contentSecurityNonce",
42
- So: "enableHtmlInAppMessages",
43
- No: "allowUserSuppliedJavascript",
44
- no: "inAppMessageZIndex",
45
- lo: "openInAppMessagesInNewTab",
41
+ Mn: "localization",
42
+ lo: "contentSecurityNonce",
43
+ Oo: "enableHtmlInAppMessages",
44
+ Co: "allowUserSuppliedJavascript",
45
+ mo: "inAppMessageZIndex",
46
+ po: "openInAppMessagesInNewTab",
46
47
  tn: "openCardsInNewTab",
47
48
  en: "openNewsFeedCardsInNewTab",
48
- Ih: "requireExplicitInAppMessageDismissal",
49
- wo: "doNotLoadFontAwesome",
50
- To: "sdkFlavor"
49
+ Lh: "requireExplicitInAppMessageDismissal",
50
+ Lo: "doNotLoadFontAwesome",
51
+ Po: "sdkFlavor"
51
52
  };
52
- class Bt {
53
+ class Wt {
53
54
  constructor() {
54
- (this.Oo = !1),
55
- (this.vo = !1),
56
- (this.Co = new u()),
57
- (this.Lo = new u()),
58
- (this.Po = {}),
59
- (this.Ro = []),
60
- (this.Mo = []),
55
+ (this.Xr = ""),
56
+ (this.Ro = ""),
57
+ (this.Mo = void 0),
58
+ (this.jo = null),
59
+ (this.Zr = null),
60
+ (this.gt = null),
61
+ (this.Ci = null),
62
+ (this.wt = null),
63
+ (this._e = null),
64
+ (this.u = null),
65
+ (this.ft = null),
66
+ (this.Do = ""),
67
+ (this.Uo = !1),
68
+ (this.Bo = !1),
69
+ (this.Wo = new E()),
70
+ (this.zo = new E()),
71
+ (this.options = {}),
72
+ (this.Vo = []),
73
+ (this.Go = []),
61
74
  (this.Se = []),
62
- (this.jo = "4.7.2");
75
+ (this.Ro = "4.8.1");
63
76
  }
64
- yo(t) {
65
- this.Co.ut(t);
77
+ Ko(t) {
78
+ this.Wo.lt(t);
66
79
  }
67
- _h(t) {
68
- this.Lo.ut(t);
80
+ Nh(t) {
81
+ this.zo.lt(t);
69
82
  }
70
- initialize(t, i) {
71
- if (this.Do())
83
+ initialize(t, s) {
84
+ if (this.ue())
72
85
  return (
73
- r.D.info("Braze has already been initialized with an API key."), !0
86
+ r.j.info("Braze has already been initialized with an API key."), !0
74
87
  );
75
- this.Po = i || {};
76
- let s = this.nn(T.po);
77
- const e = ut(H.bn());
88
+ this.options = s || {};
89
+ let e = this.nn(L.Ao);
90
+ const n = ct(Z.jn());
78
91
  if (
79
- (e && "true" === e.brazeLogging && (s = !0),
80
- r.D.init(s),
81
- r.D.info(`Initialization Options: ${JSON.stringify(this.Po, null, 2)}`),
92
+ (n && "true" === n.brazeLogging && (e = !0),
93
+ r.j.init(e),
94
+ r.j.info(
95
+ `Initialization Options: ${JSON.stringify(this.options, null, 2)}`
96
+ ),
82
97
  null == t || "" === t || "string" != typeof t)
83
98
  )
84
- return r.D.error("Braze requires a valid API key to be initialized."), !1;
85
- this._r = t;
86
- let n = this.nn(T.Xn);
87
- if (null == n || "" === n || "string" != typeof n)
88
- return r.D.error("Braze requires a valid baseUrl to be initialized."), !1;
89
- !1 === /^https?:/.test(n) && (n = `https://${n}`);
90
- let h = n;
99
+ return r.j.error("Braze requires a valid API key to be initialized."), !1;
100
+ this.Xr = t;
101
+ let o = this.nn(L.Eo);
102
+ if (null == o || "" === o || "string" != typeof o)
103
+ return r.j.error("Braze requires a valid baseUrl to be initialized."), !1;
104
+ !1 === /^https?:/.test(o) && (o = `https://${o}`);
105
+ const h = o;
91
106
  if (
92
- ((n = document.createElement("a")),
93
- (n.href = h),
94
- "/" === n.pathname && (n = `${n}api/v3`),
95
- (this.Uo = n.toString()),
96
- ot.zo && !this.nn(T.Yn))
107
+ ((o = document.createElement("a")),
108
+ (o.href = h),
109
+ "/" === o.pathname && (o = `${o}api/v3`),
110
+ (this.Do = o.toString()),
111
+ V.Ho && !this.nn(L.ho))
97
112
  )
98
113
  return (
99
- r.D.info("Ignoring activity from crawler bot " + navigator.userAgent),
100
- (this.vo = !0),
114
+ r.j.info("Ignoring activity from crawler bot " + navigator.userAgent),
115
+ (this.Bo = !0),
101
116
  !1
102
117
  );
103
- const a = this.nn(T.Zn) || !1;
118
+ const a = this.nn(L._o) || !1;
104
119
  if (
105
- ((this.h = Dt.Bo(t, a)), a && this.h.Wo(t), new G.ne(null, !0).lr(o.ae))
120
+ ((this.u = Bt.$o(t, a)), a && this.u.qo(t), new O.ee(null, !0).wr(i.ne))
106
121
  )
107
122
  return (
108
- r.D.info("Ignoring all activity due to previous opt out"),
109
- (this.vo = !0),
123
+ r.j.info("Ignoring all activity due to previous opt out"),
124
+ (this.Bo = !0),
110
125
  !1
111
126
  );
112
- for (const t of or(this.Po))
113
- -1 === Lt(r.Fo).indexOf(t) &&
114
- r.D.warn(`Ignoring unknown initialization option '${t}'.`);
127
+ for (const t of oo(this.options))
128
+ -1 === Lt(r.xo).indexOf(t) &&
129
+ r.j.warn(`Ignoring unknown initialization option '${t}'.`);
115
130
  const l = ["mparticle", "wordpress", "tealium"];
116
- if (null != this.nn(T.To)) {
117
- const t = this.nn(T.To);
131
+ if (null != this.nn(L.Po)) {
132
+ const t = this.nn(L.Po);
118
133
  -1 !== l.indexOf(t)
119
- ? (this.Vo = t)
120
- : r.D.error("Invalid sdk flavor passed: " + t);
134
+ ? (this.Mo = t)
135
+ : r.j.error("Invalid sdk flavor passed: " + t);
121
136
  }
122
- let f = this.nn(r.Fo.ho);
123
- if (null != f)
124
- if (p(f)) {
137
+ let u = this.nn(r.xo.Io);
138
+ if (null != u)
139
+ if (p(u)) {
125
140
  const t = [];
126
- for (let i = 0; i < f.length; i++)
127
- F(
141
+ for (let i = 0; i < u.length; i++)
142
+ H(
128
143
  DeviceProperties,
129
- f[i],
144
+ u[i],
130
145
  "devicePropertyAllowlist contained an invalid value.",
131
146
  "DeviceProperties"
132
- ) && t.push(f[i]);
133
- f = t;
147
+ ) && t.push(u[i]);
148
+ u = t;
134
149
  } else
135
- r.D.error(
150
+ r.j.error(
136
151
  "devicePropertyAllowlist must be an array. Defaulting to all properties."
137
152
  ),
138
- (f = null);
139
- (this.Ur = new Ot(this.h, f)),
140
- (this.gt = new Mt(this.h)),
141
- (this.v = new bt(this.gt, this.h)),
142
- (this.j = new jt(this.h, this.v, this.gt, this.nn(T.Io)));
143
- const m = new u();
153
+ (u = null);
154
+ (this.Zr = new Ot(this.u, u)),
155
+ (this.wt = new Mt(this.u)),
156
+ (this.ft = new bt(this.wt, this.u)),
157
+ (this._e = new Dt(this.u, this.ft, this.wt, this.nn(L.wo)));
158
+ const f = new E();
144
159
  return (
145
- (this.Go = new kt(this.h, this.nn(T.Eo), m)),
146
- this.jt(m),
147
- (this.vt = new Pt(
148
- this.Ur,
149
- this.h,
150
- this.Go,
151
- this.v,
152
- this.j,
153
- this.gt,
154
- this._r,
155
- this.Uo,
160
+ (this.jo = new jt(this.u, this.nn(L.So), f)),
161
+ this.jt(f),
162
+ (this.gt = new Pt(
163
+ this.Zr,
164
+ this.u,
156
165
  this.jo,
157
- this.Vo,
158
- this.nn(T.Ao)
166
+ this.ft,
167
+ this._e,
168
+ this.wt,
169
+ this.Xr,
170
+ this.Do,
171
+ this.Ro,
172
+ this.Mo || "",
173
+ this.nn(L.To)
159
174
  )),
160
175
  (this.Ci = new Rt(
161
- this._r,
162
- this.Uo,
163
- this.j,
164
- this.Ur,
165
- this.v,
166
- this.gt,
167
- this.h,
176
+ this.Xr,
177
+ this.Do,
178
+ this._e,
179
+ this.Zr,
180
+ this.ft,
181
+ this.wt,
182
+ this.u,
168
183
  t => {
169
- if (this.Do()) for (const i of this.re()) i.Rs(t);
184
+ if (this.ue()) for (const i of this.gr()) i.Ts(t);
170
185
  },
171
- this.Go,
172
- this.vt
186
+ this.jo,
187
+ this.gt
173
188
  )),
174
189
  this.Ci.initialize(),
175
- r.D.info(
190
+ r.j.info(
176
191
  `Initialized for the Braze backend at "${this.nn(
177
- T.Xn
178
- )}" with API key "${this._r}".`
192
+ L.Eo
193
+ )}" with API key "${this.Xr}".`
179
194
  ),
180
- null != this.nn(T.So) &&
181
- D(
195
+ null != this.nn(L.Oo) &&
196
+ z(
182
197
  "enableHtmlInAppMessages",
183
198
  "initialization option",
184
199
  "allowUserSuppliedJavascript"
185
200
  ),
186
- W.init(),
187
- this.gt.Fi(() => {
188
- this.Oo &&
189
- this.gt.ci() &&
201
+ et.init(),
202
+ this.wt.Ni(() => {
203
+ this.Uo &&
204
+ this.wt &&
205
+ this.wt.bi() &&
190
206
  import("../FeatureFlags/refresh-feature-flags.js").then(t => {
191
- if (!this.Oo) return;
207
+ if (!this.Uo) return;
192
208
  (0, t.default)();
193
209
  });
194
210
  }),
195
- this.Ci.cr(() => {
196
- this.Oo &&
197
- this.gt.ci() &&
211
+ this.Ci.pr(() => {
212
+ this.Uo &&
213
+ this.wt &&
214
+ this.wt.bi() &&
198
215
  import("../FeatureFlags/refresh-feature-flags.js").then(t => {
199
- if (!this.Oo) return;
216
+ if (!this.Uo) return;
200
217
  (0, t.default)(null, null, !0);
201
218
  });
202
219
  }),
203
- this.Co.St(this.Po),
204
- (this.Oo = !0),
220
+ this.Wo.Et(this.options),
221
+ (this.Uo = !0),
205
222
  !0
206
223
  );
207
224
  }
208
225
  destroy(t) {
209
- if ((r.D.destroy(), this.Do())) {
210
- this.Lo.St(), this.Lo.removeAllSubscriptions();
211
- for (const t of this.Ro) t.destroy();
212
- this.Ro = [];
213
- for (const t of this.Mo) t.clearData(!1);
214
- (this.Mo = []),
226
+ if ((r.j.destroy(), this.ue())) {
227
+ this.zo.Et(), this.zo.removeAllSubscriptions();
228
+ for (const t of this.Vo) t.destroy();
229
+ this.Vo = [];
230
+ for (const t of this.Go) t.clearData(!1);
231
+ (this.Go = []),
215
232
  this.removeAllSubscriptions(),
216
233
  (this.Se = []),
217
- this.Ci.destroy(),
234
+ null != this.Ci && this.Ci.destroy(),
218
235
  (this.Ci = null),
219
- (this.Go = null),
220
- (this.Ur = null),
221
- (this.vt = null),
236
+ (this.jo = null),
237
+ (this.Zr = null),
222
238
  (this.gt = null),
223
- (this.j = null),
224
- (this.v = null),
225
- (this.Po = {}),
226
- (this.Vo = void 0),
227
- (this.Oo = !1),
228
- (this.vo = !1),
229
- t && (this.h = null);
239
+ (this.wt = null),
240
+ (this._e = null),
241
+ (this.ft = null),
242
+ (this.options = {}),
243
+ (this.Mo = void 0),
244
+ (this.Uo = !1),
245
+ (this.Bo = !1),
246
+ t && (this.u = null);
230
247
  }
231
248
  }
232
249
  rr() {
233
- if (this.Ko()) return !1;
234
- if (!this.Do())
235
- throw new Error("Braze must be initialized before calling methods.");
250
+ if (this.Jo()) return !1;
251
+ if (!this.ue()) throw new Error(P);
236
252
  return !0;
237
253
  }
238
254
  ea() {
239
- return this._r;
255
+ return this.Xr;
240
256
  }
241
- ii() {
242
- return this.Go;
257
+ Sr() {
258
+ return this.jo;
243
259
  }
244
- Ks() {
245
- return this.Uo;
260
+ Zs() {
261
+ return this.Do;
246
262
  }
247
- ce() {
248
- return this.Ur;
263
+ ie() {
264
+ return this.Zr;
249
265
  }
250
- nr() {
251
- return this.vt;
266
+ ar() {
267
+ return this.gt;
252
268
  }
253
269
  nn(t) {
254
- return this.Po[t];
270
+ return this.options[t];
255
271
  }
256
- re() {
257
- return this.Mo;
272
+ gr() {
273
+ return this.Go;
258
274
  }
259
- mr() {
275
+ cr() {
260
276
  return this.Ci;
261
277
  }
262
- ir() {
263
- return this.gt;
278
+ tr() {
279
+ return this.wt;
264
280
  }
265
- g() {
266
- return this.j;
281
+ aa() {
282
+ return this._e;
267
283
  }
268
284
  l() {
269
- return this.h;
285
+ return this.u;
270
286
  }
271
- gr() {
272
- if (this.v && this.Ci) return new User(this.v, this.Ci);
287
+ jr() {
288
+ if (this.ft && this.Ci) return new User(this.ft, this.Ci);
273
289
  }
274
- p() {
275
- return this.v;
290
+ ir() {
291
+ return this.ft;
276
292
  }
277
- tr() {
278
- return !0 === this.nn(T.No) || !0 === this.nn(T.So);
293
+ nr() {
294
+ return !0 === this.nn(L.Co) || !0 === this.nn(L.Oo);
279
295
  }
280
- u(t) {
296
+ g(t) {
281
297
  let i = !1;
282
- for (const s of this.Ro) s === t && (i = !0);
283
- i || this.Ro.push(t);
298
+ for (const s of this.Vo) s === t && (i = !0);
299
+ i || this.Vo.push(t);
284
300
  }
285
- ar(t) {
301
+ dr(t) {
286
302
  let i = !1;
287
- for (const s of this.Mo) s.constructor === t.constructor && (i = !0);
288
- t instanceof y && !i && this.Mo.push(t);
303
+ for (const s of this.Go) s.constructor === t.constructor && (i = !0);
304
+ t instanceof y && !i && this.Go.push(t);
289
305
  }
290
306
  jt(t) {
291
- t instanceof u && this.Se.push(t);
307
+ t instanceof E && this.Se.push(t);
292
308
  }
293
309
  removeAllSubscriptions() {
294
310
  if (this.rr()) for (const t of this.Se) t.removeAllSubscriptions();
@@ -296,18 +312,18 @@ class Bt {
296
312
  removeSubscription(t) {
297
313
  if (this.rr()) for (const i of this.Se) i.removeSubscription(t);
298
314
  }
299
- le(t) {
300
- this.vo = t;
315
+ ae(t) {
316
+ this.Bo = t;
301
317
  }
302
- Do() {
303
- return this.Oo;
318
+ ue() {
319
+ return this.Uo;
304
320
  }
305
- Ko() {
306
- return this.vo;
321
+ Jo() {
322
+ return this.Bo;
307
323
  }
308
- Ds() {
309
- return this.jo;
324
+ Us() {
325
+ return this.Ro;
310
326
  }
311
327
  }
312
- const e = new Bt();
313
- export { e as default, Bt as BrazeSdkInstance, T as OPTIONS };
328
+ const e = new Wt();
329
+ export { e as default, Wt as BrazeSdkInstance, L as OPTIONS };
@@ -1,77 +1,82 @@
1
- import ot from "../util/browser-detector.js";
2
- import Ie from "../models/device.js";
1
+ import V from "../util/browser-detector.js";
2
+ import xt from "../models/device.js";
3
3
  import DeviceProperties from "../Core/device-properties.js";
4
4
  import _t from "../models/identifier.js";
5
5
  import r from "../../shared-lib/braze-shared-lib.js";
6
- import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
6
+ import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
7
7
  import { values as Lt } from "../util/code-utils.js";
8
+ import { getErrorMessage as ei } from "../util/error-utils.js";
8
9
  export default class Ot {
9
- constructor(e, t) {
10
- (this.h = e), null == t && (t = Lt(DeviceProperties)), (this.xo = t);
10
+ constructor(t, e) {
11
+ (this.u = t),
12
+ (this.Qo = e),
13
+ (this.u = t),
14
+ null == e && (e = Lt(DeviceProperties)),
15
+ (this.Qo = e);
11
16
  }
12
17
  te() {
13
- let e = this.h.tu(o.eu.Jo);
14
- null == e && ((e = new _t(r.it.nt())), this.h.uu(o.eu.Jo, e));
15
- const t = new Ie(e.iu);
16
- for (let e = 0; e < this.xo.length; e++) {
17
- const r = this.xo[e];
18
- switch (r) {
18
+ let t = this.u.tu(i.eu.Xo);
19
+ null == t && ((t = new _t(r.Z.Y())), this.u.uu(i.eu.Xo, t));
20
+ const e = new xt(t.iu);
21
+ for (let t = 0; t < this.Qo.length; t++) {
22
+ switch (this.Qo[t]) {
19
23
  case DeviceProperties.BROWSER:
20
- t[r] = ot.browser;
24
+ e.browser = V.browser;
21
25
  break;
22
26
  case DeviceProperties.BROWSER_VERSION:
23
- t[r] = ot.version;
27
+ e.Yo = V.version;
24
28
  break;
25
29
  case DeviceProperties.OS:
26
- t[r] = this.qo();
30
+ e.os = this.Zo();
27
31
  break;
28
32
  case DeviceProperties.RESOLUTION:
29
- t[r] = screen.width + "x" + screen.height;
33
+ e.sa = screen.width + "x" + screen.height;
30
34
  break;
31
35
  case DeviceProperties.LANGUAGE:
32
- t[r] = ot.language;
36
+ e.language = V.language;
33
37
  break;
34
38
  case DeviceProperties.TIME_ZONE:
35
- t[r] = this.Ho(new Date());
39
+ e.timeZone = this.oa(new Date());
36
40
  break;
37
41
  case DeviceProperties.USER_AGENT:
38
- t[r] = ot.userAgent;
42
+ e.userAgent = V.userAgent;
39
43
  }
40
44
  }
41
- return t;
45
+ return e;
42
46
  }
43
- qo() {
44
- if (ot.Qo()) return ot.Qo();
45
- const e = this.h.I(o.q.Xo);
46
- return e && e.os_version ? e.os_version : ot.Yo();
47
+ Zo() {
48
+ if (V.ca()) return V.ca();
49
+ const t = this.u.v(i.k.la);
50
+ return t && t.os_version ? t.os_version : V.Zo();
47
51
  }
48
- Ho(e) {
52
+ oa(t) {
53
+ let e = !1;
49
54
  if ("undefined" != typeof Intl && "function" == typeof Intl.DateTimeFormat)
50
55
  try {
51
56
  if ("function" == typeof Intl.DateTimeFormat().resolvedOptions) {
52
- const e = Intl.DateTimeFormat().resolvedOptions().timeZone;
53
- if (null != e && "" !== e) return e;
57
+ const t = Intl.DateTimeFormat().resolvedOptions().timeZone;
58
+ if (null != t && "" !== t) return t;
54
59
  }
55
60
  } catch (t) {
56
- r.D.info(
61
+ r.j.info(
57
62
  "Intl.DateTimeFormat threw an error, cannot detect user's time zone:" +
58
- t.message
63
+ ei(t)
59
64
  ),
60
- (e = "");
65
+ (e = !0);
61
66
  }
62
- if (!e) return e;
63
- const t = e.getTimezoneOffset();
64
- return this.Zo(t);
67
+ if (e) return "";
68
+ const s = t.getTimezoneOffset();
69
+ return this.fa(s);
65
70
  }
66
- Zo(e) {
67
- const t = parseInt(e / 60),
68
- r = parseInt(e % 60);
71
+ fa(t) {
72
+ const e = Math.trunc(t / 60),
73
+ r = Math.trunc(t % 60);
69
74
  let s = "GMT";
70
75
  return (
71
- 0 !== e &&
72
- ((s += e < 0 ? "+" : "-"),
76
+ 0 !== t &&
77
+ ((s += t < 0 ? "+" : "-"),
73
78
  (s +=
74
- ("00" + Math.abs(t)).slice(-2) +
79
+ ("00" + Math.abs(e)).slice(-2) +
75
80
  ":" +
76
81
  ("00" + Math.abs(r)).slice(-2))),
77
82
  s