@braze/web-sdk 6.0.0 → 6.1.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 +103 -33
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +22 -22
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +19 -19
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +15 -15
- package/src/Banner/banner-factory.js +2 -1
- package/src/Banner/banner-provider-factory.js +7 -7
- package/src/Banner/banner-provider.js +92 -98
- package/src/Banner/banner.js +21 -18
- package/src/Banner/display/banner-to-html.js +9 -9
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +2 -2
- package/src/Banner/get-all-banners.js +5 -5
- package/src/Banner/get-banner.js +7 -7
- package/src/Banner/log-banner-click.js +7 -7
- package/src/Banner/log-banner-impressions.js +9 -9
- package/src/Banner/request-banners-refresh.js +16 -20
- package/src/Banner/subscribe-to-banners-updates.js +7 -7
- package/src/Banner/ui/insert-banner.js +6 -6
- package/src/Card/card-manager-factory.js +7 -7
- package/src/Card/card-manager.js +35 -35
- package/src/Card/display/card-display.js +11 -11
- package/src/Card/log-card-dismissal.js +4 -4
- package/src/Card/log-content-card-click.js +4 -4
- package/src/Card/log-content-card-impressions.js +6 -6
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +68 -68
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +18 -18
- package/src/Card/util/card-factory.js +35 -35
- package/src/ContentCards/content-cards-provider-factory.js +13 -13
- package/src/ContentCards/content-cards-provider.js +136 -136
- 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 +6 -6
- package/src/ContentCards/ui/show-content-cards.js +7 -7
- package/src/Core/add-sdk-metadata.js +3 -3
- package/src/Core/change-user.js +7 -7
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +8 -8
- package/src/Core/enable-sdk.js +6 -6
- package/src/Core/get-device-id.js +4 -4
- package/src/Core/handle-braze-action.js +5 -5
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +10 -10
- package/src/Core/log-purchase.js +13 -13
- package/src/Core/open-session.js +10 -10
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +10 -10
- package/src/FeatureFlags/feature-flag.js +20 -71
- package/src/FeatureFlags/feature-flags-provider-factory.js +12 -12
- package/src/FeatureFlags/feature-flags-provider.js +87 -87
- package/src/FeatureFlags/get-all-feature-flags.js +4 -4
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/log-feature-flag-impression.js +9 -9
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -4
- package/src/InAppMessage/defer-in-app-message.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +28 -28
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/in-app-message-factory.js +15 -15
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +100 -100
- package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-html-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-impression.js +4 -4
- package/src/InAppMessage/models/control-message.js +4 -4
- package/src/InAppMessage/models/full-screen-message.js +35 -35
- package/src/InAppMessage/models/html-message.js +21 -21
- package/src/InAppMessage/models/in-app-message-button.js +5 -5
- package/src/InAppMessage/models/in-app-message.js +75 -75
- package/src/InAppMessage/models/modal-message.js +34 -34
- package/src/InAppMessage/models/slide-up-message.js +31 -31
- 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/show-in-app-message.js +19 -19
- package/src/Push/push-manager-factory.js +9 -9
- package/src/Push/push-manager.js +118 -118
- package/src/Push/utils/push-utils.js +9 -9
- package/src/User/user-manager.js +20 -20
- package/src/User/user.js +44 -45
- package/src/common/base-provider.js +1 -1
- package/src/common/content-cards-display.js +18 -18
- package/src/common/event-logger.js +10 -10
- package/src/common/properties-base.js +56 -0
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +143 -143
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +172 -168
- package/src/managers/server-config-manager.js +73 -73
- package/src/managers/session-manager.js +40 -40
- package/src/managers/storage-manager-factory.js +6 -6
- package/src/managers/storage-manager.js +97 -97
- package/src/managers/subscription-manager.js +12 -12
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +5 -5
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +13 -13
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +159 -159
- package/src/triggers/models/custom-event-data.js +1 -1
- package/src/triggers/models/custom-event-property-data.js +2 -2
- package/src/triggers/models/filter-set.js +6 -6
- package/src/triggers/models/filter.js +26 -26
- 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 +37 -37
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +16 -16
- package/src/triggers/triggers-provider-factory.js +12 -12
- package/src/triggers/triggers-provider.js +61 -61
- package/src/ui/js/attach-css.js +1 -1
- 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 +6 -6
- package/src/util/browser-detector.js +20 -13
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +1 -1
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/device-constants.js +4 -4
- package/src/util/dom-utils.js +9 -9
- package/src/util/html-display-utils.js +7 -7
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +12 -12
- package/src/util/request-header-utils.js +22 -22
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +16 -16
- package/src/util/validation-utils.js +12 -12
- package/src/util/window-utils.js +2 -2
package/src/User/user-manager.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import _t from "../models/identifier.js";
|
|
2
|
-
import { getByteLength as
|
|
2
|
+
import { getByteLength as er } from "../util/string-utils.js";
|
|
3
3
|
import ti from "../models/push-token.js";
|
|
4
|
-
import { logger as
|
|
4
|
+
import { logger as E, IndexedDBAdapter as et } 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 {
|
|
8
8
|
constructor(t, s) {
|
|
9
|
-
(this.
|
|
9
|
+
(this.h = t), (this.j = s), (this.h = t), (this.j = s);
|
|
10
10
|
}
|
|
11
11
|
getUserId() {
|
|
12
|
-
const t = this.
|
|
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 = er(i);
|
|
16
16
|
if (e > User.mr) {
|
|
17
|
-
for (; e > User.mr; ) (i = i.slice(0, i.length - 1)), (e =
|
|
18
|
-
(t.eu = i), this.
|
|
17
|
+
for (; e > User.mr; ) (i = i.slice(0, i.length - 1)), (e = er(i));
|
|
18
|
+
(t.eu = i), this.j.uu(s.iu.su, t);
|
|
19
19
|
}
|
|
20
20
|
return i;
|
|
21
21
|
}
|
|
22
22
|
ou(t) {
|
|
23
23
|
const i = null == this.getUserId();
|
|
24
|
-
this.
|
|
24
|
+
this.j.uu(s.iu.su, new _t(t)), i && this.j.ru(t);
|
|
25
25
|
}
|
|
26
26
|
setCustomUserAttribute(t, s) {
|
|
27
|
-
if (this.
|
|
27
|
+
if (this.h.hu(t))
|
|
28
28
|
return (
|
|
29
|
-
|
|
29
|
+
E.info('Custom Attribute "' + t + '" is blocklisted, ignoring.'), !1
|
|
30
30
|
);
|
|
31
31
|
const i = {};
|
|
32
32
|
return (i[t] = s), this.nu(User.lu, i, !0);
|
|
33
33
|
}
|
|
34
34
|
nu(t, s, i = !1, e = !1) {
|
|
35
|
-
const u = this.
|
|
35
|
+
const u = this.j.mu(this.getUserId(), t, s);
|
|
36
36
|
let o = "",
|
|
37
37
|
r = t,
|
|
38
38
|
h = s;
|
|
@@ -43,21 +43,21 @@ export default class bt {
|
|
|
43
43
|
((r = Object.keys(s)[0]),
|
|
44
44
|
(h = s[r]),
|
|
45
45
|
"object" == typeof h && (h = JSON.stringify(h, null, 2)))),
|
|
46
|
-
!e && u &&
|
|
46
|
+
!e && u && E.info(`Logged${o} attribute ${r} with value ${h}`),
|
|
47
47
|
u
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
Pn(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 = et.
|
|
56
|
-
h = new et(r,
|
|
55
|
+
const r = et.Us.Rs,
|
|
56
|
+
h = new et(r, E),
|
|
57
57
|
n = new ti(t, i, e, u, o);
|
|
58
|
-
this.
|
|
58
|
+
this.j.ft(s.ct.In, n.dt()), h.setItem(r.Fs.cu, r.me, !0);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
Sn(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 = et.
|
|
69
|
-
i = new et(t,
|
|
70
|
-
this.
|
|
68
|
+
const t = et.Us.Rs,
|
|
69
|
+
i = new et(t, E);
|
|
70
|
+
this.j.ft(s.ct.In, !1), i.setItem(t.Fs.cu, t.me, !1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/User/user.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
isObject as It,
|
|
5
5
|
validateValueIsFromEnum as ta,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
|
-
import { logger as
|
|
7
|
+
import { logger as E, EventTypes as m } from "../../shared-lib/index.js";
|
|
8
8
|
import {
|
|
9
9
|
isValidEmail as Ct,
|
|
10
10
|
validateCustomAttributeArrayType as St,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
validateCustomProperties as nt,
|
|
13
13
|
validateCustomString as mt,
|
|
14
14
|
validatePropertyType as Dt,
|
|
15
|
-
validateStandardString as
|
|
15
|
+
validateStandardString as ir,
|
|
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";
|
|
@@ -23,33 +23,33 @@ export default class User {
|
|
|
23
23
|
getUserId(t) {
|
|
24
24
|
const e = this.Cs.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()`)",
|
|
28
28
|
),
|
|
29
29
|
t(e);
|
|
30
30
|
}
|
|
31
31
|
addAlias(t, e) {
|
|
32
|
-
return !
|
|
33
|
-
? (
|
|
34
|
-
: !
|
|
35
|
-
? (
|
|
36
|
-
: this.Cn.En(t, e).
|
|
32
|
+
return !ir(t, "add alias", "the alias", !1) || t.length <= 0
|
|
33
|
+
? (E.error("addAlias requires a non-empty alias"), !1)
|
|
34
|
+
: !ir(e, "add alias", "the label", !1) || e.length <= 0
|
|
35
|
+
? (E.error("addAlias requires a non-empty label"), !1)
|
|
36
|
+
: this.Cn.En(t, e).W;
|
|
37
37
|
}
|
|
38
38
|
setFirstName(t) {
|
|
39
39
|
return (
|
|
40
|
-
!!
|
|
40
|
+
!!ir(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
|
+
!!ir(t, "set last name", "the lastName", !0) && this.Cs.nu("last_name", t)
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
setEmail(t) {
|
|
50
50
|
return null === t || Ct(t)
|
|
51
51
|
? this.Cs.nu("email", t)
|
|
52
|
-
: (
|
|
52
|
+
: (E.error(
|
|
53
53
|
`Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
|
|
54
54
|
),
|
|
55
55
|
!1);
|
|
@@ -84,7 +84,7 @@ export default class User {
|
|
|
84
84
|
e < 1 ||
|
|
85
85
|
r > 31 ||
|
|
86
86
|
r < 1
|
|
87
|
-
? (
|
|
87
|
+
? (E.error(
|
|
88
88
|
"Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);",
|
|
89
89
|
),
|
|
90
90
|
!1)
|
|
@@ -92,17 +92,17 @@ export default class User {
|
|
|
92
92
|
}
|
|
93
93
|
setCountry(t) {
|
|
94
94
|
return (
|
|
95
|
-
!!
|
|
95
|
+
!!ir(t, "set country", "the country", !0) && this.Cs.nu("country", t)
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
setHomeCity(t) {
|
|
99
99
|
return (
|
|
100
|
-
!!
|
|
100
|
+
!!ir(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
|
+
!!ir(t, "set language", "the language", !0) && this.Cs.nu("language", t)
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
setEmailNotificationSubscriptionType(t) {
|
|
@@ -127,16 +127,16 @@ export default class User {
|
|
|
127
127
|
}
|
|
128
128
|
setPhoneNumber(t) {
|
|
129
129
|
return (
|
|
130
|
-
!!
|
|
130
|
+
!!ir(t, "set phone number", "the phoneNumber", !0) &&
|
|
131
131
|
(null === t || t.match(User.Fn)
|
|
132
132
|
? this.Cs.nu("phone", t)
|
|
133
|
-
: (
|
|
133
|
+
: (E.error(`Cannot set phone number - "${t}" did not pass validation.`),
|
|
134
134
|
!1))
|
|
135
135
|
);
|
|
136
136
|
}
|
|
137
137
|
setLastKnownLocation(t, e, r, s, n) {
|
|
138
138
|
return null == t || null == e
|
|
139
|
-
? (
|
|
139
|
+
? (E.error(
|
|
140
140
|
"Cannot set last-known location - latitude and longitude are required.",
|
|
141
141
|
),
|
|
142
142
|
!1)
|
|
@@ -150,22 +150,21 @@ export default class User {
|
|
|
150
150
|
(null != r && isNaN(r)) ||
|
|
151
151
|
(null != s && isNaN(s)) ||
|
|
152
152
|
(null != n && isNaN(n))
|
|
153
|
-
? (
|
|
153
|
+
? (E.error(
|
|
154
154
|
"Cannot set last-known location - all supplied parameters must be numeric.",
|
|
155
155
|
),
|
|
156
156
|
!1)
|
|
157
157
|
: t > 90 || t < -90 || e > 180 || e < -180
|
|
158
|
-
? (
|
|
158
|
+
? (E.error(
|
|
159
159
|
"Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively.",
|
|
160
160
|
),
|
|
161
161
|
!1)
|
|
162
162
|
: (null != r && r < 0) || (null != n && n < 0)
|
|
163
|
-
? (
|
|
163
|
+
? (E.error(
|
|
164
164
|
"Cannot set last-known location - accuracy and altitudeAccuracy may not be negative.",
|
|
165
165
|
),
|
|
166
166
|
!1)
|
|
167
|
-
: this.Cn.setLastKnownLocation(this.Cs.getUserId(), t, e, s, r, n)
|
|
168
|
-
.tt);
|
|
167
|
+
: this.Cn.setLastKnownLocation(this.Cs.getUserId(), t, e, s, r, n).W);
|
|
169
168
|
}
|
|
170
169
|
setCustomUserAttribute(t, e, r) {
|
|
171
170
|
if (!Ut(t)) return !1;
|
|
@@ -182,11 +181,11 @@ export default class User {
|
|
|
182
181
|
if (D(e)) {
|
|
183
182
|
const [r, n] = St(t, e);
|
|
184
183
|
if (!r && !n && 0 !== e.length) return !1;
|
|
185
|
-
if (r || 0 === e.length) return this.Cn.Ln(
|
|
184
|
+
if (r || 0 === e.length) return this.Cn.Ln(m.$n, t, e).W;
|
|
186
185
|
for (const t of e) if (!s(t)) return !1;
|
|
187
186
|
} else if (It(e)) {
|
|
188
187
|
if (!s(e)) return !1;
|
|
189
|
-
if (r) return this.Cn.Ln(
|
|
188
|
+
if (r) return this.Cn.Ln(m.Bn, t, e).W;
|
|
190
189
|
} else {
|
|
191
190
|
if (!(void 0 !== e && Dt(e))) return !1;
|
|
192
191
|
if (
|
|
@@ -209,7 +208,7 @@ export default class User {
|
|
|
209
208
|
null != e &&
|
|
210
209
|
!mt(e, "add to custom user attribute array", "the given value")
|
|
211
210
|
) &&
|
|
212
|
-
this.Cn.Ln(
|
|
211
|
+
this.Cn.Ln(m.Rn, t, e).W
|
|
213
212
|
);
|
|
214
213
|
}
|
|
215
214
|
removeFromCustomAttributeArray(t, e) {
|
|
@@ -219,7 +218,7 @@ export default class User {
|
|
|
219
218
|
null != e &&
|
|
220
219
|
!mt(e, "remove from custom user attribute array", "the given value")
|
|
221
220
|
) &&
|
|
222
|
-
this.Cn.Ln(
|
|
221
|
+
this.Cn.Ln(m.On, t, e).W
|
|
223
222
|
);
|
|
224
223
|
}
|
|
225
224
|
incrementCustomUserAttribute(t, e) {
|
|
@@ -227,11 +226,11 @@ export default class User {
|
|
|
227
226
|
null == e && (e = 1);
|
|
228
227
|
const r = parseInt(e.toString());
|
|
229
228
|
return isNaN(r) || r !== parseFloat(e.toString())
|
|
230
|
-
? (
|
|
229
|
+
? (E.error(
|
|
231
230
|
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
|
|
232
231
|
),
|
|
233
232
|
!1)
|
|
234
|
-
: this.Cn.Ln(
|
|
233
|
+
: this.Cn.Ln(m.Gn, t, r).W;
|
|
235
234
|
}
|
|
236
235
|
setCustomLocationAttribute(t, e, r) {
|
|
237
236
|
return (
|
|
@@ -243,55 +242,55 @@ export default class User {
|
|
|
243
242
|
(null != e && null == r) ||
|
|
244
243
|
(null != e && (isNaN(e) || e > 90 || e < -90)) ||
|
|
245
244
|
(null != r && (isNaN(r) || r > 180 || r < -180)))
|
|
246
|
-
? (
|
|
245
|
+
? (E.error(
|
|
247
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.",
|
|
248
247
|
),
|
|
249
248
|
!1)
|
|
250
|
-
: this.Cn.Hn(t, e, r).
|
|
249
|
+
: this.Cn.Hn(t, e, r).W)
|
|
251
250
|
);
|
|
252
251
|
}
|
|
253
252
|
addToSubscriptionGroup(t) {
|
|
254
|
-
return !
|
|
253
|
+
return !ir(
|
|
255
254
|
t,
|
|
256
255
|
"add user to subscription group",
|
|
257
256
|
"subscription group ID",
|
|
258
257
|
!1,
|
|
259
258
|
) || t.length <= 0
|
|
260
|
-
? (
|
|
259
|
+
? (E.error(
|
|
261
260
|
"addToSubscriptionGroup requires a non-empty subscription group ID",
|
|
262
261
|
),
|
|
263
262
|
!1)
|
|
264
|
-
: this.Cn.Kn(t, User.Mn.SUBSCRIBED).
|
|
263
|
+
: this.Cn.Kn(t, User.Mn.SUBSCRIBED).W;
|
|
265
264
|
}
|
|
266
265
|
removeFromSubscriptionGroup(t) {
|
|
267
|
-
return !
|
|
266
|
+
return !ir(
|
|
268
267
|
t,
|
|
269
268
|
"remove user from subscription group",
|
|
270
269
|
"subscription group ID",
|
|
271
270
|
!1,
|
|
272
271
|
) || t.length <= 0
|
|
273
|
-
? (
|
|
272
|
+
? (E.error(
|
|
274
273
|
"removeFromSubscriptionGroup requires a non-empty subscription group ID",
|
|
275
274
|
),
|
|
276
275
|
!1)
|
|
277
|
-
: this.Cn.Kn(t, User.Mn.UNSUBSCRIBED).
|
|
276
|
+
: this.Cn.Kn(t, User.Mn.UNSUBSCRIBED).W;
|
|
278
277
|
}
|
|
279
278
|
setLineId(t) {
|
|
280
|
-
return
|
|
279
|
+
return ir(t, "set LINE user ID", "the ID", !0) &&
|
|
281
280
|
0 !== (null == t ? void 0 : t.length)
|
|
282
281
|
? t && t.length > User.Yn
|
|
283
|
-
? (
|
|
282
|
+
? (E.error(
|
|
284
283
|
`Rejected LINE user ID ${t} because it is longer than ${User.Yn} characters.`,
|
|
285
284
|
),
|
|
286
285
|
!1)
|
|
287
286
|
: this.Cs.nu("native_line_id", t)
|
|
288
|
-
: (
|
|
287
|
+
: (E.error("setLineId requires a non-empty ID"), !1);
|
|
289
288
|
}
|
|
290
|
-
|
|
291
|
-
this.Cs.
|
|
289
|
+
Pn(t, e, r, s, n) {
|
|
290
|
+
this.Cs.Pn(t, e, r, s, n), this.Cn.zn();
|
|
292
291
|
}
|
|
293
|
-
|
|
294
|
-
this.Cs.
|
|
292
|
+
Sn(t) {
|
|
293
|
+
this.Cs.Sn(t);
|
|
295
294
|
}
|
|
296
295
|
}
|
|
297
296
|
(User.Genders = {
|
|
@@ -309,7 +308,7 @@ export default class User {
|
|
|
309
308
|
}),
|
|
310
309
|
(User.Fn = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
311
310
|
(User.Mn = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
312
|
-
(User.
|
|
311
|
+
(User.Jn = "user_id"),
|
|
313
312
|
(User.lu = "custom"),
|
|
314
313
|
(User.mr = 997),
|
|
315
314
|
(User.Yn = 33);
|
|
@@ -9,7 +9,7 @@ import { isArray as D } 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
|
|
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
15
|
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as vt,
|
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
} from "../util/braze-actions.js";
|
|
20
20
|
import {
|
|
21
21
|
bottomHadImpression as kt,
|
|
22
|
-
impressOnBottom as
|
|
22
|
+
impressOnBottom as d,
|
|
23
23
|
impressOnTop as j,
|
|
24
24
|
topHadImpression as qt,
|
|
25
25
|
} from "./detect-impression.js";
|
|
26
|
-
import { SUBSCRIPTION_ID_DATA_ATTRIBUTE as
|
|
26
|
+
import { SUBSCRIPTION_ID_DATA_ATTRIBUTE as f } from "./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";
|
|
@@ -35,7 +35,7 @@ export function destroyContentCardsHtml(t) {
|
|
|
35
35
|
setTimeout(() => {
|
|
36
36
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
37
37
|
}, ContentCards.cr));
|
|
38
|
-
const e = t.getAttribute(
|
|
38
|
+
const e = t.getAttribute(f);
|
|
39
39
|
null != e && removeSubscription(e);
|
|
40
40
|
const n = t.getAttribute("data-listener-id");
|
|
41
41
|
null != n &&
|
|
@@ -63,8 +63,8 @@ export function generateContentCardsUI(t, e) {
|
|
|
63
63
|
for (const a of t.cards) {
|
|
64
64
|
const i = a instanceof ControlCard;
|
|
65
65
|
!i || t.ar()
|
|
66
|
-
? (o.appendChild(Ht(a, r, e, n.
|
|
67
|
-
:
|
|
66
|
+
? (o.appendChild(Ht(a, r, e, n.So())), (s = s || !i))
|
|
67
|
+
: E.error(
|
|
68
68
|
"Received a control card for a legacy news feed. Control cards are only supported with content cards.",
|
|
69
69
|
);
|
|
70
70
|
}
|
|
@@ -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.Qn || (t.Qn = {});
|
|
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.Qn[s]) {
|
|
91
91
|
r || a || Rt(o[e]);
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
94
94
|
let i = qt(o[e]),
|
|
95
95
|
l = kt(o[e]);
|
|
96
|
-
const
|
|
97
|
-
|
|
96
|
+
const c = i,
|
|
97
|
+
f = l;
|
|
98
98
|
if (
|
|
99
|
-
(!i && r && ((i = !0), j(o[e])), !l && a && ((l = !0),
|
|
99
|
+
(!i && r && ((i = !0), j(o[e])), !l && a && ((l = !0), d(o[e])), i && l)
|
|
100
100
|
) {
|
|
101
|
-
if (
|
|
101
|
+
if (c && f) continue;
|
|
102
102
|
for (const e of t.cards)
|
|
103
103
|
if (e.id === s) {
|
|
104
|
-
(t.
|
|
104
|
+
(t.Qn[e.id] = !0), n.push(e);
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -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.lo && t.keyCode !== ie.Ze) || 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.lo && t.keyCode !== ie.Ze) || l(t);
|
|
170
170
|
}),
|
|
171
171
|
(i.onclick = l),
|
|
172
172
|
s.appendChild(i),
|
|
@@ -175,7 +175,7 @@ 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 = P.oe();
|
|
179
179
|
(scrollListeners[t] = d), o.setAttribute("data-listener-id", t);
|
|
180
180
|
}
|
|
181
181
|
return o;
|
|
@@ -188,7 +188,7 @@ export function updateContentCards(t, e, n, o, s) {
|
|
|
188
188
|
if (t.url && to.test(t.url)) {
|
|
189
189
|
const e = eo(t.url);
|
|
190
190
|
if (dt(e)) {
|
|
191
|
-
|
|
191
|
+
E.error(jt(vt.Li, "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(f, t);
|
|
211
211
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { logger as
|
|
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 H from "../models/request-result.js";
|
|
5
5
|
const c = {
|
|
6
|
-
|
|
6
|
+
rt: (e, o, t) => {
|
|
7
7
|
var n, s;
|
|
8
|
-
const i = new
|
|
9
|
-
l = r.
|
|
8
|
+
const i = new H(),
|
|
9
|
+
l = r.u();
|
|
10
10
|
if (!l)
|
|
11
11
|
return (
|
|
12
|
-
|
|
12
|
+
E.info(
|
|
13
13
|
`Not logging event with type "${e}" because the current session ID could not be found.`,
|
|
14
14
|
),
|
|
15
15
|
i
|
|
16
16
|
);
|
|
17
|
-
const d = l.
|
|
17
|
+
const d = l.qo();
|
|
18
18
|
return (
|
|
19
|
-
i
|
|
19
|
+
i.ue.push(
|
|
20
20
|
new ue(
|
|
21
21
|
t || (null === (n = r.ir()) || void 0 === n ? void 0 : n.getUserId()),
|
|
22
22
|
e,
|
|
@@ -25,8 +25,8 @@ const c = {
|
|
|
25
25
|
o,
|
|
26
26
|
),
|
|
27
27
|
),
|
|
28
|
-
(i.
|
|
29
|
-
(null === (s = r.
|
|
28
|
+
(i.W =
|
|
29
|
+
(null === (s = r.p()) || void 0 === s ? void 0 : s.Eo(i.ue)) || !1),
|
|
30
30
|
i
|
|
31
31
|
);
|
|
32
32
|
},
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
|
+
export class PropertiesBase {
|
|
3
|
+
constructor(t) {
|
|
4
|
+
(this.properties = t), (this.properties = t || {});
|
|
5
|
+
}
|
|
6
|
+
To(t, r, e) {
|
|
7
|
+
const o = this.properties[t];
|
|
8
|
+
return null == o ? (this.No(t), null) : r(o) ? o.value : (this.Oo(e), null);
|
|
9
|
+
}
|
|
10
|
+
getStringProperty(t) {
|
|
11
|
+
return this.To(t, this.Fo, "string");
|
|
12
|
+
}
|
|
13
|
+
getNumberProperty(t) {
|
|
14
|
+
return this.To(t, this.Go, "number");
|
|
15
|
+
}
|
|
16
|
+
getBooleanProperty(t) {
|
|
17
|
+
return this.To(t, this.Ho, "boolean");
|
|
18
|
+
}
|
|
19
|
+
getImageProperty(t) {
|
|
20
|
+
return this.To(t, this.Ko, "image");
|
|
21
|
+
}
|
|
22
|
+
getJsonProperty(t) {
|
|
23
|
+
return this.To(t, this.Lo, "jsonobject");
|
|
24
|
+
}
|
|
25
|
+
getTimestampProperty(t) {
|
|
26
|
+
return this.To(t, this.Qo, "datetime");
|
|
27
|
+
}
|
|
28
|
+
Oo(t) {
|
|
29
|
+
E.info(`Property is not of type ${t}.`);
|
|
30
|
+
}
|
|
31
|
+
No(t) {
|
|
32
|
+
E.info(`${t} not found in properties.`);
|
|
33
|
+
}
|
|
34
|
+
Fo(t) {
|
|
35
|
+
return "string" === t.type && "string" == typeof t.value;
|
|
36
|
+
}
|
|
37
|
+
Go(t) {
|
|
38
|
+
return "number" === t.type && "number" == typeof t.value;
|
|
39
|
+
}
|
|
40
|
+
Ho(t) {
|
|
41
|
+
return "boolean" === t.type && "boolean" == typeof t.value;
|
|
42
|
+
}
|
|
43
|
+
Ko(t) {
|
|
44
|
+
return "image" === t.type && "string" == typeof t.value;
|
|
45
|
+
}
|
|
46
|
+
Lo(t) {
|
|
47
|
+
return (
|
|
48
|
+
"jsonobject" === t.type &&
|
|
49
|
+
"object" == typeof t.value &&
|
|
50
|
+
t.value.constructor == Object
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
Qo(t) {
|
|
54
|
+
return "datetime" === t.type && "number" == typeof t.value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import r, { OPTIONS as z } from "../managers/braze-instance.js";
|
|
2
2
|
import ro from "../util/browser-detector.js";
|
|
3
|
-
import
|
|
3
|
+
import lr from "./l10n-manager.js";
|
|
4
4
|
const fe = {
|
|
5
|
-
|
|
5
|
+
i: !1,
|
|
6
6
|
aa: null,
|
|
7
7
|
ea: () => {
|
|
8
|
-
if ((fe.
|
|
8
|
+
if ((fe.t(), !fe.aa)) {
|
|
9
9
|
let e = ro.language,
|
|
10
10
|
t = !1;
|
|
11
|
-
r.ee(z.
|
|
11
|
+
r.ee(z.Xn) && ((e = r.ee(z.Xn)), (t = !0)), (fe.aa = new lr(e, t));
|
|
12
12
|
}
|
|
13
13
|
return fe.aa;
|
|
14
14
|
},
|
|
15
|
-
|
|
16
|
-
fe.
|
|
15
|
+
t: () => {
|
|
16
|
+
fe.i || (r.g(fe), (fe.i = !0));
|
|
17
17
|
},
|
|
18
18
|
destroy: () => {
|
|
19
|
-
(fe.aa = null), (fe.
|
|
19
|
+
(fe.aa = null), (fe.i = !1);
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
export default fe;
|
package/src/l10n/l10n-manager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { logger as
|
|
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 lr {
|
|
4
4
|
constructor(t, e = !1) {
|
|
5
5
|
if (
|
|
6
6
|
((this.language = t),
|
|
@@ -15,14 +15,14 @@ export default class nr {
|
|
|
15
15
|
"Braze does not yet have a localization for language " +
|
|
16
16
|
t +
|
|
17
17
|
", defaulting to English. Please contact us if you are willing and able to help us translate our SDK into this language.";
|
|
18
|
-
e ?
|
|
18
|
+
e ? E.error(a) : E.info(a), (t = "en");
|
|
19
19
|
}
|
|
20
20
|
this.language = t;
|
|
21
21
|
}
|
|
22
22
|
get(t) {
|
|
23
23
|
return zt[this.language][t];
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
So() {
|
|
26
26
|
switch (this.language) {
|
|
27
27
|
case "ar":
|
|
28
28
|
case "he":
|