@braze/web-sdk 5.8.1 → 5.9.1
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 +14 -9
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +20 -20
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +3 -3
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +11 -11
- package/src/Banner/banner-provider.js +22 -19
- package/src/Banner/display/banner-to-html.js +32 -27
- package/src/Banner/get-all-banners.js +11 -5
- package/src/Banner/get-banner.js +6 -3
- package/src/Banner/log-banner-click.js +2 -2
- package/src/Banner/log-banner-impressions.js +4 -4
- package/src/Banner/request-banners-refresh.js +5 -2
- package/src/Banner/subscribe-to-banners-updates.js +2 -2
- package/src/Banner/ui/insert-banner.js +2 -2
- package/src/Card/card-manager.js +9 -9
- package/src/Card/display/card-display.js +5 -5
- package/src/Card/log-card-click.js +2 -2
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-card-impressions.js +2 -2
- package/src/Card/models/captioned-image.js +17 -17
- package/src/Card/models/card.js +58 -58
- package/src/Card/models/classic-card.js +17 -17
- package/src/Card/models/control-card.js +8 -8
- package/src/Card/models/image-only.js +15 -15
- package/src/Card/util/card-factory.js +24 -24
- package/src/ContentCards/content-cards-provider.js +77 -75
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +3 -3
- package/src/ContentCards/ui/show-content-cards.js +3 -3
- package/src/Core/change-user.js +1 -1
- package/src/Core/disable-sdk.js +4 -4
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/handle-braze-action.js +2 -2
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/open-session.js +4 -4
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/wipe-data.js +7 -5
- package/src/FeatureFlags/feature-flag-factory.js +4 -4
- package/src/FeatureFlags/feature-flag.js +3 -3
- package/src/FeatureFlags/feature-flags-provider.js +17 -11
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +1 -1
- package/src/Feed/feed-provider-factory.js +1 -1
- package/src/Feed/feed-provider.js +12 -12
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +8 -8
- package/src/InAppMessage/display/in-app-message-to-html.js +18 -18
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/in-app-message-factory.js +6 -6
- package/src/InAppMessage/in-app-message-manager.js +70 -70
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +2 -2
- package/src/InAppMessage/models/full-screen-message.js +6 -6
- package/src/InAppMessage/models/html-message.js +7 -7
- package/src/InAppMessage/models/in-app-message-button.js +3 -3
- package/src/InAppMessage/models/in-app-message.js +36 -36
- package/src/InAppMessage/models/modal-message.js +6 -6
- package/src/InAppMessage/models/slide-up-message.js +8 -8
- 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 +13 -13
- package/src/Push/push-manager.js +81 -81
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +10 -10
- package/src/User/user.js +15 -15
- package/src/common/constants.js +2 -0
- package/src/common/event-logger.js +2 -2
- package/src/common/feed-display.js +6 -6
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/managers/auth-manager.js +30 -30
- package/src/managers/braze-instance.js +94 -93
- package/src/managers/device-manager.js +14 -14
- package/src/managers/network-manager.js +123 -117
- package/src/managers/server-config-manager.js +91 -79
- package/src/managers/session-manager.js +8 -8
- package/src/managers/storage-manager-factory.js +5 -5
- package/src/managers/storage-manager.js +48 -48
- package/src/managers/subscription-manager.js +4 -4
- package/src/models/backend-errors.js +4 -4
- package/src/models/braze-event.js +9 -9
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +3 -3
- package/src/models/push-token.js +4 -4
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +18 -18
- package/src/request-controller.js +100 -88
- 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 +4 -4
- package/src/triggers/models/filter.js +6 -6
- 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 +33 -33
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +12 -12
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +17 -17
- 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 +4 -4
- package/src/util/browser-detector.js +5 -5
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/component-utils.js +2 -2
- package/src/util/dom-utils.js +3 -3
- package/src/util/html-display-utils.js +14 -14
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +2 -2
- package/src/util/request-header-utils.js +13 -13
- package/src/util/user-agent-parser.js +1 -1
- package/src/util/validation-utils.js +2 -2
- package/src/util/window-utils.js +2 -2
package/src/Push/push-manager.js
CHANGED
|
@@ -7,37 +7,37 @@ import vt from "./utils/push-utils.js";
|
|
|
7
7
|
import { getErrorMessage as si } from "../util/error-utils.js";
|
|
8
8
|
export default class na {
|
|
9
9
|
constructor(i, t, e, s, r, n, o, u, a, h, c) {
|
|
10
|
-
(this.
|
|
11
|
-
(this.
|
|
12
|
-
(this.
|
|
13
|
-
(this.
|
|
14
|
-
(this.
|
|
15
|
-
(this.
|
|
10
|
+
(this.un = i),
|
|
11
|
+
(this.an = t),
|
|
12
|
+
(this.hn = e),
|
|
13
|
+
(this.cn = r),
|
|
14
|
+
(this.fn = n),
|
|
15
|
+
(this.ln = o),
|
|
16
16
|
(this.B = u),
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
17
|
+
(this.dn = a),
|
|
18
|
+
(this.pn = h),
|
|
19
19
|
(this.C = c),
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
20
|
+
(this.un = i),
|
|
21
|
+
(this.an = t),
|
|
22
|
+
(this.hn = e),
|
|
23
|
+
(this.bn = s + "/safari/" + t),
|
|
24
|
+
(this.cn = r || "/service-worker.js"),
|
|
25
|
+
(this.ln = o),
|
|
26
26
|
(this.B = u),
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
27
|
+
(this.dn = a || !1),
|
|
28
|
+
(this.pn = h || !1),
|
|
29
29
|
(this.C = c),
|
|
30
|
-
(this.
|
|
31
|
-
(this.
|
|
30
|
+
(this.yn = vt.mn()),
|
|
31
|
+
(this.gn = vt.vn());
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
return this.
|
|
33
|
+
wn() {
|
|
34
|
+
return this.pn;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
kn(i, t, e, s, r) {
|
|
37
37
|
i.unsubscribe()
|
|
38
38
|
.then((i) => {
|
|
39
39
|
i
|
|
40
|
-
? this.
|
|
40
|
+
? this.Pn(t, e, s, r)
|
|
41
41
|
: (N.error("Failed to unsubscribe device from push."),
|
|
42
42
|
"function" == typeof r && r(!1));
|
|
43
43
|
})
|
|
@@ -46,7 +46,7 @@ export default class na {
|
|
|
46
46
|
"function" == typeof r && r(!1);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
Dn(i, t, e) {
|
|
50
50
|
var s;
|
|
51
51
|
const r = ((i) => {
|
|
52
52
|
if ("string" == typeof i) return i;
|
|
@@ -55,9 +55,9 @@ export default class na {
|
|
|
55
55
|
let t = i.endpoint;
|
|
56
56
|
const e = i;
|
|
57
57
|
return (
|
|
58
|
-
e.
|
|
59
|
-
-1 === i.endpoint.indexOf(e.
|
|
60
|
-
(t = i.endpoint + "/" + e.
|
|
58
|
+
e.Sn &&
|
|
59
|
+
-1 === i.endpoint.indexOf(e.Sn) &&
|
|
60
|
+
(t = i.endpoint + "/" + e.Sn),
|
|
61
61
|
t
|
|
62
62
|
);
|
|
63
63
|
})(i);
|
|
@@ -84,53 +84,53 @@ export default class na {
|
|
|
84
84
|
.replace(/\//g, "_")
|
|
85
85
|
: null;
|
|
86
86
|
})(u);
|
|
87
|
-
null === (s = this.
|
|
87
|
+
null === (s = this.un) || void 0 === s || s.An(r, t, n, o, a),
|
|
88
88
|
r && "function" == typeof e && e(r, n, o);
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
jn() {
|
|
91
91
|
var i;
|
|
92
|
-
null === (i = this.
|
|
92
|
+
null === (i = this.un) || void 0 === i || i.xn(!0);
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
Nn(i, t) {
|
|
95
95
|
var e;
|
|
96
|
-
null === (e = this.
|
|
96
|
+
null === (e = this.un) || void 0 === e || e.xn(!1),
|
|
97
97
|
N.info(i),
|
|
98
98
|
"function" == typeof t && t(!1);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
Un(i, t, e, s) {
|
|
101
101
|
var r;
|
|
102
102
|
if ("default" === t.permission)
|
|
103
103
|
try {
|
|
104
104
|
window.safari.pushNotification.requestPermission(
|
|
105
|
-
this.
|
|
105
|
+
this.bn,
|
|
106
106
|
i,
|
|
107
107
|
{
|
|
108
|
-
api_key: this.
|
|
108
|
+
api_key: this.an,
|
|
109
109
|
device_id:
|
|
110
|
-
(null === (r = this.
|
|
110
|
+
(null === (r = this.hn) || void 0 === r ? void 0 : r.ve().id) ||
|
|
111
111
|
"",
|
|
112
112
|
},
|
|
113
113
|
(t) => {
|
|
114
114
|
"granted" === t.permission &&
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
115
|
+
this.un &&
|
|
116
|
+
this.un.setPushNotificationSubscriptionType(
|
|
117
117
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
118
118
|
),
|
|
119
|
-
this.
|
|
119
|
+
this.Un(i, t, e, s);
|
|
120
120
|
},
|
|
121
121
|
);
|
|
122
122
|
} catch (i) {
|
|
123
|
-
this.
|
|
123
|
+
this.Nn("Could not request permission for push: " + i, s);
|
|
124
124
|
}
|
|
125
125
|
else
|
|
126
126
|
"denied" === t.permission
|
|
127
|
-
? this.
|
|
127
|
+
? this.Nn(
|
|
128
128
|
"The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
|
|
129
129
|
s,
|
|
130
130
|
)
|
|
131
131
|
: "granted" === t.permission &&
|
|
132
132
|
(N.info("Device successfully subscribed to push."),
|
|
133
|
-
this.
|
|
133
|
+
this.Dn(t.deviceToken, new Date(), e));
|
|
134
134
|
}
|
|
135
135
|
requestPermission(i, t, e) {
|
|
136
136
|
const s = (s) => {
|
|
@@ -159,14 +159,14 @@ export default class na {
|
|
|
159
159
|
: (r = !0);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
Pn(i, t, e, s) {
|
|
163
163
|
const r = { userVisibleOnly: !0 };
|
|
164
164
|
null != t && (r.applicationServerKey = t),
|
|
165
165
|
i.pushManager
|
|
166
166
|
.subscribe(r)
|
|
167
167
|
.then((i) => {
|
|
168
168
|
N.info("Device successfully subscribed to push."),
|
|
169
|
-
this.
|
|
169
|
+
this.Dn(i, new Date(), e);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
172
|
vt.isPushBlocked()
|
|
@@ -176,10 +176,10 @@ export default class na {
|
|
|
176
176
|
"function" == typeof s && s(!0));
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
if (this.
|
|
181
|
-
const i = this.
|
|
182
|
-
return navigator.serviceWorker.register(this.
|
|
179
|
+
Wn() {
|
|
180
|
+
if (this.dn) return navigator.serviceWorker.getRegistration(this.cn);
|
|
181
|
+
const i = this.fn ? { scope: this.fn } : void 0;
|
|
182
|
+
return navigator.serviceWorker.register(this.cn, i).then(() =>
|
|
183
183
|
navigator.serviceWorker.ready.then(
|
|
184
184
|
(i) => (
|
|
185
185
|
i &&
|
|
@@ -192,32 +192,32 @@ export default class na {
|
|
|
192
192
|
),
|
|
193
193
|
);
|
|
194
194
|
}
|
|
195
|
-
|
|
196
|
-
this.
|
|
195
|
+
_n(i) {
|
|
196
|
+
this.dn ||
|
|
197
197
|
(i.unregister(), N.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
199
|
subscribe(i, t) {
|
|
200
200
|
if (!vt.isPushSupported())
|
|
201
|
-
return N.info(na.
|
|
202
|
-
if (this.
|
|
203
|
-
if (!this.
|
|
204
|
-
let i = this.
|
|
201
|
+
return N.info(na.Tn), void ("function" == typeof t && t(!1));
|
|
202
|
+
if (this.yn) {
|
|
203
|
+
if (!this.dn && null != window.location) {
|
|
204
|
+
let i = this.cn;
|
|
205
205
|
-1 === i.indexOf(window.location.host) &&
|
|
206
206
|
(i = window.location.host + i),
|
|
207
207
|
-1 === i.indexOf(window.location.protocol) &&
|
|
208
208
|
(i = window.location.protocol + "//" + i);
|
|
209
209
|
}
|
|
210
210
|
if (vt.isPushBlocked())
|
|
211
|
-
return void this.
|
|
211
|
+
return void this.Nn(
|
|
212
212
|
"Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
|
|
213
213
|
t,
|
|
214
214
|
);
|
|
215
|
-
if (this.B && !this.B.
|
|
215
|
+
if (this.B && !this.B.In() && 0 === this.B.Et())
|
|
216
216
|
return (
|
|
217
217
|
N.info(
|
|
218
218
|
"Waiting for VAPID key from server config before subscribing to push.",
|
|
219
219
|
),
|
|
220
|
-
void this.B.
|
|
220
|
+
void this.B.Vn(() => {
|
|
221
221
|
this.subscribe(i, t);
|
|
222
222
|
})
|
|
223
223
|
);
|
|
@@ -236,11 +236,11 @@ export default class na {
|
|
|
236
236
|
n = vt.isPushPermissionGranted(),
|
|
237
237
|
o = () => {
|
|
238
238
|
!n &&
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
239
|
+
this.un &&
|
|
240
|
+
this.un.setPushNotificationSubscriptionType(
|
|
241
241
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
242
242
|
),
|
|
243
|
-
this.
|
|
243
|
+
this.Wn()
|
|
244
244
|
.then((e) => {
|
|
245
245
|
if (null == e)
|
|
246
246
|
return (
|
|
@@ -258,16 +258,16 @@ export default class na {
|
|
|
258
258
|
(null !=
|
|
259
259
|
(null === (n = this.B) || void 0 === n
|
|
260
260
|
? void 0
|
|
261
|
-
: n.
|
|
261
|
+
: n.In()) && (o = ei.qn(this.B.In())),
|
|
262
262
|
r)
|
|
263
263
|
) {
|
|
264
264
|
let n,
|
|
265
265
|
u = null,
|
|
266
266
|
a = null;
|
|
267
|
-
if ((this.C && (n = this.C.ft(s.gt.
|
|
267
|
+
if ((this.C && (n = this.C.ft(s.gt.zn)), n && !z(n))) {
|
|
268
268
|
let i;
|
|
269
269
|
try {
|
|
270
|
-
i = ti.
|
|
270
|
+
i = ti.Rn(n).En;
|
|
271
271
|
} catch (t) {
|
|
272
272
|
i = null;
|
|
273
273
|
}
|
|
@@ -291,31 +291,31 @@ export default class na {
|
|
|
291
291
|
: N.info(
|
|
292
292
|
"Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription.",
|
|
293
293
|
),
|
|
294
|
-
this.
|
|
294
|
+
this.kn(r, e, o, i, t))
|
|
295
295
|
: r.expirationTime &&
|
|
296
296
|
new Date(r.expirationTime).valueOf() <=
|
|
297
297
|
new Date().valueOf()
|
|
298
298
|
? (N.info(
|
|
299
299
|
"Push subscription is expired, creating new subscription.",
|
|
300
300
|
),
|
|
301
|
-
this.
|
|
301
|
+
this.kn(r, e, o, i, t))
|
|
302
302
|
: n && z(n)
|
|
303
|
-
? this.
|
|
303
|
+
? this.kn(r, e, o, i, t)
|
|
304
304
|
: null == a
|
|
305
305
|
? (N.info(
|
|
306
306
|
"No push subscription creation date found, creating new subscription.",
|
|
307
307
|
),
|
|
308
|
-
this.
|
|
308
|
+
this.kn(r, e, o, i, t))
|
|
309
309
|
: a.valueOf() <= new Date().valueOf()
|
|
310
310
|
? (N.info(
|
|
311
311
|
"Push subscription older than 6 months, creating new subscription.",
|
|
312
312
|
),
|
|
313
|
-
this.
|
|
313
|
+
this.kn(r, e, o, i, t))
|
|
314
314
|
: (N.info(
|
|
315
315
|
"Device already subscribed to push, sending existing subscription to backend.",
|
|
316
316
|
),
|
|
317
|
-
this.
|
|
318
|
-
} else this.
|
|
317
|
+
this.Dn(r, u, i));
|
|
318
|
+
} else this.Pn(e, o, i, t);
|
|
319
319
|
})
|
|
320
320
|
.catch((i) => {
|
|
321
321
|
N.error("Error checking current push subscriptions: " + i);
|
|
@@ -326,29 +326,29 @@ export default class na {
|
|
|
326
326
|
});
|
|
327
327
|
};
|
|
328
328
|
this.requestPermission(o, r, e);
|
|
329
|
-
} else if (this.
|
|
330
|
-
if (null == this.
|
|
329
|
+
} else if (this.gn) {
|
|
330
|
+
if (null == this.ln || "" === this.ln)
|
|
331
331
|
return (
|
|
332
332
|
N.error(
|
|
333
333
|
"You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari",
|
|
334
334
|
),
|
|
335
335
|
void ("function" == typeof t && t(!0))
|
|
336
336
|
);
|
|
337
|
-
const e = window.safari.pushNotification.permission(this.
|
|
338
|
-
this.
|
|
337
|
+
const e = window.safari.pushNotification.permission(this.ln);
|
|
338
|
+
this.Un(this.ln, e, i, t);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
unsubscribe(i, t) {
|
|
342
342
|
if (!vt.isPushSupported())
|
|
343
|
-
return N.info(na.
|
|
344
|
-
this.
|
|
345
|
-
? navigator.serviceWorker.getRegistration(this.
|
|
343
|
+
return N.info(na.Tn), void ("function" == typeof t && t());
|
|
344
|
+
this.yn
|
|
345
|
+
? navigator.serviceWorker.getRegistration(this.cn).then((e) => {
|
|
346
346
|
e
|
|
347
347
|
? e.pushManager
|
|
348
348
|
.getSubscription()
|
|
349
349
|
.then((s) => {
|
|
350
350
|
s
|
|
351
|
-
? (this.
|
|
351
|
+
? (this.jn(),
|
|
352
352
|
s
|
|
353
353
|
.unsubscribe()
|
|
354
354
|
.then((s) => {
|
|
@@ -361,7 +361,7 @@ export default class na {
|
|
|
361
361
|
"Failed to unsubscribe device from push.",
|
|
362
362
|
),
|
|
363
363
|
"function" == typeof t && t()),
|
|
364
|
-
this.
|
|
364
|
+
this._n(e);
|
|
365
365
|
})
|
|
366
366
|
.catch((i) => {
|
|
367
367
|
N.error("Push unsubscription error: " + i),
|
|
@@ -377,10 +377,10 @@ export default class na {
|
|
|
377
377
|
: (N.info("Device already unsubscribed from push."),
|
|
378
378
|
"function" == typeof i && i());
|
|
379
379
|
})
|
|
380
|
-
: this.
|
|
381
|
-
(this.
|
|
380
|
+
: this.gn &&
|
|
381
|
+
(this.jn(),
|
|
382
382
|
N.info("Device unsubscribed from push."),
|
|
383
383
|
"function" == typeof i && i());
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
na.
|
|
386
|
+
na.Tn = "Push notifications are not supported in this browser.";
|
|
@@ -3,7 +3,7 @@ import ra from "./push-manager-factory.js";
|
|
|
3
3
|
export function requestPushPermission(n, o) {
|
|
4
4
|
if (r.rr())
|
|
5
5
|
return ra.ea().subscribe((o, t, e) => {
|
|
6
|
-
const s = r.
|
|
6
|
+
const s = r.rn();
|
|
7
7
|
s && s.requestImmediateDataFlush(), "function" == typeof n && n(o, t, e);
|
|
8
8
|
}, o);
|
|
9
9
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const vt = {
|
|
2
|
-
|
|
2
|
+
mn: () =>
|
|
3
3
|
"serviceWorker" in navigator &&
|
|
4
4
|
"undefined" != typeof ServiceWorkerRegistration &&
|
|
5
5
|
"showNotification" in ServiceWorkerRegistration.prototype &&
|
|
6
6
|
"PushManager" in window,
|
|
7
|
-
|
|
7
|
+
vn: () =>
|
|
8
8
|
"safari" in window &&
|
|
9
9
|
"pushNotification" in window.safari &&
|
|
10
10
|
"function" == typeof window.safari.pushNotification.permission &&
|
|
11
11
|
"function" == typeof window.safari.pushNotification.requestPermission,
|
|
12
|
-
isPushSupported: () => vt.
|
|
12
|
+
isPushSupported: () => vt.mn() || vt.vn(),
|
|
13
13
|
isPushBlocked: () => {
|
|
14
14
|
const i =
|
|
15
15
|
vt.isPushSupported() &&
|
|
@@ -28,7 +28,7 @@ const vt = {
|
|
|
28
28
|
null != window.Notification &&
|
|
29
29
|
null != window.Notification.permission &&
|
|
30
30
|
"granted" === window.Notification.permission,
|
|
31
|
-
|
|
31
|
+
Tr: () =>
|
|
32
32
|
!vt.isPushBlocked() &&
|
|
33
33
|
vt.isPushSupported() &&
|
|
34
34
|
!vt.isPushPermissionGranted(),
|
package/src/User/user-manager.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _t from "../models/identifier.js";
|
|
2
2
|
import { getByteLength as er } from "../util/string-utils.js";
|
|
3
3
|
import ti from "../models/push-token.js";
|
|
4
|
-
import { logger as N, IndexedDBAdapter as
|
|
4
|
+
import { logger as N, IndexedDBAdapter as st } 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
|
-
export default class
|
|
7
|
+
export default class kt {
|
|
8
8
|
constructor(t, s) {
|
|
9
9
|
(this.B = t), (this.C = s), (this.B = t), (this.C = s);
|
|
10
10
|
}
|
|
@@ -47,17 +47,17 @@ export default class bt {
|
|
|
47
47
|
u
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
An(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 = st.Ls.Fs,
|
|
56
|
+
h = new st(r, N),
|
|
57
57
|
n = new ti(t, i, e, u, o);
|
|
58
|
-
this.C.Bt(s.gt.
|
|
58
|
+
this.C.Bt(s.gt.zn, n.bt()), h.setItem(r.Ms.cu, r.be, !0);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
xn(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.C.Bt(s.gt.
|
|
68
|
+
const t = st.Ls.Fs,
|
|
69
|
+
i = new st(t, N);
|
|
70
|
+
this.C.Bt(s.gt.zn, !1), i.setItem(t.Ms.cu, t.be, !1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/User/user.js
CHANGED
|
@@ -209,7 +209,7 @@ export default class User {
|
|
|
209
209
|
null != e &&
|
|
210
210
|
!nt(e, "add to custom user attribute array", "the given value")
|
|
211
211
|
) &&
|
|
212
|
-
this.Fi.Ln(d.
|
|
212
|
+
this.Fi.Ln(d.On, t, e).tt
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
215
|
removeFromCustomAttributeArray(t, e) {
|
|
@@ -219,7 +219,7 @@ export default class User {
|
|
|
219
219
|
null != e &&
|
|
220
220
|
!nt(e, "remove from custom user attribute array", "the given value")
|
|
221
221
|
) &&
|
|
222
|
-
this.Fi.Ln(d.
|
|
222
|
+
this.Fi.Ln(d.Gn, t, e).tt
|
|
223
223
|
);
|
|
224
224
|
}
|
|
225
225
|
incrementCustomUserAttribute(t, e) {
|
|
@@ -231,7 +231,7 @@ export default class User {
|
|
|
231
231
|
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
|
|
232
232
|
),
|
|
233
233
|
!1)
|
|
234
|
-
: this.Fi.Ln(d.
|
|
234
|
+
: this.Fi.Ln(d.Hn, t, r).tt;
|
|
235
235
|
}
|
|
236
236
|
setCustomLocationAttribute(t, e, r) {
|
|
237
237
|
return (
|
|
@@ -247,7 +247,7 @@ export default class User {
|
|
|
247
247
|
"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
248
|
),
|
|
249
249
|
!1)
|
|
250
|
-
: this.Fi.
|
|
250
|
+
: this.Fi.Kn(t, e, r).tt)
|
|
251
251
|
);
|
|
252
252
|
}
|
|
253
253
|
addToSubscriptionGroup(t) {
|
|
@@ -261,7 +261,7 @@ export default class User {
|
|
|
261
261
|
"addToSubscriptionGroup requires a non-empty subscription group ID",
|
|
262
262
|
),
|
|
263
263
|
!1)
|
|
264
|
-
: this.Fi.
|
|
264
|
+
: this.Fi.Mn(t, User.Yn.SUBSCRIBED).tt;
|
|
265
265
|
}
|
|
266
266
|
removeFromSubscriptionGroup(t) {
|
|
267
267
|
return !ir(
|
|
@@ -274,24 +274,24 @@ export default class User {
|
|
|
274
274
|
"removeFromSubscriptionGroup requires a non-empty subscription group ID",
|
|
275
275
|
),
|
|
276
276
|
!1)
|
|
277
|
-
: this.Fi.
|
|
277
|
+
: this.Fi.Mn(t, User.Yn.UNSUBSCRIBED).tt;
|
|
278
278
|
}
|
|
279
279
|
setLineId(t) {
|
|
280
280
|
return ir(t, "set LINE user ID", "the ID", !0) &&
|
|
281
281
|
0 !== (null == t ? void 0 : t.length)
|
|
282
|
-
? t && t.length > User.
|
|
282
|
+
? t && t.length > User.Jn
|
|
283
283
|
? (N.error(
|
|
284
|
-
`Rejected LINE user ID ${t} because it is longer than ${User.
|
|
284
|
+
`Rejected LINE user ID ${t} because it is longer than ${User.Jn} characters.`,
|
|
285
285
|
),
|
|
286
286
|
!1)
|
|
287
287
|
: this.Cs.nu("native_line_id", t)
|
|
288
288
|
: (N.error("setLineId requires a non-empty ID"), !1);
|
|
289
289
|
}
|
|
290
|
-
|
|
291
|
-
this.Cs.
|
|
290
|
+
An(t, e, r, s, n) {
|
|
291
|
+
this.Cs.An(t, e, r, s, n), this.Fi.Qn();
|
|
292
292
|
}
|
|
293
|
-
|
|
294
|
-
this.Cs.
|
|
293
|
+
xn(t) {
|
|
294
|
+
this.Cs.xn(t);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
(User.Genders = {
|
|
@@ -308,8 +308,8 @@ export default class User {
|
|
|
308
308
|
UNSUBSCRIBED: "unsubscribed",
|
|
309
309
|
}),
|
|
310
310
|
(User.Fn = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
311
|
-
(User.
|
|
312
|
-
(User.
|
|
311
|
+
(User.Yn = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
312
|
+
(User.Xn = "user_id"),
|
|
313
313
|
(User.lu = "custom"),
|
|
314
314
|
(User.ur = 997),
|
|
315
|
-
(User.
|
|
315
|
+
(User.Jn = 33);
|
package/src/common/constants.js
CHANGED
|
@@ -13,3 +13,5 @@ export const LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT = 72e5;
|
|
|
13
13
|
export const MAX_RETRY_COUNT_PER_REQUEST = 15;
|
|
14
14
|
export const REQUEST_ATTEMPT_DEFAULT = 1;
|
|
15
15
|
export const SUBSCRIPTION_ID_DATA_ATTRIBUTE = "data-update-subscription-id";
|
|
16
|
+
export const BANNERS_DISABLED_MESSAGE =
|
|
17
|
+
"Banners are disabled. Make sure you have at least one campaign and relaunch the app.";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { logger as N } from "../../shared-lib/index.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
3
|
import ve from "../models/braze-event.js";
|
|
4
|
-
import
|
|
4
|
+
import F from "../models/request-result.js";
|
|
5
5
|
const c = {
|
|
6
6
|
ut: (e, o, t) => {
|
|
7
7
|
var n, s;
|
|
8
|
-
const i = new
|
|
8
|
+
const i = new F(),
|
|
9
9
|
l = r.P();
|
|
10
10
|
if (!l)
|
|
11
11
|
return (
|
|
@@ -7,10 +7,10 @@ import { bottomIsInView as B, topIsInView as x } from "../util/dom-utils.js";
|
|
|
7
7
|
import { Card, ControlCard } from "../Card/index.js";
|
|
8
8
|
import { cardToHtml as Fe } from "../Card/display/card-display.js";
|
|
9
9
|
import { isArray as z } from "../util/code-utils.js";
|
|
10
|
-
import { KeyCodes as
|
|
10
|
+
import { KeyCodes as bt } from "../util/key-codes.js";
|
|
11
11
|
import ge from "../l10n/l10n-manager-factory.js";
|
|
12
12
|
import { removeSubscription } from "../Core/remove-subscription.js";
|
|
13
|
-
import { logger as N, Guid as
|
|
13
|
+
import { logger as N, Guid as K } from "../../shared-lib/index.js";
|
|
14
14
|
import { BRAZE_ACTION_URI_REGEX as to } from "../util/validation-utils.js";
|
|
15
15
|
import {
|
|
16
16
|
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as jt,
|
|
@@ -153,7 +153,7 @@ export function feedToHtml(e, t, o) {
|
|
|
153
153
|
destroyFeedHtml(s), e.stopPropagation();
|
|
154
154
|
};
|
|
155
155
|
r.addEventListener("keydown", (e) => {
|
|
156
|
-
(e.keyCode !==
|
|
156
|
+
(e.keyCode !== bt.Wo && e.keyCode !== bt.Xo) || i(e);
|
|
157
157
|
}),
|
|
158
158
|
(r.onclick = i);
|
|
159
159
|
const a = document.createElement("i");
|
|
@@ -166,7 +166,7 @@ export function feedToHtml(e, t, o) {
|
|
|
166
166
|
refreshFeed(e, s), t.stopPropagation();
|
|
167
167
|
};
|
|
168
168
|
a.addEventListener("keydown", (e) => {
|
|
169
|
-
(e.keyCode !==
|
|
169
|
+
(e.keyCode !== bt.Wo && e.keyCode !== bt.Xo) || d(e);
|
|
170
170
|
}),
|
|
171
171
|
(a.onclick = d),
|
|
172
172
|
n.appendChild(a),
|
|
@@ -175,7 +175,7 @@ export function feedToHtml(e, t, o) {
|
|
|
175
175
|
const l = () => detectFeedImpressions(e, s);
|
|
176
176
|
if ((s.addEventListener("scroll", l), !o)) {
|
|
177
177
|
window.addEventListener("scroll", l);
|
|
178
|
-
const e =
|
|
178
|
+
const e = K.ce();
|
|
179
179
|
(scrollListeners[e] = l), s.setAttribute("data-listener-id", e);
|
|
180
180
|
}
|
|
181
181
|
return s;
|
|
@@ -188,7 +188,7 @@ export function updateFeedCards(e, t, o, s, n) {
|
|
|
188
188
|
if (e.url && to.test(e.url)) {
|
|
189
189
|
const t = eo(e.url);
|
|
190
190
|
if (ft(t)) {
|
|
191
|
-
N.error(dt(jt.
|
|
191
|
+
N.error(dt(jt.Mr, "Content Card"));
|
|
192
192
|
continue;
|
|
193
193
|
}
|
|
194
194
|
}
|