@braze/web-sdk 4.6.3 → 4.7.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 +13 -8
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +2 -2
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +18 -17
- package/shared-lib/indexed-db-adapter.js +2 -2
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +15 -15
- package/src/Core/handle-braze-action.js +40 -34
- package/src/Core/log-custom-event.js +2 -7
- package/src/Core/log-purchase.js +3 -3
- package/src/Core/wipe-data.js +2 -2
- package/src/FeatureFlags/feature-flag.js +33 -16
- package/src/FeatureFlags/feature-flags-provider.js +86 -75
- package/src/FeatureFlags/get-all-feature-flags.js +5 -5
- package/src/FeatureFlags/get-feature-flag.js +6 -6
- package/src/FeatureFlags/refresh-feature-flags.js +1 -1
- package/src/FeatureFlags/types.js +1 -0
- package/src/Feed/feed-provider.js +17 -17
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +135 -120
- package/src/InAppMessage/display/in-app-message-to-html.js +21 -21
- package/src/InAppMessage/display/modal-utils.js +6 -6
- package/src/InAppMessage/in-app-message-factory.js +3 -3
- package/src/InAppMessage/in-app-message-manager-factory.js +3 -3
- package/src/InAppMessage/in-app-message-manager.js +65 -65
- package/src/InAppMessage/log-in-app-message-button-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/full-screen-message.js +1 -1
- 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 +80 -80
- package/src/InAppMessage/models/modal-message.js +2 -2
- package/src/InAppMessage/models/slide-up-message.js +8 -8
- package/src/InAppMessage/models/templated-in-app-message.js +4 -4
- 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.js +216 -209
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +11 -8
- package/src/User/user.js +52 -41
- package/src/common/base-feed.js +1 -1
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +2 -0
- package/src/common/feed-display.js +6 -6
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/managers/auth-manager.js +24 -24
- package/src/managers/braze-instance.js +120 -120
- package/src/managers/device-manager.js +11 -11
- package/src/managers/network-manager.js +63 -54
- package/src/managers/server-config-manager.js +20 -20
- package/src/managers/session-manager.js +29 -29
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +104 -104
- package/src/managers/subscription-manager.js +6 -6
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +1 -1
- package/src/models/identifier.js +6 -6
- package/src/models/push-token.js +3 -3
- package/src/models/server-config.js +15 -15
- package/src/request-controller.js +92 -88
- package/src/triggers/models/custom-event-data.js +4 -4
- package/src/triggers/models/custom-event-property-data.js +9 -9
- package/src/triggers/models/filter-set.js +9 -9
- package/src/triggers/models/filter.js +63 -63
- package/src/triggers/models/in-app-message-click-data.js +5 -5
- package/src/triggers/models/purchase-data.js +3 -3
- package/src/triggers/models/purchase-property-data.js +9 -9
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +48 -48
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +29 -29
- package/src/triggers/triggers-provider-factory.js +2 -2
- package/src/triggers/triggers-provider.js +87 -89
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +4 -4
- package/src/ui/js/iam-css.js +4 -4
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +2 -2
- package/src/util/braze-actions.js +8 -8
- package/src/util/browser-detector.js +8 -8
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/code-utils.js +10 -3
- package/src/util/component-utils.js +1 -1
- package/src/util/date-utils.js +2 -2
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +9 -9
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +3 -3
- package/src/util/user-agent-parser.js +4 -4
- package/src/util/validation-utils.js +155 -74
- package/src/util/window-utils.js +1 -1
package/src/util/code-utils.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
2
|
export function values(t) {
|
|
3
3
|
const e = [];
|
|
4
|
-
for (let r in t)
|
|
4
|
+
for (let r in t)
|
|
5
|
+
Object.prototype.hasOwnProperty.call(t, r) &&
|
|
6
|
+
void 0 !== t[r] &&
|
|
7
|
+
e.push(t[r]);
|
|
5
8
|
return e;
|
|
6
9
|
}
|
|
7
10
|
export function validateValueIsFromEnum(t, e, n, o) {
|
|
@@ -37,7 +40,7 @@ export function intersection(t) {
|
|
|
37
40
|
}
|
|
38
41
|
export function keys(t) {
|
|
39
42
|
const e = [];
|
|
40
|
-
for (let r in t)
|
|
43
|
+
for (let r in t) Object.prototype.hasOwnProperty.call(t, r) && e.push(r);
|
|
41
44
|
return e;
|
|
42
45
|
}
|
|
43
46
|
export function isEqual(t, e) {
|
|
@@ -85,7 +88,11 @@ export function isEqual(t, e) {
|
|
|
85
88
|
n = keys(t);
|
|
86
89
|
if (((i = n.length), keys(e).length !== i)) return !1;
|
|
87
90
|
for (; i--; )
|
|
88
|
-
if (
|
|
91
|
+
if (
|
|
92
|
+
((r = n[i]),
|
|
93
|
+
!Object.prototype.hasOwnProperty.call(e, r) ||
|
|
94
|
+
!isEqual(t[r], e[r], o, c))
|
|
95
|
+
)
|
|
89
96
|
return !1;
|
|
90
97
|
}
|
|
91
98
|
return o.pop(), c.pop(), !0;
|
|
@@ -5,7 +5,7 @@ export function createCloseButton(t, o, e) {
|
|
|
5
5
|
n.setAttribute("aria-label", t),
|
|
6
6
|
n.setAttribute("tabindex", "0"),
|
|
7
7
|
n.setAttribute("role", "button"),
|
|
8
|
-
oe(n, "touchstart"
|
|
8
|
+
oe(n, "touchstart"),
|
|
9
9
|
(n.className = "ab-close-button");
|
|
10
10
|
const r = ae(
|
|
11
11
|
"0 0 15 15",
|
package/src/util/date-utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isDate as
|
|
1
|
+
import { isDate as Nt } from "./code-utils.js";
|
|
2
2
|
export function convertMsToSeconds(e, n) {
|
|
3
3
|
let t = e / 1e3;
|
|
4
4
|
return n && (t = Math.floor(t)), t;
|
|
@@ -11,7 +11,7 @@ export function dateFromUnixTimestamp(e) {
|
|
|
11
11
|
return null == e || isNaN(n) ? null : new Date(1e3 * n);
|
|
12
12
|
}
|
|
13
13
|
export function toValidBackendTimeString(e) {
|
|
14
|
-
return null != e &&
|
|
14
|
+
return null != e && Nt(e) ? e.toISOString().replace(/\.[0-9]{3}Z$/, "") : e;
|
|
15
15
|
}
|
|
16
16
|
export function rehydrateDateAfterJsonization(e) {
|
|
17
17
|
return null == e || "" === e ? null : new Date(e);
|
package/src/util/dom-utils.js
CHANGED
|
@@ -16,24 +16,24 @@ export function _isInView(t, n, e, s) {
|
|
|
16
16
|
!s)
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
export const DOMUtils = {
|
|
20
|
-
export const DIRECTIONS = {
|
|
19
|
+
export const DOMUtils = { Ou: null, eo: _isInView };
|
|
20
|
+
export const DIRECTIONS = { Je: "up", Ke: "down", ot: "left", et: "right" };
|
|
21
21
|
export function supportsPassive() {
|
|
22
|
-
if (null == DOMUtils.
|
|
23
|
-
DOMUtils.
|
|
22
|
+
if (null == DOMUtils.Ou) {
|
|
23
|
+
DOMUtils.Ou = !1;
|
|
24
24
|
try {
|
|
25
25
|
const t = Object.defineProperty({}, "passive", {
|
|
26
26
|
get: () => {
|
|
27
|
-
DOMUtils.
|
|
27
|
+
DOMUtils.Ou = !0;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
window.addEventListener("testPassive", null, t),
|
|
31
31
|
window.removeEventListener("testPassive", null, t);
|
|
32
32
|
} catch (t) {}
|
|
33
33
|
}
|
|
34
|
-
return DOMUtils.
|
|
34
|
+
return DOMUtils.Ou;
|
|
35
35
|
}
|
|
36
|
-
export function addPassiveEventListener(t, n, e) {
|
|
36
|
+
export function addPassiveEventListener(t, n, e = () => {}) {
|
|
37
37
|
t.addEventListener(n, e, !!supportsPassive() && { passive: !0 });
|
|
38
38
|
}
|
|
39
39
|
export function topIsInView(t) {
|
|
@@ -65,9 +65,9 @@ export function detectSwipe(t, n, e) {
|
|
|
65
65
|
(i = null))
|
|
66
66
|
: Math.abs(u) >= 25 &&
|
|
67
67
|
(((u > 0 &&
|
|
68
|
-
n === DIRECTIONS.
|
|
68
|
+
n === DIRECTIONS.Je &&
|
|
69
69
|
t.scrollTop === t.scrollHeight - t.offsetHeight) ||
|
|
70
|
-
(u < 0 && n === DIRECTIONS.
|
|
70
|
+
(u < 0 && n === DIRECTIONS.Ke && 0 === t.scrollTop)) &&
|
|
71
71
|
e(o),
|
|
72
72
|
(s = null),
|
|
73
73
|
(i = null));
|
package/src/util/key-codes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const KeyCodes = { fo: 32, oo: 9, co: 13,
|
|
1
|
+
export const KeyCodes = { fo: 32, oo: 9, co: 13, mh: 27 };
|
package/src/util/net.js
CHANGED
|
@@ -13,7 +13,7 @@ const b = {
|
|
|
13
13
|
) {
|
|
14
14
|
const r = () => {
|
|
15
15
|
"function" == typeof t.error && t.error(e.status),
|
|
16
|
-
"function" == typeof t.
|
|
16
|
+
"function" == typeof t.wi && t.wi(!1);
|
|
17
17
|
};
|
|
18
18
|
(e.onload = () => {
|
|
19
19
|
let o = !1;
|
|
@@ -28,14 +28,14 @@ const b = {
|
|
|
28
28
|
(r = e.getAllResponseHeaders());
|
|
29
29
|
} catch (o) {
|
|
30
30
|
const n = {
|
|
31
|
-
error: "" === e.responseText ? qt.
|
|
31
|
+
error: "" === e.responseText ? qt.ca : qt.la,
|
|
32
32
|
response: e.responseText
|
|
33
33
|
};
|
|
34
34
|
t.S(n, r);
|
|
35
35
|
}
|
|
36
36
|
o && t.S(o, r);
|
|
37
37
|
}
|
|
38
|
-
"function" == typeof t.
|
|
38
|
+
"function" == typeof t.wi && t.wi(!0);
|
|
39
39
|
} else r();
|
|
40
40
|
}),
|
|
41
41
|
(e.onerror = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Oe from "./base-device-parser.js";
|
|
2
2
|
import { Browsers as ri, OperatingSystems as rt } from "./device-constants.js";
|
|
3
|
-
export default class ni extends
|
|
3
|
+
export default class ni extends Oe {
|
|
4
4
|
constructor() {
|
|
5
5
|
super(), (this.Su = ni.Vu(navigator.userAgent || ""));
|
|
6
6
|
}
|
|
@@ -10,13 +10,13 @@ export default class ni extends Se {
|
|
|
10
10
|
ef() {
|
|
11
11
|
return this.Su[1] || "Unknown Version";
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
Xo(r) {
|
|
14
14
|
for (let e = 0; e < r.length; e++) {
|
|
15
15
|
let n = r[e].string,
|
|
16
16
|
i = ni.rf(n, r[e]);
|
|
17
17
|
if (i)
|
|
18
18
|
return (
|
|
19
|
-
i === rt.jg && navigator.maxTouchPoints > 1 && (i = rt
|
|
19
|
+
i === rt.jg && navigator.maxTouchPoints > 1 && (i = rt.$e),
|
|
20
20
|
Promise.resolve(i)
|
|
21
21
|
);
|
|
22
22
|
}
|
|
@@ -1,136 +1,217 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isArray as p,
|
|
3
|
-
isDate as
|
|
4
|
-
isObject as
|
|
5
|
-
keys as
|
|
3
|
+
isDate as Nt,
|
|
4
|
+
isObject as yt,
|
|
5
|
+
keys as or
|
|
6
6
|
} from "./code-utils.js";
|
|
7
7
|
import { getByteLength as U } from "./string-utils.js";
|
|
8
8
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
9
|
-
import { toValidBackendTimeString as
|
|
10
|
-
import { BRAZE_ACTIONS as
|
|
9
|
+
import { toValidBackendTimeString as Ft } from "./date-utils.js";
|
|
10
|
+
import { BRAZE_ACTIONS as P } from "./braze-actions.js";
|
|
11
|
+
import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ut } from "../common/constants.js";
|
|
11
12
|
export const CUSTOM_DATA_REGEX = /^[^\x00-\x1F\x22]+$/;
|
|
13
|
+
export const CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX = /[$.]/;
|
|
14
|
+
export const CUSTOM_ATTRIBUTE_RESERVED_OPERATORS = [
|
|
15
|
+
"$add",
|
|
16
|
+
"$update",
|
|
17
|
+
"$remove",
|
|
18
|
+
"$identifier_key",
|
|
19
|
+
"$identifier_value",
|
|
20
|
+
"$new_object",
|
|
21
|
+
"$time"
|
|
22
|
+
];
|
|
12
23
|
export const EMAIL_ADDRESS_REGEX = new RegExp(/^.+@.+\..+$/);
|
|
13
24
|
export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES = 51200;
|
|
14
25
|
export const CUSTOM_PROPERTIES_MAX_SIZE_STRING = "50KB";
|
|
26
|
+
export const CUSTOM_ATTRIBUTES_MAX_SIZE_BYTES = 76800;
|
|
27
|
+
export const CUSTOM_ATTRIBUTES_MAX_SIZE_STRING = "75KB";
|
|
28
|
+
export const CUSTOM_ATTRIBUTE_MAX_DEPTH = 50;
|
|
15
29
|
export const BRAZE_ACTION_URI_REGEX = /^brazeActions:\/\/v\d+\//;
|
|
16
|
-
export function
|
|
17
|
-
const
|
|
30
|
+
export function validateCustomString(t, e, n) {
|
|
31
|
+
const o =
|
|
32
|
+
null != t &&
|
|
33
|
+
"string" == typeof t &&
|
|
34
|
+
("" === t || t.match(CUSTOM_DATA_REGEX));
|
|
35
|
+
return o || r.D.error(`Cannot ${e} because ${n} "${t}" is invalid.`), o;
|
|
36
|
+
}
|
|
37
|
+
export function validateCustomAttributeKey(t) {
|
|
38
|
+
return (
|
|
39
|
+
null != t &&
|
|
40
|
+
t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX) &&
|
|
41
|
+
-1 === CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t) &&
|
|
42
|
+
r.D.warn("Custom attribute keys cannot contain '$' or '.'"),
|
|
43
|
+
validateCustomString(t, "set custom user attribute", "the given key")
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
export function validatePropertyType(t) {
|
|
47
|
+
const e = typeof t;
|
|
18
48
|
return (
|
|
19
|
-
null ==
|
|
49
|
+
null == t || "number" === e || "boolean" === e || Nt(t) || "string" === e
|
|
20
50
|
);
|
|
21
51
|
}
|
|
22
|
-
export function _validateNestedProperties(e,
|
|
23
|
-
|
|
24
|
-
|
|
52
|
+
export function _validateNestedProperties(t, e, n) {
|
|
53
|
+
const o = -1 !== n;
|
|
54
|
+
if (o && n > 50)
|
|
55
|
+
return (
|
|
56
|
+
r.D.error("Nested attributes cannot be more than 50 levels deep."), !1
|
|
57
|
+
);
|
|
58
|
+
const i = o ? n + 1 : -1;
|
|
59
|
+
if (p(t) && p(e)) {
|
|
60
|
+
for (let r = 0; r < t.length && r < e.length; r++)
|
|
25
61
|
if (
|
|
26
|
-
(
|
|
62
|
+
(Nt(t[r]) && (e[r] = Ft(t[r])),
|
|
63
|
+
!_validateNestedProperties(t[r], e[r], i))
|
|
27
64
|
)
|
|
28
65
|
return !1;
|
|
29
66
|
} else {
|
|
30
|
-
if (!
|
|
31
|
-
for (const r of
|
|
67
|
+
if (!yt(t)) return validatePropertyType(t);
|
|
68
|
+
for (const r of or(t)) {
|
|
69
|
+
if (o && !validateCustomAttributeKey(r)) return !1;
|
|
32
70
|
if (
|
|
33
|
-
(
|
|
71
|
+
(Nt(t[r]) && (e[r] = Ft(t[r])),
|
|
72
|
+
!_validateNestedProperties(t[r], e[r], i))
|
|
34
73
|
)
|
|
35
74
|
return !1;
|
|
75
|
+
}
|
|
36
76
|
}
|
|
37
77
|
return !0;
|
|
38
78
|
}
|
|
39
|
-
export function _validateEventPropertyValue(
|
|
40
|
-
let
|
|
79
|
+
export function _validateEventPropertyValue(t, e, n, o, i) {
|
|
80
|
+
let a;
|
|
41
81
|
return (
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
? _validateNestedProperties(e,
|
|
45
|
-
:
|
|
46
|
-
|
|
47
|
-
|
|
82
|
+
(a =
|
|
83
|
+
yt(t) || p(t)
|
|
84
|
+
? _validateNestedProperties(t, e, i ? 1 : -1)
|
|
85
|
+
: validatePropertyType(t)),
|
|
86
|
+
a || r.D.error(`Cannot ${n} because ${o} "${t}" is invalid.`),
|
|
87
|
+
a
|
|
48
88
|
);
|
|
49
89
|
}
|
|
50
|
-
export function validateStandardString(
|
|
51
|
-
const i = "string" == typeof
|
|
52
|
-
return i || r.D.error(`Cannot ${
|
|
53
|
-
}
|
|
54
|
-
export function validateCustomString(e, t, n) {
|
|
55
|
-
const o =
|
|
56
|
-
null != e &&
|
|
57
|
-
"string" == typeof e &&
|
|
58
|
-
("" === e || e.match(CUSTOM_DATA_REGEX));
|
|
59
|
-
return o || r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`), o;
|
|
90
|
+
export function validateStandardString(t, e, n, o) {
|
|
91
|
+
const i = "string" == typeof t || (null === t && o);
|
|
92
|
+
return i || r.D.error(`Cannot ${e} because ${n} "${t}" is invalid.`), i;
|
|
60
93
|
}
|
|
61
|
-
export function validateCustomProperties(
|
|
62
|
-
if ((null ==
|
|
94
|
+
export function validateCustomProperties(t, e, n, o, i) {
|
|
95
|
+
if ((null == t && (t = {}), "object" != typeof t || p(t)))
|
|
63
96
|
return (
|
|
64
|
-
r.D.error(`${
|
|
97
|
+
r.D.error(`${e} requires that ${n} be an object. Ignoring ${i}.`),
|
|
65
98
|
[!1, null]
|
|
66
99
|
);
|
|
67
|
-
|
|
68
|
-
|
|
100
|
+
let a, s;
|
|
101
|
+
e === Ut ? ((a = 76800), (s = "75KB")) : ((a = 51200), (s = "50KB"));
|
|
102
|
+
const u = JSON.stringify(t);
|
|
103
|
+
if (U(u) > a)
|
|
69
104
|
return (
|
|
70
105
|
r.D.error(
|
|
71
|
-
`Could not ${o} because ${n} was greater than the max size of
|
|
106
|
+
`Could not ${o} because ${n} was greater than the max size of ${s}.`
|
|
72
107
|
),
|
|
73
108
|
[!1, null]
|
|
74
109
|
);
|
|
75
|
-
let
|
|
110
|
+
let l;
|
|
76
111
|
try {
|
|
77
|
-
|
|
78
|
-
} catch (
|
|
112
|
+
l = JSON.parse(u);
|
|
113
|
+
} catch (t) {
|
|
79
114
|
return (
|
|
80
115
|
r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),
|
|
81
116
|
[!1, null]
|
|
82
117
|
);
|
|
83
118
|
}
|
|
84
|
-
for (let
|
|
85
|
-
if (
|
|
119
|
+
for (let r in t) {
|
|
120
|
+
if (e === Ut && !validateCustomAttributeKey(r)) return [!1, null];
|
|
121
|
+
if (!validateCustomString(r, o, `the ${i} property name`))
|
|
86
122
|
return [!1, null];
|
|
87
|
-
const
|
|
88
|
-
if (null ==
|
|
89
|
-
delete
|
|
123
|
+
const n = t[r];
|
|
124
|
+
if (e !== Ut && null == n) {
|
|
125
|
+
delete t[r], delete l[r];
|
|
90
126
|
continue;
|
|
91
127
|
}
|
|
92
|
-
|
|
93
|
-
if (
|
|
128
|
+
Nt(n) && (l[r] = Ft(n));
|
|
129
|
+
if (
|
|
130
|
+
!_validateEventPropertyValue(
|
|
131
|
+
n,
|
|
132
|
+
l[r],
|
|
133
|
+
o,
|
|
134
|
+
`the ${i} property "${r}"`,
|
|
135
|
+
e === Ut
|
|
136
|
+
)
|
|
137
|
+
)
|
|
94
138
|
return [!1, null];
|
|
95
139
|
}
|
|
96
|
-
return [!0,
|
|
140
|
+
return [!0, l];
|
|
141
|
+
}
|
|
142
|
+
export function validateCustomAttributeArrayType(t, e) {
|
|
143
|
+
let n = !1,
|
|
144
|
+
o = !1;
|
|
145
|
+
const i = () => {
|
|
146
|
+
r.D.error(
|
|
147
|
+
"Custom attribute arrays must be either string arrays or object arrays."
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
for (const r of e)
|
|
151
|
+
if ("string" == typeof r) {
|
|
152
|
+
if (o) return i(), [!1, !1];
|
|
153
|
+
if (
|
|
154
|
+
!validateCustomString(
|
|
155
|
+
r,
|
|
156
|
+
`set custom user attribute "${t}"`,
|
|
157
|
+
"the element in the given array"
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
return [!1, !1];
|
|
161
|
+
n = !0;
|
|
162
|
+
} else {
|
|
163
|
+
if (!yt(r)) return i(), [!1, !1];
|
|
164
|
+
if (n) return i(), [!1, !1];
|
|
165
|
+
if (
|
|
166
|
+
!validateCustomProperties(
|
|
167
|
+
r,
|
|
168
|
+
Ut,
|
|
169
|
+
"attribute value",
|
|
170
|
+
`set custom user attribute "${t}"`,
|
|
171
|
+
"custom user attribute"
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
return [!1, !1];
|
|
175
|
+
o = !0;
|
|
176
|
+
}
|
|
177
|
+
return [n, o];
|
|
97
178
|
}
|
|
98
|
-
export function isValidEmail(
|
|
179
|
+
export function isValidEmail(t) {
|
|
99
180
|
return (
|
|
100
|
-
"string" == typeof
|
|
181
|
+
"string" == typeof t && null != t.toLowerCase().match(EMAIL_ADDRESS_REGEX)
|
|
101
182
|
);
|
|
102
183
|
}
|
|
103
|
-
export function isValidBrazeActionJson(
|
|
104
|
-
if (!(
|
|
105
|
-
switch (
|
|
106
|
-
case
|
|
107
|
-
if (
|
|
184
|
+
export function isValidBrazeActionJson(t) {
|
|
185
|
+
if (!(P.properties.type in t)) return !1;
|
|
186
|
+
switch (t[P.properties.type]) {
|
|
187
|
+
case P.types.ue:
|
|
188
|
+
if (P.properties.me in t) return !0;
|
|
108
189
|
break;
|
|
109
|
-
case
|
|
110
|
-
case
|
|
111
|
-
case
|
|
112
|
-
case
|
|
113
|
-
case
|
|
114
|
-
case
|
|
115
|
-
case
|
|
116
|
-
case
|
|
117
|
-
case
|
|
118
|
-
case
|
|
119
|
-
if (
|
|
190
|
+
case P.types.logCustomEvent:
|
|
191
|
+
case P.types.setEmailNotificationSubscriptionType:
|
|
192
|
+
case P.types.setPushNotificationSubscriptionType:
|
|
193
|
+
case P.types.setCustomUserAttribute:
|
|
194
|
+
case P.types.addToSubscriptionGroup:
|
|
195
|
+
case P.types.removeFromSubscriptionGroup:
|
|
196
|
+
case P.types.addToCustomAttributeArray:
|
|
197
|
+
case P.types.removeFromCustomAttributeArray:
|
|
198
|
+
case P.types.de:
|
|
199
|
+
case P.types.pe:
|
|
200
|
+
if (P.properties.fe in t) return !0;
|
|
120
201
|
break;
|
|
121
|
-
case
|
|
202
|
+
case P.types.requestPushPermission:
|
|
122
203
|
return !0;
|
|
123
204
|
default:
|
|
124
205
|
return !1;
|
|
125
206
|
}
|
|
126
207
|
return !1;
|
|
127
208
|
}
|
|
128
|
-
export function isValidBrazeActionType(
|
|
129
|
-
let
|
|
209
|
+
export function isValidBrazeActionType(t) {
|
|
210
|
+
let e = !1;
|
|
130
211
|
return (
|
|
131
|
-
Object.keys(
|
|
132
|
-
|
|
212
|
+
Object.keys(P.types).forEach(r => {
|
|
213
|
+
P.types[r] !== t.toString() || (e = !0);
|
|
133
214
|
}),
|
|
134
|
-
|
|
215
|
+
e
|
|
135
216
|
);
|
|
136
217
|
}
|
package/src/util/window-utils.js
CHANGED