@braze/web-sdk 6.10.2 → 6.12.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 +61 -6
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +12 -12
- package/shared-lib/indexed-db-adapter.js +52 -52
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +10 -10
- package/src/Core/logout.js +2 -2
- package/src/DUST/dust-config-store.js +89 -0
- package/src/DUST/dust-connection-core.js +7 -21
- package/src/DUST/dust-message-dedup.js +33 -0
- package/src/DUST/dust-provider.js +367 -397
- package/src/DUST/dust-tab-identity.js +30 -0
- package/src/DUST/index.js +7 -9
- package/src/DUST/subscribe-to-dust.js +5 -5
- package/src/FeatureFlags/feature-flag-factory.js +4 -4
- package/src/FeatureFlags/feature-flag.js +5 -5
- package/src/FeatureFlags/feature-flags-provider-factory.js +8 -1
- package/src/FeatureFlags/feature-flags-provider.js +74 -74
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
- package/src/InAppMessage/constants.js +39 -47
- package/src/InAppMessage/defer-in-app-message.js +2 -2
- package/src/InAppMessage/display/get-animation-effect.js +1 -1
- package/src/InAppMessage/display/html-message-display-utils.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +68 -66
- package/src/InAppMessage/display/modal-utils.js +14 -14
- package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +6 -6
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +101 -80
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/full-screen-message.js +25 -25
- package/src/InAppMessage/models/html-message.js +14 -14
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +100 -98
- package/src/InAppMessage/models/modal-message.js +23 -23
- package/src/InAppMessage/models/slide-up-message.js +29 -29
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +2 -2
- package/src/InAppMessage/ui/show-in-app-message.js +42 -40
- package/src/Push/index.js +1 -0
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +6 -6
- package/src/Push/push-manager.js +228 -185
- package/src/Push/register-push.js +9 -0
- package/src/Push/unregister-push-token-on-server.js +4 -4
- package/src/Push/utils/push-utils.js +16 -16
- package/src/User/user-manager.js +19 -19
- package/src/User/user.js +36 -36
- package/src/common/constants.js +1 -1
- package/src/common/content-cards-display.js +21 -21
- package/src/common/event-logger.js +2 -2
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +5 -5
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +70 -66
- package/src/managers/device-manager.js +12 -12
- package/src/managers/network-manager.js +118 -118
- package/src/managers/server-config-manager.js +84 -84
- package/src/managers/session-manager.js +10 -10
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +138 -136
- 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 +7 -7
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +6 -6
- package/src/models/push-token.js +6 -6
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +91 -91
- package/src/triggers/models/filter.js +58 -58
- package/src/triggers/models/in-app-message-click-data.js +4 -4
- package/src/triggers/models/push-click-data.js +2 -2
- package/src/triggers/models/trigger-condition.js +35 -35
- package/src/triggers/models/trigger.js +37 -37
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +61 -53
- package/src/types.js +1 -1
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +2 -2
- package/src/ui/js/iam-css.js +2 -2
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/component-utils.js +4 -4
- package/src/util/dom-utils.js +5 -5
- package/src/util/ecommerce-event-validation.js +77 -48
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +20 -20
- package/src/util/string-utils.js +5 -0
- package/src/util/user-agent-parser.js +15 -15
- package/src/util/validation-utils.js +9 -9
- package/src/util/window-utils.js +2 -2
- package/src/DUST/dust-shared-worker-code.js +0 -2
- package/src/DUST/dust-shared-worker-impl.js +0 -234
- package/src/DUST/dust-worker-bridge.js +0 -151
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger as b } from "../../shared-lib/index.js";
|
|
2
|
-
import { getErrorMessage as
|
|
2
|
+
import { getErrorMessage as ci } from "./error-utils.js";
|
|
3
3
|
import { decodeBrazeActions as uo } from "./string-utils.js";
|
|
4
4
|
import {
|
|
5
5
|
BRAZE_ACTION_URI_REGEX as to,
|
|
@@ -25,11 +25,11 @@ export const BRAZE_ACTIONS = {
|
|
|
25
25
|
properties: { type: "type", eo: "steps", so: "args" },
|
|
26
26
|
};
|
|
27
27
|
export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
|
|
28
|
-
|
|
28
|
+
Wn: "unknownBrazeAction",
|
|
29
29
|
Nc: "noPushPrompt",
|
|
30
30
|
};
|
|
31
31
|
export const ineligibleBrazeActionURLErrorMessage = (t, o) =>
|
|
32
|
-
t === INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.
|
|
32
|
+
t === INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Wn
|
|
33
33
|
? `${o} contains an unknown braze action type and will not be displayed.`
|
|
34
34
|
: "";
|
|
35
35
|
export function getDecodedBrazeAction(t) {
|
|
@@ -46,7 +46,7 @@ export function getDecodedBrazeAction(t) {
|
|
|
46
46
|
? JSON.parse(e)
|
|
47
47
|
: void b.error(`Failed to decode base64 encoded brazeAction: ${n}`);
|
|
48
48
|
} catch (o) {
|
|
49
|
-
return void b.error(`Failed to process brazeAction URL ${t} : ${
|
|
49
|
+
return void b.error(`Failed to process brazeAction URL ${t} : ${ci(o)}`);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
function po(t, o) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import Si from "./client-hints-parser.js";
|
|
2
|
-
import
|
|
3
|
-
import { Browsers as
|
|
4
|
-
class
|
|
2
|
+
import yi from "./user-agent-parser.js";
|
|
3
|
+
import { Browsers as xi, OperatingSystems as so } from "./device-constants.js";
|
|
4
|
+
class Bi {
|
|
5
5
|
constructor() {
|
|
6
6
|
let t;
|
|
7
7
|
(t =
|
|
8
|
-
navigator.userAgent.toLowerCase().includes(
|
|
8
|
+
navigator.userAgent.toLowerCase().includes(xi.Sg.toLowerCase()) ||
|
|
9
9
|
!navigator.userAgentData
|
|
10
|
-
?
|
|
10
|
+
? yi
|
|
11
11
|
: Si),
|
|
12
12
|
(this.vg = new t()),
|
|
13
13
|
(this.userAgent = navigator.userAgent),
|
|
@@ -23,18 +23,18 @@ class xi {
|
|
|
23
23
|
i.systemLanguage ||
|
|
24
24
|
""
|
|
25
25
|
).toLowerCase()),
|
|
26
|
-
(this.il =
|
|
26
|
+
(this.il = Bi.xg(this.userAgent));
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
return this.browser ===
|
|
28
|
+
mS() {
|
|
29
|
+
return this.browser === xi.Bg;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
qa() {
|
|
32
32
|
return this.OS || null;
|
|
33
33
|
}
|
|
34
34
|
Fa() {
|
|
35
35
|
return this.OS
|
|
36
36
|
? Promise.resolve(this.OS)
|
|
37
|
-
: this.vg.Fa(
|
|
37
|
+
: this.vg.Fa(Bi.Og).then((t) => ((this.OS = t), t));
|
|
38
38
|
}
|
|
39
39
|
static xg(t) {
|
|
40
40
|
t = t.toLowerCase();
|
|
@@ -63,7 +63,7 @@ class xi {
|
|
|
63
63
|
return !1;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
Bi.Og = [
|
|
67
67
|
{ string: navigator.platform, cf: "Win", identity: so.kg },
|
|
68
68
|
{ string: navigator.platform, cf: "Mac", identity: so.Pg },
|
|
69
69
|
{ string: navigator.platform, cf: "BlackBerry", identity: "BlackBerry" },
|
|
@@ -91,5 +91,5 @@ xi.Og = [
|
|
|
91
91
|
{ string: navigator.userAgent, cf: ["Android"], identity: so.Dg },
|
|
92
92
|
{ string: navigator.platform, cf: "Linux", identity: "Linux" },
|
|
93
93
|
];
|
|
94
|
-
const ro = new
|
|
95
|
-
export { ro as default,
|
|
94
|
+
const ro = new Bi();
|
|
95
|
+
export { ro as default, Bi as BrowserDetector };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Browsers as
|
|
3
|
-
export default class Si extends
|
|
1
|
+
import Oe from "./base-device-parser.js";
|
|
2
|
+
import { Browsers as xi } from "./device-constants.js";
|
|
3
|
+
export default class Si extends Oe {
|
|
4
4
|
constructor() {
|
|
5
5
|
if (
|
|
6
6
|
(super(),
|
|
@@ -41,7 +41,7 @@ export default class Si extends Ve {
|
|
|
41
41
|
s = this.userAgentData.brands;
|
|
42
42
|
if (s && s.length)
|
|
43
43
|
for (const r of s) {
|
|
44
|
-
const s = this.Vc(
|
|
44
|
+
const s = this.Vc(xi),
|
|
45
45
|
i = r.brand.match(s);
|
|
46
46
|
if (i && i.length > 0) {
|
|
47
47
|
(t.browser = i[0]), (t.version = r.version);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { addPassiveEventListener as F, buildSvg as
|
|
2
|
-
import { KeyCodes as
|
|
1
|
+
import { addPassiveEventListener as F, buildSvg as oe } from "./dom-utils.js";
|
|
2
|
+
import { KeyCodes as le } from "./key-codes.js";
|
|
3
3
|
export function createCloseButton(t, o, e, r = "ltr") {
|
|
4
4
|
const n = document.createElement("button");
|
|
5
5
|
n.setAttribute("aria-label", t),
|
|
@@ -7,7 +7,7 @@ export function createCloseButton(t, o, e, r = "ltr") {
|
|
|
7
7
|
(n.dir = r),
|
|
8
8
|
F(n, "touchstart"),
|
|
9
9
|
(n.className = "ab-close-button");
|
|
10
|
-
const l =
|
|
10
|
+
const l = oe(
|
|
11
11
|
"0 0 15 15",
|
|
12
12
|
"M15 1.5L13.5 0l-6 6-6-6L0 1.5l6 6-6 6L1.5 15l6-6 6 6 1.5-1.5-6-6 6-6z",
|
|
13
13
|
o,
|
|
@@ -16,7 +16,7 @@ export function createCloseButton(t, o, e, r = "ltr") {
|
|
|
16
16
|
n.appendChild(l),
|
|
17
17
|
l.setAttribute("aria-hidden", "true"),
|
|
18
18
|
n.addEventListener("keydown", (t) => {
|
|
19
|
-
(t.keyCode !==
|
|
19
|
+
(t.keyCode !== le.To && t.keyCode !== le.Lo) ||
|
|
20
20
|
(e(), t.stopPropagation());
|
|
21
21
|
}),
|
|
22
22
|
(n.onclick = (t) => {
|
package/src/util/dom-utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger as b } from "../../shared-lib/index.js";
|
|
2
|
-
import { getErrorMessage as
|
|
2
|
+
import { getErrorMessage as ci } from "./error-utils.js";
|
|
3
3
|
export function _isInView(t, n = !1, e = !1, s = !1) {
|
|
4
4
|
if (null == t) return !1;
|
|
5
5
|
(n = n || !1), (e = e || !1);
|
|
@@ -19,7 +19,7 @@ export function _isInView(t, n = !1, e = !1, s = !1) {
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
export const DOMUtils = { Ic: null, td: _isInView };
|
|
22
|
-
export const DIRECTIONS = {
|
|
22
|
+
export const DIRECTIONS = { Jo: "up", Ko: "down", ie: "left", ne: "right" };
|
|
23
23
|
export function supportsPassive() {
|
|
24
24
|
if (null == DOMUtils.Ic) {
|
|
25
25
|
DOMUtils.Ic = !1;
|
|
@@ -32,7 +32,7 @@ export function supportsPassive() {
|
|
|
32
32
|
window.addEventListener("testPassive", () => {}, t),
|
|
33
33
|
window.removeEventListener("testPassive", () => {}, t);
|
|
34
34
|
} catch (t) {
|
|
35
|
-
b.error(
|
|
35
|
+
b.error(ci(t));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
return DOMUtils.Ic;
|
|
@@ -69,9 +69,9 @@ export function detectSwipe(t, n, e) {
|
|
|
69
69
|
(i = null))
|
|
70
70
|
: Math.abs(u) >= 25 &&
|
|
71
71
|
(((u > 0 &&
|
|
72
|
-
n === DIRECTIONS.
|
|
72
|
+
n === DIRECTIONS.Jo &&
|
|
73
73
|
t.scrollTop === t.scrollHeight - t.offsetHeight) ||
|
|
74
|
-
(u < 0 && n === DIRECTIONS.
|
|
74
|
+
(u < 0 && n === DIRECTIONS.Ko && 0 === t.scrollTop)) &&
|
|
75
75
|
e(o),
|
|
76
76
|
(s = null),
|
|
77
77
|
(i = null));
|
|
@@ -55,7 +55,7 @@ function _n(n, t) {
|
|
|
55
55
|
),
|
|
56
56
|
!1);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function yn(n, t, e) {
|
|
59
59
|
if (e > 50)
|
|
60
60
|
return b.error(`Cannot ${ln} because ${t} is nested too deeply.`), !1;
|
|
61
61
|
if (null == n || "object" != typeof n) return !0;
|
|
@@ -71,7 +71,7 @@ function $n(n, t, e) {
|
|
|
71
71
|
),
|
|
72
72
|
!1
|
|
73
73
|
);
|
|
74
|
-
} else if (
|
|
74
|
+
} else if (!yn(u, t, e + 1)) return !1;
|
|
75
75
|
}
|
|
76
76
|
return !0;
|
|
77
77
|
}
|
|
@@ -89,11 +89,11 @@ function $n(n, t, e) {
|
|
|
89
89
|
),
|
|
90
90
|
!1
|
|
91
91
|
);
|
|
92
|
-
} else if (null != u && "object" == typeof u &&
|
|
92
|
+
} else if (null != u && "object" == typeof u && !yn(u, t, e + 1)) return !1;
|
|
93
93
|
}
|
|
94
94
|
return !0;
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function $n(n, t) {
|
|
97
97
|
if (!g(n))
|
|
98
98
|
return (
|
|
99
99
|
b.error(`Cannot ${ln} because ${t} must be an array of strings.`), !1
|
|
@@ -101,10 +101,10 @@ function vn(n, t) {
|
|
|
101
101
|
for (const e of n) if (!1 === dn(e, t, !0)) return !1;
|
|
102
102
|
return !0;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
if (
|
|
106
|
-
const [e, r] = nt(
|
|
107
|
-
return !!e && !(null != r &&
|
|
104
|
+
function vn(n, t) {
|
|
105
|
+
if (null == n) return;
|
|
106
|
+
const [e, r] = nt(n, R.QE, "metadata", ln, t);
|
|
107
|
+
return !!e && !(null != r && !yn(r, t, 0)) && r;
|
|
108
108
|
}
|
|
109
109
|
function gn(n) {
|
|
110
110
|
if (null == n || "object" != typeof n || g(n))
|
|
@@ -130,10 +130,10 @@ function gn(n) {
|
|
|
130
130
|
})(t.quantity),
|
|
131
131
|
c = pn(t.price, "product price");
|
|
132
132
|
if (!1 === e || !1 === r || !1 === u || !1 === o || !1 === c) return null;
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
if (!1 ===
|
|
136
|
-
const s =
|
|
133
|
+
const a = dn(t.image_url, "image_url", !1),
|
|
134
|
+
i = dn(t.product_url, "product_url", !1);
|
|
135
|
+
if (!1 === a || !1 === i) return null;
|
|
136
|
+
const s = vn(t.metadata, "eCommerce product metadata");
|
|
137
137
|
if (!1 === s) return null;
|
|
138
138
|
const l = {
|
|
139
139
|
product_id: e,
|
|
@@ -143,8 +143,8 @@ function gn(n) {
|
|
|
143
143
|
price: c,
|
|
144
144
|
};
|
|
145
145
|
return (
|
|
146
|
-
null !=
|
|
147
|
-
null !=
|
|
146
|
+
null != a && (l.image_url = a),
|
|
147
|
+
null != i && (l.product_url = i),
|
|
148
148
|
null != s && (l.metadata = s),
|
|
149
149
|
l
|
|
150
150
|
);
|
|
@@ -161,7 +161,7 @@ function Cn(n) {
|
|
|
161
161
|
}
|
|
162
162
|
return t;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function jn(n) {
|
|
165
165
|
const t = (function (n) {
|
|
166
166
|
if (null == n || "string" != typeof n || n.length <= 0)
|
|
167
167
|
return (
|
|
@@ -179,7 +179,7 @@ function hn(n) {
|
|
|
179
179
|
e = dn(n.source, "source", !0);
|
|
180
180
|
return !1 === t || !1 === e ? null : { currency: t, source: e };
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function hn(n, t) {
|
|
183
183
|
const e = ["subtotal_value", "tax", "shipping"];
|
|
184
184
|
for (const r of e)
|
|
185
185
|
if (null != t[r]) {
|
|
@@ -189,14 +189,43 @@ function jn(n, t) {
|
|
|
189
189
|
}
|
|
190
190
|
return !0;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
193
|
-
const e =
|
|
192
|
+
function kn(n, t) {
|
|
193
|
+
const e = vn(t, "eCommerce event metadata");
|
|
194
194
|
return !1 !== e && (null != e && (n.metadata = e), !0);
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function wn(n, t) {
|
|
197
|
+
return null == n || !1 !== dn(n, t, !1);
|
|
198
|
+
}
|
|
199
|
+
function qn(n) {
|
|
200
|
+
if (null == n || "object" != typeof n || g(n)) return !0;
|
|
201
|
+
const t = n;
|
|
202
|
+
if (!wn(t.country, "metadata.country")) return !1;
|
|
203
|
+
if (!wn(t.market_handle, "metadata.market_handle")) return !1;
|
|
204
|
+
if (null == t.presentment_currency) return !0;
|
|
205
|
+
if ("object" != typeof t.presentment_currency || g(t.presentment_currency))
|
|
206
|
+
return (
|
|
207
|
+
b.error(
|
|
208
|
+
`Cannot ${ln} because metadata.presentment_currency must be an object.`,
|
|
209
|
+
),
|
|
210
|
+
!1
|
|
211
|
+
);
|
|
212
|
+
const e = t.presentment_currency;
|
|
213
|
+
if (!wn(e.price, "metadata.presentment_currency.price")) return !1;
|
|
214
|
+
if (null == e.code) return !0;
|
|
215
|
+
const r = dn(e.code, "metadata.presentment_currency.code", !1);
|
|
216
|
+
if ("string" != typeof r) return !1;
|
|
217
|
+
const u = r.toUpperCase();
|
|
218
|
+
return or(u)
|
|
219
|
+
? ((e.code = u), !0)
|
|
220
|
+
: (b.error(
|
|
221
|
+
`${R.QE} requires a valid ISO 4217 currency code, got "${r}". Ignoring event.`,
|
|
222
|
+
),
|
|
223
|
+
!1);
|
|
224
|
+
}
|
|
225
|
+
function En(n, t) {
|
|
197
226
|
const e = dn(n.cart_id, "cart_id", !0),
|
|
198
227
|
r =
|
|
199
|
-
|
|
228
|
+
null == n.action
|
|
200
229
|
? un.REPLACE
|
|
201
230
|
: ((u = n.action),
|
|
202
231
|
!!ta(
|
|
@@ -208,11 +237,10 @@ function kn(n, t) {
|
|
|
208
237
|
var u;
|
|
209
238
|
const o = Cn(n.products);
|
|
210
239
|
if (!1 === e || !1 === r || null == o) return null;
|
|
211
|
-
const c = r === un.Ld || r === un.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const a = {
|
|
240
|
+
const c = r === un.Ld || r === un.Md,
|
|
241
|
+
a = null == n.total_value && c ? void 0 : pn(n.total_value, "total_value");
|
|
242
|
+
if (!1 === a) return null;
|
|
243
|
+
const i = {
|
|
216
244
|
cart_id: e,
|
|
217
245
|
action: r,
|
|
218
246
|
currency: t.currency,
|
|
@@ -220,8 +248,8 @@ function kn(n, t) {
|
|
|
220
248
|
source: t.source,
|
|
221
249
|
};
|
|
222
250
|
return (
|
|
223
|
-
void 0 !==
|
|
224
|
-
|
|
251
|
+
void 0 !== a && (i.total_value = a),
|
|
252
|
+
hn(i, n) && kn(i, n.metadata) ? i : null
|
|
225
253
|
);
|
|
226
254
|
}
|
|
227
255
|
export function sanitizeEcommerceEvent(n) {
|
|
@@ -229,26 +257,26 @@ export function sanitizeEcommerceEvent(n) {
|
|
|
229
257
|
if (null == t || "object" != typeof t || g(t))
|
|
230
258
|
return b.error(`${R.QE} requires a properties object.`), null;
|
|
231
259
|
const e = t,
|
|
232
|
-
r =
|
|
260
|
+
r = jn(e);
|
|
233
261
|
if (null == r) return null;
|
|
234
262
|
switch (n.name) {
|
|
235
263
|
case "ecommerce.product_viewed":
|
|
236
264
|
return (function (n, t) {
|
|
237
265
|
const e = n.metadata;
|
|
238
|
-
if (
|
|
266
|
+
if (null != n.type && !$n(n.type, "type")) return null;
|
|
239
267
|
const r = dn(n.product_id, "product_id", !0),
|
|
240
268
|
u = dn(n.product_name, "product_name", !0),
|
|
241
269
|
o = dn(n.variant_id, "variant_id", !0),
|
|
242
270
|
c = pn(n.price, "price"),
|
|
243
|
-
|
|
244
|
-
|
|
271
|
+
a = dn(n.image_url, "image_url", !1),
|
|
272
|
+
i = dn(n.product_url, "product_url", !1);
|
|
245
273
|
if (
|
|
246
274
|
!1 === r ||
|
|
247
275
|
!1 === u ||
|
|
248
276
|
!1 === o ||
|
|
249
277
|
!1 === c ||
|
|
250
|
-
!1 ===
|
|
251
|
-
!1 ===
|
|
278
|
+
!1 === a ||
|
|
279
|
+
!1 === i
|
|
252
280
|
)
|
|
253
281
|
return null;
|
|
254
282
|
const s = {
|
|
@@ -260,14 +288,14 @@ export function sanitizeEcommerceEvent(n) {
|
|
|
260
288
|
source: t.source,
|
|
261
289
|
};
|
|
262
290
|
return (
|
|
263
|
-
null !=
|
|
264
|
-
null !=
|
|
265
|
-
|
|
266
|
-
|
|
291
|
+
null != a && (s.image_url = a),
|
|
292
|
+
null != i && (s.product_url = i),
|
|
293
|
+
null != n.type && (s.type = n.type),
|
|
294
|
+
kn(s, e) ? s : null
|
|
267
295
|
);
|
|
268
296
|
})(e, r);
|
|
269
297
|
case "ecommerce.cart_updated":
|
|
270
|
-
return
|
|
298
|
+
return En(e, r);
|
|
271
299
|
case "ecommerce.checkout_started":
|
|
272
300
|
return (function (n, t) {
|
|
273
301
|
const e = dn(n.checkout_id, "checkout_id", !0),
|
|
@@ -283,7 +311,8 @@ export function sanitizeEcommerceEvent(n) {
|
|
|
283
311
|
source: t.source,
|
|
284
312
|
};
|
|
285
313
|
return (
|
|
286
|
-
null != o && (c.cart_id = o),
|
|
314
|
+
null != o && (c.cart_id = o),
|
|
315
|
+
hn(c, n) && qn(n.metadata) && kn(c, n.metadata) ? c : null
|
|
287
316
|
);
|
|
288
317
|
})(e, r);
|
|
289
318
|
case "ecommerce.order_placed":
|
|
@@ -291,10 +320,10 @@ export function sanitizeEcommerceEvent(n) {
|
|
|
291
320
|
const e = n.metadata;
|
|
292
321
|
if (null != e && "object" == typeof e && !g(e)) {
|
|
293
322
|
const n = e;
|
|
294
|
-
if (
|
|
323
|
+
if (null != n.tags && !$n(n.tags, "metadata.tags")) return null;
|
|
295
324
|
if (
|
|
296
|
-
|
|
297
|
-
|
|
325
|
+
null != n.payment_gateway_names &&
|
|
326
|
+
!$n(n.payment_gateway_names, "metadata.payment_gateway_names")
|
|
298
327
|
)
|
|
299
328
|
return null;
|
|
300
329
|
}
|
|
@@ -303,19 +332,19 @@ export function sanitizeEcommerceEvent(n) {
|
|
|
303
332
|
o = Cn(n.products),
|
|
304
333
|
c = dn(n.cart_id, "cart_id", !1);
|
|
305
334
|
if (!1 === r || !1 === u || null == o || !1 === c) return null;
|
|
306
|
-
const
|
|
335
|
+
const a = {
|
|
307
336
|
order_id: r,
|
|
308
337
|
total_value: u,
|
|
309
338
|
currency: t.currency,
|
|
310
339
|
products: o,
|
|
311
340
|
source: t.source,
|
|
312
341
|
};
|
|
313
|
-
if ((null != c && (
|
|
342
|
+
if ((null != c && (a.cart_id = c), null != n.total_discounts)) {
|
|
314
343
|
const t = pn(n.total_discounts, "total_discounts");
|
|
315
344
|
if (!1 === t) return null;
|
|
316
|
-
|
|
345
|
+
a.total_discounts = t;
|
|
317
346
|
}
|
|
318
|
-
if (
|
|
347
|
+
if (null != n.discounts) {
|
|
319
348
|
if (!g(n.discounts))
|
|
320
349
|
return (
|
|
321
350
|
b.error(`Cannot ${ln} because discounts must be an array.`), null
|
|
@@ -328,9 +357,9 @@ export function sanitizeEcommerceEvent(n) {
|
|
|
328
357
|
"eCommerce order discounts",
|
|
329
358
|
);
|
|
330
359
|
if (!t || null == e) return null;
|
|
331
|
-
|
|
360
|
+
a.discounts = e.discounts;
|
|
332
361
|
}
|
|
333
|
-
return
|
|
362
|
+
return hn(a, n) && qn(n.metadata) && kn(a, n.metadata) ? a : null;
|
|
334
363
|
})(e, r);
|
|
335
364
|
default:
|
|
336
365
|
return (
|
package/src/util/key-codes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const KeyCodes = {
|
|
1
|
+
export const KeyCodes = { To: 32, No: 9, Lo: 13, oh: 27 };
|
package/src/util/net.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger as b } from "../../shared-lib/index.js";
|
|
2
|
-
import
|
|
3
|
-
import { getErrorMessage as
|
|
2
|
+
import Re from "../models/backend-errors.js";
|
|
3
|
+
import { getErrorMessage as ci } 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 ?
|
|
30
|
+
error: "" === e.responseText ? Re.Ha : Re.Wa,
|
|
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
|
-
b.error(`Network request error: ${
|
|
54
|
+
b.error(`Network request error: ${ci(t)}`);
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
};
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { REQUEST_ATTEMPT_DEFAULT as
|
|
1
|
+
import { REQUEST_ATTEMPT_DEFAULT as Ne } 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
|
+
Cn: "data",
|
|
6
6
|
Mi: "content_cards/sync",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
vo: "feature_flags/sync",
|
|
8
|
+
Xo: "template",
|
|
9
9
|
st: "banners/sync",
|
|
10
|
-
|
|
10
|
+
ka: "push/unregister",
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
Rm: (e) => (null == e ? void 0 : e.St(s.It.
|
|
12
|
+
Il: (e) => (null == e ? void 0 : e.St(s.It.lS)),
|
|
13
|
+
Rm: (e) => (null == e ? void 0 : e.St(s.It._S)),
|
|
14
14
|
Am: (e, t) => {
|
|
15
|
-
null == e || e.Pt(s.It.
|
|
15
|
+
null == e || e.Pt(s.It.lS, t);
|
|
16
16
|
},
|
|
17
17
|
qm: (e, t) => {
|
|
18
|
-
null == e || e.Pt(s.It.
|
|
18
|
+
null == e || e.Pt(s.It._S, t);
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
gl: (e, t) => {
|
|
21
21
|
if (!e || !t) return -1;
|
|
22
|
-
const s = h.
|
|
22
|
+
const s = h.Il(e);
|
|
23
23
|
if (null == s) return -1;
|
|
24
24
|
const n = s[t];
|
|
25
25
|
return null == n || isNaN(n) ? -1 : n;
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
let s =
|
|
27
|
+
bl: (e, t) => {
|
|
28
|
+
let s = Ne;
|
|
29
29
|
if (!e || !t) return s;
|
|
30
30
|
const n = h.Rm(e);
|
|
31
|
-
return null == n ? s : ((s = n[t]), null == s || isNaN(s) ?
|
|
31
|
+
return null == n ? s : ((s = n[t]), null == s || isNaN(s) ? Ne : s);
|
|
32
32
|
},
|
|
33
33
|
nt: (e, t, s) => {
|
|
34
34
|
if (!e || !t) return;
|
|
35
|
-
let n = h.
|
|
35
|
+
let n = h.Il(e);
|
|
36
36
|
null == n && (n = {}), (n[t] = s), h.Am(e, n);
|
|
37
37
|
},
|
|
38
|
-
|
|
38
|
+
ql: (e, t, s) => {
|
|
39
39
|
if (!e || !t) return;
|
|
40
40
|
let n = h.Rm(e);
|
|
41
41
|
null == n && (n = {}), (n[t] = s), h.qm(e, n);
|
|
42
42
|
},
|
|
43
43
|
Ji: (e, t) => {
|
|
44
|
-
e && t && h.
|
|
44
|
+
e && t && h.ql(e, t, Ne);
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
Sl: (e, t) => {
|
|
47
47
|
if (!e || !t) return;
|
|
48
|
-
const s = h.
|
|
49
|
-
h.
|
|
48
|
+
const s = h.bl(e, t);
|
|
49
|
+
h.ql(e, t, s + 1);
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
export default h;
|
package/src/util/string-utils.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { logger as b } from "../../shared-lib/index.js";
|
|
2
|
+
export function isAlphanumericChar(t) {
|
|
3
|
+
return (
|
|
4
|
+
(t >= "a" && t <= "z") || (t >= "A" && t <= "Z") || (t >= "0" && t <= "9")
|
|
5
|
+
);
|
|
6
|
+
}
|
|
2
7
|
export function getByteLength(t) {
|
|
3
8
|
let e = t.length;
|
|
4
9
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Browsers as
|
|
3
|
-
export default class
|
|
1
|
+
import Oe from "./base-device-parser.js";
|
|
2
|
+
import { Browsers as xi, OperatingSystems as so } from "./device-constants.js";
|
|
3
|
+
export default class yi extends Oe {
|
|
4
4
|
constructor() {
|
|
5
|
-
super(), (this.Sd =
|
|
5
|
+
super(), (this.Sd = yi.Bc(navigator.userAgent || ""));
|
|
6
6
|
}
|
|
7
7
|
ef() {
|
|
8
8
|
return this.Sd[0] || "Unknown Browser";
|
|
@@ -13,7 +13,7 @@ export default class vi 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 = yi.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 vi 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] === xi.rO) {
|
|
44
|
+
if (r.includes(xi.Sg)) return [xi.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", xi.oO)),
|
|
52
|
+
(n[0] = n[0].replace("EdgA", xi.eO)),
|
|
53
|
+
"Edg" === n[0] && (n[0] = xi.eO),
|
|
54
54
|
[n[0], n[1]]
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
if (
|
|
58
|
-
e[1] ===
|
|
58
|
+
e[1] === xi.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", xi.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] === xi.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] === xi.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] = xi.rO),
|
|
77
77
|
"tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)),
|
|
78
78
|
"samsungbrowser" === r && (e[0] = "Samsung Browser");
|
|
79
79
|
}
|