@braze/web-sdk 6.3.1 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.d.ts +38 -5
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +30 -30
- package/shared-lib/guid.js +1 -1
- package/shared-lib/indexed-db-adapter.js +60 -60
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +24 -23
- package/src/Banner/banner-provider.js +95 -81
- package/src/Banner/banner.js +9 -9
- package/src/Banner/constants.js +4 -0
- package/src/Banner/display/banner-to-html.js +3 -3
- package/src/Banner/display/destroy-banner-html.js +3 -3
- package/src/Banner/display/detect-banner-impressions.js +16 -16
- package/src/Banner/get-all-banners.js +4 -4
- package/src/Banner/get-banner.js +5 -4
- package/src/Banner/index.js +2 -0
- package/src/Banner/log-banner-click.js +2 -2
- package/src/Banner/log-banner-impressions.js +6 -6
- package/src/Banner/request-banners-refresh.js +18 -20
- package/src/Banner/subscribe-to-banners-updates.js +5 -5
- package/src/Banner/ui/insert-banner.js +17 -14
- package/src/Card/card-manager-factory.js +6 -6
- package/src/Card/card-manager.js +28 -28
- package/src/Card/constants.js +1 -0
- package/src/Card/display/card-display.js +7 -7
- package/src/Card/log-card-dismissal.js +3 -3
- package/src/Card/log-content-card-click.js +3 -3
- package/src/Card/log-content-card-impressions.js +6 -6
- package/src/Card/models/captioned-image.js +3 -3
- package/src/Card/models/card.js +9 -9
- package/src/Card/models/classic-card.js +3 -3
- package/src/Card/models/control-card.js +3 -3
- package/src/Card/models/image-only.js +3 -3
- package/src/ContentCards/content-cards-provider-factory.js +6 -2
- package/src/ContentCards/content-cards-provider.js +101 -87
- package/src/ContentCards/content-cards.js +4 -4
- 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 +5 -5
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +1 -1
- package/src/Core/disable-sdk.js +5 -5
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +3 -3
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +7 -7
- package/src/Core/log-purchase.js +4 -4
- package/src/Core/open-session.js +6 -6
- package/src/Core/wipe-data.js +3 -3
- package/src/DUST/dust-connection-core.js +23 -0
- package/src/DUST/dust-provider-factory.js +22 -0
- package/src/DUST/dust-provider.js +520 -0
- package/src/DUST/dust-shared-worker-code.js +2 -0
- package/src/DUST/dust-shared-worker-impl.js +240 -0
- package/src/DUST/dust-worker-bridge.js +136 -0
- package/src/DUST/index.js +13 -0
- package/src/DUST/subscribe-to-dust.js +24 -0
- package/src/DUST/types.js +1 -0
- package/src/FeatureFlags/feature-flag-factory.js +8 -8
- package/src/FeatureFlags/feature-flag.js +6 -6
- package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +98 -84
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +3 -3
- package/src/FeatureFlags/log-feature-flag-impression.js +7 -7
- package/src/FeatureFlags/refresh-feature-flags.js +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -4
- package/src/InAppMessage/constants.js +4 -0
- package/src/InAppMessage/defer-in-app-message.js +2 -2
- package/src/InAppMessage/display/get-animation-effect.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +6 -6
- package/src/InAppMessage/display/in-app-message-to-html.js +34 -34
- package/src/InAppMessage/display/modal-utils.js +14 -14
- package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
- package/src/InAppMessage/in-app-message-manager.js +98 -98
- package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-click.js +11 -11
- package/src/InAppMessage/log-in-app-message-html-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-impression.js +8 -8
- package/src/InAppMessage/models/control-message.js +5 -5
- package/src/InAppMessage/models/full-screen-message.js +21 -21
- package/src/InAppMessage/models/html-message.js +18 -18
- package/src/InAppMessage/models/in-app-message-button.js +7 -7
- package/src/InAppMessage/models/in-app-message.js +145 -145
- package/src/InAppMessage/models/modal-message.js +21 -21
- package/src/InAppMessage/models/slide-up-message.js +27 -27
- 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 +5 -5
- package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +18 -0
- package/src/InAppMessage/ui/show-in-app-message.js +36 -36
- 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 +15 -15
- package/src/Push/push-manager.js +97 -97
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/Push/utils/push-utils.js +17 -17
- package/src/User/user-manager.js +24 -24
- package/src/User/user.js +55 -55
- package/src/common/constants.js +8 -10
- package/src/common/content-cards-display.js +40 -40
- package/src/common/event-logger.js +8 -8
- package/src/common/properties-base.js +16 -16
- package/src/l10n/l10n-manager-factory.js +11 -11
- package/src/l10n/l10n-manager.js +2 -2
- package/src/managers/auth-manager.js +30 -30
- package/src/managers/braze-instance.js +170 -162
- package/src/managers/device-manager.js +24 -24
- package/src/managers/network-manager.js +149 -149
- package/src/managers/server-config-manager.js +140 -95
- package/src/managers/session-manager.js +39 -39
- package/src/managers/storage-manager-factory.js +10 -10
- package/src/managers/storage-manager.js +145 -141
- package/src/managers/subscription-manager.js +11 -11
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +11 -11
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +16 -16
- package/src/models/push-token.js +13 -13
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +45 -37
- package/src/request-controller.js +163 -158
- package/src/triggers/models/custom-event-data.js +5 -5
- package/src/triggers/models/custom-event-property-data.js +6 -6
- package/src/triggers/models/filter-set.js +10 -10
- package/src/triggers/models/filter.js +27 -27
- package/src/triggers/models/in-app-message-click-data.js +13 -13
- package/src/triggers/models/purchase-data.js +2 -2
- 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 +47 -47
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +5 -5
- package/src/triggers/triggers-provider.js +63 -63
- 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 +9 -9
- package/src/util/braze-actions.js +5 -5
- package/src/util/browser-detector.js +37 -37
- package/src/util/client-hints-parser.js +11 -11
- package/src/util/component-utils.js +5 -5
- package/src/util/dom-utils.js +13 -13
- package/src/util/html-display-utils.js +7 -7
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +5 -5
- package/src/util/request-header-utils.js +27 -27
- package/src/util/user-agent-parser.js +21 -21
- package/src/util/validation-utils.js +17 -17
- package/src/util/window-utils.js +3 -3
package/src/User/user.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isArray as
|
|
2
|
+
isArray as R,
|
|
3
3
|
isDate as Nt,
|
|
4
|
-
isObject as
|
|
4
|
+
isObject as yt,
|
|
5
5
|
validateValueIsFromEnum as ta,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
|
-
import { logger as E, EventTypes as
|
|
7
|
+
import { logger as E, EventTypes as f } from "../../shared-lib/index.js";
|
|
8
8
|
import {
|
|
9
|
-
isValidEmail as
|
|
10
|
-
validateCustomAttributeArrayType as
|
|
11
|
-
validateCustomAttributeKey as
|
|
9
|
+
isValidEmail as It,
|
|
10
|
+
validateCustomAttributeArrayType as Ct,
|
|
11
|
+
validateCustomAttributeKey as St,
|
|
12
12
|
validateCustomProperties as nt,
|
|
13
13
|
validateCustomString as mt,
|
|
14
|
-
validatePropertyType as
|
|
14
|
+
validatePropertyType as Ut,
|
|
15
15
|
validateStandardString as ir,
|
|
16
16
|
} from "../util/validation-utils.js";
|
|
17
|
-
import {
|
|
18
|
-
import { toValidBackendTimeString as
|
|
17
|
+
import { CoreStrings as z } from "../common/constants.js";
|
|
18
|
+
import { toValidBackendTimeString as Dt } from "../util/date-utils.js";
|
|
19
19
|
export default class User {
|
|
20
20
|
constructor(t, e) {
|
|
21
|
-
(this.
|
|
21
|
+
(this.vs = t), (this.Ru = e), (this.vs = t), (this.Ru = e);
|
|
22
22
|
}
|
|
23
23
|
getUserId(t) {
|
|
24
|
-
const e = this.
|
|
24
|
+
const e = this.vs.getUserId();
|
|
25
25
|
if ("function" != typeof t) return e;
|
|
26
26
|
E.warn(
|
|
27
27
|
"The callback for getUserId is deprecated. You can access its return value directly instead (e.g. `const id = braze.getUser().getUserId()`)",
|
|
@@ -33,22 +33,22 @@ export default class User {
|
|
|
33
33
|
? (E.error("addAlias requires a non-empty alias"), !1)
|
|
34
34
|
: !ir(e, "add alias", "the label", !1) || e.length <= 0
|
|
35
35
|
? (E.error("addAlias requires a non-empty label"), !1)
|
|
36
|
-
: this.
|
|
36
|
+
: this.Ru.Gu(t, e).W;
|
|
37
37
|
}
|
|
38
38
|
setFirstName(t) {
|
|
39
39
|
return (
|
|
40
40
|
!!ir(t, "set first name", "the firstName", !0) &&
|
|
41
|
-
this.
|
|
41
|
+
this.vs.zu("first_name", t)
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
setLastName(t) {
|
|
45
45
|
return (
|
|
46
|
-
!!ir(t, "set last name", "the lastName", !0) && this.
|
|
46
|
+
!!ir(t, "set last name", "the lastName", !0) && this.vs.zu("last_name", t)
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
setEmail(t) {
|
|
50
|
-
return null === t ||
|
|
51
|
-
? this.
|
|
50
|
+
return null === t || It(t)
|
|
51
|
+
? this.vs.zu("email", t)
|
|
52
52
|
: (E.error(
|
|
53
53
|
`Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
|
|
54
54
|
),
|
|
@@ -65,12 +65,12 @@ export default class User {
|
|
|
65
65
|
`Gender "${t}" is not a valid gender.`,
|
|
66
66
|
"User.Genders",
|
|
67
67
|
)
|
|
68
|
-
) && this.
|
|
68
|
+
) && this.vs.zu("gender", t)
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
setDateOfBirth(t, e, r) {
|
|
72
72
|
return null === t && null === e && null === r
|
|
73
|
-
? this.
|
|
73
|
+
? this.vs.zu("dob", null)
|
|
74
74
|
: ((t = null != t ? parseInt(t.toString()) : null),
|
|
75
75
|
(e = null != e ? parseInt(e.toString()) : null),
|
|
76
76
|
(r = null != r ? parseInt(r.toString()) : null),
|
|
@@ -88,21 +88,21 @@ export default class User {
|
|
|
88
88
|
"Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);",
|
|
89
89
|
),
|
|
90
90
|
!1)
|
|
91
|
-
: this.
|
|
91
|
+
: this.vs.zu("dob", `${t}-${e}-${r}`));
|
|
92
92
|
}
|
|
93
93
|
setCountry(t) {
|
|
94
94
|
return (
|
|
95
|
-
!!ir(t, "set country", "the country", !0) && this.
|
|
95
|
+
!!ir(t, "set country", "the country", !0) && this.vs.zu("country", t)
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
setHomeCity(t) {
|
|
99
99
|
return (
|
|
100
|
-
!!ir(t, "set home city", "the homeCity", !0) && this.
|
|
100
|
+
!!ir(t, "set home city", "the homeCity", !0) && this.vs.zu("home_city", t)
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
setLanguage(t) {
|
|
104
104
|
return (
|
|
105
|
-
!!ir(t, "set language", "the language", !0) && this.
|
|
105
|
+
!!ir(t, "set language", "the language", !0) && this.vs.zu("language", t)
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
setEmailNotificationSubscriptionType(t) {
|
|
@@ -112,7 +112,7 @@ export default class User {
|
|
|
112
112
|
t,
|
|
113
113
|
`Email notification setting "${t}" is not a valid subscription type.`,
|
|
114
114
|
"User.NotificationSubscriptionTypes",
|
|
115
|
-
) && this.
|
|
115
|
+
) && this.vs.zu("email_subscribe", t)
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
setPushNotificationSubscriptionType(t) {
|
|
@@ -122,14 +122,14 @@ export default class User {
|
|
|
122
122
|
t,
|
|
123
123
|
`Push notification setting "${t}" is not a valid subscription type.`,
|
|
124
124
|
"User.NotificationSubscriptionTypes",
|
|
125
|
-
) && this.
|
|
125
|
+
) && this.vs.zu("push_subscribe", t)
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
setPhoneNumber(t) {
|
|
129
129
|
return (
|
|
130
130
|
!!ir(t, "set phone number", "the phoneNumber", !0) &&
|
|
131
|
-
(null === t || t.match(User.
|
|
132
|
-
? this.
|
|
131
|
+
(null === t || t.match(User.Hu)
|
|
132
|
+
? this.vs.zu("phone", t)
|
|
133
133
|
: (E.error(`Cannot set phone number - "${t}" did not pass validation.`),
|
|
134
134
|
!1))
|
|
135
135
|
);
|
|
@@ -164,32 +164,32 @@ export default class User {
|
|
|
164
164
|
"Cannot set last-known location - accuracy and altitudeAccuracy may not be negative.",
|
|
165
165
|
),
|
|
166
166
|
!1)
|
|
167
|
-
: this.
|
|
167
|
+
: this.Ru.setLastKnownLocation(this.vs.getUserId(), t, e, s, r, n).W);
|
|
168
168
|
}
|
|
169
169
|
setCustomUserAttribute(t, e, r) {
|
|
170
|
-
if (!
|
|
170
|
+
if (!St(t)) return !1;
|
|
171
171
|
const s = (e) => {
|
|
172
172
|
const [r] = nt(
|
|
173
173
|
e,
|
|
174
|
-
|
|
174
|
+
z.Ku,
|
|
175
175
|
"attribute value",
|
|
176
176
|
`set custom user attribute "${t}"`,
|
|
177
177
|
"custom user attribute",
|
|
178
178
|
);
|
|
179
179
|
return r;
|
|
180
180
|
};
|
|
181
|
-
if (
|
|
182
|
-
const [r, n] =
|
|
181
|
+
if (R(e)) {
|
|
182
|
+
const [r, n] = Ct(t, e);
|
|
183
183
|
if (!r && !n && 0 !== e.length) return !1;
|
|
184
|
-
if (r || 0 === e.length) return this.
|
|
184
|
+
if (r || 0 === e.length) return this.Ru.Mu(f.Yu, t, e).W;
|
|
185
185
|
for (const t of e) if (!s(t)) return !1;
|
|
186
|
-
} else if (
|
|
186
|
+
} else if (yt(e)) {
|
|
187
187
|
if (!s(e)) return !1;
|
|
188
|
-
if (r) return this.
|
|
188
|
+
if (r) return this.Ru.Mu(f.Vu, t, e).W;
|
|
189
189
|
} else {
|
|
190
|
-
if (!(void 0 !== e &&
|
|
190
|
+
if (!(void 0 !== e && Ut(e))) return !1;
|
|
191
191
|
if (
|
|
192
|
-
(Nt(e) && (e =
|
|
192
|
+
(Nt(e) && (e = Dt(e)),
|
|
193
193
|
"string" == typeof e &&
|
|
194
194
|
!mt(
|
|
195
195
|
e,
|
|
@@ -199,7 +199,7 @@ export default class User {
|
|
|
199
199
|
)
|
|
200
200
|
return !1;
|
|
201
201
|
}
|
|
202
|
-
return this.
|
|
202
|
+
return this.vs.setCustomUserAttribute(t, e);
|
|
203
203
|
}
|
|
204
204
|
addToCustomAttributeArray(t, e) {
|
|
205
205
|
return (
|
|
@@ -208,7 +208,7 @@ export default class User {
|
|
|
208
208
|
null != e &&
|
|
209
209
|
!mt(e, "add to custom user attribute array", "the given value")
|
|
210
210
|
) &&
|
|
211
|
-
this.
|
|
211
|
+
this.Ru.Mu(f.Qu, t, e).W
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
removeFromCustomAttributeArray(t, e) {
|
|
@@ -218,7 +218,7 @@ export default class User {
|
|
|
218
218
|
null != e &&
|
|
219
219
|
!mt(e, "remove from custom user attribute array", "the given value")
|
|
220
220
|
) &&
|
|
221
|
-
this.
|
|
221
|
+
this.Ru.Mu(f.Xu, t, e).W
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
224
|
incrementCustomUserAttribute(t, e) {
|
|
@@ -230,7 +230,7 @@ export default class User {
|
|
|
230
230
|
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
|
|
231
231
|
),
|
|
232
232
|
!1)
|
|
233
|
-
: this.
|
|
233
|
+
: this.Ru.Mu(f.Zu, t, r).W;
|
|
234
234
|
}
|
|
235
235
|
setCustomLocationAttribute(t, e, r) {
|
|
236
236
|
return (
|
|
@@ -246,7 +246,7 @@ export default class User {
|
|
|
246
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.",
|
|
247
247
|
),
|
|
248
248
|
!1)
|
|
249
|
-
: this.
|
|
249
|
+
: this.Ru.Na(t, e, r).W)
|
|
250
250
|
);
|
|
251
251
|
}
|
|
252
252
|
addToSubscriptionGroup(t) {
|
|
@@ -260,7 +260,7 @@ export default class User {
|
|
|
260
260
|
"addToSubscriptionGroup requires a non-empty subscription group ID",
|
|
261
261
|
),
|
|
262
262
|
!1)
|
|
263
|
-
: this.
|
|
263
|
+
: this.Ru.Ra(t, User.Pa.SUBSCRIBED).W;
|
|
264
264
|
}
|
|
265
265
|
removeFromSubscriptionGroup(t) {
|
|
266
266
|
return !ir(
|
|
@@ -273,24 +273,24 @@ export default class User {
|
|
|
273
273
|
"removeFromSubscriptionGroup requires a non-empty subscription group ID",
|
|
274
274
|
),
|
|
275
275
|
!1)
|
|
276
|
-
: this.
|
|
276
|
+
: this.Ru.Ra(t, User.Pa.UNSUBSCRIBED).W;
|
|
277
277
|
}
|
|
278
278
|
setLineId(t) {
|
|
279
279
|
return ir(t, "set LINE user ID", "the ID", !0) &&
|
|
280
280
|
0 !== (null == t ? void 0 : t.length)
|
|
281
|
-
? t && t.length > User.
|
|
281
|
+
? t && t.length > User.Oa
|
|
282
282
|
? (E.error(
|
|
283
|
-
`Rejected LINE user ID ${t} because it is longer than ${User.
|
|
283
|
+
`Rejected LINE user ID ${t} because it is longer than ${User.Oa} characters.`,
|
|
284
284
|
),
|
|
285
285
|
!1)
|
|
286
|
-
: this.
|
|
286
|
+
: this.vs.zu("native_line_id", t)
|
|
287
287
|
: (E.error("setLineId requires a non-empty ID"), !1);
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
this.
|
|
289
|
+
gu(t, e, r, s, n) {
|
|
290
|
+
this.vs.gu(t, e, r, s, n), this.Ru.Ya();
|
|
291
291
|
}
|
|
292
|
-
|
|
293
|
-
this.
|
|
292
|
+
wu(t) {
|
|
293
|
+
this.vs.wu(t);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
(User.Genders = {
|
|
@@ -306,9 +306,9 @@ export default class User {
|
|
|
306
306
|
SUBSCRIBED: "subscribed",
|
|
307
307
|
UNSUBSCRIBED: "unsubscribed",
|
|
308
308
|
}),
|
|
309
|
-
(User.
|
|
310
|
-
(User.
|
|
311
|
-
(User.
|
|
312
|
-
(User.
|
|
309
|
+
(User.Hu = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
310
|
+
(User.Pa = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
311
|
+
(User.Va = "user_id"),
|
|
312
|
+
(User.Bu = "custom"),
|
|
313
313
|
(User.mr = 997),
|
|
314
|
-
(User.
|
|
314
|
+
(User.Oa = 33);
|
package/src/common/constants.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
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
2
|
export const FEED_ANIMATION_DURATION = 500;
|
|
6
|
-
export const LOG_CUSTOM_EVENT_STRING = "logCustomEvent";
|
|
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
3
|
export const GLOBAL_RATE_LIMIT_CAPACITY_DEFAULT = 30;
|
|
11
4
|
export const GLOBAL_RATE_LIMIT_REFILL_RATE_DEFAULT = 30;
|
|
12
5
|
export const LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT = 72e5;
|
|
13
6
|
export const MAX_RETRY_COUNT_PER_REQUEST = 15;
|
|
14
7
|
export const REQUEST_ATTEMPT_DEFAULT = 1;
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
17
|
-
|
|
8
|
+
export const REQUEST_BACKOFF_MIN_SLEEP_MS_DEFAULT = 1e4;
|
|
9
|
+
export const REQUEST_BACKOFF_SCALE_FACTOR_DEFAULT = 3;
|
|
10
|
+
export const REQUEST_BACKOFF_MAX_SLEEP_MS_DEFAULT = 3e5;
|
|
11
|
+
export const CoreStrings = {
|
|
12
|
+
ee: "Braze must be initialized before calling methods.",
|
|
13
|
+
$e: "logCustomEvent",
|
|
14
|
+
Ku: "setCustomUserAttribute",
|
|
15
|
+
};
|
|
@@ -2,28 +2,28 @@ import {
|
|
|
2
2
|
getCardId as xt,
|
|
3
3
|
markCardAsRead as Rt,
|
|
4
4
|
} from "../Card/display/card-display.js";
|
|
5
|
-
import { bottomIsInView as
|
|
5
|
+
import { bottomIsInView as I, topIsInView as B } from "../util/dom-utils.js";
|
|
6
6
|
import { Card, ControlCard } from "../Card/index.js";
|
|
7
|
-
import { cardToHtml as
|
|
8
|
-
import { isArray as
|
|
9
|
-
import { KeyCodes as
|
|
10
|
-
import
|
|
7
|
+
import { cardToHtml as Lt } from "../Card/display/card-display.js";
|
|
8
|
+
import { isArray as R } from "../util/code-utils.js";
|
|
9
|
+
import { KeyCodes as Ce } from "../util/key-codes.js";
|
|
10
|
+
import Me from "../l10n/l10n-manager-factory.js";
|
|
11
11
|
import { removeSubscription } from "../Core/remove-subscription.js";
|
|
12
12
|
import { logger as E, Guid as P } from "../../shared-lib/index.js";
|
|
13
13
|
import { BRAZE_ACTION_URI_REGEX as to } from "../util/validation-utils.js";
|
|
14
14
|
import {
|
|
15
|
-
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as
|
|
16
|
-
ineligibleBrazeActionURLErrorMessage as
|
|
15
|
+
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as jt,
|
|
16
|
+
ineligibleBrazeActionURLErrorMessage as dt,
|
|
17
17
|
getDecodedBrazeAction as eo,
|
|
18
|
-
containsUnknownBrazeAction as
|
|
18
|
+
containsUnknownBrazeAction as gt,
|
|
19
19
|
} from "../util/braze-actions.js";
|
|
20
20
|
import {
|
|
21
|
-
bottomHadImpression as
|
|
22
|
-
impressOnBottom as
|
|
23
|
-
impressOnTop as
|
|
24
|
-
topHadImpression as
|
|
21
|
+
bottomHadImpression as Ft,
|
|
22
|
+
impressOnBottom as $,
|
|
23
|
+
impressOnTop as g,
|
|
24
|
+
topHadImpression as Ht,
|
|
25
25
|
} from "./detect-impression.js";
|
|
26
|
-
import {
|
|
26
|
+
import { BannerStrings as j } from "../Banner/constants.js";
|
|
27
27
|
import ContentCards from "../ContentCards/content-cards.js";
|
|
28
28
|
export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE =
|
|
29
29
|
"data-last-requested-refresh";
|
|
@@ -34,8 +34,8 @@ export function destroyContentCardsHtml(t) {
|
|
|
34
34
|
((t.className = t.className.replace("ab-show", "ab-hide")),
|
|
35
35
|
setTimeout(() => {
|
|
36
36
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
37
|
-
}, ContentCards.
|
|
38
|
-
const e = t.getAttribute(
|
|
37
|
+
}, ContentCards.hr));
|
|
38
|
+
const e = t.getAttribute(j.ea);
|
|
39
39
|
null != e && removeSubscription(e);
|
|
40
40
|
const n = t.getAttribute("data-listener-id");
|
|
41
41
|
null != n &&
|
|
@@ -43,7 +43,7 @@ export function destroyContentCardsHtml(t) {
|
|
|
43
43
|
delete scrollListeners[n]);
|
|
44
44
|
}
|
|
45
45
|
export function generateContentCardsUI(t, e) {
|
|
46
|
-
const n =
|
|
46
|
+
const n = Me.ra(),
|
|
47
47
|
o = document.createElement("div");
|
|
48
48
|
if (
|
|
49
49
|
((o.className = "ab-feed-body"),
|
|
@@ -59,11 +59,11 @@ export function generateContentCardsUI(t, e) {
|
|
|
59
59
|
o.appendChild(t);
|
|
60
60
|
} else {
|
|
61
61
|
let s = !1;
|
|
62
|
-
const r = (e) => t.
|
|
62
|
+
const r = (e) => t.dr(e);
|
|
63
63
|
for (const a of t.cards) {
|
|
64
64
|
const i = a instanceof ControlCard;
|
|
65
|
-
!i || t.
|
|
66
|
-
? (o.appendChild(
|
|
65
|
+
!i || t.cr()
|
|
66
|
+
? (o.appendChild(Lt(a, r, e, n.Ta())), (s = s || !i))
|
|
67
67
|
: E.error(
|
|
68
68
|
"Received a control card for a legacy news feed. Control cards are only supported with content cards.",
|
|
69
69
|
);
|
|
@@ -82,26 +82,26 @@ export function detectContentCardsImpressions(t, e) {
|
|
|
82
82
|
if (null != t && null != e) {
|
|
83
83
|
const n = [],
|
|
84
84
|
o = e.querySelectorAll(".ab-card");
|
|
85
|
-
t.
|
|
85
|
+
t.Qa || (t.Qa = {});
|
|
86
86
|
for (let e = 0; e < o.length; e++) {
|
|
87
87
|
const s = xt(o[e]),
|
|
88
|
-
r =
|
|
89
|
-
a =
|
|
90
|
-
if (t.
|
|
88
|
+
r = B(o[e]),
|
|
89
|
+
a = I(o[e]);
|
|
90
|
+
if (t.Qa[s]) {
|
|
91
91
|
r || a || Rt(o[e]);
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
94
|
-
let i =
|
|
95
|
-
l =
|
|
96
|
-
const
|
|
97
|
-
|
|
94
|
+
let i = Ht(o[e]),
|
|
95
|
+
l = Ft(o[e]);
|
|
96
|
+
const d = i,
|
|
97
|
+
c = l;
|
|
98
98
|
if (
|
|
99
|
-
(!i && r && ((i = !0),
|
|
99
|
+
(!i && r && ((i = !0), g(o[e])), !l && a && ((l = !0), $(o[e])), i && l)
|
|
100
100
|
) {
|
|
101
|
-
if (
|
|
101
|
+
if (d && c) continue;
|
|
102
102
|
for (const e of t.cards)
|
|
103
103
|
if (e.id === s) {
|
|
104
|
-
(t.
|
|
104
|
+
(t.Qa[e.id] = !0), n.push(e);
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -124,15 +124,15 @@ export function refreshContentCardsUI(t, e) {
|
|
|
124
124
|
const n = e.querySelectorAll(".ab-initial-spinner")[0];
|
|
125
125
|
if (null != n) {
|
|
126
126
|
const t = document.createElement("span");
|
|
127
|
-
(t.innerHTML =
|
|
127
|
+
(t.innerHTML = Me.ra().get("FEED_TIMEOUT_MESSAGE") || ""),
|
|
128
128
|
null != n.parentNode &&
|
|
129
129
|
(n.parentNode.appendChild(t), n.parentNode.removeChild(n));
|
|
130
130
|
}
|
|
131
131
|
"true" === e.getAttribute("aria-busy") &&
|
|
132
132
|
e.setAttribute("aria-busy", "false");
|
|
133
133
|
}
|
|
134
|
-
}, ContentCards.
|
|
135
|
-
t.
|
|
134
|
+
}, ContentCards.lr),
|
|
135
|
+
t.ur();
|
|
136
136
|
}
|
|
137
137
|
export function contentCardsToHtml(t, e, n) {
|
|
138
138
|
const o = document.createElement("div");
|
|
@@ -153,7 +153,7 @@ export function contentCardsToHtml(t, e, n) {
|
|
|
153
153
|
destroyContentCardsHtml(o), t.stopPropagation();
|
|
154
154
|
};
|
|
155
155
|
r.addEventListener("keydown", (t) => {
|
|
156
|
-
(t.keyCode !==
|
|
156
|
+
(t.keyCode !== Ce.Ho && t.keyCode !== Ce.Go) || a(t);
|
|
157
157
|
}),
|
|
158
158
|
(r.onclick = a);
|
|
159
159
|
const i = document.createElement("i");
|
|
@@ -166,7 +166,7 @@ export function contentCardsToHtml(t, e, n) {
|
|
|
166
166
|
refreshContentCardsUI(t, o), e.stopPropagation();
|
|
167
167
|
};
|
|
168
168
|
i.addEventListener("keydown", (t) => {
|
|
169
|
-
(t.keyCode !==
|
|
169
|
+
(t.keyCode !== Ce.Ho && t.keyCode !== Ce.Go) || l(t);
|
|
170
170
|
}),
|
|
171
171
|
(i.onclick = l),
|
|
172
172
|
s.appendChild(i),
|
|
@@ -175,20 +175,20 @@ export function contentCardsToHtml(t, e, n) {
|
|
|
175
175
|
const d = () => detectContentCardsImpressions(t, o);
|
|
176
176
|
if ((o.addEventListener("scroll", d), !n)) {
|
|
177
177
|
window.addEventListener("scroll", d);
|
|
178
|
-
const t = P.
|
|
178
|
+
const t = P.se();
|
|
179
179
|
(scrollListeners[t] = d), o.setAttribute("data-listener-id", t);
|
|
180
180
|
}
|
|
181
181
|
return o;
|
|
182
182
|
}
|
|
183
183
|
export function updateContentCards(t, e, n, o, s) {
|
|
184
|
-
if (!
|
|
184
|
+
if (!R(e)) return;
|
|
185
185
|
const r = [];
|
|
186
186
|
for (const t of e)
|
|
187
187
|
if (t instanceof Card) {
|
|
188
188
|
if (t.url && to.test(t.url)) {
|
|
189
189
|
const e = eo(t.url);
|
|
190
|
-
if (
|
|
191
|
-
E.error(jt
|
|
190
|
+
if (gt(e)) {
|
|
191
|
+
E.error(dt(jt.Pn, "Content Card"));
|
|
192
192
|
continue;
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -207,5 +207,5 @@ export function updateContentCards(t, e, n, o, s) {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
export function registerContentCardsSubscriptionId(t, e) {
|
|
210
|
-
t && e.setAttribute(
|
|
210
|
+
t && e.setAttribute(j.ea, t);
|
|
211
211
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
|
-
import
|
|
3
|
+
import De from "../models/braze-event.js";
|
|
4
4
|
import H from "../models/request-result.js";
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const v = {
|
|
6
|
+
lt: (e, o, t) => {
|
|
7
7
|
var n, s;
|
|
8
8
|
const i = new H(),
|
|
9
9
|
l = r.u();
|
|
@@ -14,10 +14,10 @@ const c = {
|
|
|
14
14
|
),
|
|
15
15
|
i
|
|
16
16
|
);
|
|
17
|
-
const d = l.
|
|
17
|
+
const d = l.el();
|
|
18
18
|
return (
|
|
19
|
-
i.
|
|
20
|
-
new
|
|
19
|
+
i.Ee.push(
|
|
20
|
+
new De(
|
|
21
21
|
t || (null === (n = r.ir()) || void 0 === n ? void 0 : n.getUserId()),
|
|
22
22
|
e,
|
|
23
23
|
new Date().valueOf(),
|
|
@@ -26,9 +26,9 @@ const c = {
|
|
|
26
26
|
),
|
|
27
27
|
),
|
|
28
28
|
(i.W =
|
|
29
|
-
(null === (s = r.p()) || void 0 === s ? void 0 : s.
|
|
29
|
+
(null === (s = r.p()) || void 0 === s ? void 0 : s.ol(i.Ee)) || !1),
|
|
30
30
|
i
|
|
31
31
|
);
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
|
-
export default
|
|
34
|
+
export default v;
|
|
@@ -3,54 +3,54 @@ export class PropertiesBase {
|
|
|
3
3
|
constructor(t) {
|
|
4
4
|
(this.properties = t), (this.properties = t || {});
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
tp(t, r, e) {
|
|
7
7
|
const o = this.properties[t];
|
|
8
|
-
return null == o ? (this.
|
|
8
|
+
return null == o ? (this.rp(t), null) : r(o) ? o.value : (this.ep(e), null);
|
|
9
9
|
}
|
|
10
10
|
getStringProperty(t) {
|
|
11
|
-
return this.
|
|
11
|
+
return this.tp(t, this.op, "string");
|
|
12
12
|
}
|
|
13
13
|
getNumberProperty(t) {
|
|
14
|
-
return this.
|
|
14
|
+
return this.tp(t, this.sp, "number");
|
|
15
15
|
}
|
|
16
16
|
getBooleanProperty(t) {
|
|
17
|
-
return this.
|
|
17
|
+
return this.tp(t, this.ip, "boolean");
|
|
18
18
|
}
|
|
19
19
|
getImageProperty(t) {
|
|
20
|
-
return this.
|
|
20
|
+
return this.tp(t, this.np, "image");
|
|
21
21
|
}
|
|
22
22
|
getJsonProperty(t) {
|
|
23
|
-
return this.
|
|
23
|
+
return this.tp(t, this.pp, "jsonobject");
|
|
24
24
|
}
|
|
25
25
|
getTimestampProperty(t) {
|
|
26
|
-
return this.
|
|
26
|
+
return this.tp(t, this.up, "datetime");
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
ep(t) {
|
|
29
29
|
E.info(`Property is not of type ${t}.`);
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
rp(t) {
|
|
32
32
|
E.info(`${t} not found in properties.`);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
op(t) {
|
|
35
35
|
return "string" === t.type && "string" == typeof t.value;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
sp(t) {
|
|
38
38
|
return "number" === t.type && "number" == typeof t.value;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
ip(t) {
|
|
41
41
|
return "boolean" === t.type && "boolean" == typeof t.value;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
np(t) {
|
|
44
44
|
return "image" === t.type && "string" == typeof t.value;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
pp(t) {
|
|
47
47
|
return (
|
|
48
48
|
"jsonobject" === t.type &&
|
|
49
49
|
"object" == typeof t.value &&
|
|
50
50
|
t.value.constructor == Object
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
up(t) {
|
|
54
54
|
return "datetime" === t.type && "number" == typeof t.value;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as D } from "../managers/braze-instance.js";
|
|
2
2
|
import ro from "../util/browser-detector.js";
|
|
3
|
-
import
|
|
4
|
-
const
|
|
3
|
+
import mr from "./l10n-manager.js";
|
|
4
|
+
const Me = {
|
|
5
5
|
i: !1,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if ((
|
|
6
|
+
na: null,
|
|
7
|
+
ra: () => {
|
|
8
|
+
if ((Me.t(), !Me.na)) {
|
|
9
9
|
let e = ro.language,
|
|
10
10
|
t = !1;
|
|
11
|
-
r.
|
|
11
|
+
r.re(D.Wa) && ((e = r.re(D.Wa)), (t = !0)), (Me.na = new mr(e, t));
|
|
12
12
|
}
|
|
13
|
-
return
|
|
13
|
+
return Me.na;
|
|
14
14
|
},
|
|
15
15
|
t: () => {
|
|
16
|
-
|
|
16
|
+
Me.i || (r.g(Me), (Me.i = !0));
|
|
17
17
|
},
|
|
18
18
|
destroy: () => {
|
|
19
|
-
(
|
|
19
|
+
(Me.na = null), (Me.i = !1);
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
-
export default
|
|
22
|
+
export default Me;
|
package/src/l10n/l10n-manager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import zt from "../common/translations.js";
|
|
3
|
-
export default class
|
|
3
|
+
export default class mr {
|
|
4
4
|
constructor(t, e = !1) {
|
|
5
5
|
if (
|
|
6
6
|
((this.language = t),
|
|
@@ -22,7 +22,7 @@ export default class lr {
|
|
|
22
22
|
get(t) {
|
|
23
23
|
return zt[this.language][t];
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
Ta() {
|
|
26
26
|
switch (this.language) {
|
|
27
27
|
case "ar":
|
|
28
28
|
case "he":
|