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