@braze/web-sdk 6.3.1 → 6.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 +35 -3
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +23 -23
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +7 -7
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +22 -21
- package/src/Banner/display/banner-to-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +7 -7
- package/src/Banner/index.js +2 -0
- package/src/Banner/request-banners-refresh.js +6 -6
- package/src/Banner/ui/insert-banner.js +4 -4
- package/src/Card/card-manager-factory.js +5 -5
- package/src/Card/card-manager.js +4 -4
- 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/card.js +7 -7
- package/src/Card/util/card-factory.js +6 -6
- package/src/ContentCards/content-cards-provider-factory.js +14 -10
- package/src/ContentCards/content-cards-provider.js +28 -28
- package/src/ContentCards/content-cards.js +4 -4
- package/src/ContentCards/get-cached-content-cards.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +2 -2
- package/src/ContentCards/subscribe-to-content-cards-updates.js +3 -3
- package/src/ContentCards/ui/show-content-cards.js +8 -8
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +5 -5
- package/src/Core/disable-sdk.js +3 -3
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/get-user.js +1 -1
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +9 -9
- package/src/Core/log-purchase.js +7 -7
- package/src/Core/open-session.js +11 -11
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +5 -5
- package/src/DUST/dust-provider-factory.js +20 -0
- package/src/DUST/dust-provider.js +288 -0
- package/src/DUST/index.js +3 -0
- package/src/DUST/subscribe-to-dust.js +24 -0
- package/src/DUST/types.js +1 -0
- package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +38 -38
- 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 +5 -5
- package/src/FeatureFlags/refresh-feature-flags.js +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +5 -5
- package/src/InAppMessage/display/in-app-message-to-html.js +22 -22
- package/src/InAppMessage/display/modal-utils.js +5 -5
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +80 -80
- package/src/InAppMessage/log-in-app-message-button-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +12 -12
- package/src/InAppMessage/models/html-message.js +14 -14
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +119 -121
- package/src/InAppMessage/models/modal-message.js +12 -12
- package/src/InAppMessage/models/slide-up-message.js +21 -21
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +18 -0
- package/src/InAppMessage/ui/show-in-app-message.js +24 -24
- 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 +8 -8
- package/src/Push/push-manager.js +90 -90
- package/src/Push/utils/push-utils.js +17 -17
- package/src/User/user-manager.js +12 -12
- package/src/User/user.js +48 -48
- package/src/common/constants.js +1 -0
- package/src/common/content-cards-display.js +20 -20
- package/src/common/event-logger.js +4 -4
- package/src/common/properties-base.js +16 -16
- package/src/l10n/l10n-manager-factory.js +2 -2
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +29 -29
- package/src/managers/braze-instance.js +141 -133
- package/src/managers/device-manager.js +18 -18
- package/src/managers/network-manager.js +139 -139
- package/src/managers/server-config-manager.js +99 -82
- package/src/managers/session-manager.js +32 -32
- package/src/managers/storage-manager-factory.js +8 -8
- package/src/managers/storage-manager.js +76 -74
- package/src/managers/subscription-manager.js +10 -10
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +9 -9
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +12 -12
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +38 -34
- package/src/request-controller.js +136 -134
- package/src/triggers/models/custom-event-data.js +4 -4
- package/src/triggers/models/custom-event-property-data.js +5 -5
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +30 -30
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +2 -2
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +36 -36
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +15 -15
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +25 -25
- 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 +3 -3
- package/src/util/braze-actions.js +3 -3
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/component-utils.js +1 -1
- package/src/util/dom-utils.js +10 -10
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +22 -22
- package/src/util/user-agent-parser.js +14 -14
- package/src/util/validation-utils.js +9 -9
- package/src/util/window-utils.js +1 -1
package/src/User/user-manager.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _t from "../models/identifier.js";
|
|
2
|
-
import { getByteLength as
|
|
2
|
+
import { getByteLength as rr } from "../util/string-utils.js";
|
|
3
3
|
import ti from "../models/push-token.js";
|
|
4
|
-
import { logger as E, IndexedDBAdapter as
|
|
4
|
+
import { logger as E, IndexedDBAdapter as it } from "../../shared-lib/index.js";
|
|
5
5
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
6
6
|
import { User } from "../User/index.js";
|
|
7
7
|
export default class bt {
|
|
@@ -12,9 +12,9 @@ export default class bt {
|
|
|
12
12
|
const t = this.j.tu(s.iu.su);
|
|
13
13
|
if (null == t) return null;
|
|
14
14
|
let i = t.eu,
|
|
15
|
-
e =
|
|
15
|
+
e = rr(i);
|
|
16
16
|
if (e > User.mr) {
|
|
17
|
-
for (; e > User.mr; ) (i = i.slice(0, i.length - 1)), (e =
|
|
17
|
+
for (; e > User.mr; ) (i = i.slice(0, i.length - 1)), (e = rr(i));
|
|
18
18
|
(t.eu = i), this.j.uu(s.iu.su, t);
|
|
19
19
|
}
|
|
20
20
|
return i;
|
|
@@ -47,17 +47,17 @@ export default class bt {
|
|
|
47
47
|
u
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
Yn(t, i, e, u, o) {
|
|
51
51
|
this.nu("push_token", t, !1, !0),
|
|
52
52
|
this.nu("custom_push_public_key", e, !1, !0),
|
|
53
53
|
this.nu("custom_push_user_auth", u, !1, !0),
|
|
54
54
|
this.nu("custom_push_vapid_public_key", o, !1, !0);
|
|
55
|
-
const r =
|
|
56
|
-
h = new
|
|
55
|
+
const r = it.Us.Rs,
|
|
56
|
+
h = new it(r, E),
|
|
57
57
|
n = new ti(t, i, e, u, o);
|
|
58
|
-
this.j.ft(s.ct.
|
|
58
|
+
this.j.ft(s.ct.Wo, n.dt()), h.setItem(r.Fs.cu, r.me, !0);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
Hn(t) {
|
|
61
61
|
if (
|
|
62
62
|
(this.nu("push_token", null, !1, !0),
|
|
63
63
|
this.nu("custom_push_public_key", null, !1, !0),
|
|
@@ -65,9 +65,9 @@ export default class bt {
|
|
|
65
65
|
this.nu("custom_push_vapid_public_key", null, !1, !0),
|
|
66
66
|
t)
|
|
67
67
|
) {
|
|
68
|
-
const t =
|
|
69
|
-
i = new
|
|
70
|
-
this.j.ft(s.ct.
|
|
68
|
+
const t = it.Us.Rs,
|
|
69
|
+
i = new it(t, E);
|
|
70
|
+
this.j.ft(s.ct.Wo, !1), i.setItem(t.Fs.cu, t.me, !1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/User/user.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isArray as
|
|
2
|
+
isArray as z,
|
|
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
7
|
import { logger as E, EventTypes as m } from "../../shared-lib/index.js";
|
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
isValidEmail as Ct,
|
|
10
10
|
validateCustomAttributeArrayType as St,
|
|
11
11
|
validateCustomAttributeKey as Ut,
|
|
12
|
-
validateCustomProperties as
|
|
13
|
-
validateCustomString as
|
|
12
|
+
validateCustomProperties as rt,
|
|
13
|
+
validateCustomString as nt,
|
|
14
14
|
validatePropertyType as Dt,
|
|
15
|
-
validateStandardString as
|
|
15
|
+
validateStandardString as er,
|
|
16
16
|
} from "../util/validation-utils.js";
|
|
17
17
|
import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft } from "../common/constants.js";
|
|
18
18
|
import { toValidBackendTimeString as Lt } from "../util/date-utils.js";
|
|
19
19
|
export default class User {
|
|
20
20
|
constructor(t, e) {
|
|
21
|
-
(this.Cs = t), (this.
|
|
21
|
+
(this.Cs = t), (this.au = e), (this.Cs = t), (this.au = e);
|
|
22
22
|
}
|
|
23
23
|
getUserId(t) {
|
|
24
24
|
const e = this.Cs.getUserId();
|
|
@@ -29,21 +29,21 @@ export default class User {
|
|
|
29
29
|
t(e);
|
|
30
30
|
}
|
|
31
31
|
addAlias(t, e) {
|
|
32
|
-
return !
|
|
32
|
+
return !er(t, "add alias", "the alias", !1) || t.length <= 0
|
|
33
33
|
? (E.error("addAlias requires a non-empty alias"), !1)
|
|
34
|
-
: !
|
|
34
|
+
: !er(e, "add alias", "the label", !1) || e.length <= 0
|
|
35
35
|
? (E.error("addAlias requires a non-empty label"), !1)
|
|
36
|
-
: this.
|
|
36
|
+
: this.au.du(t, e).W;
|
|
37
37
|
}
|
|
38
38
|
setFirstName(t) {
|
|
39
39
|
return (
|
|
40
|
-
!!
|
|
40
|
+
!!er(t, "set first name", "the firstName", !0) &&
|
|
41
41
|
this.Cs.nu("first_name", t)
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
setLastName(t) {
|
|
45
45
|
return (
|
|
46
|
-
!!
|
|
46
|
+
!!er(t, "set last name", "the lastName", !0) && this.Cs.nu("last_name", t)
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
setEmail(t) {
|
|
@@ -92,17 +92,17 @@ export default class User {
|
|
|
92
92
|
}
|
|
93
93
|
setCountry(t) {
|
|
94
94
|
return (
|
|
95
|
-
!!
|
|
95
|
+
!!er(t, "set country", "the country", !0) && this.Cs.nu("country", t)
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
setHomeCity(t) {
|
|
99
99
|
return (
|
|
100
|
-
!!
|
|
100
|
+
!!er(t, "set home city", "the homeCity", !0) && this.Cs.nu("home_city", t)
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
setLanguage(t) {
|
|
104
104
|
return (
|
|
105
|
-
!!
|
|
105
|
+
!!er(t, "set language", "the language", !0) && this.Cs.nu("language", t)
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
setEmailNotificationSubscriptionType(t) {
|
|
@@ -127,8 +127,8 @@ export default class User {
|
|
|
127
127
|
}
|
|
128
128
|
setPhoneNumber(t) {
|
|
129
129
|
return (
|
|
130
|
-
!!
|
|
131
|
-
(null === t || t.match(User.
|
|
130
|
+
!!er(t, "set phone number", "the phoneNumber", !0) &&
|
|
131
|
+
(null === t || t.match(User.pu)
|
|
132
132
|
? this.Cs.nu("phone", t)
|
|
133
133
|
: (E.error(`Cannot set phone number - "${t}" did not pass validation.`),
|
|
134
134
|
!1))
|
|
@@ -164,12 +164,12 @@ 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.au.setLastKnownLocation(this.Cs.getUserId(), t, e, s, r, n).W);
|
|
168
168
|
}
|
|
169
169
|
setCustomUserAttribute(t, e, r) {
|
|
170
170
|
if (!Ut(t)) return !1;
|
|
171
171
|
const s = (e) => {
|
|
172
|
-
const [r] =
|
|
172
|
+
const [r] = rt(
|
|
173
173
|
e,
|
|
174
174
|
Ft,
|
|
175
175
|
"attribute value",
|
|
@@ -178,20 +178,20 @@ export default class User {
|
|
|
178
178
|
);
|
|
179
179
|
return r;
|
|
180
180
|
};
|
|
181
|
-
if (
|
|
181
|
+
if (z(e)) {
|
|
182
182
|
const [r, n] = St(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.au.bu(m.fu, 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.au.bu(m.gu, t, e).W;
|
|
189
189
|
} else {
|
|
190
190
|
if (!(void 0 !== e && Dt(e))) return !1;
|
|
191
191
|
if (
|
|
192
192
|
(Nt(e) && (e = Lt(e)),
|
|
193
193
|
"string" == typeof e &&
|
|
194
|
-
!
|
|
194
|
+
!nt(
|
|
195
195
|
e,
|
|
196
196
|
`set custom user attribute "${t}"`,
|
|
197
197
|
"the element in the given array",
|
|
@@ -203,26 +203,26 @@ export default class User {
|
|
|
203
203
|
}
|
|
204
204
|
addToCustomAttributeArray(t, e) {
|
|
205
205
|
return (
|
|
206
|
-
!!
|
|
206
|
+
!!nt(t, "add to custom user attribute array", "the given key") &&
|
|
207
207
|
!(
|
|
208
208
|
null != e &&
|
|
209
|
-
!
|
|
209
|
+
!nt(e, "add to custom user attribute array", "the given value")
|
|
210
210
|
) &&
|
|
211
|
-
this.
|
|
211
|
+
this.au.bu(m.Nu, t, e).W
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
removeFromCustomAttributeArray(t, e) {
|
|
215
215
|
return (
|
|
216
|
-
!!
|
|
216
|
+
!!nt(t, "remove from custom user attribute array", "the given key") &&
|
|
217
217
|
!(
|
|
218
218
|
null != e &&
|
|
219
|
-
!
|
|
219
|
+
!nt(e, "remove from custom user attribute array", "the given value")
|
|
220
220
|
) &&
|
|
221
|
-
this.
|
|
221
|
+
this.au.bu(m.yu, t, e).W
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
224
|
incrementCustomUserAttribute(t, e) {
|
|
225
|
-
if (!
|
|
225
|
+
if (!nt(t, "increment custom user attribute", "the given key")) return !1;
|
|
226
226
|
null == e && (e = 1);
|
|
227
227
|
const r = parseInt(e.toString());
|
|
228
228
|
return isNaN(r) || r !== parseFloat(e.toString())
|
|
@@ -230,11 +230,11 @@ 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.au.bu(m.vu, t, r).W;
|
|
234
234
|
}
|
|
235
235
|
setCustomLocationAttribute(t, e, r) {
|
|
236
236
|
return (
|
|
237
|
-
!!
|
|
237
|
+
!!nt(t, "set custom location attribute", "the given key") &&
|
|
238
238
|
((null !== e || null !== r) &&
|
|
239
239
|
((e = null != e ? parseFloat(e.toString()) : null),
|
|
240
240
|
(r = null != r ? parseFloat(r.toString()) : null),
|
|
@@ -246,11 +246,11 @@ 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.au.Iu(t, e, r).W)
|
|
250
250
|
);
|
|
251
251
|
}
|
|
252
252
|
addToSubscriptionGroup(t) {
|
|
253
|
-
return !
|
|
253
|
+
return !er(
|
|
254
254
|
t,
|
|
255
255
|
"add user to subscription group",
|
|
256
256
|
"subscription group ID",
|
|
@@ -260,10 +260,10 @@ export default class User {
|
|
|
260
260
|
"addToSubscriptionGroup requires a non-empty subscription group ID",
|
|
261
261
|
),
|
|
262
262
|
!1)
|
|
263
|
-
: this.
|
|
263
|
+
: this.au.Cu(t, User.Eu.SUBSCRIBED).W;
|
|
264
264
|
}
|
|
265
265
|
removeFromSubscriptionGroup(t) {
|
|
266
|
-
return !
|
|
266
|
+
return !er(
|
|
267
267
|
t,
|
|
268
268
|
"remove user from subscription group",
|
|
269
269
|
"subscription group ID",
|
|
@@ -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.au.Cu(t, User.Eu.UNSUBSCRIBED).W;
|
|
277
277
|
}
|
|
278
278
|
setLineId(t) {
|
|
279
|
-
return
|
|
279
|
+
return er(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.Su
|
|
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.Su} characters.`,
|
|
284
284
|
),
|
|
285
285
|
!1)
|
|
286
286
|
: this.Cs.nu("native_line_id", t)
|
|
287
287
|
: (E.error("setLineId requires a non-empty ID"), !1);
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
this.Cs.
|
|
289
|
+
Yn(t, e, r, s, n) {
|
|
290
|
+
this.Cs.Yn(t, e, r, s, n), this.au.Au();
|
|
291
291
|
}
|
|
292
|
-
|
|
293
|
-
this.Cs.
|
|
292
|
+
Hn(t) {
|
|
293
|
+
this.Cs.Hn(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.
|
|
309
|
+
(User.pu = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
310
|
+
(User.Eu = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
311
|
+
(User.Uu = "user_id"),
|
|
312
312
|
(User.lu = "custom"),
|
|
313
313
|
(User.mr = 997),
|
|
314
|
-
(User.
|
|
314
|
+
(User.Su = 33);
|
package/src/common/constants.js
CHANGED
|
@@ -15,3 +15,4 @@ export const REQUEST_ATTEMPT_DEFAULT = 1;
|
|
|
15
15
|
export const SUBSCRIPTION_ID_DATA_ATTRIBUTE = "data-update-subscription-id";
|
|
16
16
|
export const BANNERS_DISABLED_MESSAGE =
|
|
17
17
|
"Banners are disabled. Make sure you have at least one campaign and relaunch the app.";
|
|
18
|
+
export const PAUSE_SCROLLING_CLASS = "ab-pause-scrolling";
|
|
@@ -5,17 +5,17 @@ import {
|
|
|
5
5
|
import { bottomIsInView as x, topIsInView as g } from "../util/dom-utils.js";
|
|
6
6
|
import { Card, ControlCard } from "../Card/index.js";
|
|
7
7
|
import { cardToHtml as Ht } from "../Card/display/card-display.js";
|
|
8
|
-
import { isArray as
|
|
8
|
+
import { isArray as z } from "../util/code-utils.js";
|
|
9
9
|
import { KeyCodes as ie } from "../util/key-codes.js";
|
|
10
10
|
import fe from "../l10n/l10n-manager-factory.js";
|
|
11
11
|
import { removeSubscription } from "../Core/remove-subscription.js";
|
|
12
|
-
import { logger as E, Guid as
|
|
12
|
+
import { logger as E, Guid as L } 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
21
|
bottomHadImpression as kt,
|
|
@@ -34,7 +34,7 @@ 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.
|
|
37
|
+
}, ContentCards.hr));
|
|
38
38
|
const e = t.getAttribute(f);
|
|
39
39
|
null != e && removeSubscription(e);
|
|
40
40
|
const n = t.getAttribute("data-listener-id");
|
|
@@ -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(Ht(a, r, e, n.
|
|
65
|
+
!i || t.cr()
|
|
66
|
+
? (o.appendChild(Ht(a, r, e, n.Ho())), (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,12 +82,12 @@ 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.Eo || (t.Eo = {});
|
|
86
86
|
for (let e = 0; e < o.length; e++) {
|
|
87
87
|
const s = xt(o[e]),
|
|
88
88
|
r = g(o[e]),
|
|
89
89
|
a = x(o[e]);
|
|
90
|
-
if (t.
|
|
90
|
+
if (t.Eo[s]) {
|
|
91
91
|
r || a || Rt(o[e]);
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
@@ -101,7 +101,7 @@ export function detectContentCardsImpressions(t, e) {
|
|
|
101
101
|
if (c && f) continue;
|
|
102
102
|
for (const e of t.cards)
|
|
103
103
|
if (e.id === s) {
|
|
104
|
-
(t.
|
|
104
|
+
(t.Eo[e.id] = !0), n.push(e);
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -131,8 +131,8 @@ export function refreshContentCardsUI(t, e) {
|
|
|
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 !== ie.
|
|
156
|
+
(t.keyCode !== ie.do && t.keyCode !== ie.lo) || 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 !== ie.
|
|
169
|
+
(t.keyCode !== ie.do && t.keyCode !== ie.lo) || 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 =
|
|
178
|
+
const t = L.oe();
|
|
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 (!z(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.Zr, "Content Card"));
|
|
192
192
|
continue;
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
3
|
import ue from "../models/braze-event.js";
|
|
4
|
-
import
|
|
4
|
+
import G from "../models/request-result.js";
|
|
5
5
|
const c = {
|
|
6
6
|
rt: (e, o, t) => {
|
|
7
7
|
var n, s;
|
|
8
|
-
const i = new
|
|
8
|
+
const i = new G(),
|
|
9
9
|
l = r.u();
|
|
10
10
|
if (!l)
|
|
11
11
|
return (
|
|
@@ -14,7 +14,7 @@ const c = {
|
|
|
14
14
|
),
|
|
15
15
|
i
|
|
16
16
|
);
|
|
17
|
-
const d = l.
|
|
17
|
+
const d = l.Fo();
|
|
18
18
|
return (
|
|
19
19
|
i.ue.push(
|
|
20
20
|
new ue(
|
|
@@ -26,7 +26,7 @@ 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.Go(i.ue)) || !1),
|
|
30
30
|
i
|
|
31
31
|
);
|
|
32
32
|
},
|
|
@@ -3,54 +3,54 @@ export class PropertiesBase {
|
|
|
3
3
|
constructor(t) {
|
|
4
4
|
(this.properties = t), (this.properties = t || {});
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
Oo(t, r, e) {
|
|
7
7
|
const o = this.properties[t];
|
|
8
|
-
return null == o ? (this.
|
|
8
|
+
return null == o ? (this.Ko(t), null) : r(o) ? o.value : (this.Lo(e), null);
|
|
9
9
|
}
|
|
10
10
|
getStringProperty(t) {
|
|
11
|
-
return this.
|
|
11
|
+
return this.Oo(t, this.Qo, "string");
|
|
12
12
|
}
|
|
13
13
|
getNumberProperty(t) {
|
|
14
|
-
return this.
|
|
14
|
+
return this.Oo(t, this.Ro, "number");
|
|
15
15
|
}
|
|
16
16
|
getBooleanProperty(t) {
|
|
17
|
-
return this.
|
|
17
|
+
return this.Oo(t, this.Xo, "boolean");
|
|
18
18
|
}
|
|
19
19
|
getImageProperty(t) {
|
|
20
|
-
return this.
|
|
20
|
+
return this.Oo(t, this.Yo, "image");
|
|
21
21
|
}
|
|
22
22
|
getJsonProperty(t) {
|
|
23
|
-
return this.
|
|
23
|
+
return this.Oo(t, this.Zo, "jsonobject");
|
|
24
24
|
}
|
|
25
25
|
getTimestampProperty(t) {
|
|
26
|
-
return this.
|
|
26
|
+
return this.Oo(t, this.tp, "datetime");
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
Lo(t) {
|
|
29
29
|
E.info(`Property is not of type ${t}.`);
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
Ko(t) {
|
|
32
32
|
E.info(`${t} not found in properties.`);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
Qo(t) {
|
|
35
35
|
return "string" === t.type && "string" == typeof t.value;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
Ro(t) {
|
|
38
38
|
return "number" === t.type && "number" == typeof t.value;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
Xo(t) {
|
|
41
41
|
return "boolean" === t.type && "boolean" == typeof t.value;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
Yo(t) {
|
|
44
44
|
return "image" === t.type && "string" == typeof t.value;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
Zo(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
|
+
tp(t) {
|
|
54
54
|
return "datetime" === t.type && "number" == typeof t.value;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as q } from "../managers/braze-instance.js";
|
|
2
2
|
import ro from "../util/browser-detector.js";
|
|
3
3
|
import lr from "./l10n-manager.js";
|
|
4
4
|
const fe = {
|
|
@@ -8,7 +8,7 @@ const fe = {
|
|
|
8
8
|
if ((fe.t(), !fe.aa)) {
|
|
9
9
|
let e = ro.language,
|
|
10
10
|
t = !1;
|
|
11
|
-
r.ee(
|
|
11
|
+
r.ee(q.Ea) && ((e = r.ee(q.Ea)), (t = !0)), (fe.aa = new lr(e, t));
|
|
12
12
|
}
|
|
13
13
|
return fe.aa;
|
|
14
14
|
},
|
package/src/l10n/l10n-manager.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { STORAGE_KEYS as s } from "./storage-manager.js";
|
|
2
2
|
import u from "./subscription-manager.js";
|
|
3
|
-
import { logger as E, IndexedDBAdapter as
|
|
3
|
+
import { logger as E, IndexedDBAdapter as it } from "../../shared-lib/index.js";
|
|
4
4
|
export default class Bt {
|
|
5
5
|
constructor(t, i, s) {
|
|
6
6
|
(this.j = t),
|
|
7
|
-
(this.
|
|
8
|
-
(this.
|
|
7
|
+
(this.gh = i),
|
|
8
|
+
(this.ph = s),
|
|
9
9
|
(this.j = t),
|
|
10
|
-
(this.
|
|
11
|
-
(this.
|
|
12
|
-
(this.
|
|
13
|
-
(this.
|
|
14
|
-
(this.
|
|
15
|
-
}
|
|
16
|
-
fh() {
|
|
17
|
-
return this.Zn;
|
|
10
|
+
(this.gh = i || !1),
|
|
11
|
+
(this.ph = s),
|
|
12
|
+
(this.Fh = new u()),
|
|
13
|
+
(this.kh = 0),
|
|
14
|
+
(this.fh = 1);
|
|
18
15
|
}
|
|
19
16
|
wh() {
|
|
20
|
-
return this.
|
|
17
|
+
return this.gh;
|
|
18
|
+
}
|
|
19
|
+
jh() {
|
|
20
|
+
return this.j.lt(s.ct.xh);
|
|
21
21
|
}
|
|
22
22
|
setSdkAuthenticationSignature(t) {
|
|
23
|
-
const i = this.
|
|
24
|
-
this.j.ft(s.ct.
|
|
25
|
-
const e =
|
|
26
|
-
new
|
|
23
|
+
const i = this.jh();
|
|
24
|
+
this.j.ft(s.ct.xh, t);
|
|
25
|
+
const e = it.Us.Rs;
|
|
26
|
+
new it(e, E).setItem(e.Fs.qh, this.fh, t), i !== t && this.Z();
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
this.j.Nt(s.ct.
|
|
30
|
-
const t =
|
|
31
|
-
new
|
|
28
|
+
yh() {
|
|
29
|
+
this.j.Nt(s.ct.xh);
|
|
30
|
+
const t = it.Us.Rs;
|
|
31
|
+
new it(t, E).be(t.Fs.qh, this.fh);
|
|
32
32
|
}
|
|
33
33
|
subscribeToSdkAuthenticationFailures(t) {
|
|
34
|
-
return this.
|
|
34
|
+
return this.ph.wt(t);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
}
|
|
39
|
-
Bh() {
|
|
40
|
-
this.ph.removeAllSubscriptions();
|
|
36
|
+
Bh(t) {
|
|
37
|
+
this.ph.L(t);
|
|
41
38
|
}
|
|
42
39
|
Gh() {
|
|
43
|
-
this.Fh
|
|
40
|
+
this.Fh.removeAllSubscriptions();
|
|
44
41
|
}
|
|
45
42
|
Hh() {
|
|
46
|
-
|
|
43
|
+
this.kh += 1;
|
|
44
|
+
}
|
|
45
|
+
Jh() {
|
|
46
|
+
return this.kh;
|
|
47
47
|
}
|
|
48
48
|
Z() {
|
|
49
|
-
this.
|
|
49
|
+
this.kh = 0;
|
|
50
50
|
}
|
|
51
51
|
}
|