@braze/web-sdk 4.8.3 → 4.9.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 +121 -6
- 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 +22 -21
- 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 +15 -15
- 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 +3 -3
- 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 +57 -57
- 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 +125 -125
- package/src/managers/device-manager.js +20 -20
- package/src/managers/network-manager.js +100 -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 +132 -129
- package/src/managers/subscription-manager.js +8 -8
- 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 +191 -178
- 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 +64 -60
- 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 +55 -59
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +47 -35
- package/src/triggers/triggers-provider-factory.js +10 -6
- package/src/triggers/triggers-provider.js +203 -185
- 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/ui/js/load-font-awesome.js +1 -1
- 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 +30 -24
- 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 +4 -3
- package/src/util/device-constants.js +10 -10
- package/src/util/dom-utils.js +32 -28
- 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 +32 -32
- package/src/util/window-utils.js +11 -12
package/src/User/user.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isArray as p,
|
|
3
3
|
isDate as Nt,
|
|
4
|
-
isObject as
|
|
5
|
-
validateValueIsFromEnum as H
|
|
4
|
+
isObject as yt,
|
|
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
24
|
null == t &&
|
|
25
25
|
r.j.error(
|
|
26
|
-
"getUserId must be supplied with a callback. e.g., braze.getUser().getUserId(function(userId) {console.log('the user id is ' + userId)})"
|
|
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
28
|
"function" == typeof t && t(this.ft.getUserId());
|
|
29
29
|
}
|
|
@@ -32,7 +32,7 @@ export default class User {
|
|
|
32
32
|
? (r.j.error("addAlias requires a non-empty alias"), !1)
|
|
33
33
|
: !J(e, "add alias", "the label", !1) || e.length <= 0
|
|
34
34
|
? (r.j.error("addAlias requires a non-empty label"), !1)
|
|
35
|
-
: this.
|
|
35
|
+
: this.ki.$n(t, e).O;
|
|
36
36
|
}
|
|
37
37
|
setFirstName(t) {
|
|
38
38
|
return (
|
|
@@ -46,10 +46,10 @@ export default class User {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
setEmail(t) {
|
|
49
|
-
return null === t ||
|
|
49
|
+
return null === t || Ct(t)
|
|
50
50
|
? this.ft.nu("email", t)
|
|
51
51
|
: (r.j.error(
|
|
52
|
-
`Cannot set email address - "${t}" did not pass RFC-5322 validation
|
|
52
|
+
`Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
|
|
53
53
|
),
|
|
54
54
|
!1);
|
|
55
55
|
}
|
|
@@ -62,7 +62,7 @@ export default class User {
|
|
|
62
62
|
User.Genders,
|
|
63
63
|
t,
|
|
64
64
|
`Gender "${t}" is not a valid gender.`,
|
|
65
|
-
"User.Genders"
|
|
65
|
+
"User.Genders",
|
|
66
66
|
)
|
|
67
67
|
) && this.ft.nu("gender", t)
|
|
68
68
|
);
|
|
@@ -84,7 +84,7 @@ export default class User {
|
|
|
84
84
|
s > 31 ||
|
|
85
85
|
s < 1
|
|
86
86
|
? (r.j.error(
|
|
87
|
-
"Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"
|
|
87
|
+
"Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);",
|
|
88
88
|
),
|
|
89
89
|
!1)
|
|
90
90
|
: this.ft.nu("dob", `${t}-${e}-${s}`));
|
|
@@ -108,7 +108,7 @@ export default class User {
|
|
|
108
108
|
User.NotificationSubscriptionTypes,
|
|
109
109
|
t,
|
|
110
110
|
`Email notification setting "${t}" is not a valid subscription type.`,
|
|
111
|
-
"User.NotificationSubscriptionTypes"
|
|
111
|
+
"User.NotificationSubscriptionTypes",
|
|
112
112
|
) && this.ft.nu("email_subscribe", t)
|
|
113
113
|
);
|
|
114
114
|
}
|
|
@@ -118,17 +118,17 @@ export default class User {
|
|
|
118
118
|
User.NotificationSubscriptionTypes,
|
|
119
119
|
t,
|
|
120
120
|
`Push notification setting "${t}" is not a valid subscription type.`,
|
|
121
|
-
"User.NotificationSubscriptionTypes"
|
|
121
|
+
"User.NotificationSubscriptionTypes",
|
|
122
122
|
) && this.ft.nu("push_subscribe", t)
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
setPhoneNumber(t) {
|
|
126
126
|
return (
|
|
127
127
|
!!J(t, "set phone number", "the phoneNumber", !0) &&
|
|
128
|
-
(null === t || t.match(User.
|
|
128
|
+
(null === t || t.match(User.Ln)
|
|
129
129
|
? this.ft.nu("phone", t)
|
|
130
130
|
: (r.j.error(
|
|
131
|
-
`Cannot set phone number - "${t}" did not pass validation
|
|
131
|
+
`Cannot set phone number - "${t}" did not pass validation.`,
|
|
132
132
|
),
|
|
133
133
|
!1))
|
|
134
134
|
);
|
|
@@ -136,7 +136,7 @@ export default class User {
|
|
|
136
136
|
setLastKnownLocation(t, e, s, i, n) {
|
|
137
137
|
return null == t || null == e
|
|
138
138
|
? (r.j.error(
|
|
139
|
-
"Cannot set last-known location - latitude and longitude are required."
|
|
139
|
+
"Cannot set last-known location - latitude and longitude are required.",
|
|
140
140
|
),
|
|
141
141
|
!1)
|
|
142
142
|
: ((t = parseFloat(t.toString())),
|
|
@@ -150,50 +150,50 @@ export default class User {
|
|
|
150
150
|
(null != i && isNaN(i)) ||
|
|
151
151
|
(null != n && isNaN(n))
|
|
152
152
|
? (r.j.error(
|
|
153
|
-
"Cannot set last-known location - all supplied parameters must be numeric."
|
|
153
|
+
"Cannot set last-known location - all supplied parameters must be numeric.",
|
|
154
154
|
),
|
|
155
155
|
!1)
|
|
156
156
|
: t > 90 || t < -90 || e > 180 || e < -180
|
|
157
157
|
? (r.j.error(
|
|
158
|
-
"Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively."
|
|
158
|
+
"Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively.",
|
|
159
159
|
),
|
|
160
160
|
!1)
|
|
161
161
|
: (null != s && s < 0) || (null != n && n < 0)
|
|
162
162
|
? (r.j.error(
|
|
163
|
-
"Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."
|
|
163
|
+
"Cannot set last-known location - accuracy and altitudeAccuracy may not be negative.",
|
|
164
164
|
),
|
|
165
165
|
!1)
|
|
166
|
-
: this.
|
|
166
|
+
: this.ki.setLastKnownLocation(this.ft.getUserId(), t, e, i, s, n).O);
|
|
167
167
|
}
|
|
168
168
|
setCustomUserAttribute(t, e, s) {
|
|
169
|
-
if (!
|
|
170
|
-
const i = e => {
|
|
169
|
+
if (!At(t)) return !1;
|
|
170
|
+
const i = (e) => {
|
|
171
171
|
const [r] = rt(
|
|
172
172
|
e,
|
|
173
|
-
|
|
173
|
+
Ft,
|
|
174
174
|
"attribute value",
|
|
175
175
|
`set custom user attribute "${t}"`,
|
|
176
|
-
"custom user attribute"
|
|
176
|
+
"custom user attribute",
|
|
177
177
|
);
|
|
178
178
|
return r;
|
|
179
179
|
};
|
|
180
180
|
if (p(e)) {
|
|
181
|
-
const [s, n] =
|
|
181
|
+
const [s, n] = St(t, e);
|
|
182
182
|
if (!s && !n && 0 !== e.length) return !1;
|
|
183
|
-
if (s || 0 === e.length) return this.
|
|
183
|
+
if (s || 0 === e.length) return this.ki.Gn(r.q.Hn, t, e).O;
|
|
184
184
|
for (const t of e) if (!i(t)) return !1;
|
|
185
|
-
} else if (
|
|
185
|
+
} else if (yt(e)) {
|
|
186
186
|
if (!i(e)) return !1;
|
|
187
|
-
if (s) return this.
|
|
187
|
+
if (s) return this.ki.Gn(r.q.Kn, t, e).O;
|
|
188
188
|
} else {
|
|
189
|
-
if (!(void 0 !== e &&
|
|
189
|
+
if (!(void 0 !== e && Ut(e))) return !1;
|
|
190
190
|
if (
|
|
191
|
-
(Nt(e) && (e =
|
|
191
|
+
(Nt(e) && (e = $t(e)),
|
|
192
192
|
"string" == typeof e &&
|
|
193
193
|
!ot(
|
|
194
194
|
e,
|
|
195
195
|
`set custom user attribute "${t}"`,
|
|
196
|
-
"the element in the given array"
|
|
196
|
+
"the element in the given array",
|
|
197
197
|
))
|
|
198
198
|
)
|
|
199
199
|
return !1;
|
|
@@ -207,7 +207,7 @@ export default class User {
|
|
|
207
207
|
null != e &&
|
|
208
208
|
!ot(e, "add to custom user attribute array", "the given value")
|
|
209
209
|
) &&
|
|
210
|
-
|
|
210
|
+
this.ki.Gn(r.q.Jn, t, e).O
|
|
211
211
|
);
|
|
212
212
|
}
|
|
213
213
|
removeFromCustomAttributeArray(t, e) {
|
|
@@ -217,7 +217,7 @@ export default class User {
|
|
|
217
217
|
null != e &&
|
|
218
218
|
!ot(e, "remove from custom user attribute array", "the given value")
|
|
219
219
|
) &&
|
|
220
|
-
|
|
220
|
+
this.ki.Gn(r.q.Qn, t, e).O
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
223
|
incrementCustomUserAttribute(t, e) {
|
|
@@ -226,10 +226,10 @@ export default class User {
|
|
|
226
226
|
const s = parseInt(e.toString());
|
|
227
227
|
return isNaN(s) || s !== parseFloat(e.toString())
|
|
228
228
|
? (r.j.error(
|
|
229
|
-
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer
|
|
229
|
+
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
|
|
230
230
|
),
|
|
231
231
|
!1)
|
|
232
|
-
: this.
|
|
232
|
+
: this.ki.Gn(r.q.Xn, t, s).O;
|
|
233
233
|
}
|
|
234
234
|
setCustomLocationAttribute(t, e, s) {
|
|
235
235
|
return (
|
|
@@ -242,10 +242,10 @@ export default class User {
|
|
|
242
242
|
(null != e && (isNaN(e) || e > 90 || e < -90)) ||
|
|
243
243
|
(null != s && (isNaN(s) || s > 180 || s < -180)))
|
|
244
244
|
? (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."
|
|
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
246
|
),
|
|
247
247
|
!1)
|
|
248
|
-
: this.
|
|
248
|
+
: this.ki.Zn(t, e, s).O)
|
|
249
249
|
);
|
|
250
250
|
}
|
|
251
251
|
addToSubscriptionGroup(t) {
|
|
@@ -253,32 +253,32 @@ export default class User {
|
|
|
253
253
|
t,
|
|
254
254
|
"add user to subscription group",
|
|
255
255
|
"subscription group ID",
|
|
256
|
-
!1
|
|
256
|
+
!1,
|
|
257
257
|
) || t.length <= 0
|
|
258
258
|
? (r.j.error(
|
|
259
|
-
"addToSubscriptionGroup requires a non-empty subscription group ID"
|
|
259
|
+
"addToSubscriptionGroup requires a non-empty subscription group ID",
|
|
260
260
|
),
|
|
261
261
|
!1)
|
|
262
|
-
: this.
|
|
262
|
+
: this.ki.au(t, User.du.SUBSCRIBED).O;
|
|
263
263
|
}
|
|
264
264
|
removeFromSubscriptionGroup(t) {
|
|
265
265
|
return !J(
|
|
266
266
|
t,
|
|
267
267
|
"remove user from subscription group",
|
|
268
268
|
"subscription group ID",
|
|
269
|
-
!1
|
|
269
|
+
!1,
|
|
270
270
|
) || t.length <= 0
|
|
271
271
|
? (r.j.error(
|
|
272
|
-
"removeFromSubscriptionGroup requires a non-empty subscription group ID"
|
|
272
|
+
"removeFromSubscriptionGroup requires a non-empty subscription group ID",
|
|
273
273
|
),
|
|
274
274
|
!1)
|
|
275
|
-
: this.
|
|
275
|
+
: this.ki.au(t, User.du.UNSUBSCRIBED).O;
|
|
276
276
|
}
|
|
277
|
-
|
|
278
|
-
this.ft.
|
|
277
|
+
_n(t, e, r, s, i) {
|
|
278
|
+
this.ft._n(t, e, r, s, i), this.ki.pu();
|
|
279
279
|
}
|
|
280
|
-
|
|
281
|
-
this.ft.
|
|
280
|
+
Nn(t) {
|
|
281
|
+
this.ft.Nn(t);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
(User.Genders = {
|
|
@@ -287,15 +287,15 @@ export default class User {
|
|
|
287
287
|
OTHER: "o",
|
|
288
288
|
UNKNOWN: "u",
|
|
289
289
|
NOT_APPLICABLE: "n",
|
|
290
|
-
PREFER_NOT_TO_SAY: "p"
|
|
290
|
+
PREFER_NOT_TO_SAY: "p",
|
|
291
291
|
}),
|
|
292
292
|
(User.NotificationSubscriptionTypes = {
|
|
293
293
|
OPTED_IN: "opted_in",
|
|
294
294
|
SUBSCRIBED: "subscribed",
|
|
295
|
-
UNSUBSCRIBED: "unsubscribed"
|
|
295
|
+
UNSUBSCRIBED: "unsubscribed",
|
|
296
296
|
}),
|
|
297
|
-
(User.
|
|
298
|
-
(User.
|
|
299
|
-
(User.
|
|
297
|
+
(User.Ln = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
298
|
+
(User.du = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
299
|
+
(User.bu = "user_id"),
|
|
300
300
|
(User.lu = "custom"),
|
|
301
301
|
(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
|
}
|