@braze/web-sdk 5.0.0 → 5.1.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/README.md +1 -1
- package/index.d.ts +12 -5
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +29 -29
- package/shared-lib/guid.js +3 -3
- package/shared-lib/index.js +6 -0
- package/shared-lib/indexed-db-adapter.js +70 -70
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +21 -21
- package/src/Card/card-manager.js +43 -45
- package/src/Card/display/card-display.js +60 -60
- package/src/Card/log-card-click.js +4 -4
- package/src/Card/log-card-dismissal.js +2 -3
- package/src/Card/log-card-impressions.js +7 -7
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +73 -73
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +19 -19
- package/src/Card/util/card-factory.js +68 -68
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +255 -245
- package/src/ContentCards/content-cards.js +2 -2
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +6 -6
- package/src/ContentCards/ui/hide-content-cards.js +1 -1
- package/src/ContentCards/ui/show-content-cards.js +24 -24
- package/src/ContentCards/ui/toggle-content-cards.js +1 -1
- package/src/Core/add-sdk-metadata.js +21 -19
- package/src/Core/change-user.js +10 -10
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +11 -11
- package/src/Core/enable-sdk.js +7 -7
- package/src/Core/get-device-id.js +6 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +41 -41
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +15 -15
- package/src/Core/log-purchase.js +31 -37
- package/src/Core/open-session.js +12 -12
- package/src/Core/remove-all-subscriptions.js +1 -1
- package/src/Core/remove-subscription.js +1 -1
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +3 -3
- package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -4
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +9 -9
- package/src/FeatureFlags/feature-flag-factory.js +12 -12
- package/src/FeatureFlags/feature-flag.js +10 -10
- package/src/FeatureFlags/feature-flags-provider-factory.js +3 -2
- package/src/FeatureFlags/feature-flags-provider.js +108 -80
- package/src/FeatureFlags/get-all-feature-flags.js +5 -5
- package/src/FeatureFlags/get-feature-flag.js +6 -6
- package/src/FeatureFlags/log-feature-flag-impression.js +15 -13
- package/src/FeatureFlags/refresh-feature-flags.js +1 -1
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +7 -4
- package/src/Feed/feed-provider-factory.js +2 -2
- package/src/Feed/feed-provider.js +44 -44
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.js +4 -4
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/hide-feed.js +1 -1
- package/src/Feed/ui/show-feed.js +28 -28
- package/src/Feed/ui/toggle-feed.js +1 -1
- package/src/InAppMessage/defer-in-app-message.js +5 -5
- package/src/InAppMessage/display/html-message-to-html.js +54 -54
- package/src/InAppMessage/display/in-app-message-to-html.js +79 -79
- package/src/InAppMessage/display/modal-utils.js +8 -8
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +49 -49
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +143 -138
- package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-impression.js +6 -6
- package/src/InAppMessage/models/full-screen-message.js +33 -33
- package/src/InAppMessage/models/html-message.js +20 -20
- package/src/InAppMessage/models/in-app-message-button.js +6 -6
- package/src/InAppMessage/models/in-app-message.js +99 -99
- package/src/InAppMessage/models/modal-message.js +32 -32
- package/src/InAppMessage/models/slide-up-message.js +28 -28
- 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 +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +81 -81
- package/src/Push/is-push-blocked.js +1 -1
- package/src/Push/is-push-permission-granted.js +1 -1
- package/src/Push/is-push-supported.js +1 -1
- package/src/Push/push-manager-factory.js +5 -5
- package/src/Push/push-manager.js +176 -173
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +29 -29
- package/src/User/user.js +72 -74
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +2 -0
- package/src/common/event-logger.js +21 -18
- package/src/common/feed-display.js +44 -44
- package/src/l10n/l10n-manager-factory.js +3 -3
- package/src/l10n/l10n-manager.js +7 -7
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +188 -189
- package/src/managers/device-manager.js +28 -28
- package/src/managers/network-manager.js +189 -138
- package/src/managers/server-config-manager.js +69 -53
- package/src/managers/session-manager.js +34 -30
- package/src/managers/storage-manager-factory.js +16 -16
- package/src/managers/storage-manager.js +210 -188
- package/src/managers/subscription-manager.js +12 -12
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +3 -3
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +34 -14
- package/src/models/push-token.js +8 -8
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +32 -23
- package/src/request-controller.js +187 -180
- package/src/triggers/models/custom-event-data.js +7 -7
- package/src/triggers/models/custom-event-property-data.js +10 -10
- package/src/triggers/models/filter-set.js +13 -13
- package/src/triggers/models/filter.js +45 -45
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +10 -10
- package/src/triggers/models/push-click-data.js +7 -7
- package/src/triggers/models/trigger-condition.js +57 -59
- package/src/triggers/models/trigger-events.js +4 -4
- package/src/triggers/models/trigger.js +38 -38
- package/src/triggers/triggers-provider-factory.js +4 -4
- package/src/triggers/triggers-provider.js +127 -130
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +3 -3
- package/src/util/braze-actions.js +35 -35
- package/src/util/browser-detector.js +21 -21
- package/src/util/client-hints-parser.js +8 -8
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +1 -1
- package/src/util/deprecation-utils.js +4 -4
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +18 -18
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +18 -18
- package/src/util/request-header-utils.js +39 -37
- package/src/util/string-utils.js +10 -10
- package/src/util/user-agent-parser.js +18 -18
- package/src/util/validation-utils.js +37 -39
- package/src/util/window-utils.js +3 -3
- package/shared-lib/braze-shared-lib.js +0 -8
package/src/User/user-manager.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
import _t from "../models/identifier.js";
|
|
2
|
-
import { getByteLength as
|
|
2
|
+
import { getByteLength as O } from "../util/string-utils.js";
|
|
3
3
|
import ti from "../models/push-token.js";
|
|
4
|
-
import r from "../../shared-lib/
|
|
5
|
-
import { STORAGE_KEYS as
|
|
4
|
+
import { logger as r, IndexedDBAdapter as A } from "../../shared-lib/index.js";
|
|
5
|
+
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
6
6
|
import { User } from "../User/index.js";
|
|
7
7
|
export default class bt {
|
|
8
8
|
constructor(t, s) {
|
|
9
9
|
(this.yt = t), (this.u = s), (this.yt = t), (this.u = s);
|
|
10
10
|
}
|
|
11
11
|
getUserId() {
|
|
12
|
-
const t = this.u.tu(
|
|
12
|
+
const t = this.u.tu(o.iu.su);
|
|
13
13
|
if (null == t) return null;
|
|
14
|
-
let s = t.
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
for (;
|
|
18
|
-
(t.
|
|
14
|
+
let s = t.eu,
|
|
15
|
+
i = O(s);
|
|
16
|
+
if (i > User.lr) {
|
|
17
|
+
for (; i > User.lr; ) (s = s.slice(0, s.length - 1)), (i = O(s));
|
|
18
|
+
(t.eu = s), this.u.uu(o.iu.su, t);
|
|
19
19
|
}
|
|
20
20
|
return s;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
ou(t) {
|
|
23
23
|
const s = null == this.getUserId();
|
|
24
|
-
this.u.uu(
|
|
24
|
+
this.u.uu(o.iu.su, new _t(t)), s && this.u.ru(t);
|
|
25
25
|
}
|
|
26
26
|
setCustomUserAttribute(t, s) {
|
|
27
27
|
if (this.yt.hu(t))
|
|
28
28
|
return (
|
|
29
|
-
r.
|
|
29
|
+
r.info('Custom Attribute "' + t + '" is blocklisted, ignoring.'), !1
|
|
30
30
|
);
|
|
31
|
-
const
|
|
32
|
-
return (
|
|
31
|
+
const i = {};
|
|
32
|
+
return (i[t] = s), this.nu(User.lu, i, !0);
|
|
33
33
|
}
|
|
34
|
-
nu(t, s,
|
|
34
|
+
nu(t, s, i = !1, e = !1) {
|
|
35
35
|
const u = this.u.mu(this.getUserId(), t, s);
|
|
36
36
|
let o = "",
|
|
37
37
|
h = t,
|
|
38
38
|
n = s;
|
|
39
39
|
return (
|
|
40
|
-
|
|
40
|
+
i &&
|
|
41
41
|
((o = " custom"),
|
|
42
42
|
"object" == typeof s &&
|
|
43
43
|
((h = Object.keys(s)[0]),
|
|
44
44
|
(n = s[h]),
|
|
45
45
|
"object" == typeof n && (n = JSON.stringify(n, null, 2)))),
|
|
46
|
-
!
|
|
46
|
+
!e && u && r.info(`Logged${o} attribute ${h} with value ${n}`),
|
|
47
47
|
u
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
Sn(t, s, i, e, u) {
|
|
51
51
|
this.nu("push_token", t, !1, !0),
|
|
52
|
-
this.nu("custom_push_public_key",
|
|
53
|
-
this.nu("custom_push_user_auth",
|
|
54
|
-
this.nu("custom_push_vapid_public_key",
|
|
55
|
-
const h =
|
|
56
|
-
n = new
|
|
57
|
-
l = new ti(t, s, e, u
|
|
58
|
-
this.u.
|
|
52
|
+
this.nu("custom_push_public_key", i, !1, !0),
|
|
53
|
+
this.nu("custom_push_user_auth", e, !1, !0),
|
|
54
|
+
this.nu("custom_push_vapid_public_key", u, !1, !0);
|
|
55
|
+
const h = A.Yt.Qt,
|
|
56
|
+
n = new A(h, r),
|
|
57
|
+
l = new ti(t, s, i, e, u);
|
|
58
|
+
this.u.k(o.C.zn, l.Y()), n.setItem(h.ss.cu, h.ie, !0);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
jn(t) {
|
|
61
61
|
if (
|
|
62
62
|
(this.nu("push_token", null, !1, !0),
|
|
63
63
|
this.nu("custom_push_public_key", null, !1, !0),
|
|
@@ -65,9 +65,9 @@ export default class bt {
|
|
|
65
65
|
this.nu("custom_push_vapid_public_key", null, !1, !0),
|
|
66
66
|
t)
|
|
67
67
|
) {
|
|
68
|
-
const t =
|
|
69
|
-
s = new
|
|
70
|
-
this.u.
|
|
68
|
+
const t = A.Yt.Qt,
|
|
69
|
+
s = new A(t, r);
|
|
70
|
+
this.u.k(o.C.zn, !1), s.setItem(t.ss.cu, t.ie, !1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/User/user.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isArray as
|
|
2
|
+
isArray as j,
|
|
3
3
|
isDate as yt,
|
|
4
4
|
isObject as Nt,
|
|
5
|
-
validateValueIsFromEnum as
|
|
5
|
+
validateValueIsFromEnum as J,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
|
-
import r from "../../shared-lib/
|
|
7
|
+
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
8
8
|
import {
|
|
9
9
|
isValidEmail as Ct,
|
|
10
10
|
validateCustomAttributeArrayType as St,
|
|
11
11
|
validateCustomAttributeKey as At,
|
|
12
|
-
validateCustomProperties as
|
|
13
|
-
validateCustomString as
|
|
12
|
+
validateCustomProperties as ot,
|
|
13
|
+
validateCustomString as rt,
|
|
14
14
|
validatePropertyType as Ut,
|
|
15
|
-
validateStandardString as
|
|
15
|
+
validateStandardString as P,
|
|
16
16
|
} from "../util/validation-utils.js";
|
|
17
17
|
import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft } from "../common/constants.js";
|
|
18
18
|
import { toValidBackendTimeString as $t } from "../util/date-utils.js";
|
|
19
19
|
export default class User {
|
|
20
20
|
constructor(t, e) {
|
|
21
|
-
(this.wt = t), (this.
|
|
21
|
+
(this.wt = t), (this.Ei = e), (this.wt = t), (this.Ei = e);
|
|
22
22
|
}
|
|
23
23
|
getUserId(t) {
|
|
24
24
|
const e = this.wt.getUserId();
|
|
25
25
|
if ("function" != typeof t) return e;
|
|
26
|
-
r.
|
|
26
|
+
r.warn(
|
|
27
27
|
"The callback for getUserId is deprecated. You can access its return value directly instead (e.g. `const id = braze.getUser().getUserId()`)",
|
|
28
28
|
),
|
|
29
29
|
t(e);
|
|
30
30
|
}
|
|
31
31
|
addAlias(t, e) {
|
|
32
|
-
return !
|
|
33
|
-
? (r.
|
|
34
|
-
: !
|
|
35
|
-
? (r.
|
|
36
|
-
: this.
|
|
32
|
+
return !P(t, "add alias", "the alias", !1) || t.length <= 0
|
|
33
|
+
? (r.error("addAlias requires a non-empty alias"), !1)
|
|
34
|
+
: !P(e, "add alias", "the label", !1) || e.length <= 0
|
|
35
|
+
? (r.error("addAlias requires a non-empty label"), !1)
|
|
36
|
+
: this.Ei.Fn(t, e).L;
|
|
37
37
|
}
|
|
38
38
|
setFirstName(t) {
|
|
39
39
|
return (
|
|
40
|
-
!!
|
|
40
|
+
!!P(t, "set first name", "the firstName", !0) &&
|
|
41
41
|
this.wt.nu("first_name", t)
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
setLastName(t) {
|
|
45
45
|
return (
|
|
46
|
-
!!
|
|
46
|
+
!!P(t, "set last name", "the lastName", !0) && this.wt.nu("last_name", t)
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
setEmail(t) {
|
|
50
50
|
return null === t || Ct(t)
|
|
51
51
|
? this.wt.nu("email", t)
|
|
52
|
-
: (r.
|
|
52
|
+
: (r.error(
|
|
53
53
|
`Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
|
|
54
54
|
),
|
|
55
55
|
!1);
|
|
@@ -59,7 +59,7 @@ export default class User {
|
|
|
59
59
|
"string" == typeof t && (t = t.toLowerCase()),
|
|
60
60
|
!(
|
|
61
61
|
null !== t &&
|
|
62
|
-
!
|
|
62
|
+
!J(
|
|
63
63
|
User.Genders,
|
|
64
64
|
t,
|
|
65
65
|
`Gender "${t}" is not a valid gender.`,
|
|
@@ -84,28 +84,28 @@ export default class User {
|
|
|
84
84
|
e < 1 ||
|
|
85
85
|
s > 31 ||
|
|
86
86
|
s < 1
|
|
87
|
-
? (r.
|
|
87
|
+
? (r.error(
|
|
88
88
|
"Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);",
|
|
89
89
|
),
|
|
90
90
|
!1)
|
|
91
91
|
: this.wt.nu("dob", `${t}-${e}-${s}`));
|
|
92
92
|
}
|
|
93
93
|
setCountry(t) {
|
|
94
|
-
return !!
|
|
94
|
+
return !!P(t, "set country", "the country", !0) && this.wt.nu("country", t);
|
|
95
95
|
}
|
|
96
96
|
setHomeCity(t) {
|
|
97
97
|
return (
|
|
98
|
-
!!
|
|
98
|
+
!!P(t, "set home city", "the homeCity", !0) && this.wt.nu("home_city", t)
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
setLanguage(t) {
|
|
102
102
|
return (
|
|
103
|
-
!!
|
|
103
|
+
!!P(t, "set language", "the language", !0) && this.wt.nu("language", t)
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
setEmailNotificationSubscriptionType(t) {
|
|
107
107
|
return (
|
|
108
|
-
!!
|
|
108
|
+
!!J(
|
|
109
109
|
User.NotificationSubscriptionTypes,
|
|
110
110
|
t,
|
|
111
111
|
`Email notification setting "${t}" is not a valid subscription type.`,
|
|
@@ -115,7 +115,7 @@ export default class User {
|
|
|
115
115
|
}
|
|
116
116
|
setPushNotificationSubscriptionType(t) {
|
|
117
117
|
return (
|
|
118
|
-
!!
|
|
118
|
+
!!J(
|
|
119
119
|
User.NotificationSubscriptionTypes,
|
|
120
120
|
t,
|
|
121
121
|
`Push notification setting "${t}" is not a valid subscription type.`,
|
|
@@ -125,51 +125,49 @@ export default class User {
|
|
|
125
125
|
}
|
|
126
126
|
setPhoneNumber(t) {
|
|
127
127
|
return (
|
|
128
|
-
!!
|
|
129
|
-
(null === t || t.match(User
|
|
128
|
+
!!P(t, "set phone number", "the phoneNumber", !0) &&
|
|
129
|
+
(null === t || t.match(User.$n)
|
|
130
130
|
? this.wt.nu("phone", t)
|
|
131
|
-
: (r.
|
|
132
|
-
`Cannot set phone number - "${t}" did not pass validation.`,
|
|
133
|
-
),
|
|
131
|
+
: (r.error(`Cannot set phone number - "${t}" did not pass validation.`),
|
|
134
132
|
!1))
|
|
135
133
|
);
|
|
136
134
|
}
|
|
137
|
-
setLastKnownLocation(t, e, s,
|
|
135
|
+
setLastKnownLocation(t, e, s, n, i) {
|
|
138
136
|
return null == t || null == e
|
|
139
|
-
? (r.
|
|
137
|
+
? (r.error(
|
|
140
138
|
"Cannot set last-known location - latitude and longitude are required.",
|
|
141
139
|
),
|
|
142
140
|
!1)
|
|
143
141
|
: ((t = parseFloat(t.toString())),
|
|
144
142
|
(e = parseFloat(e.toString())),
|
|
145
143
|
null != s && (s = parseFloat(s.toString())),
|
|
146
|
-
null != i && (i = parseFloat(i.toString())),
|
|
147
144
|
null != n && (n = parseFloat(n.toString())),
|
|
145
|
+
null != i && (i = parseFloat(i.toString())),
|
|
148
146
|
isNaN(t) ||
|
|
149
147
|
isNaN(e) ||
|
|
150
148
|
(null != s && isNaN(s)) ||
|
|
151
|
-
(null !=
|
|
152
|
-
(null !=
|
|
153
|
-
? (r.
|
|
149
|
+
(null != n && isNaN(n)) ||
|
|
150
|
+
(null != i && isNaN(i))
|
|
151
|
+
? (r.error(
|
|
154
152
|
"Cannot set last-known location - all supplied parameters must be numeric.",
|
|
155
153
|
),
|
|
156
154
|
!1)
|
|
157
155
|
: t > 90 || t < -90 || e > 180 || e < -180
|
|
158
|
-
? (r.
|
|
156
|
+
? (r.error(
|
|
159
157
|
"Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively.",
|
|
160
158
|
),
|
|
161
159
|
!1)
|
|
162
|
-
: (null != s && s < 0) || (null !=
|
|
163
|
-
? (r.
|
|
160
|
+
: (null != s && s < 0) || (null != i && i < 0)
|
|
161
|
+
? (r.error(
|
|
164
162
|
"Cannot set last-known location - accuracy and altitudeAccuracy may not be negative.",
|
|
165
163
|
),
|
|
166
164
|
!1)
|
|
167
|
-
: this.
|
|
165
|
+
: this.Ei.setLastKnownLocation(this.wt.getUserId(), t, e, n, s, i).L);
|
|
168
166
|
}
|
|
169
|
-
setCustomUserAttribute(t, e,
|
|
167
|
+
setCustomUserAttribute(t, e, r) {
|
|
170
168
|
if (!At(t)) return !1;
|
|
171
|
-
const
|
|
172
|
-
const [r] =
|
|
169
|
+
const s = (e) => {
|
|
170
|
+
const [r] = ot(
|
|
173
171
|
e,
|
|
174
172
|
Ft,
|
|
175
173
|
"attribute value",
|
|
@@ -178,20 +176,20 @@ export default class User {
|
|
|
178
176
|
);
|
|
179
177
|
return r;
|
|
180
178
|
};
|
|
181
|
-
if (
|
|
182
|
-
const [
|
|
183
|
-
if (!
|
|
184
|
-
if (
|
|
185
|
-
for (const t of e) if (!
|
|
179
|
+
if (j(e)) {
|
|
180
|
+
const [r, n] = St(t, e);
|
|
181
|
+
if (!r && !n && 0 !== e.length) return !1;
|
|
182
|
+
if (r || 0 === e.length) return this.Ei.Bn(i.Ln, t, e).L;
|
|
183
|
+
for (const t of e) if (!s(t)) return !1;
|
|
186
184
|
} else if (Nt(e)) {
|
|
187
|
-
if (!
|
|
188
|
-
if (
|
|
185
|
+
if (!s(e)) return !1;
|
|
186
|
+
if (r) return this.Ei.Bn(i.Rn, t, e).L;
|
|
189
187
|
} else {
|
|
190
188
|
if (!(void 0 !== e && Ut(e))) return !1;
|
|
191
189
|
if (
|
|
192
190
|
(yt(e) && (e = $t(e)),
|
|
193
191
|
"string" == typeof e &&
|
|
194
|
-
!
|
|
192
|
+
!rt(
|
|
195
193
|
e,
|
|
196
194
|
`set custom user attribute "${t}"`,
|
|
197
195
|
"the element in the given array",
|
|
@@ -203,38 +201,38 @@ export default class User {
|
|
|
203
201
|
}
|
|
204
202
|
addToCustomAttributeArray(t, e) {
|
|
205
203
|
return (
|
|
206
|
-
!!
|
|
204
|
+
!!rt(t, "add to custom user attribute array", "the given key") &&
|
|
207
205
|
!(
|
|
208
206
|
null != e &&
|
|
209
|
-
!
|
|
207
|
+
!rt(e, "add to custom user attribute array", "the given value")
|
|
210
208
|
) &&
|
|
211
|
-
this.
|
|
209
|
+
this.Ei.Bn(i.On, t, e).L
|
|
212
210
|
);
|
|
213
211
|
}
|
|
214
212
|
removeFromCustomAttributeArray(t, e) {
|
|
215
213
|
return (
|
|
216
|
-
!!
|
|
214
|
+
!!rt(t, "remove from custom user attribute array", "the given key") &&
|
|
217
215
|
!(
|
|
218
216
|
null != e &&
|
|
219
|
-
!
|
|
217
|
+
!rt(e, "remove from custom user attribute array", "the given value")
|
|
220
218
|
) &&
|
|
221
|
-
this.
|
|
219
|
+
this.Ei.Bn(i.Gn, t, e).L
|
|
222
220
|
);
|
|
223
221
|
}
|
|
224
222
|
incrementCustomUserAttribute(t, e) {
|
|
225
|
-
if (!
|
|
223
|
+
if (!rt(t, "increment custom user attribute", "the given key")) return !1;
|
|
226
224
|
null == e && (e = 1);
|
|
227
225
|
const s = parseInt(e.toString());
|
|
228
226
|
return isNaN(s) || s !== parseFloat(e.toString())
|
|
229
|
-
? (r.
|
|
227
|
+
? (r.error(
|
|
230
228
|
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
|
|
231
229
|
),
|
|
232
230
|
!1)
|
|
233
|
-
: this.
|
|
231
|
+
: this.Ei.Bn(i.Hn, t, s).L;
|
|
234
232
|
}
|
|
235
233
|
setCustomLocationAttribute(t, e, s) {
|
|
236
234
|
return (
|
|
237
|
-
!!
|
|
235
|
+
!!rt(t, "set custom location attribute", "the given key") &&
|
|
238
236
|
((null !== e || null !== s) &&
|
|
239
237
|
((e = null != e ? parseFloat(e.toString()) : null),
|
|
240
238
|
(s = null != s ? parseFloat(s.toString()) : null),
|
|
@@ -242,44 +240,44 @@ export default class User {
|
|
|
242
240
|
(null != e && null == s) ||
|
|
243
241
|
(null != e && (isNaN(e) || e > 90 || e < -90)) ||
|
|
244
242
|
(null != s && (isNaN(s) || s > 180 || s < -180)))
|
|
245
|
-
? (r.
|
|
243
|
+
? (r.error(
|
|
246
244
|
"Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal.",
|
|
247
245
|
),
|
|
248
246
|
!1)
|
|
249
|
-
: this.
|
|
247
|
+
: this.Ei.Kn(t, e, s).L)
|
|
250
248
|
);
|
|
251
249
|
}
|
|
252
250
|
addToSubscriptionGroup(t) {
|
|
253
|
-
return !
|
|
251
|
+
return !P(
|
|
254
252
|
t,
|
|
255
253
|
"add user to subscription group",
|
|
256
254
|
"subscription group ID",
|
|
257
255
|
!1,
|
|
258
256
|
) || t.length <= 0
|
|
259
|
-
? (r.
|
|
257
|
+
? (r.error(
|
|
260
258
|
"addToSubscriptionGroup requires a non-empty subscription group ID",
|
|
261
259
|
),
|
|
262
260
|
!1)
|
|
263
|
-
: this.
|
|
261
|
+
: this.Ei.Mn(t, User.Yn.SUBSCRIBED).L;
|
|
264
262
|
}
|
|
265
263
|
removeFromSubscriptionGroup(t) {
|
|
266
|
-
return !
|
|
264
|
+
return !P(
|
|
267
265
|
t,
|
|
268
266
|
"remove user from subscription group",
|
|
269
267
|
"subscription group ID",
|
|
270
268
|
!1,
|
|
271
269
|
) || t.length <= 0
|
|
272
|
-
? (r.
|
|
270
|
+
? (r.error(
|
|
273
271
|
"removeFromSubscriptionGroup requires a non-empty subscription group ID",
|
|
274
272
|
),
|
|
275
273
|
!1)
|
|
276
|
-
: this.
|
|
274
|
+
: this.Ei.Mn(t, User.Yn.UNSUBSCRIBED).L;
|
|
277
275
|
}
|
|
278
|
-
|
|
279
|
-
this.wt.
|
|
276
|
+
Sn(t, e, r, s, n) {
|
|
277
|
+
this.wt.Sn(t, e, r, s, n), this.Ei.Jn();
|
|
280
278
|
}
|
|
281
|
-
|
|
282
|
-
this.wt.
|
|
279
|
+
jn(t) {
|
|
280
|
+
this.wt.jn(t);
|
|
283
281
|
}
|
|
284
282
|
}
|
|
285
283
|
(User.Genders = {
|
|
@@ -295,8 +293,8 @@ export default class User {
|
|
|
295
293
|
SUBSCRIBED: "subscribed",
|
|
296
294
|
UNSUBSCRIBED: "unsubscribed",
|
|
297
295
|
}),
|
|
298
|
-
(User
|
|
299
|
-
(User.
|
|
300
|
-
(User.
|
|
296
|
+
(User.$n = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
297
|
+
(User.Yn = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
298
|
+
(User.Qn = "user_id"),
|
|
301
299
|
(User.lu = "custom"),
|
|
302
300
|
(User.lr = 997);
|
package/src/common/base-feed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
2
|
import { ControlCard } from "../Card/index.js";
|
|
3
3
|
export const FEED_ANIMATION_DURATION = 500;
|
|
4
4
|
export default class x {
|
|
@@ -13,17 +13,17 @@ export default class x {
|
|
|
13
13
|
for (const e of this.cards) e.viewed || e instanceof ControlCard || s++;
|
|
14
14
|
return s;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
r.
|
|
16
|
+
dr() {
|
|
17
|
+
r.error("Must be implemented in a subclass");
|
|
18
18
|
}
|
|
19
19
|
logCardImpressions(s) {
|
|
20
|
-
r.
|
|
20
|
+
r.error("Must be implemented in a subclass");
|
|
21
21
|
}
|
|
22
22
|
logCardClick(s) {
|
|
23
|
-
r.
|
|
23
|
+
r.error("Must be implemented in a subclass");
|
|
24
24
|
}
|
|
25
25
|
sr() {
|
|
26
|
-
r.
|
|
26
|
+
r.error("Must be implemented in a subclass");
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
(x.
|
|
29
|
+
(x.ur = 6e4), (x.Oh = 500), (x.Co = 1e4);
|
package/src/common/constants.js
CHANGED
|
@@ -9,6 +9,8 @@ export const BRAZE_MUST_BE_INITIALIZED_ERROR =
|
|
|
9
9
|
"Braze must be initialized before calling methods.";
|
|
10
10
|
export const CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT = 5;
|
|
11
11
|
export const CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT = 90;
|
|
12
|
+
export const GLOBAL_RATE_LIMIT_CAPACITY_DEFAULT = 30;
|
|
13
|
+
export const GLOBAL_RATE_LIMIT_REFILL_RATE_DEFAULT = 30;
|
|
12
14
|
export const LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT = 72e5;
|
|
13
15
|
export const MAX_ERROR_RETRIES_CONTENT_CARDS = 3;
|
|
14
16
|
export const REQUEST_ATTEMPT_DEFAULT = 1;
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
2
|
import e from "../managers/braze-instance.js";
|
|
3
3
|
import ue from "../models/braze-event.js";
|
|
4
4
|
import t from "../models/request-result.js";
|
|
5
5
|
const s = {
|
|
6
|
-
|
|
7
|
-
var i;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
if (!
|
|
6
|
+
q: (o, n, s) => {
|
|
7
|
+
var i, l;
|
|
8
|
+
const d = new t(),
|
|
9
|
+
m = e.zr();
|
|
10
|
+
if (!m)
|
|
11
11
|
return (
|
|
12
|
-
r.
|
|
12
|
+
r.info(
|
|
13
13
|
`Not logging event with type "${o}" because the current session ID could not be found.`,
|
|
14
14
|
),
|
|
15
|
-
|
|
15
|
+
d
|
|
16
16
|
);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const u = m.xo();
|
|
18
|
+
return (
|
|
19
|
+
d.ge.push(
|
|
20
|
+
new ue(
|
|
21
|
+
s || (null === (i = e.er()) || void 0 === i ? void 0 : i.getUserId()),
|
|
22
|
+
o,
|
|
23
|
+
new Date().valueOf(),
|
|
24
|
+
u,
|
|
25
|
+
n,
|
|
26
|
+
),
|
|
25
27
|
),
|
|
28
|
+
(d.L =
|
|
29
|
+
(null === (l = e.l()) || void 0 === l ? void 0 : l.zo(d.ge)) || !1),
|
|
30
|
+
d
|
|
26
31
|
);
|
|
27
|
-
const u = e.l();
|
|
28
|
-
return u && (a.O = u.bo(a.ve)), a;
|
|
29
32
|
},
|
|
30
33
|
};
|
|
31
34
|
export default s;
|