@braze/web-sdk 6.11.0 → 6.12.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 +36 -5
- package/package.json +1 -1
- package/shared-lib/event-types.js +4 -4
- package/shared-lib/indexed-db-adapter.js +51 -51
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +9 -9
- package/src/DUST/dust-config-store.js +89 -0
- package/src/DUST/dust-connection-core.js +7 -21
- package/src/DUST/dust-message-dedup.js +33 -0
- package/src/DUST/dust-provider.js +367 -397
- package/src/DUST/dust-tab-identity.js +30 -0
- package/src/DUST/index.js +7 -9
- package/src/DUST/subscribe-to-dust.js +5 -5
- package/src/FeatureFlags/feature-flag-factory.js +4 -4
- package/src/FeatureFlags/feature-flag.js +5 -5
- package/src/FeatureFlags/feature-flags-provider-factory.js +8 -1
- package/src/FeatureFlags/feature-flags-provider.js +74 -74
- 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 +3 -3
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
- 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-display-utils.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +42 -42
- 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 +6 -6
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +73 -73
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-impression.js +2 -2
- package/src/InAppMessage/models/full-screen-message.js +9 -9
- package/src/InAppMessage/models/html-message.js +4 -4
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +52 -52
- package/src/InAppMessage/models/modal-message.js +7 -7
- package/src/InAppMessage/models/slide-up-message.js +11 -11
- 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/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 +6 -6
- package/src/Push/push-manager.js +14 -14
- package/src/Push/unregister-push-token-on-server.js +3 -3
- package/src/Push/utils/push-utils.js +10 -10
- package/src/User/user.js +19 -19
- package/src/common/content-cards-display.js +21 -21
- package/src/common/event-logger.js +2 -2
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +5 -5
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +41 -41
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +108 -108
- package/src/managers/server-config-manager.js +83 -83
- package/src/managers/session-manager.js +6 -6
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +127 -125
- package/src/managers/subscription-manager.js +1 -1
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +3 -3
- package/src/models/push-token.js +3 -3
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +39 -39
- package/src/triggers/models/filter.js +58 -58
- package/src/triggers/models/in-app-message-click-data.js +4 -4
- package/src/triggers/models/push-click-data.js +2 -2
- package/src/triggers/models/trigger-condition.js +35 -35
- package/src/triggers/models/trigger.js +37 -37
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +50 -50
- package/src/types.js +2 -2
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +2 -2
- package/src/ui/js/iam-css.js +2 -2
- package/src/util/base-device-parser.js +2 -2
- package/src/util/braze-actions.js +2 -2
- package/src/util/browser-detector.js +15 -15
- package/src/util/client-hints-parser.js +5 -5
- package/src/util/component-utils.js +4 -4
- package/src/util/dom-utils.js +5 -5
- package/src/util/ecommerce-event-validation.js +77 -48
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +20 -20
- package/src/util/string-utils.js +5 -0
- package/src/util/user-agent-parser.js +18 -18
- package/src/util/validation-utils.js +4 -4
- package/src/util/window-utils.js +2 -2
- package/src/DUST/dust-shared-worker-code.js +0 -2
- package/src/DUST/dust-shared-worker-impl.js +0 -234
- package/src/DUST/dust-worker-bridge.js +0 -151
|
@@ -3,27 +3,27 @@ import ControlMessage from "../models/control-message.js";
|
|
|
3
3
|
import HtmlMessage from "../models/html-message.js";
|
|
4
4
|
import InAppMessage from "../models/in-app-message.js";
|
|
5
5
|
import SlideUpMessage from "../models/slide-up-message.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import me from "../display/get-animation-effect.js";
|
|
7
|
+
import ge from "../display/in-app-message-to-html.js";
|
|
8
8
|
import { logInAppMessageImpression } from "../log-in-app-message-impression.js";
|
|
9
9
|
import {
|
|
10
|
-
ORIENTATION as
|
|
10
|
+
ORIENTATION as je,
|
|
11
11
|
WindowUtils as no,
|
|
12
12
|
} from "../../util/window-utils.js";
|
|
13
13
|
import { isURIJavascriptOrData as tt } from "../../util/url-utils.js";
|
|
14
|
-
import { KeyCodes as
|
|
14
|
+
import { KeyCodes as le } from "../../util/key-codes.js";
|
|
15
15
|
import { setupInAppMessageUI as rs } from "../../ui/js/index.js";
|
|
16
16
|
import { logger as b } from "../../../shared-lib/index.js";
|
|
17
|
-
import { toRgba as
|
|
18
|
-
import { isIFrame as
|
|
19
|
-
import
|
|
17
|
+
import { toRgba as ae } from "../../util/color-utils.js";
|
|
18
|
+
import { isIFrame as xt } from "../utils/in-app-message-utils.js";
|
|
19
|
+
import he from "../../l10n/l10n-manager-factory.js";
|
|
20
20
|
import {
|
|
21
|
-
IamTiming as
|
|
22
|
-
IamClickAction as
|
|
21
|
+
IamTiming as kt,
|
|
22
|
+
IamClickAction as ce,
|
|
23
23
|
IamDismissType as pr,
|
|
24
|
-
IamOrientation as
|
|
25
|
-
IamSlideFrom as
|
|
26
|
-
IAM_SHOWING_CLASS as
|
|
24
|
+
IamOrientation as be,
|
|
25
|
+
IamSlideFrom as fe,
|
|
26
|
+
IAM_SHOWING_CLASS as we,
|
|
27
27
|
} from "../constants.js";
|
|
28
28
|
export function showInAppMessage(e, t, s) {
|
|
29
29
|
if (!r.rr()) return;
|
|
@@ -48,7 +48,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
48
48
|
!1
|
|
49
49
|
);
|
|
50
50
|
if ((null == t && (t = document.body), e.zo())) {
|
|
51
|
-
if (t.querySelectorAll(`.ab-modal-interactions, .${
|
|
51
|
+
if (t.querySelectorAll(`.ab-modal-interactions, .${we}`).length > 0)
|
|
52
52
|
return (
|
|
53
53
|
b.info(
|
|
54
54
|
`Cannot show in-app message ${e.message} because another message is being shown.`,
|
|
@@ -56,14 +56,14 @@ export function showInAppMessage(e, t, s) {
|
|
|
56
56
|
!1
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
|
-
if (no.
|
|
60
|
-
const t = no.
|
|
59
|
+
if (no.pa()) {
|
|
60
|
+
const t = no.fa();
|
|
61
61
|
if (
|
|
62
|
-
(t ===
|
|
63
|
-
(t ===
|
|
62
|
+
(t === je.PORTRAIT && e.orientation === be.LANDSCAPE) ||
|
|
63
|
+
(t === je.LANDSCAPE && e.orientation === be.PORTRAIT)
|
|
64
64
|
) {
|
|
65
|
-
const s = t ===
|
|
66
|
-
o = e.orientation ===
|
|
65
|
+
const s = t === je.PORTRAIT ? "portrait" : "landscape",
|
|
66
|
+
o = e.orientation === be.PORTRAIT ? "portrait" : "landscape";
|
|
67
67
|
return (
|
|
68
68
|
b.info(
|
|
69
69
|
`Not showing ${o} in-app message ${e.message} because the screen is currently ${s}`,
|
|
@@ -77,11 +77,11 @@ export function showInAppMessage(e, t, s) {
|
|
|
77
77
|
if (e.buttons && e.buttons.length > 0) {
|
|
78
78
|
const s = e.buttons;
|
|
79
79
|
for (let e = 0; e < s.length; e++)
|
|
80
|
-
if (s[e].clickAction ===
|
|
80
|
+
if (s[e].clickAction === ce.URI) {
|
|
81
81
|
const o = s[e].uri;
|
|
82
82
|
t = tt(o);
|
|
83
83
|
}
|
|
84
|
-
} else e.clickAction ===
|
|
84
|
+
} else e.clickAction === ce.URI && (t = tt(e.uri));
|
|
85
85
|
if (t)
|
|
86
86
|
return (
|
|
87
87
|
b.error(
|
|
@@ -93,36 +93,36 @@ export function showInAppMessage(e, t, s) {
|
|
|
93
93
|
const i = document.createElement("div");
|
|
94
94
|
if (
|
|
95
95
|
((i.className = "ab-iam-root v3"),
|
|
96
|
-
e.zo() && (i.className += ` ${
|
|
97
|
-
(i.className +=
|
|
96
|
+
e.zo() && (i.className += ` ${we}`),
|
|
97
|
+
(i.className += me(e)),
|
|
98
98
|
e.language && !o && (i.lang = e.language),
|
|
99
|
-
e.
|
|
100
|
-
r.er(U.
|
|
99
|
+
e.ko() && (i.id = e.htmlId),
|
|
100
|
+
r.er(U.ca) && (i.style.zIndex = (r.er(U.ca) + 1).toString()),
|
|
101
101
|
t.appendChild(i),
|
|
102
102
|
e.Mo())
|
|
103
103
|
) {
|
|
104
104
|
const t = document.createElement("style");
|
|
105
105
|
(t.innerHTML = e.css),
|
|
106
|
-
(t.id = e.
|
|
106
|
+
(t.id = e.Co()),
|
|
107
107
|
null != r.er(U.sr) && t.setAttribute("nonce", r.er(U.sr)),
|
|
108
108
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
109
109
|
}
|
|
110
110
|
const n = e instanceof SlideUpMessage,
|
|
111
|
-
a =
|
|
111
|
+
a = ge(
|
|
112
112
|
e,
|
|
113
113
|
(t) => {
|
|
114
114
|
if (e.zo() && e.od()) {
|
|
115
115
|
const s = document.createElement("div");
|
|
116
116
|
if (
|
|
117
117
|
((s.className = "ab-page-blocker"),
|
|
118
|
-
e.Mo() || (s.style.backgroundColor =
|
|
119
|
-
r.er(U.
|
|
118
|
+
e.Mo() || (s.style.backgroundColor = ae(e.frameColor)),
|
|
119
|
+
r.er(U.ca) && (s.style.zIndex = r.er(U.ca).toString()),
|
|
120
120
|
i.appendChild(s),
|
|
121
121
|
!r.er(U.lh))
|
|
122
122
|
) {
|
|
123
123
|
const o = new Date().valueOf();
|
|
124
124
|
s.onclick = (s) => {
|
|
125
|
-
new Date().valueOf() - o >
|
|
125
|
+
new Date().valueOf() - o > kt.sE &&
|
|
126
126
|
(e.tl(t), s.stopPropagation());
|
|
127
127
|
};
|
|
128
128
|
}
|
|
@@ -135,7 +135,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
135
135
|
o = s[e];
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
|
-
if (e.slideFrom ===
|
|
138
|
+
if (e.slideFrom === fe.TOP) {
|
|
139
139
|
let e = 0;
|
|
140
140
|
null != o && (e = o.offsetTop + o.offsetHeight),
|
|
141
141
|
(t.style.top = Math.max(e, 0) + "px");
|
|
@@ -149,10 +149,10 @@ export function showInAppMessage(e, t, s) {
|
|
|
149
149
|
}
|
|
150
150
|
} else if (o && !r.er(U.lh)) {
|
|
151
151
|
const s = e;
|
|
152
|
-
|
|
152
|
+
xt(t) &&
|
|
153
153
|
t.contentWindow &&
|
|
154
154
|
t.contentWindow.addEventListener("keydown", function (e) {
|
|
155
|
-
e.keyCode ===
|
|
155
|
+
e.keyCode === le.oh && s.closeMessage();
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
logInAppMessageImpression(e),
|
|
@@ -165,11 +165,11 @@ export function showInAppMessage(e, t, s) {
|
|
|
165
165
|
(e) => {
|
|
166
166
|
b.info(e), i.parentNode && i.parentNode.removeChild(i);
|
|
167
167
|
},
|
|
168
|
-
r.er(U.
|
|
169
|
-
r.er(U.
|
|
168
|
+
r.er(U.da),
|
|
169
|
+
r.er(U.ca),
|
|
170
170
|
r.er(U.sr),
|
|
171
171
|
t,
|
|
172
|
-
|
|
172
|
+
he.ra().ga(),
|
|
173
173
|
);
|
|
174
174
|
return (o || n) && (i.appendChild(a), e.nh(i)), !0;
|
|
175
175
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import Dt from "./utils/push-utils.js";
|
|
3
3
|
export function isPushPermissionGranted() {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return Dt.isPushPermissionGranted();
|
|
5
5
|
}
|
|
@@ -8,15 +8,15 @@ const ra = {
|
|
|
8
8
|
ra.na ||
|
|
9
9
|
(ra.na = new na(
|
|
10
10
|
r.zr(),
|
|
11
|
-
r.
|
|
11
|
+
r.ja(),
|
|
12
12
|
r.ue(),
|
|
13
13
|
r.ht(),
|
|
14
|
-
r.er(U.
|
|
15
|
-
r.er(U.
|
|
16
|
-
r.er(U.
|
|
14
|
+
r.er(U.za),
|
|
15
|
+
r.er(U.ba),
|
|
16
|
+
r.er(U.ha),
|
|
17
17
|
r.l(),
|
|
18
|
-
r.er(U.
|
|
19
|
-
r.er(U.
|
|
18
|
+
r.er(U.wa),
|
|
19
|
+
r.er(U.xa),
|
|
20
20
|
r.p(),
|
|
21
21
|
)),
|
|
22
22
|
ra.na
|
package/src/Push/push-manager.js
CHANGED
|
@@ -3,8 +3,8 @@ import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
|
3
3
|
import ui from "../models/push-token.js";
|
|
4
4
|
import { User } from "../User/index.js";
|
|
5
5
|
import { isArray as g, isEqual as hi } from "../util/code-utils.js";
|
|
6
|
-
import { getErrorMessage as
|
|
7
|
-
import
|
|
6
|
+
import { getErrorMessage as ci } from "../util/error-utils.js";
|
|
7
|
+
import Dt from "./utils/push-utils.js";
|
|
8
8
|
export default class na {
|
|
9
9
|
constructor(i, e, t, s, r, o, n, u, h, a, c) {
|
|
10
10
|
(this.iu = i),
|
|
@@ -27,8 +27,8 @@ export default class na {
|
|
|
27
27
|
(this.nu = h || !1),
|
|
28
28
|
(this.uu = a || !1),
|
|
29
29
|
(this.j = c),
|
|
30
|
-
(this.au =
|
|
31
|
-
(this.fu =
|
|
30
|
+
(this.au = Dt.cu()),
|
|
31
|
+
(this.fu = Dt.du());
|
|
32
32
|
}
|
|
33
33
|
lu() {
|
|
34
34
|
return this.uu;
|
|
@@ -71,7 +71,7 @@ export default class na {
|
|
|
71
71
|
(o = btoa(String.fromCharCode.apply(null, i))),
|
|
72
72
|
(n = btoa(String.fromCharCode.apply(null, e)));
|
|
73
73
|
} catch (i) {
|
|
74
|
-
b.error(
|
|
74
|
+
b.error(ci(i));
|
|
75
75
|
}
|
|
76
76
|
const h = ((i) => {
|
|
77
77
|
let e;
|
|
@@ -169,7 +169,7 @@ export default class na {
|
|
|
169
169
|
this.mu(i, new Date(), t);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
|
-
|
|
172
|
+
Dt.isPushBlocked()
|
|
173
173
|
? (b.info("Permission for push notifications was denied."),
|
|
174
174
|
"function" == typeof s && s(!1))
|
|
175
175
|
: (b.error("Push subscription failed: " + i),
|
|
@@ -197,7 +197,7 @@ export default class na {
|
|
|
197
197
|
(i.unregister(), b.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
199
|
subscribe(i, e) {
|
|
200
|
-
if (!
|
|
200
|
+
if (!Dt.isPushSupported())
|
|
201
201
|
return b.info(na.Au), void ("function" == typeof e && e(!1));
|
|
202
202
|
if (this.au) {
|
|
203
203
|
if (!this.nu && null != window.location) {
|
|
@@ -207,7 +207,7 @@ export default class na {
|
|
|
207
207
|
-1 === i.indexOf(window.location.protocol) &&
|
|
208
208
|
(i = window.location.protocol + "//" + i);
|
|
209
209
|
}
|
|
210
|
-
if (
|
|
210
|
+
if (Dt.isPushBlocked())
|
|
211
211
|
return void this.Pu(
|
|
212
212
|
"Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
|
|
213
213
|
e,
|
|
@@ -227,13 +227,13 @@ export default class na {
|
|
|
227
227
|
},
|
|
228
228
|
s = () => {
|
|
229
229
|
let i = "Permission for push notifications was ignored.";
|
|
230
|
-
|
|
230
|
+
Dt.isPushBlocked() &&
|
|
231
231
|
(i +=
|
|
232
232
|
" The browser has automatically blocked further permission requests for a period (probably 1 week)."),
|
|
233
233
|
b.info(i),
|
|
234
234
|
"function" == typeof e && e(!0);
|
|
235
235
|
},
|
|
236
|
-
r =
|
|
236
|
+
r = Dt.isPushPermissionGranted(),
|
|
237
237
|
o = () => {
|
|
238
238
|
!r &&
|
|
239
239
|
this.iu &&
|
|
@@ -256,10 +256,10 @@ export default class na {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
registerPush(i, e) {
|
|
259
|
-
if (!
|
|
259
|
+
if (!Dt.isPushSupported())
|
|
260
260
|
return b.info(na.Au), void ("function" == typeof e && e(!1));
|
|
261
261
|
if (this.au) {
|
|
262
|
-
if (
|
|
262
|
+
if (Dt.isPushBlocked())
|
|
263
263
|
return void this.Pu(
|
|
264
264
|
"Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
|
|
265
265
|
e,
|
|
@@ -273,7 +273,7 @@ export default class na {
|
|
|
273
273
|
this.registerPush(i, e);
|
|
274
274
|
})
|
|
275
275
|
);
|
|
276
|
-
if (!
|
|
276
|
+
if (!Dt.isPushPermissionGranted())
|
|
277
277
|
return void b.info(
|
|
278
278
|
"Push permission has not been granted, so registerPush is a no-op. Call requestPushPermission to prompt the user for permission.",
|
|
279
279
|
);
|
|
@@ -382,7 +382,7 @@ export default class na {
|
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
384
|
unsubscribe(i, e) {
|
|
385
|
-
if (!
|
|
385
|
+
if (!Dt.isPushSupported())
|
|
386
386
|
return b.info(na.Au), void ("function" == typeof i && i());
|
|
387
387
|
this.au
|
|
388
388
|
? navigator.serviceWorker.getRegistration(this.su).then((t) => {
|
|
@@ -14,12 +14,12 @@ export function unregisterPushTokenOnServer() {
|
|
|
14
14
|
if (!o.endpoint) return;
|
|
15
15
|
const i = e.Z({}, !0);
|
|
16
16
|
i.push_token = o.endpoint;
|
|
17
|
-
const a = e.tt(i, h.it.
|
|
17
|
+
const a = e.tt(i, h.it.ka);
|
|
18
18
|
e.et(
|
|
19
19
|
i,
|
|
20
20
|
(n = -1) => {
|
|
21
21
|
r.rr() &&
|
|
22
|
-
(h.nt(t, h.it.
|
|
22
|
+
(h.nt(t, h.it.ka, new Date().valueOf()),
|
|
23
23
|
-1 !== n && a.push(["X-Braze-Req-Tokens-Remaining", n.toString()]),
|
|
24
24
|
l.ot({
|
|
25
25
|
url: `${e.ht()}/push/unregister`,
|
|
@@ -30,6 +30,6 @@ export function unregisterPushTokenOnServer() {
|
|
|
30
30
|
},
|
|
31
31
|
}));
|
|
32
32
|
},
|
|
33
|
-
h.it.
|
|
33
|
+
h.it.ka,
|
|
34
34
|
);
|
|
35
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Dt = {
|
|
2
2
|
cu: () =>
|
|
3
3
|
"serviceWorker" in navigator &&
|
|
4
4
|
"undefined" != typeof ServiceWorkerRegistration &&
|
|
@@ -9,38 +9,38 @@ const It = {
|
|
|
9
9
|
"pushNotification" in window.safari &&
|
|
10
10
|
"function" == typeof window.safari.pushNotification.permission &&
|
|
11
11
|
"function" == typeof window.safari.pushNotification.requestPermission,
|
|
12
|
-
isPushSupported: () =>
|
|
12
|
+
isPushSupported: () => Dt.cu() || Dt.du(),
|
|
13
13
|
isPushBlocked: () => {
|
|
14
14
|
const o =
|
|
15
|
-
|
|
15
|
+
Dt.isPushSupported() &&
|
|
16
16
|
"Notification" in window &&
|
|
17
17
|
null != window.Notification &&
|
|
18
18
|
null != window.Notification.permission &&
|
|
19
19
|
"denied" === window.Notification.permission,
|
|
20
20
|
i =
|
|
21
|
-
|
|
21
|
+
Dt.isPushSupported() &&
|
|
22
22
|
(!("Notification" in window) || null == window.Notification);
|
|
23
23
|
return o || i;
|
|
24
24
|
},
|
|
25
25
|
isPushPermissionGranted: () =>
|
|
26
|
-
|
|
26
|
+
Dt.isPushSupported() &&
|
|
27
27
|
"Notification" in window &&
|
|
28
28
|
null != window.Notification &&
|
|
29
29
|
null != window.Notification.permission &&
|
|
30
30
|
"granted" === window.Notification.permission,
|
|
31
31
|
Yn: () =>
|
|
32
|
-
|
|
32
|
+
Dt.isPushBlocked()
|
|
33
33
|
? { Zn: !1, reason: "blocked" }
|
|
34
|
-
:
|
|
35
|
-
?
|
|
34
|
+
: Dt.isPushSupported()
|
|
35
|
+
? Dt.isPushPermissionGranted()
|
|
36
36
|
? { Zn: !1, reason: "permissionGranted" }
|
|
37
37
|
: { Zn: !0 }
|
|
38
38
|
: { Zn: !1, reason: "unsupported" },
|
|
39
|
-
|
|
39
|
+
So: (o, i) =>
|
|
40
40
|
"blocked" === o
|
|
41
41
|
? `${i} containing a push prompt is not being shown because the user has already declined push permission prompt.`
|
|
42
42
|
: "unsupported" === o
|
|
43
43
|
? `${i} containing a push prompt is not being shown because the browser doesn't support push notifications.`
|
|
44
44
|
: `${i} containing a push prompt is not being shown because the user has already accepted the permission prompt.`,
|
|
45
45
|
};
|
|
46
|
-
export default
|
|
46
|
+
export default Dt;
|
package/src/User/user.js
CHANGED
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
7
|
import { logger as b, EventTypes as p } from "../../shared-lib/index.js";
|
|
8
8
|
import {
|
|
9
|
-
isValidEmail as
|
|
10
|
-
validateCustomAttributeArrayType as
|
|
11
|
-
validateCustomAttributeKey as
|
|
9
|
+
isValidEmail as Ft,
|
|
10
|
+
validateCustomAttributeArrayType as Lt,
|
|
11
|
+
validateCustomAttributeKey as $t,
|
|
12
12
|
validateCustomProperties as nt,
|
|
13
13
|
validateCustomString as mt,
|
|
14
|
-
validatePropertyType as
|
|
14
|
+
validatePropertyType as Bt,
|
|
15
15
|
validateStandardString as tr,
|
|
16
16
|
} from "../util/validation-utils.js";
|
|
17
17
|
import { CoreStrings as R } from "../common/constants.js";
|
|
18
|
-
import { toValidBackendTimeString as
|
|
18
|
+
import { toValidBackendTimeString as Rt } from "../util/date-utils.js";
|
|
19
19
|
export default class User {
|
|
20
20
|
constructor(t, e) {
|
|
21
21
|
(this.Ss = t), (this.Ru = e), (this.Ss = t), (this.Ru = e);
|
|
@@ -47,7 +47,7 @@ export default class User {
|
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
setEmail(t) {
|
|
50
|
-
return null === t ||
|
|
50
|
+
return null === t || Ft(t)
|
|
51
51
|
? this.Ss.Bu("email", t)
|
|
52
52
|
: (b.error(
|
|
53
53
|
`Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
|
|
@@ -168,7 +168,7 @@ export default class User {
|
|
|
168
168
|
.lt);
|
|
169
169
|
}
|
|
170
170
|
setCustomUserAttribute(t, e, r) {
|
|
171
|
-
if (
|
|
171
|
+
if (!$t(t)) return !1;
|
|
172
172
|
const s = (e) => {
|
|
173
173
|
const [r] = nt(
|
|
174
174
|
e,
|
|
@@ -180,7 +180,7 @@ export default class User {
|
|
|
180
180
|
return r;
|
|
181
181
|
};
|
|
182
182
|
if (g(e)) {
|
|
183
|
-
const [r, n] =
|
|
183
|
+
const [r, n] = Lt(t, e);
|
|
184
184
|
if (!r && !n && 0 !== e.length) return !1;
|
|
185
185
|
if (r || 0 === e.length) return this.Ru.Yu(p.Vu, t, e).lt;
|
|
186
186
|
for (const t of e) if (!s(t)) return !1;
|
|
@@ -188,9 +188,9 @@ export default class User {
|
|
|
188
188
|
if (!s(e)) return !1;
|
|
189
189
|
if (r) return this.Ru.Yu(p.Qu, t, e).lt;
|
|
190
190
|
} else {
|
|
191
|
-
if (!(void 0 !== e &&
|
|
191
|
+
if (!(void 0 !== e && Bt(e))) return !1;
|
|
192
192
|
if (
|
|
193
|
-
(Nt(e) && (e =
|
|
193
|
+
(Nt(e) && (e = Rt(e)),
|
|
194
194
|
"string" == typeof e &&
|
|
195
195
|
!mt(
|
|
196
196
|
e,
|
|
@@ -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.Ru.
|
|
250
|
+
: this.Ru.ya(t, e, r).lt)
|
|
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.Ru.
|
|
264
|
+
: this.Ru.va(t, User.Ia.SUBSCRIBED).lt;
|
|
265
265
|
}
|
|
266
266
|
removeFromSubscriptionGroup(t) {
|
|
267
267
|
return !tr(
|
|
@@ -274,21 +274,21 @@ export default class User {
|
|
|
274
274
|
"removeFromSubscriptionGroup requires a non-empty subscription group ID",
|
|
275
275
|
),
|
|
276
276
|
!1)
|
|
277
|
-
: this.Ru.
|
|
277
|
+
: this.Ru.va(t, User.Ia.UNSUBSCRIBED).lt;
|
|
278
278
|
}
|
|
279
279
|
setLineId(t) {
|
|
280
280
|
return tr(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.Ca
|
|
283
283
|
? (b.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.Ca} characters.`,
|
|
285
285
|
),
|
|
286
286
|
!1)
|
|
287
287
|
: this.Ss.Bu("native_line_id", t)
|
|
288
288
|
: (b.error("setLineId requires a non-empty ID"), !1);
|
|
289
289
|
}
|
|
290
290
|
yu(t, e, r, s, n) {
|
|
291
|
-
this.Ss.yu(t, e, r, s, n), this.Ru.
|
|
291
|
+
this.Ss.yu(t, e, r, s, n), this.Ru.Ea();
|
|
292
292
|
}
|
|
293
293
|
wu(t) {
|
|
294
294
|
this.Ss.wu(t);
|
|
@@ -308,8 +308,8 @@ export default class User {
|
|
|
308
308
|
UNSUBSCRIBED: "unsubscribed",
|
|
309
309
|
}),
|
|
310
310
|
(User.Ku = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
311
|
-
(User.
|
|
312
|
-
(User.
|
|
311
|
+
(User.Ia = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
312
|
+
(User.Sa = "user_id"),
|
|
313
313
|
(User.Eu = "custom"),
|
|
314
314
|
(User.br = 997),
|
|
315
|
-
(User.
|
|
315
|
+
(User.Ca = 33);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getCardId as
|
|
3
|
-
markCardAsRead as
|
|
2
|
+
getCardId as qt,
|
|
3
|
+
markCardAsRead as Ot,
|
|
4
4
|
} from "../Card/display/card-display.js";
|
|
5
5
|
import { bottomIsInView as q, topIsInView as k } from "../util/dom-utils.js";
|
|
6
6
|
import { Card, ControlCard } from "../Card/index.js";
|
|
7
|
-
import { cardToHtml as
|
|
7
|
+
import { cardToHtml as Gt } from "../Card/display/card-display.js";
|
|
8
8
|
import { isArray as g } from "../util/code-utils.js";
|
|
9
|
-
import { KeyCodes as
|
|
10
|
-
import
|
|
9
|
+
import { KeyCodes as le } from "../util/key-codes.js";
|
|
10
|
+
import he from "../l10n/l10n-manager-factory.js";
|
|
11
11
|
import { removeSubscription } from "../Core/remove-subscription.js";
|
|
12
12
|
import { logger as b, Guid as V } 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 Tt,
|
|
16
|
+
ineligibleBrazeActionURLErrorMessage as Mt,
|
|
17
17
|
getDecodedBrazeAction as eo,
|
|
18
|
-
containsUnknownBrazeAction as
|
|
18
|
+
containsUnknownBrazeAction as At,
|
|
19
19
|
} from "../util/braze-actions.js";
|
|
20
20
|
import {
|
|
21
|
-
bottomHadImpression as
|
|
21
|
+
bottomHadImpression as Qt,
|
|
22
22
|
impressOnBottom as $,
|
|
23
23
|
impressOnTop as B,
|
|
24
|
-
topHadImpression as
|
|
24
|
+
topHadImpression as Kt,
|
|
25
25
|
} from "./detect-impression.js";
|
|
26
26
|
import { BannerStrings as x } from "../Banner/constants.js";
|
|
27
27
|
import ContentCards from "../ContentCards/content-cards.js";
|
|
@@ -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 = he.ra(),
|
|
47
47
|
o = document.createElement("div");
|
|
48
48
|
if (
|
|
49
49
|
((o.className = "ab-feed-body"),
|
|
@@ -63,7 +63,7 @@ export function generateContentCardsUI(t, e) {
|
|
|
63
63
|
for (const a of t.cards) {
|
|
64
64
|
const i = a instanceof ControlCard;
|
|
65
65
|
!i || t.hr()
|
|
66
|
-
? (o.appendChild(
|
|
66
|
+
? (o.appendChild(Gt(a, r, e, n.ga())), (s = s || !i))
|
|
67
67
|
: b.error(
|
|
68
68
|
"Received a control card for a legacy news feed. Control cards are only supported with content cards.",
|
|
69
69
|
);
|
|
@@ -84,15 +84,15 @@ export function detectContentCardsImpressions(t, e) {
|
|
|
84
84
|
o = e.querySelectorAll(".ab-card");
|
|
85
85
|
t.Ta || (t.Ta = {});
|
|
86
86
|
for (let e = 0; e < o.length; e++) {
|
|
87
|
-
const s =
|
|
87
|
+
const s = qt(o[e]),
|
|
88
88
|
r = k(o[e]),
|
|
89
89
|
a = q(o[e]);
|
|
90
90
|
if (t.Ta[s]) {
|
|
91
|
-
r || a ||
|
|
91
|
+
r || a || Ot(o[e]);
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
94
|
-
let i =
|
|
95
|
-
l =
|
|
94
|
+
let i = Kt(o[e]),
|
|
95
|
+
l = Qt(o[e]);
|
|
96
96
|
const d = i,
|
|
97
97
|
c = l;
|
|
98
98
|
if (
|
|
@@ -124,7 +124,7 @@ 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 = he.ra().get("FEED_TIMEOUT_MESSAGE") || ""),
|
|
128
128
|
null != n.parentNode &&
|
|
129
129
|
(n.parentNode.appendChild(t), n.parentNode.removeChild(n));
|
|
130
130
|
}
|
|
@@ -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 !== le.To && t.keyCode !== le.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 !==
|
|
169
|
+
(t.keyCode !== le.To && t.keyCode !== le.Lo) || l(t);
|
|
170
170
|
}),
|
|
171
171
|
(i.onclick = l),
|
|
172
172
|
s.appendChild(i),
|
|
@@ -187,8 +187,8 @@ export function updateContentCards(t, e, n, o, s) {
|
|
|
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
|
-
b.error(
|
|
190
|
+
if (At(e)) {
|
|
191
|
+
b.error(Mt(Tt.Wn, "Content Card"));
|
|
192
192
|
continue;
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger as b } from "../../shared-lib/index.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
|
-
import
|
|
3
|
+
import ve from "../models/braze-event.js";
|
|
4
4
|
import L from "../models/request-result.js";
|
|
5
5
|
const v = {
|
|
6
6
|
Dt: (e, o, t) => {
|
|
@@ -17,7 +17,7 @@ const v = {
|
|
|
17
17
|
const d = l.el();
|
|
18
18
|
return (
|
|
19
19
|
i.Ce.push(
|
|
20
|
-
new
|
|
20
|
+
new ve(
|
|
21
21
|
t || (null === (n = r.ir()) || void 0 === n ? void 0 : n.getUserId()),
|
|
22
22
|
e,
|
|
23
23
|
new Date().valueOf(),
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import r, { OPTIONS as U } from "../managers/braze-instance.js";
|
|
2
2
|
import ro from "../util/browser-detector.js";
|
|
3
3
|
import jr from "./l10n-manager.js";
|
|
4
|
-
const
|
|
4
|
+
const he = {
|
|
5
5
|
i: !1,
|
|
6
6
|
na: null,
|
|
7
7
|
ra: () => {
|
|
8
|
-
if ((
|
|
8
|
+
if ((he.t(), !he.na)) {
|
|
9
9
|
let e = ro.language,
|
|
10
10
|
t = !1;
|
|
11
|
-
r.er(U.
|
|
11
|
+
r.er(U.Ma) && ((e = r.er(U.Ma)), (t = !0)), (he.na = new jr(e, t));
|
|
12
12
|
}
|
|
13
|
-
return
|
|
13
|
+
return he.na;
|
|
14
14
|
},
|
|
15
15
|
t: () => {
|
|
16
|
-
|
|
16
|
+
he.i || (r.g(he), (he.i = !0));
|
|
17
17
|
},
|
|
18
18
|
destroy: () => {
|
|
19
|
-
(
|
|
19
|
+
(he.na = null), (he.i = !1);
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
-
export default
|
|
22
|
+
export default he;
|