@braze/web-sdk 4.9.0 → 4.10.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 (202) hide show
  1. package/index.d.ts +2296 -2235
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -8
  4. package/shared-lib/encoding-utils.js +1 -12
  5. package/shared-lib/event-types.js +1 -34
  6. package/shared-lib/guid.js +1 -10
  7. package/shared-lib/indexed-db-adapter.js +1 -352
  8. package/shared-lib/logger.js +1 -38
  9. package/shared-lib/supported-options.js +1 -26
  10. package/shared-lib/types.js +1 -1
  11. package/src/Card/card-manager-factory.js +1 -14
  12. package/src/Card/card-manager.js +1 -78
  13. package/src/Card/display/card-display.js +1 -138
  14. package/src/Card/index.js +1 -6
  15. package/src/Card/log-card-click.js +1 -11
  16. package/src/Card/log-card-dismissal.js +1 -11
  17. package/src/Card/log-card-impressions.js +1 -13
  18. package/src/Card/log-content-card-click.js +1 -4
  19. package/src/Card/log-content-card-impressions.js +1 -4
  20. package/src/Card/models/banner.js +1 -31
  21. package/src/Card/models/captioned-image.js +1 -33
  22. package/src/Card/models/card.js +1 -196
  23. package/src/Card/models/classic-card.js +1 -32
  24. package/src/Card/models/control-card.js +1 -23
  25. package/src/Card/models/image-only.js +1 -32
  26. package/src/Card/models/index.js +1 -6
  27. package/src/Card/types.js +1 -1
  28. package/src/Card/util/card-factory.js +1 -104
  29. package/src/ContentCards/content-cards-provider-factory.js +1 -20
  30. package/src/ContentCards/content-cards-provider.js +1 -391
  31. package/src/ContentCards/content-cards.js +1 -24
  32. package/src/ContentCards/get-cached-content-cards.js +1 -5
  33. package/src/ContentCards/index.js +1 -8
  34. package/src/ContentCards/log-content-cards-displayed.js +1 -5
  35. package/src/ContentCards/request-content-cards-refresh.js +1 -5
  36. package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -17
  37. package/src/ContentCards/types.js +1 -1
  38. package/src/ContentCards/ui/hide-content-cards.js +1 -8
  39. package/src/ContentCards/ui/show-content-cards.js +1 -77
  40. package/src/ContentCards/ui/toggle-content-cards.js +1 -8
  41. package/src/Core/add-sdk-metadata.js +1 -26
  42. package/src/Core/braze-sdk-metadata.js +1 -10
  43. package/src/Core/change-user.js +1 -17
  44. package/src/Core/destroy.js +1 -5
  45. package/src/Core/device-properties.js +1 -9
  46. package/src/Core/disable-sdk.js +1 -15
  47. package/src/Core/enable-sdk.js +1 -11
  48. package/src/Core/get-device-id.js +1 -11
  49. package/src/Core/get-user.js +1 -4
  50. package/src/Core/handle-braze-action.js +1 -87
  51. package/src/Core/index.js +1 -23
  52. package/src/Core/initialize.js +1 -4
  53. package/src/Core/is-disabled.js +1 -4
  54. package/src/Core/log-custom-event.js +1 -38
  55. package/src/Core/log-purchase.js +1 -245
  56. package/src/Core/open-session.js +1 -25
  57. package/src/Core/remove-all-subscriptions.js +1 -4
  58. package/src/Core/remove-subscription.js +1 -4
  59. package/src/Core/request-immediate-data-flush.js +1 -6
  60. package/src/Core/set-logger.js +1 -4
  61. package/src/Core/set-sdk-authentication-signature.js +1 -8
  62. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -6
  63. package/src/Core/toggle-logging.js +1 -4
  64. package/src/Core/types.js +1 -1
  65. package/src/Core/wipe-data.js +1 -16
  66. package/src/FeatureFlags/feature-flag-factory.js +1 -24
  67. package/src/FeatureFlags/feature-flag.js +1 -64
  68. package/src/FeatureFlags/feature-flags-provider-factory.js +1 -19
  69. package/src/FeatureFlags/feature-flags-provider.js +1 -145
  70. package/src/FeatureFlags/get-all-feature-flags.js +1 -12
  71. package/src/FeatureFlags/get-feature-flag.js +1 -12
  72. package/src/FeatureFlags/index.js +1 -6
  73. package/src/FeatureFlags/log-feature-flag-impression.js +1 -23
  74. package/src/FeatureFlags/refresh-feature-flags.js +1 -9
  75. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -9
  76. package/src/FeatureFlags/types.js +1 -1
  77. package/src/Feed/feed-provider-factory.js +1 -18
  78. package/src/Feed/feed-provider.js +1 -90
  79. package/src/Feed/feed.js +1 -20
  80. package/src/Feed/get-cached-feed.js +1 -5
  81. package/src/Feed/index.js +1 -8
  82. package/src/Feed/log-feed-displayed.js +1 -7
  83. package/src/Feed/request-feed-refresh.js +1 -5
  84. package/src/Feed/subscribe-to-feed-updates.js +1 -5
  85. package/src/Feed/types.js +1 -1
  86. package/src/Feed/ui/hide-feed.js +1 -7
  87. package/src/Feed/ui/show-feed.js +1 -96
  88. package/src/Feed/ui/toggle-feed.js +1 -8
  89. package/src/InAppMessage/defer-in-app-message.js +1 -13
  90. package/src/InAppMessage/display/get-animation-effect.js +1 -19
  91. package/src/InAppMessage/display/html-message-to-html.js +1 -244
  92. package/src/InAppMessage/display/in-app-message-to-html.js +1 -188
  93. package/src/InAppMessage/display/modal-utils.js +1 -73
  94. package/src/InAppMessage/get-deferred-in-app-message.js +1 -5
  95. package/src/InAppMessage/in-app-message-factory.js +1 -166
  96. package/src/InAppMessage/in-app-message-manager-factory.js +1 -16
  97. package/src/InAppMessage/in-app-message-manager.js +1 -248
  98. package/src/InAppMessage/index.js +1 -16
  99. package/src/InAppMessage/log-in-app-message-button-click.js +1 -27
  100. package/src/InAppMessage/log-in-app-message-click.js +1 -19
  101. package/src/InAppMessage/log-in-app-message-html-click.js +1 -23
  102. package/src/InAppMessage/log-in-app-message-impression.js +1 -13
  103. package/src/InAppMessage/models/control-message.js +1 -11
  104. package/src/InAppMessage/models/full-screen-message.js +1 -105
  105. package/src/InAppMessage/models/html-message.js +1 -68
  106. package/src/InAppMessage/models/in-app-message-button.js +1 -47
  107. package/src/InAppMessage/models/in-app-message.js +1 -382
  108. package/src/InAppMessage/models/modal-message.js +1 -101
  109. package/src/InAppMessage/models/slide-up-message.js +1 -84
  110. package/src/InAppMessage/models/templated-in-app-message.js +1 -19
  111. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -10
  112. package/src/InAppMessage/types.js +1 -1
  113. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +1 -15
  114. package/src/InAppMessage/ui/show-in-app-message.js +1 -181
  115. package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
  116. package/src/Push/index.js +1 -5
  117. package/src/Push/is-push-blocked.js +1 -5
  118. package/src/Push/is-push-permission-granted.js +1 -5
  119. package/src/Push/is-push-supported.js +1 -5
  120. package/src/Push/push-manager-factory.js +1 -30
  121. package/src/Push/push-manager.js +1 -387
  122. package/src/Push/request-push-permission.js +1 -9
  123. package/src/Push/types.js +1 -1
  124. package/src/Push/unregister-push.js +1 -5
  125. package/src/Push/utils/push-utils.js +1 -36
  126. package/src/User/index.js +1 -1
  127. package/src/User/types.js +1 -1
  128. package/src/User/user-manager.js +1 -73
  129. package/src/User/user.js +1 -301
  130. package/src/common/base-feed.js +1 -28
  131. package/src/common/base-provider.js +1 -6
  132. package/src/common/constants.js +1 -14
  133. package/src/common/event-logger.js +1 -31
  134. package/src/common/feed-display.js +1 -210
  135. package/src/common/translations.js +1 -148
  136. package/src/common/types.js +1 -1
  137. package/src/index.js +1 -9
  138. package/src/l10n/l10n-manager-factory.js +1 -22
  139. package/src/l10n/l10n-manager.js +1 -25
  140. package/src/l10n/types.js +1 -1
  141. package/src/managers/auth-manager.js +1 -51
  142. package/src/managers/braze-instance.js +1 -329
  143. package/src/managers/device-manager.js +1 -85
  144. package/src/managers/network-manager.js +1 -253
  145. package/src/managers/server-config-manager.js +1 -108
  146. package/src/managers/session-manager.js +1 -75
  147. package/src/managers/storage-manager-factory.js +1 -42
  148. package/src/managers/storage-manager.js +1 -419
  149. package/src/managers/subscription-manager.js +1 -28
  150. package/src/managers/types.js +1 -1
  151. package/src/models/backend-errors.js +1 -8
  152. package/src/models/braze-event.js +1 -47
  153. package/src/models/braze-sdk-metadata.js +1 -10
  154. package/src/models/device.js +1 -18
  155. package/src/models/identifier.js +1 -19
  156. package/src/models/push-token.js +1 -27
  157. package/src/models/request-result.js +1 -8
  158. package/src/models/server-config.js +1 -48
  159. package/src/models/types.js +1 -1
  160. package/src/request-controller.js +1 -307
  161. package/src/triggers/models/custom-event-data.js +1 -14
  162. package/src/triggers/models/custom-event-property-data.js +1 -21
  163. package/src/triggers/models/filter-set.js +1 -55
  164. package/src/triggers/models/filter.js +1 -102
  165. package/src/triggers/models/in-app-message-click-data.js +1 -25
  166. package/src/triggers/models/purchase-data.js +1 -14
  167. package/src/triggers/models/purchase-property-data.js +1 -21
  168. package/src/triggers/models/push-click-data.js +1 -15
  169. package/src/triggers/models/trigger-condition.js +1 -105
  170. package/src/triggers/models/trigger-events.js +1 -8
  171. package/src/triggers/models/trigger.js +1 -122
  172. package/src/triggers/triggers-provider-factory.js +1 -34
  173. package/src/triggers/triggers-provider.js +1 -326
  174. package/src/triggers/types.js +1 -1
  175. package/src/types.js +1 -1
  176. package/src/ui/js/attach-css.js +1 -13
  177. package/src/ui/js/feed-css.js +1 -12
  178. package/src/ui/js/iam-css.js +1 -12
  179. package/src/ui/js/index.js +1 -3
  180. package/src/ui/js/load-font-awesome.js +1 -13
  181. package/src/util/base-device-parser.js +1 -14
  182. package/src/util/braze-actions.js +1 -84
  183. package/src/util/browser-detector.js +1 -84
  184. package/src/util/client-hints-parser.js +1 -66
  185. package/src/util/code-utils.js +1 -100
  186. package/src/util/color-utils.js +1 -29
  187. package/src/util/component-utils.js +1 -26
  188. package/src/util/date-utils.js +1 -28
  189. package/src/util/deprecation-utils.js +1 -5
  190. package/src/util/device-constants.js +1 -14
  191. package/src/util/dom-utils.js +1 -91
  192. package/src/util/error-utils.js +1 -2
  193. package/src/util/key-codes.js +1 -1
  194. package/src/util/math.js +1 -5
  195. package/src/util/net.js +1 -71
  196. package/src/util/request-header-utils.js +1 -46
  197. package/src/util/string-utils.js +1 -22
  198. package/src/util/types.js +1 -1
  199. package/src/util/url-utils.js +1 -20
  200. package/src/util/user-agent-parser.js +1 -85
  201. package/src/util/validation-utils.js +1 -217
  202. package/src/util/window-utils.js +1 -34
