@braze/web-sdk 6.12.0 → 6.13.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 +240 -3
- package/package.json +1 -1
- package/shared-lib/event-types.js +18 -18
- package/shared-lib/indexed-db-adapter.js +58 -58
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +25 -24
- package/src/ConversationalChat/automatically-manage-chat.js +5 -0
- package/src/ConversationalChat/chat-message-factory.js +25 -0
- package/src/ConversationalChat/chat-message.js +33 -0
- package/src/ConversationalChat/constants.js +1 -0
- package/src/ConversationalChat/conversational-chat-provider-factory.js +26 -0
- package/src/ConversationalChat/conversational-chat-provider.js +372 -0
- package/src/ConversationalChat/display/chat-widget-manager.js +113 -0
- package/src/ConversationalChat/display/chat-widget-to-html.js +58 -0
- package/src/ConversationalChat/get-chat-messages.js +7 -0
- package/src/ConversationalChat/index.js +12 -0
- package/src/ConversationalChat/is-chat-conversation-ended.js +7 -0
- package/src/ConversationalChat/is-chat-turn-errored.js +7 -0
- package/src/ConversationalChat/is-chat-turn-in-progress.js +7 -0
- package/src/ConversationalChat/register-chat-action-handler.js +10 -0
- package/src/ConversationalChat/reset-chat-conversation.js +5 -0
- package/src/ConversationalChat/retrieve-chat-config.js +7 -0
- package/src/ConversationalChat/send-chat-message.js +17 -0
- package/src/ConversationalChat/subscribe-to-chat-action.js +5 -0
- package/src/ConversationalChat/subscribe-to-chat-conversation-updated.js +5 -0
- package/src/ConversationalChat/subscribe-to-chat-message-received.js +5 -0
- package/src/ConversationalChat/trigger-chat-action.js +11 -0
- package/src/ConversationalChat/types.js +1 -0
- package/src/Core/add-sdk-metadata.js +5 -5
- package/src/Core/change-user.js +6 -6
- package/src/Core/disable-sdk.js +6 -6
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/handle-braze-action.js +20 -13
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +9 -9
- package/src/Core/log-ecommerce-event.js +4 -4
- package/src/Core/log-purchase.js +14 -14
- package/src/Core/open-session.js +8 -8
- package/src/Core/set-sdk-authentication-signature.js +3 -3
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/Core/wipe-data.js +1 -1
- package/src/DUST/dust-config-store.js +35 -35
- package/src/DUST/dust-message-dedup.js +3 -3
- package/src/DUST/dust-provider-factory.js +10 -10
- package/src/DUST/dust-provider.js +234 -234
- package/src/DUST/subscribe-to-dust.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +2 -2
- package/src/FeatureFlags/feature-flag.js +4 -4
- package/src/FeatureFlags/feature-flags-provider-factory.js +11 -11
- 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 +4 -4
- 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-display-utils.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +13 -13
- package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
- 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 +92 -92
- package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-click.js +7 -7
- package/src/InAppMessage/log-in-app-message-html-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/full-screen-message.js +39 -39
- package/src/InAppMessage/models/html-message.js +20 -20
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +102 -102
- package/src/InAppMessage/models/modal-message.js +38 -38
- package/src/InAppMessage/models/slide-up-message.js +34 -34
- 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 +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +27 -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 +15 -15
- package/src/Push/push-manager.js +13 -13
- package/src/Push/register-push.js +2 -2
- package/src/Push/request-push-permission.js +2 -2
- package/src/Push/unregister-push-token-on-server.js +3 -3
- package/src/Push/unregister-push.js +3 -3
- package/src/Push/utils/push-utils.js +15 -15
- package/src/User/user-manager.js +9 -9
- package/src/User/user.js +50 -50
- package/src/common/constants.js +1 -1
- package/src/common/content-cards-display.js +22 -22
- package/src/common/event-logger.js +3 -3
- package/src/index.js +2 -9
- package/src/l10n/l10n-manager-factory.js +4 -4
- package/src/l10n/l10n-manager.js +6 -6
- package/src/managers/auth-manager.js +28 -28
- package/src/managers/braze-action-manager.js +14 -0
- package/src/managers/braze-instance.js +159 -151
- package/src/managers/device-manager.js +26 -26
- package/src/managers/network-manager.js +120 -120
- package/src/managers/server-config-manager.js +95 -86
- package/src/managers/session-manager.js +25 -25
- package/src/managers/storage-manager-factory.js +12 -12
- package/src/managers/storage-manager.js +129 -124
- package/src/managers/subscription-manager.js +8 -8
- 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 +8 -8
- package/src/models/push-token.js +6 -6
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +27 -27
- package/src/request-controller.js +117 -117
- package/src/standard-index.js +9 -0
- 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 +5 -5
- package/src/triggers/models/filter.js +31 -31
- package/src/triggers/models/in-app-message-click-data.js +9 -9
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +5 -5
- package/src/triggers/models/push-click-data.js +4 -4
- package/src/triggers/models/trigger-condition.js +35 -35
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +5 -5
- package/src/triggers/triggers-provider.js +128 -128
- package/src/types.js +2 -2
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/chat-widget-css.js +11 -0
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +5 -5
- package/src/util/browser-detector.js +41 -41
- package/src/util/client-hints-parser.js +10 -10
- package/src/util/component-utils.js +1 -1
- package/src/util/date-utils.js +2 -2
- package/src/util/device-constants.js +5 -5
- package/src/util/dom-utils.js +8 -8
- package/src/util/ecommerce-event-validation.js +13 -13
- package/src/util/html-display-utils.js +6 -6
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +82 -44
- package/src/util/request-header-utils.js +26 -24
- package/src/util/user-agent-parser.js +21 -21
- package/src/util/validation-utils.js +29 -21
- package/src/util/window-utils.js +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IamStrings as
|
|
1
|
+
import { IamStrings as pr } from "../constants.js";
|
|
2
2
|
export function removeAllVisibleInAppMessages() {
|
|
3
3
|
const o = document.querySelectorAll(".ab-iam-root");
|
|
4
4
|
for (let t = 0; t < o.length; t++) {
|
|
@@ -10,9 +10,9 @@ export function removeAllVisibleInAppMessages() {
|
|
|
10
10
|
}
|
|
11
11
|
s.parentNode && s.parentNode.removeChild(s);
|
|
12
12
|
}
|
|
13
|
-
const t = document.getElementsByClassName(
|
|
13
|
+
const t = document.getElementsByClassName(pr.TE);
|
|
14
14
|
for (let o = 0; o < t.length; o++) {
|
|
15
15
|
const s = t[o].classList;
|
|
16
|
-
s.contains(
|
|
16
|
+
s.contains(pr.TE) && s.remove(pr.TE);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -15,12 +15,12 @@ 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
17
|
import { toRgba as ae } from "../../util/color-utils.js";
|
|
18
|
-
import { isIFrame as
|
|
18
|
+
import { isIFrame as Pt } from "../utils/in-app-message-utils.js";
|
|
19
19
|
import he from "../../l10n/l10n-manager-factory.js";
|
|
20
20
|
import {
|
|
21
|
-
IamTiming as
|
|
21
|
+
IamTiming as qt,
|
|
22
22
|
IamClickAction as ce,
|
|
23
|
-
IamDismissType as
|
|
23
|
+
IamDismissType as cr,
|
|
24
24
|
IamOrientation as be,
|
|
25
25
|
IamSlideFrom as fe,
|
|
26
26
|
IAM_SHOWING_CLASS as we,
|
|
@@ -38,7 +38,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
38
38
|
);
|
|
39
39
|
if (!(e instanceof InAppMessage)) return !1;
|
|
40
40
|
if (e.constructor === InAppMessage) return !1;
|
|
41
|
-
e.
|
|
41
|
+
e._h();
|
|
42
42
|
const o = e instanceof HtmlMessage;
|
|
43
43
|
if (o && !e.trusted && !r.dr())
|
|
44
44
|
return (
|
|
@@ -56,8 +56,8 @@ export function showInAppMessage(e, t, s) {
|
|
|
56
56
|
!1
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
|
-
if (no
|
|
60
|
-
const t = no.
|
|
59
|
+
if (no.$a()) {
|
|
60
|
+
const t = no.Ua();
|
|
61
61
|
if (
|
|
62
62
|
(t === je.PORTRAIT && e.orientation === be.LANDSCAPE) ||
|
|
63
63
|
(t === je.LANDSCAPE && e.orientation === be.PORTRAIT)
|
|
@@ -79,7 +79,10 @@ export function showInAppMessage(e, t, s) {
|
|
|
79
79
|
for (let e = 0; e < s.length; e++)
|
|
80
80
|
if (s[e].clickAction === ce.URI) {
|
|
81
81
|
const o = s[e].uri;
|
|
82
|
-
|
|
82
|
+
if (tt(o)) {
|
|
83
|
+
t = !0;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
87
|
} else e.clickAction === ce.URI && (t = tt(e.uri));
|
|
85
88
|
if (t)
|
|
@@ -96,14 +99,14 @@ export function showInAppMessage(e, t, s) {
|
|
|
96
99
|
e.zo() && (i.className += ` ${we}`),
|
|
97
100
|
(i.className += me(e)),
|
|
98
101
|
e.language && !o && (i.lang = e.language),
|
|
99
|
-
e.
|
|
100
|
-
r.er(U.
|
|
102
|
+
e.Eo() && (i.id = e.htmlId),
|
|
103
|
+
r.er(U.Ee) && (i.style.zIndex = (r.er(U.Ee) + 1).toString()),
|
|
101
104
|
t.appendChild(i),
|
|
102
|
-
e.
|
|
105
|
+
e.Oo())
|
|
103
106
|
) {
|
|
104
107
|
const t = document.createElement("style");
|
|
105
108
|
(t.innerHTML = e.css),
|
|
106
|
-
(t.id = e.
|
|
109
|
+
(t.id = e.ko()),
|
|
107
110
|
null != r.er(U.sr) && t.setAttribute("nonce", r.er(U.sr)),
|
|
108
111
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
109
112
|
}
|
|
@@ -115,18 +118,18 @@ export function showInAppMessage(e, t, s) {
|
|
|
115
118
|
const s = document.createElement("div");
|
|
116
119
|
if (
|
|
117
120
|
((s.className = "ab-page-blocker"),
|
|
118
|
-
e.
|
|
119
|
-
r.er(U.
|
|
121
|
+
e.Oo() || (s.style.backgroundColor = ae(e.frameColor)),
|
|
122
|
+
r.er(U.Ee) && (s.style.zIndex = r.er(U.Ee).toString()),
|
|
120
123
|
i.appendChild(s),
|
|
121
|
-
!r.er(U.
|
|
124
|
+
!r.er(U.Zh))
|
|
122
125
|
) {
|
|
123
126
|
const o = new Date().valueOf();
|
|
124
127
|
s.onclick = (s) => {
|
|
125
|
-
new Date().valueOf() - o >
|
|
128
|
+
new Date().valueOf() - o > qt.sE &&
|
|
126
129
|
(e.tl(t), s.stopPropagation());
|
|
127
130
|
};
|
|
128
131
|
}
|
|
129
|
-
i.appendChild(t), t.focus(), e.
|
|
132
|
+
i.appendChild(t), t.focus(), e.Wh(i);
|
|
130
133
|
} else if (n) {
|
|
131
134
|
const s = document.querySelectorAll(".ab-slideup");
|
|
132
135
|
let o = null;
|
|
@@ -147,16 +150,16 @@ export function showInAppMessage(e, t, s) {
|
|
|
147
150
|
o.offsetTop),
|
|
148
151
|
(t.style.bottom = Math.max(e, 0) + "px");
|
|
149
152
|
}
|
|
150
|
-
} else if (o && !r.er(U.
|
|
153
|
+
} else if (o && !r.er(U.Zh)) {
|
|
151
154
|
const s = e;
|
|
152
|
-
|
|
155
|
+
Pt(t) &&
|
|
153
156
|
t.contentWindow &&
|
|
154
157
|
t.contentWindow.addEventListener("keydown", function (e) {
|
|
155
|
-
e.keyCode === le.
|
|
158
|
+
e.keyCode === le.Yh && s.closeMessage();
|
|
156
159
|
});
|
|
157
160
|
}
|
|
158
161
|
logInAppMessageImpression(e),
|
|
159
|
-
e.dismissType ===
|
|
162
|
+
e.dismissType === cr.AUTO_DISMISS &&
|
|
160
163
|
setTimeout(() => {
|
|
161
164
|
i.contains(t) && e.tl(t);
|
|
162
165
|
}, e.duration),
|
|
@@ -165,11 +168,11 @@ export function showInAppMessage(e, t, s) {
|
|
|
165
168
|
(e) => {
|
|
166
169
|
b.info(e), i.parentNode && i.parentNode.removeChild(i);
|
|
167
170
|
},
|
|
168
|
-
r.er(U.
|
|
169
|
-
r.er(U.
|
|
171
|
+
r.er(U.Ja),
|
|
172
|
+
r.er(U.Ee),
|
|
170
173
|
r.er(U.sr),
|
|
171
174
|
t,
|
|
172
|
-
he.ra().
|
|
175
|
+
he.ra().Ca(),
|
|
173
176
|
);
|
|
174
|
-
return (o || n) && (i.appendChild(a), e.
|
|
177
|
+
return (o || n) && (i.appendChild(a), e.Wh(i)), !0;
|
|
175
178
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import _t from "./utils/push-utils.js";
|
|
3
3
|
export function isPushPermissionGranted() {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return _t.isPushPermissionGranted();
|
|
5
5
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import r, { OPTIONS as U } from "../managers/braze-instance.js";
|
|
2
2
|
import na from "./push-manager.js";
|
|
3
|
-
const
|
|
3
|
+
const ia = {
|
|
4
4
|
i: !1,
|
|
5
5
|
na: null,
|
|
6
6
|
ra: () => (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
(
|
|
7
|
+
ia.t(),
|
|
8
|
+
ia.na ||
|
|
9
|
+
(ia.na = new na(
|
|
10
10
|
r.zr(),
|
|
11
|
-
r.
|
|
12
|
-
r.
|
|
11
|
+
r.Fa(),
|
|
12
|
+
r.Ie(),
|
|
13
13
|
r.ht(),
|
|
14
|
-
r.er(U.
|
|
15
|
-
r.er(U.
|
|
16
|
-
r.er(U.
|
|
14
|
+
r.er(U.Ha),
|
|
15
|
+
r.er(U.Ka),
|
|
16
|
+
r.er(U.La),
|
|
17
17
|
r.l(),
|
|
18
|
-
r.er(U.
|
|
19
|
-
r.er(U.
|
|
18
|
+
r.er(U.Na),
|
|
19
|
+
r.er(U.Oa),
|
|
20
20
|
r.p(),
|
|
21
21
|
)),
|
|
22
|
-
|
|
22
|
+
ia.na
|
|
23
23
|
),
|
|
24
24
|
t: () => {
|
|
25
|
-
|
|
25
|
+
ia.i || (r.g(ia), (ia.i = !0));
|
|
26
26
|
},
|
|
27
27
|
destroy: () => {
|
|
28
|
-
(
|
|
28
|
+
(ia.na = null), (ia.i = !1);
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
|
-
export default
|
|
31
|
+
export default ia;
|
package/src/Push/push-manager.js
CHANGED
|
@@ -4,7 +4,7 @@ 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
6
|
import { getErrorMessage as ci } from "../util/error-utils.js";
|
|
7
|
-
import
|
|
7
|
+
import _t 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 = _t.cu()),
|
|
31
|
+
(this.fu = _t.du());
|
|
32
32
|
}
|
|
33
33
|
lu() {
|
|
34
34
|
return this.uu;
|
|
@@ -107,7 +107,7 @@ export default class na {
|
|
|
107
107
|
{
|
|
108
108
|
api_key: this.eu,
|
|
109
109
|
device_id:
|
|
110
|
-
(null === (r = this.tu) || void 0 === r ? void 0 : r.
|
|
110
|
+
(null === (r = this.tu) || void 0 === r ? void 0 : r.Ye().id) ||
|
|
111
111
|
"",
|
|
112
112
|
},
|
|
113
113
|
(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
|
+
_t.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 (!_t.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 (_t.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
|
+
_t.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 = _t.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 (!_t.isPushSupported())
|
|
260
260
|
return b.info(na.Au), void ("function" == typeof e && e(!1));
|
|
261
261
|
if (this.au) {
|
|
262
|
-
if (
|
|
262
|
+
if (_t.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 (!_t.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 (!_t.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) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import ia from "./push-manager-factory.js";
|
|
3
3
|
export function registerPush(t, n) {
|
|
4
4
|
if (r.rr())
|
|
5
|
-
return
|
|
5
|
+
return ia.ra().registerPush((n, o, e) => {
|
|
6
6
|
const s = r.nn();
|
|
7
7
|
s && s.requestImmediateDataFlush(), "function" == typeof t && t(n, o, e);
|
|
8
8
|
}, n);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import ia from "./push-manager-factory.js";
|
|
3
3
|
export function requestPushPermission(n, o) {
|
|
4
4
|
if (r.rr())
|
|
5
|
-
return
|
|
5
|
+
return ia.ra().subscribe((o, t, e) => {
|
|
6
6
|
const s = r.nn();
|
|
7
7
|
s && s.requestImmediateDataFlush(), "function" == typeof n && n(o, t, e);
|
|
8
8
|
}, o);
|
|
@@ -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.Xa);
|
|
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.Xa, 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.Xa,
|
|
34
34
|
);
|
|
35
35
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
3
|
-
import { unregisterPushTokenOnServer as
|
|
2
|
+
import ia from "./push-manager-factory.js";
|
|
3
|
+
import { unregisterPushTokenOnServer as hr } from "./unregister-push-token-on-server.js";
|
|
4
4
|
export function unregisterPush(e, n) {
|
|
5
|
-
if (r.rr()) return
|
|
5
|
+
if (r.rr()) return hr(), ia.ra().unsubscribe(e, n);
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const _t = {
|
|
2
2
|
cu: () =>
|
|
3
3
|
"serviceWorker" in navigator &&
|
|
4
4
|
"undefined" != typeof ServiceWorkerRegistration &&
|
|
@@ -9,38 +9,38 @@ const Dt = {
|
|
|
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: () => _t.cu() || _t.du(),
|
|
13
13
|
isPushBlocked: () => {
|
|
14
14
|
const o =
|
|
15
|
-
|
|
15
|
+
_t.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
|
+
_t.isPushSupported() &&
|
|
22
22
|
(!("Notification" in window) || null == window.Notification);
|
|
23
23
|
return o || i;
|
|
24
24
|
},
|
|
25
25
|
isPushPermissionGranted: () =>
|
|
26
|
-
|
|
26
|
+
_t.isPushSupported() &&
|
|
27
27
|
"Notification" in window &&
|
|
28
28
|
null != window.Notification &&
|
|
29
29
|
null != window.Notification.permission &&
|
|
30
30
|
"granted" === window.Notification.permission,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
? {
|
|
34
|
-
:
|
|
35
|
-
?
|
|
36
|
-
? {
|
|
37
|
-
: {
|
|
38
|
-
: {
|
|
39
|
-
|
|
31
|
+
va: () =>
|
|
32
|
+
_t.isPushBlocked()
|
|
33
|
+
? { ba: !1, reason: "blocked" }
|
|
34
|
+
: _t.isPushSupported()
|
|
35
|
+
? _t.isPushPermissionGranted()
|
|
36
|
+
? { ba: !1, reason: "permissionGranted" }
|
|
37
|
+
: { ba: !0 }
|
|
38
|
+
: { ba: !1, reason: "unsupported" },
|
|
39
|
+
Ia: (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 _t;
|
package/src/User/user-manager.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getByteLength as
|
|
1
|
+
import Ut from "../models/identifier.js";
|
|
2
|
+
import { getByteLength as sr } from "../util/string-utils.js";
|
|
3
3
|
import ui from "../models/push-token.js";
|
|
4
4
|
import { logger as b, 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
|
-
export default class
|
|
7
|
+
export default class Nt {
|
|
8
8
|
constructor(t, s) {
|
|
9
9
|
(this.h = t), (this.j = s), (this.h = t), (this.j = s);
|
|
10
10
|
}
|
|
@@ -12,16 +12,16 @@ export default class Ut {
|
|
|
12
12
|
const t = this.j.$u(s.Ou.Cu);
|
|
13
13
|
if (null == t) return null;
|
|
14
14
|
let i = t.Iu,
|
|
15
|
-
e =
|
|
16
|
-
if (e > User.
|
|
17
|
-
for (; e > User.
|
|
15
|
+
e = sr(i);
|
|
16
|
+
if (e > User.Ur) {
|
|
17
|
+
for (; e > User.Ur; ) (i = i.slice(0, i.length - 1)), (e = sr(i));
|
|
18
18
|
(t.Iu = i), this.j.Ju(s.Ou.Cu, t);
|
|
19
19
|
}
|
|
20
20
|
return i;
|
|
21
21
|
}
|
|
22
22
|
Lu(t) {
|
|
23
23
|
const i = null == this.getUserId();
|
|
24
|
-
this.j.Ju(s.Ou.Cu, new
|
|
24
|
+
this.j.Ju(s.Ou.Cu, new Ut(t)), i && this.j.qu(t);
|
|
25
25
|
}
|
|
26
26
|
setCustomUserAttribute(t, s) {
|
|
27
27
|
if (this.h.zu(t))
|
|
@@ -55,7 +55,7 @@ export default class Ut {
|
|
|
55
55
|
const r = et._s.Xs,
|
|
56
56
|
h = new et(r, b),
|
|
57
57
|
n = new ui(t, i, e, u, o);
|
|
58
|
-
this.j.Pt(s.It.xu, n.qt()), h.setItem(r.Ws.Gu, r.
|
|
58
|
+
this.j.Pt(s.It.xu, n.qt()), h.setItem(r.Ws.Gu, r.ze, !0);
|
|
59
59
|
}
|
|
60
60
|
wu(t) {
|
|
61
61
|
if (
|
|
@@ -67,7 +67,7 @@ export default class Ut {
|
|
|
67
67
|
) {
|
|
68
68
|
const t = et._s.Xs,
|
|
69
69
|
i = new et(t, b);
|
|
70
|
-
this.j.Pt(s.It.xu, !1), i.setItem(t.Ws.Gu, t.
|
|
70
|
+
this.j.Pt(s.It.xu, !1), i.setItem(t.Ws.Gu, t.ze, !1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|