@braze/web-sdk 4.8.3 → 4.10.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 +2247 -2071
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +7 -7
- package/shared-lib/encoding-utils.js +4 -4
- package/shared-lib/event-types.js +23 -22
- package/shared-lib/guid.js +7 -7
- package/shared-lib/indexed-db-adapter.js +172 -135
- package/shared-lib/logger.js +26 -26
- package/shared-lib/supported-options.js +14 -13
- package/shared-lib/types.js +1 -0
- package/src/Card/card-manager-factory.js +1 -1
- package/src/Card/card-manager.js +2 -2
- package/src/Card/display/card-display.js +5 -4
- package/src/Card/models/banner.js +10 -10
- package/src/Card/models/captioned-image.js +7 -7
- package/src/Card/models/card.js +37 -36
- package/src/Card/models/classic-card.js +7 -7
- package/src/Card/models/control-card.js +3 -3
- package/src/Card/models/image-only.js +32 -0
- package/src/Card/models/index.js +1 -0
- package/src/Card/util/card-factory.js +16 -16
- package/src/ContentCards/content-cards-provider-factory.js +1 -1
- package/src/ContentCards/content-cards-provider.js +102 -102
- 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 +4 -4
- package/src/ContentCards/ui/show-content-cards.js +15 -12
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/braze-sdk-metadata.js +1 -1
- package/src/Core/change-user.js +1 -1
- package/src/Core/device-properties.js +1 -1
- package/src/Core/disable-sdk.js +10 -7
- package/src/Core/enable-sdk.js +5 -2
- package/src/Core/get-device-id.js +9 -7
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +14 -14
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +4 -4
- package/src/Core/log-purchase.js +9 -9
- package/src/Core/open-session.js +10 -10
- package/src/FeatureFlags/feature-flag-factory.js +5 -3
- package/src/FeatureFlags/feature-flag.js +17 -14
- package/src/FeatureFlags/feature-flags-provider-factory.js +1 -1
- package/src/FeatureFlags/feature-flags-provider.js +56 -43
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/index.js +1 -0
- package/src/FeatureFlags/log-feature-flag-impression.js +23 -0
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
- package/src/Feed/feed-provider-factory.js +1 -1
- package/src/Feed/feed-provider.js +20 -20
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/show-feed.js +13 -10
- package/src/InAppMessage/defer-in-app-message.js +13 -0
- package/src/InAppMessage/display/get-animation-effect.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +47 -47
- package/src/InAppMessage/display/in-app-message-to-html.js +92 -91
- package/src/InAppMessage/display/modal-utils.js +16 -16
- package/src/InAppMessage/get-deferred-in-app-message.js +5 -0
- package/src/InAppMessage/in-app-message-factory.js +77 -57
- package/src/InAppMessage/in-app-message-manager-factory.js +6 -6
- package/src/InAppMessage/in-app-message-manager.js +121 -82
- package/src/InAppMessage/index.js +2 -0
- package/src/InAppMessage/log-in-app-message-button-click.js +17 -9
- package/src/InAppMessage/log-in-app-message-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-html-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/full-screen-message.js +65 -29
- package/src/InAppMessage/models/html-message.js +32 -13
- package/src/InAppMessage/models/in-app-message-button.js +7 -7
- package/src/InAppMessage/models/in-app-message.js +203 -134
- package/src/InAppMessage/models/modal-message.js +64 -29
- package/src/InAppMessage/models/slide-up-message.js +52 -24
- 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 +6 -6
- package/src/InAppMessage/ui/show-in-app-message.js +49 -47
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
- 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 +19 -19
- package/src/Push/push-manager.js +131 -131
- package/src/Push/request-push-permission.js +2 -2
- package/src/Push/unregister-push.js +2 -2
- package/src/Push/utils/push-utils.js +12 -10
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +63 -62
- package/src/common/base-feed.js +1 -1
- package/src/common/constants.js +1 -0
- package/src/common/event-logger.js +6 -6
- package/src/common/feed-display.js +34 -34
- package/src/common/translations.js +33 -33
- package/src/l10n/l10n-manager-factory.js +8 -8
- package/src/l10n/l10n-manager.js +6 -2
- package/src/l10n/types.js +1 -0
- package/src/managers/auth-manager.js +29 -29
- package/src/managers/braze-instance.js +132 -130
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +103 -98
- package/src/managers/server-config-manager.js +23 -23
- package/src/managers/session-manager.js +5 -5
- package/src/managers/storage-manager-factory.js +9 -9
- package/src/managers/storage-manager.js +134 -131
- package/src/managers/subscription-manager.js +7 -7
- package/src/models/backend-errors.js +6 -6
- package/src/models/braze-event.js +11 -11
- package/src/models/braze-sdk-metadata.js +1 -1
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +1 -1
- package/src/models/push-token.js +5 -5
- package/src/models/server-config.js +7 -7
- package/src/request-controller.js +197 -180
- package/src/triggers/models/custom-event-data.js +4 -4
- package/src/triggers/models/custom-event-property-data.js +7 -7
- package/src/triggers/models/filter-set.js +5 -5
- package/src/triggers/models/filter.js +65 -61
- package/src/triggers/models/in-app-message-click-data.js +9 -9
- package/src/triggers/models/purchase-data.js +4 -4
- package/src/triggers/models/purchase-property-data.js +6 -6
- package/src/triggers/models/push-click-data.js +6 -6
- package/src/triggers/models/trigger-condition.js +52 -56
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +50 -38
- package/src/triggers/triggers-provider-factory.js +10 -6
- package/src/triggers/triggers-provider.js +204 -186
- package/src/triggers/types.js +1 -0
- package/src/ui/js/attach-css.js +5 -4
- package/src/ui/js/feed-css.js +5 -5
- package/src/ui/js/iam-css.js +5 -5
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +35 -30
- package/src/util/browser-detector.js +30 -31
- package/src/util/client-hints-parser.js +28 -22
- package/src/util/code-utils.js +22 -21
- package/src/util/color-utils.js +19 -13
- package/src/util/component-utils.js +4 -4
- package/src/util/date-utils.js +6 -5
- package/src/util/device-constants.js +10 -10
- package/src/util/dom-utils.js +28 -24
- package/src/util/error-utils.js +1 -1
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +53 -57
- package/src/util/request-header-utils.js +34 -11
- package/src/util/string-utils.js +14 -14
- package/src/util/types.js +1 -0
- package/src/util/url-utils.js +1 -4
- package/src/util/user-agent-parser.js +39 -39
- package/src/util/validation-utils.js +34 -34
- package/src/util/window-utils.js +11 -12
package/src/User/user.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isArray as p,
|
|
3
|
-
isDate as
|
|
4
|
-
isObject as
|
|
5
|
-
validateValueIsFromEnum as H
|
|
3
|
+
isDate as yt,
|
|
4
|
+
isObject as Nt,
|
|
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
|
|
9
|
+
isValidEmail as Ct,
|
|
10
|
+
validateCustomAttributeArrayType as St,
|
|
11
|
+
validateCustomAttributeKey as At,
|
|
12
12
|
validateCustomProperties as rt,
|
|
13
13
|
validateCustomString as ot,
|
|
14
|
-
validatePropertyType as
|
|
15
|
-
validateStandardString as J
|
|
14
|
+
validatePropertyType as Ut,
|
|
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 Ft } from "../common/constants.js";
|
|
18
|
+
import { toValidBackendTimeString as $t } from "../util/date-utils.js";
|
|
19
19
|
export default class User {
|
|
20
20
|
constructor(t, e) {
|
|
21
|
-
(this.ft = t), (this.
|
|
21
|
+
(this.ft = t), (this.ki = e), (this.ft = t), (this.ki = e);
|
|
22
22
|
}
|
|
23
23
|
getUserId(t) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
),
|
|
28
|
-
|
|
24
|
+
const e = this.ft.getUserId();
|
|
25
|
+
if ("function" != typeof t) return e;
|
|
26
|
+
r.j.warn(
|
|
27
|
+
"The callback for getUserId is deprecated. You can access its return value directly instead (e.g. `const id = braze.getUser().getUserId()`)",
|
|
28
|
+
),
|
|
29
|
+
t(e);
|
|
29
30
|
}
|
|
30
31
|
addAlias(t, e) {
|
|
31
32
|
return !J(t, "add alias", "the alias", !1) || t.length <= 0
|
|
32
33
|
? (r.j.error("addAlias requires a non-empty alias"), !1)
|
|
33
34
|
: !J(e, "add alias", "the label", !1) || e.length <= 0
|
|
34
35
|
? (r.j.error("addAlias requires a non-empty label"), !1)
|
|
35
|
-
: this.
|
|
36
|
+
: this.ki.$n(t, e).O;
|
|
36
37
|
}
|
|
37
38
|
setFirstName(t) {
|
|
38
39
|
return (
|
|
@@ -46,10 +47,10 @@ export default class User {
|
|
|
46
47
|
);
|
|
47
48
|
}
|
|
48
49
|
setEmail(t) {
|
|
49
|
-
return null === t ||
|
|
50
|
+
return null === t || Ct(t)
|
|
50
51
|
? this.ft.nu("email", t)
|
|
51
52
|
: (r.j.error(
|
|
52
|
-
`Cannot set email address - "${t}" did not pass RFC-5322 validation
|
|
53
|
+
`Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
|
|
53
54
|
),
|
|
54
55
|
!1);
|
|
55
56
|
}
|
|
@@ -62,7 +63,7 @@ export default class User {
|
|
|
62
63
|
User.Genders,
|
|
63
64
|
t,
|
|
64
65
|
`Gender "${t}" is not a valid gender.`,
|
|
65
|
-
"User.Genders"
|
|
66
|
+
"User.Genders",
|
|
66
67
|
)
|
|
67
68
|
) && this.ft.nu("gender", t)
|
|
68
69
|
);
|
|
@@ -84,7 +85,7 @@ export default class User {
|
|
|
84
85
|
s > 31 ||
|
|
85
86
|
s < 1
|
|
86
87
|
? (r.j.error(
|
|
87
|
-
"Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"
|
|
88
|
+
"Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);",
|
|
88
89
|
),
|
|
89
90
|
!1)
|
|
90
91
|
: this.ft.nu("dob", `${t}-${e}-${s}`));
|
|
@@ -108,7 +109,7 @@ export default class User {
|
|
|
108
109
|
User.NotificationSubscriptionTypes,
|
|
109
110
|
t,
|
|
110
111
|
`Email notification setting "${t}" is not a valid subscription type.`,
|
|
111
|
-
"User.NotificationSubscriptionTypes"
|
|
112
|
+
"User.NotificationSubscriptionTypes",
|
|
112
113
|
) && this.ft.nu("email_subscribe", t)
|
|
113
114
|
);
|
|
114
115
|
}
|
|
@@ -118,17 +119,17 @@ export default class User {
|
|
|
118
119
|
User.NotificationSubscriptionTypes,
|
|
119
120
|
t,
|
|
120
121
|
`Push notification setting "${t}" is not a valid subscription type.`,
|
|
121
|
-
"User.NotificationSubscriptionTypes"
|
|
122
|
+
"User.NotificationSubscriptionTypes",
|
|
122
123
|
) && this.ft.nu("push_subscribe", t)
|
|
123
124
|
);
|
|
124
125
|
}
|
|
125
126
|
setPhoneNumber(t) {
|
|
126
127
|
return (
|
|
127
128
|
!!J(t, "set phone number", "the phoneNumber", !0) &&
|
|
128
|
-
(null === t || t.match(User.
|
|
129
|
+
(null === t || t.match(User.Ln)
|
|
129
130
|
? this.ft.nu("phone", t)
|
|
130
131
|
: (r.j.error(
|
|
131
|
-
`Cannot set phone number - "${t}" did not pass validation
|
|
132
|
+
`Cannot set phone number - "${t}" did not pass validation.`,
|
|
132
133
|
),
|
|
133
134
|
!1))
|
|
134
135
|
);
|
|
@@ -136,7 +137,7 @@ export default class User {
|
|
|
136
137
|
setLastKnownLocation(t, e, s, i, n) {
|
|
137
138
|
return null == t || null == e
|
|
138
139
|
? (r.j.error(
|
|
139
|
-
"Cannot set last-known location - latitude and longitude are required."
|
|
140
|
+
"Cannot set last-known location - latitude and longitude are required.",
|
|
140
141
|
),
|
|
141
142
|
!1)
|
|
142
143
|
: ((t = parseFloat(t.toString())),
|
|
@@ -150,50 +151,50 @@ export default class User {
|
|
|
150
151
|
(null != i && isNaN(i)) ||
|
|
151
152
|
(null != n && isNaN(n))
|
|
152
153
|
? (r.j.error(
|
|
153
|
-
"Cannot set last-known location - all supplied parameters must be numeric."
|
|
154
|
+
"Cannot set last-known location - all supplied parameters must be numeric.",
|
|
154
155
|
),
|
|
155
156
|
!1)
|
|
156
157
|
: t > 90 || t < -90 || e > 180 || e < -180
|
|
157
158
|
? (r.j.error(
|
|
158
|
-
"Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively."
|
|
159
|
+
"Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively.",
|
|
159
160
|
),
|
|
160
161
|
!1)
|
|
161
162
|
: (null != s && s < 0) || (null != n && n < 0)
|
|
162
163
|
? (r.j.error(
|
|
163
|
-
"Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."
|
|
164
|
+
"Cannot set last-known location - accuracy and altitudeAccuracy may not be negative.",
|
|
164
165
|
),
|
|
165
166
|
!1)
|
|
166
|
-
: this.
|
|
167
|
+
: this.ki.setLastKnownLocation(this.ft.getUserId(), t, e, i, s, n).O);
|
|
167
168
|
}
|
|
168
169
|
setCustomUserAttribute(t, e, s) {
|
|
169
|
-
if (!
|
|
170
|
-
const i = e => {
|
|
170
|
+
if (!At(t)) return !1;
|
|
171
|
+
const i = (e) => {
|
|
171
172
|
const [r] = rt(
|
|
172
173
|
e,
|
|
173
|
-
|
|
174
|
+
Ft,
|
|
174
175
|
"attribute value",
|
|
175
176
|
`set custom user attribute "${t}"`,
|
|
176
|
-
"custom user attribute"
|
|
177
|
+
"custom user attribute",
|
|
177
178
|
);
|
|
178
179
|
return r;
|
|
179
180
|
};
|
|
180
181
|
if (p(e)) {
|
|
181
|
-
const [s, n] =
|
|
182
|
+
const [s, n] = St(t, e);
|
|
182
183
|
if (!s && !n && 0 !== e.length) return !1;
|
|
183
|
-
if (s || 0 === e.length) return this.
|
|
184
|
+
if (s || 0 === e.length) return this.ki.Gn(r.q.Hn, t, e).O;
|
|
184
185
|
for (const t of e) if (!i(t)) return !1;
|
|
185
|
-
} else if (
|
|
186
|
+
} else if (Nt(e)) {
|
|
186
187
|
if (!i(e)) return !1;
|
|
187
|
-
if (s) return this.
|
|
188
|
+
if (s) return this.ki.Gn(r.q.Kn, t, e).O;
|
|
188
189
|
} else {
|
|
189
|
-
if (!(void 0 !== e &&
|
|
190
|
+
if (!(void 0 !== e && Ut(e))) return !1;
|
|
190
191
|
if (
|
|
191
|
-
(
|
|
192
|
+
(yt(e) && (e = $t(e)),
|
|
192
193
|
"string" == typeof e &&
|
|
193
194
|
!ot(
|
|
194
195
|
e,
|
|
195
196
|
`set custom user attribute "${t}"`,
|
|
196
|
-
"the element in the given array"
|
|
197
|
+
"the element in the given array",
|
|
197
198
|
))
|
|
198
199
|
)
|
|
199
200
|
return !1;
|
|
@@ -207,7 +208,7 @@ export default class User {
|
|
|
207
208
|
null != e &&
|
|
208
209
|
!ot(e, "add to custom user attribute array", "the given value")
|
|
209
210
|
) &&
|
|
210
|
-
|
|
211
|
+
this.ki.Gn(r.q.Jn, t, e).O
|
|
211
212
|
);
|
|
212
213
|
}
|
|
213
214
|
removeFromCustomAttributeArray(t, e) {
|
|
@@ -217,7 +218,7 @@ export default class User {
|
|
|
217
218
|
null != e &&
|
|
218
219
|
!ot(e, "remove from custom user attribute array", "the given value")
|
|
219
220
|
) &&
|
|
220
|
-
|
|
221
|
+
this.ki.Gn(r.q.Qn, t, e).O
|
|
221
222
|
);
|
|
222
223
|
}
|
|
223
224
|
incrementCustomUserAttribute(t, e) {
|
|
@@ -226,10 +227,10 @@ export default class User {
|
|
|
226
227
|
const s = parseInt(e.toString());
|
|
227
228
|
return isNaN(s) || s !== parseFloat(e.toString())
|
|
228
229
|
? (r.j.error(
|
|
229
|
-
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer
|
|
230
|
+
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
|
|
230
231
|
),
|
|
231
232
|
!1)
|
|
232
|
-
: this.
|
|
233
|
+
: this.ki.Gn(r.q.Xn, t, s).O;
|
|
233
234
|
}
|
|
234
235
|
setCustomLocationAttribute(t, e, s) {
|
|
235
236
|
return (
|
|
@@ -242,10 +243,10 @@ export default class User {
|
|
|
242
243
|
(null != e && (isNaN(e) || e > 90 || e < -90)) ||
|
|
243
244
|
(null != s && (isNaN(s) || s > 180 || s < -180)))
|
|
244
245
|
? (r.j.error(
|
|
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."
|
|
246
|
+
"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.",
|
|
246
247
|
),
|
|
247
248
|
!1)
|
|
248
|
-
: this.
|
|
249
|
+
: this.ki.Zn(t, e, s).O)
|
|
249
250
|
);
|
|
250
251
|
}
|
|
251
252
|
addToSubscriptionGroup(t) {
|
|
@@ -253,32 +254,32 @@ export default class User {
|
|
|
253
254
|
t,
|
|
254
255
|
"add user to subscription group",
|
|
255
256
|
"subscription group ID",
|
|
256
|
-
!1
|
|
257
|
+
!1,
|
|
257
258
|
) || t.length <= 0
|
|
258
259
|
? (r.j.error(
|
|
259
|
-
"addToSubscriptionGroup requires a non-empty subscription group ID"
|
|
260
|
+
"addToSubscriptionGroup requires a non-empty subscription group ID",
|
|
260
261
|
),
|
|
261
262
|
!1)
|
|
262
|
-
: this.
|
|
263
|
+
: this.ki.au(t, User.du.SUBSCRIBED).O;
|
|
263
264
|
}
|
|
264
265
|
removeFromSubscriptionGroup(t) {
|
|
265
266
|
return !J(
|
|
266
267
|
t,
|
|
267
268
|
"remove user from subscription group",
|
|
268
269
|
"subscription group ID",
|
|
269
|
-
!1
|
|
270
|
+
!1,
|
|
270
271
|
) || t.length <= 0
|
|
271
272
|
? (r.j.error(
|
|
272
|
-
"removeFromSubscriptionGroup requires a non-empty subscription group ID"
|
|
273
|
+
"removeFromSubscriptionGroup requires a non-empty subscription group ID",
|
|
273
274
|
),
|
|
274
275
|
!1)
|
|
275
|
-
: this.
|
|
276
|
+
: this.ki.au(t, User.du.UNSUBSCRIBED).O;
|
|
276
277
|
}
|
|
277
|
-
|
|
278
|
-
this.ft.
|
|
278
|
+
_n(t, e, r, s, i) {
|
|
279
|
+
this.ft._n(t, e, r, s, i), this.ki.pu();
|
|
279
280
|
}
|
|
280
|
-
|
|
281
|
-
this.ft.
|
|
281
|
+
Nn(t) {
|
|
282
|
+
this.ft.Nn(t);
|
|
282
283
|
}
|
|
283
284
|
}
|
|
284
285
|
(User.Genders = {
|
|
@@ -287,15 +288,15 @@ export default class User {
|
|
|
287
288
|
OTHER: "o",
|
|
288
289
|
UNKNOWN: "u",
|
|
289
290
|
NOT_APPLICABLE: "n",
|
|
290
|
-
PREFER_NOT_TO_SAY: "p"
|
|
291
|
+
PREFER_NOT_TO_SAY: "p",
|
|
291
292
|
}),
|
|
292
293
|
(User.NotificationSubscriptionTypes = {
|
|
293
294
|
OPTED_IN: "opted_in",
|
|
294
295
|
SUBSCRIBED: "subscribed",
|
|
295
|
-
UNSUBSCRIBED: "unsubscribed"
|
|
296
|
+
UNSUBSCRIBED: "unsubscribed",
|
|
296
297
|
}),
|
|
297
|
-
(User.
|
|
298
|
-
(User.
|
|
299
|
-
(User.
|
|
298
|
+
(User.Ln = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
299
|
+
(User.du = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
300
|
+
(User.bu = "user_id"),
|
|
300
301
|
(User.lu = "custom"),
|
|
301
302
|
(User.lr = 997);
|
package/src/common/base-feed.js
CHANGED
package/src/common/constants.js
CHANGED
|
@@ -11,3 +11,4 @@ export const CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT = 5;
|
|
|
11
11
|
export const CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT = 90;
|
|
12
12
|
export const LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT = 72e5;
|
|
13
13
|
export const MAX_ERROR_RETRIES_CONTENT_CARDS = 3;
|
|
14
|
+
export const REQUEST_ATTEMPT_DEFAULT = 1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
2
|
import e from "../managers/braze-instance.js";
|
|
3
|
-
import
|
|
3
|
+
import be from "../models/braze-event.js";
|
|
4
4
|
import t from "../models/request-result.js";
|
|
5
5
|
const s = {
|
|
6
6
|
N: (o, n, s) => {
|
|
@@ -10,22 +10,22 @@ const s = {
|
|
|
10
10
|
if (!l)
|
|
11
11
|
return (
|
|
12
12
|
r.j.info(
|
|
13
|
-
`Not logging event with type "${o}" because the current session ID could not be found
|
|
13
|
+
`Not logging event with type "${o}" because the current session ID could not be found.`,
|
|
14
14
|
),
|
|
15
15
|
a
|
|
16
16
|
);
|
|
17
17
|
const m = l.co();
|
|
18
18
|
a.ve.push(
|
|
19
|
-
new
|
|
19
|
+
new be(
|
|
20
20
|
s || (null === (i = e.ir()) || void 0 === i ? void 0 : i.getUserId()),
|
|
21
21
|
o,
|
|
22
22
|
new Date().valueOf(),
|
|
23
23
|
m,
|
|
24
|
-
n
|
|
25
|
-
)
|
|
24
|
+
n,
|
|
25
|
+
),
|
|
26
26
|
);
|
|
27
27
|
const u = e.l();
|
|
28
28
|
return u && (a.O = u.bo(a.ve)), a;
|
|
29
|
-
}
|
|
29
|
+
},
|
|
30
30
|
};
|
|
31
31
|
export default s;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import x from "./base-feed.js";
|
|
2
2
|
import {
|
|
3
|
-
bottomHadImpression as
|
|
4
|
-
getCardId as
|
|
5
|
-
impressOnBottom as
|
|
6
|
-
impressOnTop as
|
|
7
|
-
markCardAsRead as
|
|
8
|
-
topHadImpression as
|
|
3
|
+
bottomHadImpression as ye,
|
|
4
|
+
getCardId as Fe,
|
|
5
|
+
impressOnBottom as Te,
|
|
6
|
+
impressOnTop as xe,
|
|
7
|
+
markCardAsRead as Ee,
|
|
8
|
+
topHadImpression as he,
|
|
9
9
|
} from "../Card/display/card-display.js";
|
|
10
|
-
import { bottomIsInView as
|
|
10
|
+
import { bottomIsInView as Se, topIsInView as _e } from "../util/dom-utils.js";
|
|
11
11
|
import { Card, ControlCard } from "../Card/index.js";
|
|
12
|
-
import { cardToHtml as
|
|
12
|
+
import { cardToHtml as je } from "../Card/display/card-display.js";
|
|
13
13
|
import { isArray as p } from "../util/code-utils.js";
|
|
14
14
|
import { KeyCodes as lt } from "../util/key-codes.js";
|
|
15
|
-
import
|
|
15
|
+
import Ce from "../l10n/l10n-manager-factory.js";
|
|
16
16
|
import { removeSubscription } from "../Core/remove-subscription.js";
|
|
17
17
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
18
18
|
import { BRAZE_ACTION_URI_REGEX as X } from "../util/validation-utils.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as vt,
|
|
21
21
|
ineligibleBrazeActionURLErrorMessage as dt,
|
|
22
22
|
getDecodedBrazeAction as Q,
|
|
23
|
-
containsUnknownBrazeAction as ft
|
|
23
|
+
containsUnknownBrazeAction as ft,
|
|
24
24
|
} from "../util/braze-actions.js";
|
|
25
25
|
export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE =
|
|
26
26
|
"data-last-requested-refresh";
|
|
@@ -32,7 +32,7 @@ export function destroyFeedHtml(e) {
|
|
|
32
32
|
((e.className = e.className.replace("ab-show", "ab-hide")),
|
|
33
33
|
setTimeout(() => {
|
|
34
34
|
e && e.parentNode && e.parentNode.removeChild(e);
|
|
35
|
-
}, x.
|
|
35
|
+
}, x.Oh));
|
|
36
36
|
const t = e.getAttribute("data-update-subscription-id");
|
|
37
37
|
null != t && removeSubscription(t);
|
|
38
38
|
const o = e.getAttribute("data-listener-id");
|
|
@@ -56,19 +56,19 @@ export function generateFeedBody(e, t) {
|
|
|
56
56
|
o.appendChild(e);
|
|
57
57
|
} else {
|
|
58
58
|
let s = !1;
|
|
59
|
-
const logCardClick = t => e.logCardClick(t);
|
|
59
|
+
const logCardClick = (t) => e.logCardClick(t);
|
|
60
60
|
for (const n of e.cards) {
|
|
61
61
|
const i = n instanceof ControlCard;
|
|
62
62
|
!i || e.ur()
|
|
63
|
-
? (o.appendChild(
|
|
63
|
+
? (o.appendChild(je(n, logCardClick, t)), (s = s || !i))
|
|
64
64
|
: r.j.error(
|
|
65
|
-
"Received a control card for a legacy news feed. Control cards are only supported with content cards."
|
|
65
|
+
"Received a control card for a legacy news feed. Control cards are only supported with content cards.",
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
if (!s) {
|
|
69
69
|
const e = document.createElement("div");
|
|
70
70
|
(e.className = "ab-no-cards-message"),
|
|
71
|
-
(e.innerHTML =
|
|
71
|
+
(e.innerHTML = Ce.m().get("NO_CARDS_MESSAGE") || ""),
|
|
72
72
|
e.setAttribute("role", "article"),
|
|
73
73
|
o.appendChild(e);
|
|
74
74
|
}
|
|
@@ -79,28 +79,28 @@ export function detectFeedImpressions(e, t) {
|
|
|
79
79
|
if (null != e && null != t) {
|
|
80
80
|
const o = [],
|
|
81
81
|
s = t.querySelectorAll(".ab-card");
|
|
82
|
-
e.
|
|
82
|
+
e.yo || (e.yo = {});
|
|
83
83
|
for (let t = 0; t < s.length; t++) {
|
|
84
|
-
const n =
|
|
85
|
-
r =
|
|
86
|
-
i =
|
|
87
|
-
if (e.
|
|
88
|
-
r || i ||
|
|
84
|
+
const n = Fe(s[t]),
|
|
85
|
+
r = _e(s[t]),
|
|
86
|
+
i = Se(s[t]);
|
|
87
|
+
if (e.yo[n]) {
|
|
88
|
+
r || i || Ee(s[t]);
|
|
89
89
|
continue;
|
|
90
90
|
}
|
|
91
|
-
let a =
|
|
92
|
-
d =
|
|
91
|
+
let a = he(s[t]),
|
|
92
|
+
d = ye(s[t]);
|
|
93
93
|
const l = a,
|
|
94
94
|
c = d;
|
|
95
95
|
if (
|
|
96
|
-
(!a && r && ((a = !0),
|
|
97
|
-
!d && i && ((d = !0),
|
|
96
|
+
(!a && r && ((a = !0), xe(s[t])),
|
|
97
|
+
!d && i && ((d = !0), Te(s[t])),
|
|
98
98
|
a && d)
|
|
99
99
|
) {
|
|
100
100
|
if (l && c) continue;
|
|
101
101
|
for (const t of e.cards)
|
|
102
102
|
if (t.id === n) {
|
|
103
|
-
(e.
|
|
103
|
+
(e.yo[t.id] = !0), o.push(t);
|
|
104
104
|
break;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -123,7 +123,7 @@ export function refreshFeed(e, t) {
|
|
|
123
123
|
const o = t.querySelectorAll(".ab-initial-spinner")[0];
|
|
124
124
|
if (null != o) {
|
|
125
125
|
const e = document.createElement("span");
|
|
126
|
-
(e.innerHTML =
|
|
126
|
+
(e.innerHTML = Ce.m().get("FEED_TIMEOUT_MESSAGE") || ""),
|
|
127
127
|
null != o.parentNode &&
|
|
128
128
|
(o.parentNode.appendChild(e), o.parentNode.removeChild(o));
|
|
129
129
|
}
|
|
@@ -148,11 +148,11 @@ export function feedToHtml(e, t, o) {
|
|
|
148
148
|
i.setAttribute("aria-label", "Close Feed"),
|
|
149
149
|
i.setAttribute("tabindex", "0"),
|
|
150
150
|
i.setAttribute("role", "button");
|
|
151
|
-
const a = e => {
|
|
151
|
+
const a = (e) => {
|
|
152
152
|
destroyFeedHtml(s), e.stopPropagation();
|
|
153
153
|
};
|
|
154
|
-
i.addEventListener("keydown", e => {
|
|
155
|
-
(e.keyCode !== lt.
|
|
154
|
+
i.addEventListener("keydown", (e) => {
|
|
155
|
+
(e.keyCode !== lt.Fo && e.keyCode !== lt.To) || a(e);
|
|
156
156
|
}),
|
|
157
157
|
(i.onclick = a);
|
|
158
158
|
const d = document.createElement("i");
|
|
@@ -161,11 +161,11 @@ export function feedToHtml(e, t, o) {
|
|
|
161
161
|
d.setAttribute("aria-label", "Refresh Feed"),
|
|
162
162
|
d.setAttribute("tabindex", "0"),
|
|
163
163
|
d.setAttribute("role", "button");
|
|
164
|
-
const l = t => {
|
|
164
|
+
const l = (t) => {
|
|
165
165
|
refreshFeed(e, s), t.stopPropagation();
|
|
166
166
|
};
|
|
167
|
-
d.addEventListener("keydown", e => {
|
|
168
|
-
(e.keyCode !== lt.
|
|
167
|
+
d.addEventListener("keydown", (e) => {
|
|
168
|
+
(e.keyCode !== lt.Fo && e.keyCode !== lt.To) || l(e);
|
|
169
169
|
}),
|
|
170
170
|
(d.onclick = l),
|
|
171
171
|
n.appendChild(d),
|
|
@@ -187,7 +187,7 @@ export function updateFeedCards(e, t, o, s, n) {
|
|
|
187
187
|
if (e.url && X.test(e.url)) {
|
|
188
188
|
const t = Q(e.url);
|
|
189
189
|
if (ft(t)) {
|
|
190
|
-
r.j.error(dt(vt.
|
|
190
|
+
r.j.error(dt(vt._r, "Content Card"));
|
|
191
191
|
continue;
|
|
192
192
|
}
|
|
193
193
|
}
|