@@ -1,307 +1 @@
1
- import C from "./util/net.js";
2
- import be from "./models/braze-event.js";
3
- import s from "./common/event-logger.js";
4
- import { randomInclusive as D } from "./util/math.js";
5
- import t from "./models/request-result.js";
6
- import r from "../shared-lib/braze-shared-lib.js";
7
- import { STORAGE_KEYS as i } from "./managers/storage-manager.js";
8
- import E from "./managers/subscription-manager.js";
9
- import jt from "./Push/utils/push-utils.js";
10
- import T from "./util/request-header-utils.js";
11
- export default class Rt {
12
- constructor(t, i, s, e, o, h, n, r, u, l) {
13
- (this.cn = t),
14
- (this.baseUrl = i),
15
- (this._e = s),
16
- (this.fn = e),
17
- (this.ft = o),
18
- (this.wt = h),
19
- (this.u = n),
20
- (this.$h = r),
21
- (this.Do = u),
22
- (this.gt = l),
23
- (this.cn = t),
24
- (this.baseUrl = i),
25
- (this.Kh = 0),
26
- (this.gE = n.RE() || 0),
27
- (this.Wh = null),
28
- (this._e = s),
29
- (this.fn = e),
30
- (this.ft = o),
31
- (this.wt = h),
32
- (this.u = n),
33
- (this.Do = u),
34
- (this.gt = l),
35
- (this.$h = r),
36
- (this.Qh = new E()),
37
- (this.Vh = null),
38
- (this.Yh = 50),
39
- (this.Zh = !1);
40
- }
41
- fu(t, i) {
42
- return !t && !i && this.Do.Jh() >= this.Yh;
43
- }
44
- gu(t) {
45
- let i = this._e.El();
46
- if (t.length > 0) {
47
- const s = this.ft.getUserId();
48
- for (const e of t) {
49
- const t = (!e.userId && !s) || e.userId === s;
50
- e.type === r.q.Wl && t && (i = !0);
51
- }
52
- }
53
- return i;
54
- }
55
- vu(t = !1, s = !1, e = !0, o, h, n, u = !1, l = !1) {
56
- e && this.wu();
57
- const a = this.u.cE(),
58
- c = this.u.AE();
59
- let d = !1;
60
- const f = (t, s) => {
61
- let r = !1;
62
- T.Ws(this.u, T.Os.Ja, new Date().valueOf()),
63
- C.Xs({
64
- url: this.baseUrl + "/data/",
65
- data: t,
66
- headers: s,
67
- O: (e) => {
68
- null != t.respond_with &&
69
- t.respond_with.triggers &&
70
- (this.Kh = Math.max(this.Kh - 1, 0)),
71
- this.gt.Zs(t, e, s)
72
- ? (this.Do.ti(),
73
- this.wt.ul(e),
74
- (null != t.respond_with &&
75
- t.respond_with.user_id != this.ft.getUserId()) ||
76
- (null != t.device && this.u.D(i.k.Ca, t.device),
77
- null != t.sdk_metadata &&
78
- (this.u.D(i.k.Xa, t.sdk_metadata),
79
- this.u.D(i.k.Ea, this._e.Pa())),
80
- this.$h(e),
81
- T.si(this.u, T.Os.Ja, 1),
82
- "function" == typeof o && o()))
83
- : e.auth_error && (r = !0);
84
- },
85
- error: () => {
86
- null != t.respond_with &&
87
- t.respond_with.triggers &&
88
- (this.Kh = Math.max(this.Kh - 1, 0)),
89
- this.gt.$a(t.events, t.attributes),
90
- "function" == typeof h && h();
91
- },
92
- ei: (t) => {
93
- if (("function" == typeof n && n(t), e && !d)) {
94
- if (t && !r) this.ku();
95
- else {
96
- T.hi(this.u, T.Os.Ja);
97
- let t = this.Wh;
98
- (null == t || t < 1e3 * this.gE) && (t = 1e3 * this.gE),
99
- this.ku(Math.min(3e5, D(1e3 * this.gE, 3 * t)));
100
- }
101
- d = !0;
102
- }
103
- },
104
- });
105
- },
106
- m = this.gu(a),
107
- g = s || m;
108
- if (this.fu(u, m))
109
- return void r.j.info(
110
- "Declining to flush data due to 50 consecutive authentication failures",
111
- );
112
- if (e && !this.gt.Wa(a, c, t, g))
113
- return this.ku(), void ("function" == typeof n && n(!0));
114
- const v = this.gt.Ya(t, g, a, c, l);
115
- g && this.Kh++;
116
- let p = !1;
117
- if (v)
118
- for (const t of v)
119
- this.gt.Qs(t.requestData, () => f(t.requestData, t.headers)), (p = !0);
120
- this.Do.wh() && e && !p
121
- ? this.ku()
122
- : m && (r.j.info("Invoking new session subscriptions"), this.Qh.Et());
123
- }
124
- yu() {
125
- return this.Kh > 0;
126
- }
127
- ku(t = 1e3 * this.gE) {
128
- this.Zh ||
129
- (this.wu(),
130
- (this.Vh = window.setTimeout(() => {
131
- if (document.hidden) {
132
- const t = "visibilitychange",
133
- i = () => {
134
- document.hidden ||
135
- (document.removeEventListener(t, i, !1), this.vu());
136
- };
137
- document.addEventListener(t, i, !1);
138
- } else this.vu();
139
- }, t)),
140
- (this.Wh = t));
141
- }
142
- wu() {
143
- null != this.Vh && (clearTimeout(this.Vh), (this.Vh = null));
144
- }
145
- initialize() {
146
- (this.Zh = !1), this.ku();
147
- }
148
- destroy() {
149
- this.Qh.removeAllSubscriptions(),
150
- this.Do.Gh(),
151
- this.wu(),
152
- (this.Zh = !0),
153
- this.vu(void 0, void 0, !1, void 0, void 0, void 0, void 0, !0),
154
- (this.Vh = null);
155
- }
156
- pr(t) {
157
- return this.Qh.lt(t);
158
- }
159
- openSession() {
160
- const t = this._e.Pa() !== this._e.co();
161
- t && (this.u.uE(i.eu.Xo), this.u.uE(i.eu.su), this.u.ni(i.k.qi)),
162
- this.vu(void 0, !1, void 0, void 0, void 0),
163
- this.pu(),
164
- t &&
165
- import("./Push/push-manager-factory.js").then((t) => {
166
- if (this.Zh) return;
167
- const s = t.default.m();
168
- if (
169
- null != s &&
170
- (jt.isPushPermissionGranted() || jt.isPushBlocked())
171
- ) {
172
- const t = () => {
173
- s.Sn()
174
- ? r.j.info(
175
- "Push token maintenance is disabled, not refreshing token for backend.",
176
- )
177
- : s.subscribe();
178
- },
179
- e = (i, s) => {
180
- s && t();
181
- },
182
- o = () => {
183
- const s = this.u.v(i.k.Bn);
184
- (null == s || s) && t();
185
- },
186
- h = r.zt.Ft;
187
- new r.xt(h, r.j).hr(h.Jt.cu, e, o);
188
- }
189
- });
190
- }
191
- changeUser(t, s, e) {
192
- const o = this.ft.getUserId();
193
- if (o !== t) {
194
- this._e.kl(),
195
- null != o && this.vu(void 0, !1, void 0, void 0, void 0),
196
- this.ft.ru(t),
197
- e ? this.Do.setSdkAuthenticationSignature(e) : this.Do.yh();
198
- for (let t = 0; t < s.length; t++) s[t].changeUser(null == o);
199
- null != o && this.u.ni(i.k.L),
200
- this.u.ni(i.k.Ca),
201
- this.openSession(),
202
- r.j.info('Changed user to "' + t + '".');
203
- } else {
204
- let i = "Doing nothing.";
205
- e &&
206
- this.Do.jh() !== e &&
207
- (this.Do.setSdkAuthenticationSignature(e),
208
- (i = "Updated SDK authentication signature")),
209
- r.j.info(`Current user is already ${t}. ${i}`);
210
- }
211
- }
212
- requestImmediateDataFlush(t) {
213
- this.wu(), this._e.co();
214
- this.vu(
215
- void 0,
216
- void 0,
217
- void 0,
218
- void 0,
219
- () => {
220
- r.j.error(
221
- "Failed to flush data, request will be retried automatically.",
222
- );
223
- },
224
- t,
225
- !0,
226
- );
227
- }
228
- requestFeedRefresh() {
229
- this._e.co(), this.vu(!0);
230
- }
231
- $r(t, i) {
232
- this._e.co(),
233
- r.j.info("Requesting explicit trigger refresh."),
234
- this.vu(void 0, !0, void 0, t, i);
235
- }
236
- $n(t, i) {
237
- const e = r.q.ju,
238
- o = { a: t, l: i },
239
- h = s.N(e, o);
240
- return h && r.j.info(`Logged alias ${t} with label ${i}`), h;
241
- }
242
- Gn(i, e, o) {
243
- if (this.wt.hu(e))
244
- return (
245
- r.j.info(`Custom Attribute "${e}" is blocklisted, ignoring.`), new t()
246
- );
247
- const h = { key: e, value: o },
248
- n = s.N(i, h);
249
- if (n) {
250
- const t = "object" == typeof o ? JSON.stringify(o, null, 2) : o;
251
- r.j.info(`Logged custom attribute: ${e} with value: ${t}`);
252
- }
253
- return n;
254
- }
255
- setLastKnownLocation(t, i, e, o, h, n) {
256
- const u = { latitude: i, longitude: e };
257
- null != o && (u.altitude = o),
258
- null != h && (u.ll_accuracy = h),
259
- null != n && (u.alt_accuracy = n);
260
- const l = s.N(r.q.Su, u, t || void 0);
261
- return (
262
- l &&
263
- r.j.info(
264
- `Set user last known location as ${JSON.stringify(u, null, 2)}`,
265
- ),
266
- l
267
- );
268
- }
269
- vr(t, i) {
270
- const s = this._e.co();
271
- return new be(this.ft.getUserId(), r.q.$u, t, s, { cid: i });
272
- }
273
- pu() {
274
- const t = r.zt.Ft;
275
- new r.xt(t, r.j).setItem(t.Jt.Ja, 1, {
276
- baseUrl: this.baseUrl,
277
- data: { api_key: this.cn, device_id: this.fn.ce().id },
278
- userId: this.ft.getUserId(),
279
- sdkAuthEnabled: this.Do.wh(),
280
- });
281
- }
282
- yr(t) {
283
- for (const i of t)
284
- if (i.api_key === this.cn) this.gt.$a(i.events, i.attributes);
285
- else {
286
- const t = r.zt.Ft;
287
- new r.xt(t, r.j).setItem(t.Jt.wr, r.Z.Y(), i);
288
- }
289
- }
290
- Zn(i, e, o) {
291
- if (this.wt.hu(i))
292
- return (
293
- r.j.info(`Custom Attribute "${i}" is blocklisted, ignoring.`), new t()
294
- );
295
- let h, n;
296
- return (
297
- null === e && null === o
298
- ? ((h = r.q.qu), (n = { key: i }))
299
- : ((h = r.q.Au), (n = { key: i, latitude: e, longitude: o })),
300
- s.N(h, n)
301
- );
302
- }
303
- au(t, i) {
304
- const e = { group_id: t, status: i };
305
- return s.N(r.q.Cu, e);
306
- }
307
- }
1
+ import C from"./util/net.js";import be from"./models/braze-event.js";import s from"./common/event-logger.js";import{randomInclusive as D}from"./util/math.js";import t from"./models/request-result.js";import r from"../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as i}from"./managers/storage-manager.js";import E from"./managers/subscription-manager.js";import jt from"./Push/utils/push-utils.js";import T from"./util/request-header-utils.js";export default class Lt{constructor(t,i,s,e,h,o,n,r,u,l){this.cn=t,this.baseUrl=i,this._e=s,this.fn=e,this.ft=h,this.wt=o,this.u=n,this.fu=r,this.Uo=u,this.gt=l,this.cn=t,this.baseUrl=i,this.gu=0,this.gE=n.RE()||0,this.vu=null,this._e=s,this.fn=e,this.ft=h,this.wt=o,this.u=n,this.Uo=u,this.gt=l,this.fu=r,this.wu=new E,this.ku=null,this.yu=50,this.ju=!1}Su(t,i){return!t&&!i&&this.Uo.Jh()>=this.yu}$u(t){let i=this._e.El();if(t.length>0){const s=this.ft.getUserId();for(const e of t){const t=!e.userId&&!s||e.userId===s;e.type===r.q.Wl&&t&&(i=!0)}}return i}qu(t=!1,s=!1,e=!0,h,o,n,u=!1,l=!1){e&&this.Au();const a=this.u.cE(),c=this.u.AE();let d=!1;const f=(t,s)=>{let r=!1;T.Ws(this.u,T.Os.Na,(new Date).valueOf()),C.Xs({url:this.baseUrl+"/data/",data:t,headers:s,O:e=>{null!=t.respond_with&&t.respond_with.triggers&&(this.gu=Math.max(this.gu-1,0)),this.gt.Zs(t,e,s)?(this.Uo.ti(),this.wt.ul(e),null!=t.respond_with&&t.respond_with.user_id!=this.ft.getUserId()||(null!=t.device&&this.u.D(i.k.Fa,t.device),null!=t.sdk_metadata&&(this.u.D(i.k.Kh,t.sdk_metadata),this.u.D(i.k.Wh,this._e.Yh())),this.fu(e),T.si(this.u,T.Os.Na,1),"function"==typeof h&&h())):e.auth_error&&(r=!0)},error:()=>{null!=t.respond_with&&t.respond_with.triggers&&(this.gu=Math.max(this.gu-1,0)),this.gt.Qh(t.events,t.attributes),"function"==typeof o&&o()},ei:t=>{if("function"==typeof n&&n(t),e&&!d){if(t&&!r)this.Cu();else{T.hi(this.u,T.Os.Na);let t=this.vu;(null==t||t<1e3*this.gE)&&(t=1e3*this.gE),this.Cu(Math.min(3e5,D(1e3*this.gE,3*t)))}d=!0}}})},m=this.$u(a),g=s||m;if(this.Su(u,m))return void r.j.info("Declining to flush data due to 50 consecutive authentication failures");if(e&&!this.gt.Pa(a,c,t,g))return this.Cu(),void("function"==typeof n&&n(!0));const v=this.gt.$a(t,g,a,c,l);g&&this.gu++;let p=!1;if(v)for(const t of v)this.gt.Qs(t.requestData,(()=>f(t.requestData,t.headers))),p=!0;this.Uo.wh()&&e&&!p?this.Cu():m&&(r.j.info("Invoking new session subscriptions"),this.wu.Et())}Du(){return this.gu>0}Cu(t=1e3*this.gE){this.ju||(this.Au(),this.ku=window.setTimeout((()=>{if(document.hidden){const t="visibilitychange",i=()=>{document.hidden||(document.removeEventListener(t,i,!1),this.qu())};document.addEventListener(t,i,!1)}else this.qu()}),t),this.vu=t)}Au(){null!=this.ku&&(clearTimeout(this.ku),this.ku=null)}initialize(){this.ju=!1,this.Cu()}destroy(){this.wu.removeAllSubscriptions(),this.Uo.Gh(),this.Au(),this.ju=!0,this.qu(void 0,void 0,!1,void 0,void 0,void 0,void 0,!0),this.ku=null}pr(t){return this.wu.lt(t)}openSession(){const t=this._e.Yh()!==this._e.co();t&&(this.u.uE(i.eu.Zo),this.u.uE(i.eu.su)),this.qu(void 0,!1,void 0,void 0,void 0),this.pu(),t&&import("./Push/push-manager-factory.js").then((t=>{if(this.ju)return;const s=t.default.m();if(null!=s&&(jt.isPushPermissionGranted()||jt.isPushBlocked())){const t=()=>{s.Sn()?r.j.info("Push token maintenance is disabled, not refreshing token for backend."):s.subscribe()},e=(i,s)=>{s&&t()},h=()=>{const s=this.u.v(i.k.Bn);(null==s||s)&&t()},o=r.zt.Ft;new r.xt(o,r.j).hr(o.Jt.cu,e,h)}}))}Fu(){this.u.ni(i.k.Ri),this.u.ni(i.k.Yt),this.u.ni(i.k.rn)}changeUser(t,s,e){const h=this.ft.getUserId();if(h!==t){this._e.kl(),this.Fu(),null!=h&&this.qu(void 0,!1,void 0,void 0,void 0),this.ft.ru(t),e?this.Uo.setSdkAuthenticationSignature(e):this.Uo.yh();for(let t=0;t<s.length;t++)s[t].changeUser(null==h);null!=h&&this.u.ni(i.k.L),this.u.ni(i.k.Fa),this.openSession(),r.j.info('Changed user to "'+t+'".')}else{let i="Doing nothing.";e&&this.Uo.jh()!==e&&(this.Uo.setSdkAuthenticationSignature(e),i="Updated SDK authentication signature"),r.j.info(`Current user is already ${t}. ${i}`)}}requestImmediateDataFlush(t){this.Au(),this._e.co();this.qu(void 0,void 0,void 0,void 0,(()=>{r.j.error("Failed to flush data, request will be retried automatically.")}),t,!0)}requestFeedRefresh(){this._e.co(),this.qu(!0)}$r(t,i){this._e.co(),r.j.info("Requesting explicit trigger refresh."),this.qu(void 0,!0,void 0,t,i)}$n(t,i){const e=r.q.Tu,h={a:t,l:i},o=s.N(e,h);return o&&r.j.info(`Logged alias ${t} with label ${i}`),o}Gn(i,e,h){if(this.wt.hu(e))return r.j.info(`Custom Attribute "${e}" is blocklisted, ignoring.`),new t;const o={key:e,value:h},n=s.N(i,o);if(n){const t="object"==typeof h?JSON.stringify(h,null,2):h;r.j.info(`Logged custom attribute: ${e} with value: ${t}`)}return n}setLastKnownLocation(t,i,e,h,o,n){const u={latitude:i,longitude:e};null!=h&&(u.altitude=h),null!=o&&(u.ll_accuracy=o),null!=n&&(u.alt_accuracy=n);const l=s.N(r.q.Lu,u,t||void 0);return l&&r.j.info(`Set user last known location as ${JSON.stringify(u,null,2)}`),l}vr(t,i){const s=this._e.co();return new be(this.ft.getUserId(),r.q.Mu,t,s,{cid:i})}pu(){const t=r.zt.Ft;new r.xt(t,r.j).setItem(t.Jt.Na,1,{baseUrl:this.baseUrl,data:{api_key:this.cn,device_id:this.fn.ce().id},userId:this.ft.getUserId(),sdkAuthEnabled:this.Uo.wh()})}yr(t){for(const i of t)if(i.api_key===this.cn)this.gt.Qh(i.events,i.attributes);else{const t=r.zt.Ft;new r.xt(t,r.j).setItem(t.Jt.wr,r.Z.Y(),i)}}Zn(i,e,h){if(this.wt.hu(i))return r.j.info(`Custom Attribute "${i}" is blocklisted, ignoring.`),new t;let o,n;return null===e&&null===h?(o=r.q.Pu,n={key:i}):(o=r.q.Ru,n={key:i,latitude:e,longitude:h}),s.N(o,n)}au(t,i){const e={group_id:t,status:i};return s.N(r.q.Nu,e)}}
@@ -1,14 +1 @@
1
- export default class Qt {
2
- constructor(t) {
3
- (this.yl = t), (this.yl = t);
4
- }
5
- Bl(t) {
6
- return null == this.yl || this.yl === t[0];
7
- }
8
- static fromJson(t) {
9
- return new Qt(t ? t.event_name : null);
10
- }
11
- ss() {
12
- return this.yl;
13
- }
14
- }
1
+ export default class Qt{constructor(t){this.yl=t,this.yl=t}Bl(t){return null==this.yl||this.yl===t[0]}static fromJson(t){return new Qt(t?t.event_name:null)}ss(){return this.yl}}
@@ -1,21 +1 @@
1
- import Yt from "./filter-set.js";
2
- export default class Zt {
3
- constructor(t, s) {
4
- (this.yl = t), (this.Jl = s), (this.yl = t), (this.Jl = s);
5
- }
6
- Bl(t) {
7
- if (null == this.yl || null == this.Jl) return !1;
8
- const s = t[0],
9
- i = t[1];
10
- return s === this.yl && this.Jl.Bl(i);
11
- }
12
- static fromJson(t) {
13
- return new Zt(
14
- t ? t.event_name : null,
15
- t ? Yt.fromJson(t.property_filters) : null,
16
- );
17
- }
18
- ss() {
19
- return { e: this.yl, pf: this.Jl ? this.Jl.ss() : null };
20
- }
21
- }
1
+ import Yt from"./filter-set.js";export default class Zt{constructor(t,s){this.yl=t,this.Jl=s,this.yl=t,this.Jl=s}Bl(t){if(null==this.yl||null==this.Jl)return!1;const s=t[0],i=t[1];return s===this.yl&&this.Jl.Bl(i)}static fromJson(t){return new Zt(t?t.event_name:null,t?Yt.fromJson(t.property_filters):null)}ss(){return{e:this.yl,pf:this.Jl?this.Jl.ss():null}}}
@@ -1,55 +1 @@
1
- import sr from "./filter.js";
2
- import { isArray as p } from "../../util/code-utils.js";
3
- export default class Yt {
4
- constructor(t) {
5
- (this.filters = t), (this.filters = t);
6
- }
7
- Bl(t) {
8
- let r = !0;
9
- for (let e = 0; e < this.filters.length; e++) {
10
- const o = this.filters[e];
11
- let s = !1;
12
- for (let r = 0; r < o.length; r++)
13
- if (o[r].Bl(t)) {
14
- s = !0;
15
- break;
16
- }
17
- if (!s) {
18
- r = !1;
19
- break;
20
- }
21
- }
22
- return r;
23
- }
24
- static fromJson(t) {
25
- if (null == t || !p(t)) return null;
26
- const r = [];
27
- for (let e = 0; e < t.length; e++) {
28
- const o = [],
29
- s = t[e];
30
- for (let t = 0; t < s.length; t++) o.push(sr.fromJson(s[t]));
31
- r.push(o);
32
- }
33
- return new Yt(r);
34
- }
35
- ss() {
36
- const t = [];
37
- for (let r = 0; r < this.filters.length; r++) {
38
- const e = this.filters[r],
39
- o = [];
40
- for (let t = 0; t < e.length; t++) o.push(e[t].ss());
41
- t.push(o);
42
- }
43
- return t;
44
- }
45
- static Yn(t) {
46
- const r = [];
47
- for (let e = 0; e < t.length; e++) {
48
- const o = [],
49
- s = t[e];
50
- for (let t = 0; t < s.length; t++) o.push(sr.Yn(s[t]));
51
- r.push(o);
52
- }
53
- return new Yt(r);
54
- }
55
- }
1
+ import sr from"./filter.js";import{isArray as p}from"../../util/code-utils.js";export default class Yt{constructor(t){this.filters=t,this.filters=t}Bl(t){let r=!0;for(let e=0;e<this.filters.length;e++){const o=this.filters[e];let s=!1;for(let r=0;r<o.length;r++)if(o[r].Bl(t)){s=!0;break}if(!s){r=!1;break}}return r}static fromJson(t){if(null==t||!p(t))return null;const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(sr.fromJson(s[t]));r.push(o)}return new Yt(r)}ss(){const t=[];for(let r=0;r<this.filters.length;r++){const e=this.filters[r],o=[];for(let t=0;t<e.length;t++)o.push(e[t].ss());t.push(o)}return t}static Yn(t){const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(sr.Yn(s[t]));r.push(o)}return new Yt(r)}}
@@ -1,102 +1 @@
1
- import { isDate as Nt } from "../../util/code-utils.js";
2
- import {
3
- convertMsToSeconds as h,
4
- dateFromUnixTimestamp as l,
5
- secondsAgo as ts,
6
- secondsInTheFuture as es,
7
- } from "../../util/date-utils.js";
8
- export default class sr {
9
- constructor(t, s, e, i) {
10
- (this.Tl = t),
11
- (this.Al = s),
12
- (this.comparator = e),
13
- (this._l = i),
14
- (this.Tl = t),
15
- (this.Al = s),
16
- (this.comparator = e),
17
- (this._l = i),
18
- this.Al === sr.Rl.Ml &&
19
- this.comparator !== sr.Il.Ll &&
20
- this.comparator !== sr.Il.Ol &&
21
- this.comparator !== sr.Il.Ul &&
22
- this.comparator !== sr.Il.Ql &&
23
- (this._l = l(this._l));
24
- }
25
- Bl(t) {
26
- let s = null;
27
- switch ((null != t && (s = t[this.Tl]), this.comparator)) {
28
- case sr.Il.Xl:
29
- return null != s && s.valueOf() === this._l.valueOf();
30
- case sr.Il.Fl:
31
- return null == s || s.valueOf() !== this._l.valueOf();
32
- case sr.Il.Kl:
33
- return null != s && typeof s == typeof this._l && s > this._l;
34
- case sr.Il.Ll:
35
- return this.Al === sr.Rl.Ml
36
- ? null != s && Nt(s) && ts(s) <= this._l.valueOf()
37
- : null != s && typeof s == typeof this._l && s >= this._l;
38
- case sr.Il.Pl:
39
- return null != s && typeof s == typeof this._l && s < this._l;
40
- case sr.Il.Ol:
41
- return this.Al === sr.Rl.Ml
42
- ? null != s && Nt(s) && ts(s) >= this._l.valueOf()
43
- : null != s && typeof s == typeof this._l && s <= this._l;
44
- case sr.Il.Yl:
45
- return (
46
- null != s &&
47
- "string" == typeof s &&
48
- typeof s == typeof this._l &&
49
- null != s.match(this._l)
50
- );
51
- case sr.Il.Zl:
52
- return null != s;
53
- case sr.Il.$l:
54
- return null == s;
55
- case sr.Il.Ul:
56
- return null != s && Nt(s) && es(s) < this._l;
57
- case sr.Il.Ql:
58
- return null != s && Nt(s) && es(s) > this._l;
59
- case sr.Il.Eu:
60
- return (
61
- null == s ||
62
- typeof s != typeof this._l ||
63
- "string" != typeof s ||
64
- null == s.match(this._l)
65
- );
66
- }
67
- return !1;
68
- }
69
- static fromJson(t) {
70
- return new sr(
71
- t.property_key,
72
- t.property_type,
73
- t.comparator,
74
- t.property_value,
75
- );
76
- }
77
- ss() {
78
- let t = this._l;
79
- return (
80
- Nt(this._l) && (t = h(t.valueOf())),
81
- { k: this.Tl, t: this.Al, c: this.comparator, v: t }
82
- );
83
- }
84
- static Yn(t) {
85
- return new sr(t.k, t.t, t.c, t.v);
86
- }
87
- }
88
- (sr.Rl = { Tu: "boolean", _u: "number", Nu: "string", Ml: "date" }),
89
- (sr.Il = {
90
- Xl: 1,
91
- Fl: 2,
92
- Kl: 3,
93
- Ll: 4,
94
- Pl: 5,
95
- Ol: 6,
96
- Yl: 10,
97
- Zl: 11,
98
- $l: 12,
99
- Ul: 15,
100
- Ql: 16,
101
- Eu: 17,
102
- });
1
+ import{isDate as yt}from"../../util/code-utils.js";import{convertMsToSeconds as h,dateFromUnixTimestamp as l,secondsAgo as ts,secondsInTheFuture as es}from"../../util/date-utils.js";export default class sr{constructor(t,s,e,i){this.Tl=t,this.Al=s,this.comparator=e,this._l=i,this.Tl=t,this.Al=s,this.comparator=e,this._l=i,this.Al===sr.Rl.Ml&&this.comparator!==sr.Il.Ll&&this.comparator!==sr.Il.Ol&&this.comparator!==sr.Il.Ul&&this.comparator!==sr.Il.Ql&&(this._l=l(this._l))}Bl(t){let s=null;switch(null!=t&&(s=t[this.Tl]),this.comparator){case sr.Il.Xl:return null!=s&&s.valueOf()===this._l.valueOf();case sr.Il.Fl:return null==s||s.valueOf()!==this._l.valueOf();case sr.Il.Kl:return null!=s&&typeof s==typeof this._l&&s>this._l;case sr.Il.Ll:return this.Al===sr.Rl.Ml?null!=s&&yt(s)&&ts(s)<=this._l.valueOf():null!=s&&typeof s==typeof this._l&&s>=this._l;case sr.Il.Pl:return null!=s&&typeof s==typeof this._l&&s<this._l;case sr.Il.Ol:return this.Al===sr.Rl.Ml?null!=s&&yt(s)&&ts(s)>=this._l.valueOf():null!=s&&typeof s==typeof this._l&&s<=this._l;case sr.Il.Yl:return null!=s&&"string"==typeof s&&typeof s==typeof this._l&&null!=s.match(this._l);case sr.Il.Zl:return null!=s;case sr.Il.$l:return null==s;case sr.Il.Ul:return null!=s&&yt(s)&&es(s)<this._l;case sr.Il.Ql:return null!=s&&yt(s)&&es(s)>this._l;case sr.Il.Eu:return null==s||typeof s!=typeof this._l||"string"!=typeof s||null==s.match(this._l)}return!1}static fromJson(t){return new sr(t.property_key,t.property_type,t.comparator,t.property_value)}ss(){let t=this._l;return yt(this._l)&&(t=h(t.valueOf())),{k:this.Tl,t:this.Al,c:this.comparator,v:t}}static Yn(t){return new sr(t.k,t.t,t.c,t.v)}}sr.Rl={_u:"boolean",Hu:"number",Iu:"string",Ml:"date"},sr.Il={Xl:1,Fl:2,Kl:3,Ll:4,Pl:5,Ol:6,Yl:10,Zl:11,$l:12,Ul:15,Ql:16,Eu:17};
@@ -1,25 +1 @@
1
- import ri from "./trigger-condition.js";
2
- export default class si {
3
- constructor(t, i) {
4
- (this.xu = t), (this.zu = i), (this.xu = t), (this.zu = i);
5
- }
6
- Bl(t) {
7
- if (null == this.xu) return !1;
8
- const i = ri.Bu(t[0], this.xu);
9
- if (!i) return !1;
10
- let r = null == this.zu || 0 === this.zu.length;
11
- if (null != this.zu)
12
- for (let i = 0; i < this.zu.length; i++)
13
- if (this.zu[i] === t[1]) {
14
- r = !0;
15
- break;
16
- }
17
- return i && r;
18
- }
19
- static fromJson(t) {
20
- return new si(t ? t.id : null, t ? t.buttons : null);
21
- }
22
- ss() {
23
- return this.xu;
24
- }
25
- }
1
+ import ri from"./trigger-condition.js";export default class si{constructor(t,i){this.xu=t,this.zu=i,this.xu=t,this.zu=i}Bl(t){if(null==this.xu)return!1;const i=ri.Bu(t[0],this.xu);if(!i)return!1;let r=null==this.zu||0===this.zu.length;if(null!=this.zu)for(let i=0;i<this.zu.length;i++)if(this.zu[i]===t[1]){r=!0;break}return i&&r}static fromJson(t){return new si(t?t.id:null,t?t.buttons:null)}ss(){return this.xu}}
@@ -1,14 +1 @@
1
- export default class rs {
2
- constructor(t) {
3
- (this.productId = t), (this.productId = t);
4
- }
5
- Bl(t) {
6
- return null == this.productId || t[0] === this.productId;
7
- }
8
- static fromJson(t) {
9
- return new rs(t ? t.product_id : null);
10
- }
11
- ss() {
12
- return this.productId;
13
- }
14
- }
1
+ export default class rs{constructor(t){this.productId=t,this.productId=t}Bl(t){return null==this.productId||t[0]===this.productId}static fromJson(t){return new rs(t?t.product_id:null)}ss(){return this.productId}}
@@ -1,21 +1 @@
1
- import Yt from "./filter-set.js";
2
- export default class is {
3
- constructor(t, s) {
4
- (this.productId = t), (this.Jl = s), (this.productId = t), (this.Jl = s);
5
- }
6
- Bl(t) {
7
- if (null == this.productId || null == this.Jl) return !1;
8
- const s = t[0],
9
- i = t[1];
10
- return s === this.productId && this.Jl.Bl(i);
11
- }
12
- static fromJson(t) {
13
- return new is(
14
- t ? t.product_id : null,
15
- t ? Yt.fromJson(t.property_filters) : null,
16
- );
17
- }
18
- ss() {
19
- return { id: this.productId, pf: this.Jl ? this.Jl.ss() : null };
20
- }
21
- }
1
+ import Yt from"./filter-set.js";export default class is{constructor(t,s){this.productId=t,this.Jl=s,this.productId=t,this.Jl=s}Bl(t){if(null==this.productId||null==this.Jl)return!1;const s=t[0],i=t[1];return s===this.productId&&this.Jl.Bl(i)}static fromJson(t){return new is(t?t.product_id:null,t?Yt.fromJson(t.property_filters):null)}ss(){return{id:this.productId,pf:this.Jl?this.Jl.ss():null}}}
@@ -1,15 +1 @@
1
- import ri from "./trigger-condition.js";
2
- export default class lr {
3
- constructor(t) {
4
- (this.xu = t), (this.xu = t);
5
- }
6
- Bl(t) {
7
- return null == this.xu || ri.Bu(t[0], this.xu);
8
- }
9
- static fromJson(t) {
10
- return new lr(t ? t.campaign_id : null);
11
- }
12
- ss() {
13
- return this.xu;
14
- }
15
- }
1
+ import ri from"./trigger-condition.js";export default class lr{constructor(t){this.xu=t,this.xu=t}Bl(t){return null==this.xu||ri.Bu(t[0],this.xu)}static fromJson(t){return new lr(t?t.campaign_id:null)}ss(){return this.xu}}