@braze/web-sdk 6.7.1 → 6.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.
- package/index.d.ts +74 -27
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +2 -2
- package/shared-lib/event-types.js +13 -13
- package/shared-lib/indexed-db-adapter.js +3 -3
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +8 -8
- package/src/Banner/log-banner-impressions.js +20 -11
- package/src/ContentCards/content-cards-provider-factory.js +13 -11
- package/src/ContentCards/content-cards-provider.js +4 -4
- package/src/ContentCards/get-cached-content-cards.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +2 -2
- package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
- package/src/ContentCards/ui/show-content-cards.js +3 -3
- package/src/Core/change-user.js +2 -2
- package/src/Core/index.js +1 -0
- package/src/Core/log-ecommerce-event.js +29 -0
- package/src/Core/log-purchase.js +17 -192
- package/src/Core/open-session.js +6 -6
- package/src/Core/set-sdk-authentication-signature.js +1 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/DUST/dust-connection-core.js +1 -0
- package/src/DUST/dust-provider-factory.js +10 -10
- package/src/DUST/dust-provider.js +181 -158
- package/src/DUST/dust-shared-worker-code.js +1 -1
- package/src/DUST/dust-shared-worker-impl.js +93 -100
- package/src/DUST/dust-worker-bridge.js +27 -27
- package/src/DUST/subscribe-to-dust.js +7 -7
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
- package/src/InAppMessage/display/modal-utils.js +2 -2
- package/src/InAppMessage/in-app-message-manager.js +64 -64
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +7 -7
- package/src/InAppMessage/models/html-message.js +1 -1
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +22 -22
- package/src/InAppMessage/models/modal-message.js +5 -5
- package/src/InAppMessage/models/slide-up-message.js +6 -6
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +20 -20
- package/src/Push/push-manager-factory.js +2 -2
- package/src/Push/push-manager.js +8 -8
- package/src/Push/utils/push-utils.js +6 -6
- package/src/User/user-manager.js +5 -5
- package/src/User/user.js +8 -8
- package/src/common/constants.js +1 -0
- package/src/common/content-cards-display.js +2 -2
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/braze-instance.js +21 -21
- package/src/managers/device-manager.js +6 -6
- package/src/managers/network-manager.js +93 -92
- package/src/managers/server-config-manager.js +68 -68
- package/src/managers/session-manager.js +2 -2
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +120 -120
- package/src/managers/subscription-manager.js +1 -1
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +3 -3
- package/src/models/device.js +1 -1
- package/src/models/identifier.js +3 -3
- package/src/models/push-token.js +5 -5
- package/src/models/server-config.js +27 -27
- package/src/request-controller.js +99 -99
- package/src/triggers/models/custom-event-data.js +4 -4
- package/src/triggers/models/custom-event-property-data.js +5 -5
- package/src/triggers/models/filter-set.js +2 -2
- package/src/triggers/models/filter.js +1 -1
- package/src/triggers/models/in-app-message-click-data.js +5 -5
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +2 -2
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +42 -42
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +10 -10
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +30 -30
- package/src/types.js +5 -1
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +5 -5
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +2 -2
- package/src/util/dom-utils.js +2 -2
- package/src/util/ecommerce-event-validation.js +326 -0
- package/src/util/iso-4217-currency-codes.js +176 -0
- package/src/util/net.js +3 -3
- package/src/util/request-header-utils.js +18 -18
- package/src/util/user-agent-parser.js +14 -14
- package/src/util/validation-utils.js +2 -2
- package/src/util/window-utils.js +2 -2
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
|
+
import { isValidIso4217CurrencyCode as or } from "./iso-4217-currency-codes.js";
|
|
3
|
+
import { CoreStrings as R } from "../common/constants.js";
|
|
4
|
+
import { CartUpdatedActions as un } from "../types.js";
|
|
5
|
+
import {
|
|
6
|
+
isArray as g,
|
|
7
|
+
isObject as Ct,
|
|
8
|
+
validateValueIsFromEnum as ta,
|
|
9
|
+
} from "./code-utils.js";
|
|
10
|
+
import {
|
|
11
|
+
validateCustomProperties as nt,
|
|
12
|
+
validateCustomString as mt,
|
|
13
|
+
} from "./validation-utils.js";
|
|
14
|
+
const ln = "log eCommerce event";
|
|
15
|
+
function dn(n, t, e) {
|
|
16
|
+
if (null == n) {
|
|
17
|
+
if (!e) return;
|
|
18
|
+
return E.error(`Cannot ${ln} because ${t} must be a non-empty string.`), !1;
|
|
19
|
+
}
|
|
20
|
+
return "string" != typeof n || (e && n.length <= 0)
|
|
21
|
+
? (E.error(
|
|
22
|
+
`Cannot ${ln} because ${t} must be a string${
|
|
23
|
+
e ? "" : " when provided"
|
|
24
|
+
}.`,
|
|
25
|
+
),
|
|
26
|
+
!1)
|
|
27
|
+
: n.length > 255
|
|
28
|
+
? (E.error(`Cannot ${ln} because ${t} must be at most 255 characters.`), !1)
|
|
29
|
+
: !!mt(n, ln, t) && n;
|
|
30
|
+
}
|
|
31
|
+
function mn(n, t) {
|
|
32
|
+
return "number" != typeof n || isNaN(n) || !isFinite(n)
|
|
33
|
+
? (E.error(`Cannot ${ln} because ${t} must be a finite number.`), !1)
|
|
34
|
+
: n;
|
|
35
|
+
}
|
|
36
|
+
function pn(n, t) {
|
|
37
|
+
const e = mn(n, t);
|
|
38
|
+
return (
|
|
39
|
+
!1 !== e &&
|
|
40
|
+
(e < 0 ? (E.error(`Cannot ${ln} because ${t} must be at least 0.`), !1) : e)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const bn = /^[A-Za-z0-9\-_.,:;!?@#%&*()+={}[\]|\\/'`~^<>]+$/;
|
|
44
|
+
function _n(n, t) {
|
|
45
|
+
return 0 === n.length || n.length > 255
|
|
46
|
+
? (E.error(
|
|
47
|
+
`Cannot ${ln} because each ${t} key must be between 1 and 255 characters.`,
|
|
48
|
+
),
|
|
49
|
+
!1)
|
|
50
|
+
: "$" === n.charAt(0)
|
|
51
|
+
? (E.error(`Cannot ${ln} because ${t} keys cannot begin with "$".`), !1)
|
|
52
|
+
: !!bn.test(n) ||
|
|
53
|
+
(E.error(
|
|
54
|
+
`Cannot ${ln} because ${t} key "${n}" contains invalid characters.`,
|
|
55
|
+
),
|
|
56
|
+
!1);
|
|
57
|
+
}
|
|
58
|
+
function $n(n, t, e) {
|
|
59
|
+
if (e > 50)
|
|
60
|
+
return E.error(`Cannot ${ln} because ${t} is nested too deeply.`), !1;
|
|
61
|
+
if (null == n || "object" != typeof n) return !0;
|
|
62
|
+
if (g(n)) {
|
|
63
|
+
const r = n;
|
|
64
|
+
for (let n = 0; n < r.length; n++) {
|
|
65
|
+
const u = r[n];
|
|
66
|
+
if ("string" == typeof u) {
|
|
67
|
+
if (u.length > 255)
|
|
68
|
+
return (
|
|
69
|
+
E.error(
|
|
70
|
+
`Cannot ${ln} because a ${t} string value exceeds 255 characters.`,
|
|
71
|
+
),
|
|
72
|
+
!1
|
|
73
|
+
);
|
|
74
|
+
} else if (!$n(u, t, e + 1)) return !1;
|
|
75
|
+
}
|
|
76
|
+
return !0;
|
|
77
|
+
}
|
|
78
|
+
if (!Ct(n)) return !0;
|
|
79
|
+
const r = n;
|
|
80
|
+
for (const n in r) {
|
|
81
|
+
if (!Object.prototype.hasOwnProperty.call(r, n)) continue;
|
|
82
|
+
if (!_n(n, t)) return !1;
|
|
83
|
+
const u = r[n];
|
|
84
|
+
if ("string" == typeof u) {
|
|
85
|
+
if (u.length > 255)
|
|
86
|
+
return (
|
|
87
|
+
E.error(
|
|
88
|
+
`Cannot ${ln} because a ${t} string value exceeds 255 characters.`,
|
|
89
|
+
),
|
|
90
|
+
!1
|
|
91
|
+
);
|
|
92
|
+
} else if (null != u && "object" == typeof u && !$n(u, t, e + 1)) return !1;
|
|
93
|
+
}
|
|
94
|
+
return !0;
|
|
95
|
+
}
|
|
96
|
+
function vn(n, t) {
|
|
97
|
+
if (!g(n))
|
|
98
|
+
return (
|
|
99
|
+
E.error(`Cannot ${ln} because ${t} must be an array of strings.`), !1
|
|
100
|
+
);
|
|
101
|
+
for (const e of n) if (!1 === dn(e, t, !0)) return !1;
|
|
102
|
+
return !0;
|
|
103
|
+
}
|
|
104
|
+
function yn(n, t) {
|
|
105
|
+
if (void 0 === n) return;
|
|
106
|
+
const [e, r] = nt(null != n ? n : {}, R.QE, "metadata", ln, t);
|
|
107
|
+
return !!e && !(null != r && !$n(r, t, 0)) && r;
|
|
108
|
+
}
|
|
109
|
+
function gn(n) {
|
|
110
|
+
if (null == n || "object" != typeof n || g(n))
|
|
111
|
+
return (
|
|
112
|
+
E.error(`Cannot ${ln} because each product must be an object.`), null
|
|
113
|
+
);
|
|
114
|
+
const t = n,
|
|
115
|
+
e = dn(t.product_id, "product_id", !0),
|
|
116
|
+
r = dn(t.product_name, "product_name", !0),
|
|
117
|
+
u = dn(t.variant_id, "variant_id", !0),
|
|
118
|
+
o = (function (n) {
|
|
119
|
+
if (!1 === mn(n, "product quantity")) return !1;
|
|
120
|
+
const t = parseInt(n.toString(), 10);
|
|
121
|
+
return t !== n
|
|
122
|
+
? (E.error(`Cannot ${ln} because product quantity must be an integer.`),
|
|
123
|
+
!1)
|
|
124
|
+
: n < 0 || n > Number.MAX_SAFE_INTEGER
|
|
125
|
+
? (E.error(
|
|
126
|
+
`Cannot ${ln} because product quantity must be between 0 and Number.MAX_SAFE_INTEGER.`,
|
|
127
|
+
),
|
|
128
|
+
!1)
|
|
129
|
+
: t;
|
|
130
|
+
})(t.quantity),
|
|
131
|
+
c = pn(t.price, "product price");
|
|
132
|
+
if (!1 === e || !1 === r || !1 === u || !1 === o || !1 === c) return null;
|
|
133
|
+
const i = dn(t.image_url, "image_url", !1),
|
|
134
|
+
a = dn(t.product_url, "product_url", !1);
|
|
135
|
+
if (!1 === i || !1 === a) return null;
|
|
136
|
+
const s = yn(t.metadata, "eCommerce product metadata");
|
|
137
|
+
if (!1 === s) return null;
|
|
138
|
+
const l = {
|
|
139
|
+
product_id: e,
|
|
140
|
+
product_name: r,
|
|
141
|
+
variant_id: u,
|
|
142
|
+
quantity: o,
|
|
143
|
+
price: c,
|
|
144
|
+
};
|
|
145
|
+
return (
|
|
146
|
+
null != i && (l.image_url = i),
|
|
147
|
+
null != a && (l.product_url = a),
|
|
148
|
+
null != s && (l.metadata = s),
|
|
149
|
+
l
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
function Cn(n) {
|
|
153
|
+
if (null == n || !g(n))
|
|
154
|
+
return E.error(`Cannot ${ln} because products must be an array.`), null;
|
|
155
|
+
const t = [],
|
|
156
|
+
e = n;
|
|
157
|
+
for (const n of e) {
|
|
158
|
+
const e = gn(n);
|
|
159
|
+
if (null == e) return null;
|
|
160
|
+
t.push(e);
|
|
161
|
+
}
|
|
162
|
+
return t;
|
|
163
|
+
}
|
|
164
|
+
function jn(n) {
|
|
165
|
+
const t = (function (n) {
|
|
166
|
+
if (null == n || "string" != typeof n || n.length <= 0)
|
|
167
|
+
return (
|
|
168
|
+
E.error(`Cannot ${ln} because currency must be a non-empty string.`),
|
|
169
|
+
!1
|
|
170
|
+
);
|
|
171
|
+
const t = n.toUpperCase();
|
|
172
|
+
return or(t)
|
|
173
|
+
? t
|
|
174
|
+
: (E.error(
|
|
175
|
+
`${R.QE} requires a valid ISO 4217 currency code, got "${n}". Ignoring event.`,
|
|
176
|
+
),
|
|
177
|
+
!1);
|
|
178
|
+
})(n.currency),
|
|
179
|
+
e = dn(n.source, "source", !0);
|
|
180
|
+
return !1 === t || !1 === e ? null : { currency: t, source: e };
|
|
181
|
+
}
|
|
182
|
+
function hn(n, t) {
|
|
183
|
+
const e = yn(t, "eCommerce event metadata");
|
|
184
|
+
return !1 !== e && (null != e && (n.metadata = e), !0);
|
|
185
|
+
}
|
|
186
|
+
function wn(n, t) {
|
|
187
|
+
const e = dn(n.cart_id, "cart_id", !0),
|
|
188
|
+
r =
|
|
189
|
+
void 0 === n.action
|
|
190
|
+
? un.REPLACE
|
|
191
|
+
: ((u = n.action),
|
|
192
|
+
!!ta(
|
|
193
|
+
un,
|
|
194
|
+
u,
|
|
195
|
+
`Cannot ${ln} because action is invalid.`,
|
|
196
|
+
"CartUpdatedActions",
|
|
197
|
+
) && u);
|
|
198
|
+
var u;
|
|
199
|
+
const o = Cn(n.products);
|
|
200
|
+
if (!1 === e || !1 === r || null == o) return null;
|
|
201
|
+
const c = r === un.Ed || r === un.Ad,
|
|
202
|
+
i =
|
|
203
|
+
void 0 === n.total_value && c ? void 0 : pn(n.total_value, "total_value");
|
|
204
|
+
if (!1 === i) return null;
|
|
205
|
+
const a = {
|
|
206
|
+
cart_id: e,
|
|
207
|
+
action: r,
|
|
208
|
+
currency: t.currency,
|
|
209
|
+
products: o,
|
|
210
|
+
source: t.source,
|
|
211
|
+
};
|
|
212
|
+
return void 0 !== i && (a.total_value = i), hn(a, n.metadata) ? a : null;
|
|
213
|
+
}
|
|
214
|
+
export function sanitizeEcommerceEvent(n) {
|
|
215
|
+
const t = n.properties;
|
|
216
|
+
if (null == t || "object" != typeof t || g(t))
|
|
217
|
+
return E.error(`${R.QE} requires a properties object.`), null;
|
|
218
|
+
const e = t,
|
|
219
|
+
r = jn(e);
|
|
220
|
+
if (null == r) return null;
|
|
221
|
+
switch (n.name) {
|
|
222
|
+
case "ecommerce.product_viewed":
|
|
223
|
+
return (function (n, t) {
|
|
224
|
+
const e = n.metadata;
|
|
225
|
+
if (null != e && "object" == typeof e && !g(e)) {
|
|
226
|
+
const n = e;
|
|
227
|
+
if (void 0 !== n.type && !vn(n.type, "metadata.type")) return null;
|
|
228
|
+
}
|
|
229
|
+
const r = dn(n.product_id, "product_id", !0),
|
|
230
|
+
u = dn(n.product_name, "product_name", !0),
|
|
231
|
+
o = dn(n.variant_id, "variant_id", !0),
|
|
232
|
+
c = pn(n.price, "price"),
|
|
233
|
+
i = dn(n.image_url, "image_url", !1),
|
|
234
|
+
a = dn(n.product_url, "product_url", !1);
|
|
235
|
+
if (
|
|
236
|
+
!1 === r ||
|
|
237
|
+
!1 === u ||
|
|
238
|
+
!1 === o ||
|
|
239
|
+
!1 === c ||
|
|
240
|
+
!1 === i ||
|
|
241
|
+
!1 === a
|
|
242
|
+
)
|
|
243
|
+
return null;
|
|
244
|
+
const s = {
|
|
245
|
+
product_id: r,
|
|
246
|
+
product_name: u,
|
|
247
|
+
variant_id: o,
|
|
248
|
+
price: c,
|
|
249
|
+
currency: t.currency,
|
|
250
|
+
source: t.source,
|
|
251
|
+
};
|
|
252
|
+
return (
|
|
253
|
+
null != i && (s.image_url = i),
|
|
254
|
+
null != a && (s.product_url = a),
|
|
255
|
+
hn(s, e) ? s : null
|
|
256
|
+
);
|
|
257
|
+
})(e, r);
|
|
258
|
+
case "ecommerce.cart_updated":
|
|
259
|
+
return wn(e, r);
|
|
260
|
+
case "ecommerce.checkout_started":
|
|
261
|
+
return (function (n, t) {
|
|
262
|
+
const e = dn(n.checkout_id, "checkout_id", !0),
|
|
263
|
+
r = pn(n.total_value, "total_value"),
|
|
264
|
+
u = Cn(n.products),
|
|
265
|
+
o = dn(n.cart_id, "cart_id", !1);
|
|
266
|
+
if (!1 === e || !1 === r || null == u || !1 === o) return null;
|
|
267
|
+
const c = {
|
|
268
|
+
checkout_id: e,
|
|
269
|
+
total_value: r,
|
|
270
|
+
currency: t.currency,
|
|
271
|
+
products: u,
|
|
272
|
+
source: t.source,
|
|
273
|
+
};
|
|
274
|
+
return null != o && (c.cart_id = o), hn(c, n.metadata) ? c : null;
|
|
275
|
+
})(e, r);
|
|
276
|
+
case "ecommerce.order_placed":
|
|
277
|
+
return (function (n, t) {
|
|
278
|
+
const e = n.metadata;
|
|
279
|
+
if (null != e && "object" == typeof e && !g(e)) {
|
|
280
|
+
const n = e;
|
|
281
|
+
if (void 0 !== n.tags && !vn(n.tags, "metadata.tags")) return null;
|
|
282
|
+
if (
|
|
283
|
+
void 0 !== n.payment_gateway_names &&
|
|
284
|
+
!vn(n.payment_gateway_names, "metadata.payment_gateway_names")
|
|
285
|
+
)
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
const r = dn(n.order_id, "order_id", !0),
|
|
289
|
+
u = pn(n.total_value, "total_value"),
|
|
290
|
+
o = Cn(n.products),
|
|
291
|
+
c = dn(n.cart_id, "cart_id", !1);
|
|
292
|
+
if (!1 === r || !1 === u || null == o || !1 === c) return null;
|
|
293
|
+
const i = {
|
|
294
|
+
order_id: r,
|
|
295
|
+
total_value: u,
|
|
296
|
+
currency: t.currency,
|
|
297
|
+
products: o,
|
|
298
|
+
source: t.source,
|
|
299
|
+
};
|
|
300
|
+
if ((null != c && (i.cart_id = c), null != n.total_discounts)) {
|
|
301
|
+
const t = pn(n.total_discounts, "total_discounts");
|
|
302
|
+
if (!1 === t) return null;
|
|
303
|
+
i.total_discounts = t;
|
|
304
|
+
}
|
|
305
|
+
if (void 0 !== n.discounts) {
|
|
306
|
+
const [t, e] = nt(
|
|
307
|
+
{ discounts: n.discounts },
|
|
308
|
+
R.QE,
|
|
309
|
+
"discounts",
|
|
310
|
+
ln,
|
|
311
|
+
"eCommerce order discounts",
|
|
312
|
+
);
|
|
313
|
+
if (!t || null == e) return null;
|
|
314
|
+
i.discounts = e.discounts;
|
|
315
|
+
}
|
|
316
|
+
return hn(i, n.metadata) ? i : null;
|
|
317
|
+
})(e, r);
|
|
318
|
+
default:
|
|
319
|
+
return (
|
|
320
|
+
E.error(
|
|
321
|
+
"logEcommerceEvent received an unknown event name. Ignoring event.",
|
|
322
|
+
),
|
|
323
|
+
null
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const DD = [
|
|
2
|
+
"AED",
|
|
3
|
+
"AFN",
|
|
4
|
+
"ALL",
|
|
5
|
+
"AMD",
|
|
6
|
+
"ANG",
|
|
7
|
+
"AOA",
|
|
8
|
+
"ARS",
|
|
9
|
+
"AUD",
|
|
10
|
+
"AWG",
|
|
11
|
+
"AZN",
|
|
12
|
+
"BAM",
|
|
13
|
+
"BBD",
|
|
14
|
+
"BDT",
|
|
15
|
+
"BGN",
|
|
16
|
+
"BHD",
|
|
17
|
+
"BIF",
|
|
18
|
+
"BMD",
|
|
19
|
+
"BND",
|
|
20
|
+
"BOB",
|
|
21
|
+
"BRL",
|
|
22
|
+
"BSD",
|
|
23
|
+
"BTC",
|
|
24
|
+
"BTN",
|
|
25
|
+
"BWP",
|
|
26
|
+
"BYR",
|
|
27
|
+
"BZD",
|
|
28
|
+
"CAD",
|
|
29
|
+
"CDF",
|
|
30
|
+
"CHF",
|
|
31
|
+
"CLF",
|
|
32
|
+
"CLP",
|
|
33
|
+
"CNY",
|
|
34
|
+
"COP",
|
|
35
|
+
"CRC",
|
|
36
|
+
"CUC",
|
|
37
|
+
"CUP",
|
|
38
|
+
"CVE",
|
|
39
|
+
"CZK",
|
|
40
|
+
"DJF",
|
|
41
|
+
"DKK",
|
|
42
|
+
"DOP",
|
|
43
|
+
"DZD",
|
|
44
|
+
"EEK",
|
|
45
|
+
"EGP",
|
|
46
|
+
"ERN",
|
|
47
|
+
"ETB",
|
|
48
|
+
"EUR",
|
|
49
|
+
"FJD",
|
|
50
|
+
"FKP",
|
|
51
|
+
"GBP",
|
|
52
|
+
"GEL",
|
|
53
|
+
"GGP",
|
|
54
|
+
"GHS",
|
|
55
|
+
"GIP",
|
|
56
|
+
"GMD",
|
|
57
|
+
"GNF",
|
|
58
|
+
"GTQ",
|
|
59
|
+
"GYD",
|
|
60
|
+
"HKD",
|
|
61
|
+
"HNL",
|
|
62
|
+
"HRK",
|
|
63
|
+
"HTG",
|
|
64
|
+
"HUF",
|
|
65
|
+
"IDR",
|
|
66
|
+
"ILS",
|
|
67
|
+
"IMP",
|
|
68
|
+
"INR",
|
|
69
|
+
"IQD",
|
|
70
|
+
"IRR",
|
|
71
|
+
"ISK",
|
|
72
|
+
"JEP",
|
|
73
|
+
"JMD",
|
|
74
|
+
"JOD",
|
|
75
|
+
"JPY",
|
|
76
|
+
"KES",
|
|
77
|
+
"KGS",
|
|
78
|
+
"KHR",
|
|
79
|
+
"KMF",
|
|
80
|
+
"KPW",
|
|
81
|
+
"KRW",
|
|
82
|
+
"KWD",
|
|
83
|
+
"KYD",
|
|
84
|
+
"KZT",
|
|
85
|
+
"LAK",
|
|
86
|
+
"LBP",
|
|
87
|
+
"LKR",
|
|
88
|
+
"LRD",
|
|
89
|
+
"LSL",
|
|
90
|
+
"LTL",
|
|
91
|
+
"LVL",
|
|
92
|
+
"LYD",
|
|
93
|
+
"MAD",
|
|
94
|
+
"MDL",
|
|
95
|
+
"MGA",
|
|
96
|
+
"MKD",
|
|
97
|
+
"MMK",
|
|
98
|
+
"MNT",
|
|
99
|
+
"MOP",
|
|
100
|
+
"MRO",
|
|
101
|
+
"MTL",
|
|
102
|
+
"MUR",
|
|
103
|
+
"MVR",
|
|
104
|
+
"MWK",
|
|
105
|
+
"MXN",
|
|
106
|
+
"MYR",
|
|
107
|
+
"MZN",
|
|
108
|
+
"NAD",
|
|
109
|
+
"NGN",
|
|
110
|
+
"NIO",
|
|
111
|
+
"NOK",
|
|
112
|
+
"NPR",
|
|
113
|
+
"NZD",
|
|
114
|
+
"OMR",
|
|
115
|
+
"PAB",
|
|
116
|
+
"PEN",
|
|
117
|
+
"PGK",
|
|
118
|
+
"PHP",
|
|
119
|
+
"PKR",
|
|
120
|
+
"PLN",
|
|
121
|
+
"PYG",
|
|
122
|
+
"QAR",
|
|
123
|
+
"RON",
|
|
124
|
+
"RSD",
|
|
125
|
+
"RUB",
|
|
126
|
+
"RWF",
|
|
127
|
+
"SAR",
|
|
128
|
+
"SBD",
|
|
129
|
+
"SCR",
|
|
130
|
+
"SDG",
|
|
131
|
+
"SEK",
|
|
132
|
+
"SGD",
|
|
133
|
+
"SHP",
|
|
134
|
+
"SLL",
|
|
135
|
+
"SOS",
|
|
136
|
+
"SRD",
|
|
137
|
+
"STD",
|
|
138
|
+
"SVC",
|
|
139
|
+
"SYP",
|
|
140
|
+
"SZL",
|
|
141
|
+
"THB",
|
|
142
|
+
"TJS",
|
|
143
|
+
"TMT",
|
|
144
|
+
"TND",
|
|
145
|
+
"TOP",
|
|
146
|
+
"TRY",
|
|
147
|
+
"TTD",
|
|
148
|
+
"TWD",
|
|
149
|
+
"TZS",
|
|
150
|
+
"UAH",
|
|
151
|
+
"UGX",
|
|
152
|
+
"USD",
|
|
153
|
+
"UYU",
|
|
154
|
+
"UZS",
|
|
155
|
+
"VEF",
|
|
156
|
+
"VND",
|
|
157
|
+
"VUV",
|
|
158
|
+
"WST",
|
|
159
|
+
"XAF",
|
|
160
|
+
"XAG",
|
|
161
|
+
"XAU",
|
|
162
|
+
"XCD",
|
|
163
|
+
"XDR",
|
|
164
|
+
"XOF",
|
|
165
|
+
"XPD",
|
|
166
|
+
"XPF",
|
|
167
|
+
"XPT",
|
|
168
|
+
"YER",
|
|
169
|
+
"ZAR",
|
|
170
|
+
"ZMK",
|
|
171
|
+
"ZMW",
|
|
172
|
+
"ZWL",
|
|
173
|
+
];
|
|
174
|
+
export function isValidIso4217CurrencyCode(D) {
|
|
175
|
+
return -1 !== DD.indexOf(D);
|
|
176
|
+
}
|
package/src/util/net.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import Ne from "../models/backend-errors.js";
|
|
3
|
-
import { getErrorMessage as
|
|
3
|
+
import { getErrorMessage as hi } from "./error-utils.js";
|
|
4
4
|
const l = {
|
|
5
5
|
ot: (t) => {
|
|
6
6
|
let e, o;
|
|
@@ -27,7 +27,7 @@ const l = {
|
|
|
27
27
|
o = JSON.parse(e.responseText);
|
|
28
28
|
} catch (o) {
|
|
29
29
|
const n = {
|
|
30
|
-
error: "" === e.responseText ? Ne.
|
|
30
|
+
error: "" === e.responseText ? Ne.Qa : Ne.Za,
|
|
31
31
|
response: e.responseText,
|
|
32
32
|
};
|
|
33
33
|
(0, t.lt)(n, r);
|
|
@@ -51,7 +51,7 @@ const l = {
|
|
|
51
51
|
for (const t of i) e.setRequestHeader(t[0], t[1]);
|
|
52
52
|
e.send(o);
|
|
53
53
|
} catch (t) {
|
|
54
|
-
E.error(`Network request error: ${
|
|
54
|
+
E.error(`Network request error: ${hi(t)}`);
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { REQUEST_ATTEMPT_DEFAULT as
|
|
1
|
+
import { REQUEST_ATTEMPT_DEFAULT as Qe } from "../common/constants.js";
|
|
2
2
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
3
3
|
const h = {
|
|
4
4
|
it: {
|
|
5
|
-
|
|
5
|
+
wn: "data",
|
|
6
6
|
Ji: "content_cards/sync",
|
|
7
7
|
Co: "feature_flags/sync",
|
|
8
|
-
|
|
8
|
+
ta: "template",
|
|
9
9
|
st: "banners/sync",
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
Am: (t) => (null == t ? void 0 : t.Rt(s.Tt.
|
|
11
|
+
xl: (t) => (null == t ? void 0 : t.Rt(s.Tt.ES)),
|
|
12
|
+
Am: (t) => (null == t ? void 0 : t.Rt(s.Tt.SS)),
|
|
13
13
|
Rm: (t, e) => {
|
|
14
|
-
null == t || t.It(s.Tt.
|
|
14
|
+
null == t || t.It(s.Tt.ES, e);
|
|
15
15
|
},
|
|
16
16
|
qm: (t, e) => {
|
|
17
|
-
null == t || t.It(s.Tt.
|
|
17
|
+
null == t || t.It(s.Tt.SS, e);
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
Dl: (t, e) => {
|
|
20
20
|
if (!t || !e) return -1;
|
|
21
|
-
const s = h.
|
|
21
|
+
const s = h.xl(t);
|
|
22
22
|
if (null == s) return -1;
|
|
23
23
|
const n = s[e];
|
|
24
24
|
return null == n || isNaN(n) ? -1 : n;
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
let s =
|
|
26
|
+
kl: (t, e) => {
|
|
27
|
+
let s = Qe;
|
|
28
28
|
if (!t || !e) return s;
|
|
29
29
|
const n = h.Am(t);
|
|
30
|
-
return null == n ? s : ((s = n[e]), null == s || isNaN(s) ?
|
|
30
|
+
return null == n ? s : ((s = n[e]), null == s || isNaN(s) ? Qe : s);
|
|
31
31
|
},
|
|
32
32
|
nt: (t, e, s) => {
|
|
33
33
|
if (!t || !e) return;
|
|
34
|
-
let n = h.
|
|
34
|
+
let n = h.xl(t);
|
|
35
35
|
null == n && (n = {}), (n[e] = s), h.Rm(t, n);
|
|
36
36
|
},
|
|
37
|
-
|
|
37
|
+
yl: (t, e, s) => {
|
|
38
38
|
if (!t || !e) return;
|
|
39
39
|
let n = h.Am(t);
|
|
40
40
|
null == n && (n = {}), (n[e] = s), h.qm(t, n);
|
|
41
41
|
},
|
|
42
42
|
Li: (t, e) => {
|
|
43
|
-
t && e && h.
|
|
43
|
+
t && e && h.yl(t, e, Qe);
|
|
44
44
|
},
|
|
45
|
-
|
|
45
|
+
Ml: (t, e) => {
|
|
46
46
|
if (!t || !e) return;
|
|
47
|
-
const s = h.
|
|
48
|
-
h.
|
|
47
|
+
const s = h.kl(t, e);
|
|
48
|
+
h.yl(t, e, s + 1);
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
export default h;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Ve from "./base-device-parser.js";
|
|
2
|
-
import { Browsers as
|
|
3
|
-
export default class
|
|
2
|
+
import { Browsers as yi, OperatingSystems as so } from "./device-constants.js";
|
|
3
|
+
export default class vi extends Ve {
|
|
4
4
|
constructor() {
|
|
5
|
-
super(), (this.Sd =
|
|
5
|
+
super(), (this.Sd = vi.hf(navigator.userAgent || ""));
|
|
6
6
|
}
|
|
7
7
|
ef() {
|
|
8
8
|
return this.Sd[0] || "Unknown Browser";
|
|
@@ -13,7 +13,7 @@ export default class bi extends Ve {
|
|
|
13
13
|
Fa(r) {
|
|
14
14
|
for (let n = 0; n < r.length; n++) {
|
|
15
15
|
const e = r[n].string;
|
|
16
|
-
let i =
|
|
16
|
+
let i = vi.nf(e, r[n]);
|
|
17
17
|
if (i)
|
|
18
18
|
return (
|
|
19
19
|
i === so.Pg && navigator.maxTouchPoints > 1 && (i = so.co),
|
|
@@ -40,40 +40,40 @@ export default class bi extends Ve {
|
|
|
40
40
|
if (-1 !== r.indexOf("PhilipsTV")) return ["Philips Smart TV", null];
|
|
41
41
|
if (r.match(/\b(Roku)\b/)) return ["Roku", null];
|
|
42
42
|
if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null];
|
|
43
|
-
if (e[1] ===
|
|
44
|
-
if (r.includes(
|
|
43
|
+
if (e[1] === yi.rO) {
|
|
44
|
+
if (r.includes(yi.Sg)) return [yi.Sg, e[2]];
|
|
45
45
|
if (
|
|
46
46
|
((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
|
|
47
47
|
null != n)
|
|
48
48
|
)
|
|
49
49
|
return (
|
|
50
50
|
(n = n.slice(1)),
|
|
51
|
-
(n[0] = n[0].replace("OPR",
|
|
52
|
-
(n[0] = n[0].replace("EdgA",
|
|
53
|
-
"Edg" === n[0] && (n[0] =
|
|
51
|
+
(n[0] = n[0].replace("OPR", yi.oO)),
|
|
52
|
+
(n[0] = n[0].replace("EdgA", yi.eO)),
|
|
53
|
+
"Edg" === n[0] && (n[0] = yi.eO),
|
|
54
54
|
[n[0], n[1]]
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
if (
|
|
58
|
-
e[1] ===
|
|
58
|
+
e[1] === yi.Bg &&
|
|
59
59
|
((n = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != n)
|
|
60
60
|
)
|
|
61
61
|
return (
|
|
62
|
-
(n = n.slice(1)), (n[0] = n[0].replace("EdgiOS",
|
|
62
|
+
(n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", yi.eO)), [n[0], n[1]]
|
|
63
63
|
);
|
|
64
64
|
if (
|
|
65
65
|
((e = e[2] ? [e[1], e[2]] : [null, null]),
|
|
66
|
-
e[0] ===
|
|
66
|
+
e[0] === yi.Bg &&
|
|
67
67
|
null != (n = r.match(/version\/(\.?\d+(\.\d+)*)/i)) &&
|
|
68
68
|
e.splice(1, 1, n[1]),
|
|
69
69
|
null != (n = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) &&
|
|
70
70
|
e.splice(1, 1, n[2]),
|
|
71
|
-
e[0] ===
|
|
71
|
+
e[0] === yi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
|
|
72
72
|
)
|
|
73
73
|
return ["Opera Mini", n[1] || ""];
|
|
74
74
|
if (e[0]) {
|
|
75
75
|
const r = e[0].toLowerCase();
|
|
76
|
-
"crios" === r && (e[0] =
|
|
76
|
+
"crios" === r && (e[0] = yi.rO),
|
|
77
77
|
"tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)),
|
|
78
78
|
"samsungbrowser" === r && (e[0] = "Samsung Browser");
|
|
79
79
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
isObject as Ct,
|
|
5
5
|
keys as D,
|
|
6
6
|
} from "./code-utils.js";
|
|
7
|
-
import { getByteLength as
|
|
7
|
+
import { getByteLength as er } from "./string-utils.js";
|
|
8
8
|
import { logger as E } from "../../shared-lib/index.js";
|
|
9
9
|
import { toValidBackendTimeString as $t } from "./date-utils.js";
|
|
10
10
|
import { BRAZE_ACTIONS as oo } from "./braze-actions.js";
|
|
@@ -102,7 +102,7 @@ export function validateCustomProperties(t, e, r, n, o) {
|
|
|
102
102
|
let i, a;
|
|
103
103
|
e === R.Ku ? ((i = 76800), (a = "75KB")) : ((i = 51200), (a = "50KB"));
|
|
104
104
|
const s = JSON.stringify(t);
|
|
105
|
-
if (
|
|
105
|
+
if (er(s) > i)
|
|
106
106
|
return (
|
|
107
107
|
E.error(
|
|
108
108
|
`Could not ${n} because ${r} was greater than the max size of ${a}.`,
|