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