@braze/web-sdk 6.8.0 → 6.10.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 +113 -21
- package/package.json +1 -1
- package/shared-lib/event-types.js +20 -20
- package/shared-lib/indexed-db-adapter.js +64 -64
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +8 -8
- package/src/Banner/banner-provider.js +67 -59
- package/src/Banner/banner.js +40 -19
- package/src/Banner/dismiss-banner.js +4 -0
- package/src/Banner/display/banner-to-html.js +10 -10
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/get-all-banners.js +6 -6
- package/src/Banner/get-banner.js +6 -6
- package/src/Banner/index.js +1 -0
- package/src/Banner/log-banner-click.js +7 -7
- package/src/Banner/log-banner-dismissal.js +7 -7
- package/src/Banner/log-banner-impressions.js +10 -10
- package/src/Banner/request-banners-refresh.js +8 -8
- package/src/Banner/subscribe-to-banners-updates.js +5 -5
- package/src/Banner/ui/insert-banner.js +8 -8
- package/src/Card/card-manager.js +31 -31
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-content-card-click.js +2 -2
- package/src/Card/log-content-card-impressions.js +4 -4
- package/src/Card/models/captioned-image.js +15 -15
- package/src/Card/models/card.js +89 -89
- package/src/Card/models/classic-card.js +16 -16
- package/src/Card/models/control-card.js +7 -7
- package/src/Card/models/image-only.js +13 -13
- package/src/Card/util/card-factory.js +32 -32
- package/src/ContentCards/content-cards-provider.js +102 -102
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +3 -3
- package/src/ContentCards/ui/show-content-cards.js +5 -5
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +3 -3
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +4 -4
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/handle-braze-action.js +5 -5
- package/src/Core/index.js +1 -0
- package/src/Core/log-custom-event.js +5 -5
- package/src/Core/log-ecommerce-event.js +5 -5
- package/src/Core/log-purchase.js +9 -9
- package/src/Core/logout.js +22 -0
- package/src/Core/open-session.js +7 -7
- package/src/Core/set-logger.js +2 -2
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +6 -6
- package/src/DUST/dust-provider.js +249 -240
- package/src/DUST/dust-shared-worker-code.js +1 -1
- package/src/DUST/dust-shared-worker-impl.js +15 -14
- package/src/DUST/dust-worker-bridge.js +50 -35
- package/src/DUST/subscribe-to-dust.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +8 -8
- package/src/FeatureFlags/feature-flag.js +3 -3
- package/src/FeatureFlags/feature-flags-provider.js +21 -21
- package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
- package/src/InAppMessage/constants.js +3 -3
- package/src/InAppMessage/defer-in-app-message.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +4 -4
- package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
- package/src/InAppMessage/in-app-message-factory.js +36 -36
- package/src/InAppMessage/in-app-message-manager.js +78 -78
- package/src/InAppMessage/log-in-app-message-button-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
- 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 +4 -4
- package/src/InAppMessage/models/html-message.js +3 -3
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +12 -12
- package/src/InAppMessage/models/modal-message.js +4 -4
- package/src/InAppMessage/models/slide-up-message.js +4 -4
- 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 +14 -14
- package/src/Push/push-manager-factory.js +2 -2
- package/src/Push/push-manager.js +38 -38
- package/src/Push/unregister-push-token-on-server.js +35 -0
- package/src/Push/unregister-push.js +2 -1
- package/src/Push/utils/push-utils.js +6 -6
- package/src/User/user-manager.js +14 -14
- package/src/User/user.js +25 -25
- package/src/common/base-provider.js +1 -1
- package/src/common/content-cards-display.js +7 -7
- package/src/common/event-logger.js +3 -3
- package/src/common/properties-base.js +3 -3
- package/src/l10n/l10n-manager-factory.js +2 -2
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +11 -11
- package/src/managers/braze-instance.js +56 -56
- package/src/managers/device-manager.js +10 -10
- package/src/managers/network-manager.js +103 -102
- package/src/managers/server-config-manager.js +112 -95
- package/src/managers/session-manager.js +20 -20
- package/src/managers/storage-manager-factory.js +9 -9
- package/src/managers/storage-manager.js +73 -73
- package/src/managers/subscription-manager.js +2 -2
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +1 -1
- package/src/models/device.js +1 -1
- package/src/models/identifier.js +2 -2
- package/src/models/push-token.js +6 -6
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +42 -24
- package/src/request-controller.js +126 -126
- 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 +2 -2
- package/src/triggers/models/filter.js +1 -1
- 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 +3 -3
- package/src/triggers/models/trigger-condition.js +36 -36
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +33 -33
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +68 -68
- package/src/types.js +2 -2
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +7 -7
- package/src/util/browser-detector.js +2 -2
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/code-utils.js +2 -2
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/dom-utils.js +7 -7
- package/src/util/ecommerce-event-validation.js +52 -35
- package/src/util/html-display-utils.js +11 -11
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +36 -35
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +2 -2
- package/src/util/validation-utils.js +12 -12
- package/src/util/window-utils.js +2 -2
|
@@ -46,7 +46,7 @@ export default class HtmlMessage extends InAppMessage {
|
|
|
46
46
|
od() {
|
|
47
47
|
return !1;
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
Yt(i) {
|
|
50
50
|
if (this.ko === dt.iE) {
|
|
51
51
|
if (this.rd) return !1;
|
|
52
52
|
this.rd = !0;
|
|
@@ -57,10 +57,10 @@ export default class HtmlMessage extends InAppMessage {
|
|
|
57
57
|
const i = super.qt(dt.iE);
|
|
58
58
|
return (i[cr.qE] = this.messageFields), i;
|
|
59
59
|
}
|
|
60
|
-
static
|
|
60
|
+
static ha(i) {
|
|
61
61
|
return new HtmlMessage(
|
|
62
62
|
i[cr.rE],
|
|
63
|
-
i[cr.
|
|
63
|
+
i[cr.Is],
|
|
64
64
|
i[cr.FE],
|
|
65
65
|
i[cr.BE],
|
|
66
66
|
i[cr.lE],
|
|
@@ -15,13 +15,13 @@ export default class InAppMessageButton {
|
|
|
15
15
|
(this.borderColor = r || this.backgroundColor),
|
|
16
16
|
(this.clickAction = h || Le.NONE),
|
|
17
17
|
(this.uri = e),
|
|
18
|
-
null == n && (n = InAppMessageButton.
|
|
18
|
+
null == n && (n = InAppMessageButton.Kn),
|
|
19
19
|
(this.id = n),
|
|
20
20
|
(this.rd = !1),
|
|
21
21
|
(this.ti = new f());
|
|
22
22
|
}
|
|
23
23
|
subscribeToClickedEvent(s) {
|
|
24
|
-
return this.ti.
|
|
24
|
+
return this.ti.Ut(s);
|
|
25
25
|
}
|
|
26
26
|
removeSubscription(s) {
|
|
27
27
|
this.ti.removeSubscription(s);
|
|
@@ -29,7 +29,7 @@ export default class InAppMessageButton {
|
|
|
29
29
|
removeAllSubscriptions() {
|
|
30
30
|
this.ti.removeAllSubscriptions();
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
Yt() {
|
|
33
33
|
return !this.rd && ((this.rd = !0), this.ti.A(), !0);
|
|
34
34
|
}
|
|
35
35
|
static fromJson(s) {
|
|
@@ -44,4 +44,4 @@ export default class InAppMessageButton {
|
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
InAppMessageButton.
|
|
47
|
+
InAppMessageButton.Kn = -1;
|
|
@@ -128,7 +128,7 @@ export default class InAppMessage {
|
|
|
128
128
|
(this.language = D),
|
|
129
129
|
(this.altImageText = z),
|
|
130
130
|
(this.th = !1),
|
|
131
|
-
(this.
|
|
131
|
+
(this.hs = !1),
|
|
132
132
|
(this.rd = !1),
|
|
133
133
|
(this.sh = !1),
|
|
134
134
|
(this.Eo = null),
|
|
@@ -138,10 +138,10 @@ export default class InAppMessage {
|
|
|
138
138
|
(this.Go = Fe.CENTER);
|
|
139
139
|
}
|
|
140
140
|
subscribeToClickedEvent(t) {
|
|
141
|
-
return this.ti.
|
|
141
|
+
return this.ti.Ut(t);
|
|
142
142
|
}
|
|
143
143
|
subscribeToDismissedEvent(t) {
|
|
144
|
-
return this.ih.
|
|
144
|
+
return this.ih.Ut(t);
|
|
145
145
|
}
|
|
146
146
|
removeSubscription(t) {
|
|
147
147
|
this.ti.removeSubscription(t), this.ih.removeSubscription(t);
|
|
@@ -167,16 +167,16 @@ export default class InAppMessage {
|
|
|
167
167
|
Oo() {
|
|
168
168
|
if (this.Bo() && this.Mo()) return this.htmlId + "-css";
|
|
169
169
|
}
|
|
170
|
-
|
|
171
|
-
return !this.
|
|
170
|
+
js() {
|
|
171
|
+
return !this.hs && ((this.hs = !0), !0);
|
|
172
172
|
}
|
|
173
173
|
sm() {
|
|
174
|
-
return this.
|
|
174
|
+
return this.hs;
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
Yt(t) {
|
|
177
177
|
return !this.rd && ((this.rd = !0), this.ti.A(), !0);
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
Ft() {
|
|
180
180
|
return !this.sh && ((this.sh = !0), this.ih.A(), !0);
|
|
181
181
|
}
|
|
182
182
|
hide(t) {
|
|
@@ -215,7 +215,7 @@ export default class InAppMessage {
|
|
|
215
215
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
216
216
|
}
|
|
217
217
|
null != e && "Safari" === ro.browser && (e.scrollTop = n),
|
|
218
|
-
s ? s() : this.
|
|
218
|
+
s ? s() : this.Ft();
|
|
219
219
|
};
|
|
220
220
|
h ? setTimeout(r, Et.gr) : r(), this.$o && this.$o.focus();
|
|
221
221
|
}
|
|
@@ -289,7 +289,7 @@ export default class InAppMessage {
|
|
|
289
289
|
? ((s[cr.rE] = this.message),
|
|
290
290
|
(s[cr.mE] = this.messageAlignment),
|
|
291
291
|
(s[cr.GE] = this.slideFrom),
|
|
292
|
-
(s[cr.
|
|
292
|
+
(s[cr.Is] = this.extras),
|
|
293
293
|
(s[cr.FE] = this.triggerId),
|
|
294
294
|
(s[cr.HE] = this.clickAction),
|
|
295
295
|
(s[cr.URI] = this.uri),
|
|
@@ -297,7 +297,7 @@ export default class InAppMessage {
|
|
|
297
297
|
(s[cr.BE] = this.dismissType),
|
|
298
298
|
(s[cr.lE] = this.duration),
|
|
299
299
|
(s[cr.bE] = this.icon),
|
|
300
|
-
(s[cr.
|
|
300
|
+
(s[cr.Bs] = this.imageUrl),
|
|
301
301
|
(s[cr.gE] = this.imageStyle),
|
|
302
302
|
(s[cr.YE] = this.iconColor),
|
|
303
303
|
(s[cr.KE] = this.iconBackgroundColor),
|
|
@@ -318,7 +318,7 @@ export default class InAppMessage {
|
|
|
318
318
|
(s[cr.xs] = t),
|
|
319
319
|
(s[cr.JE] = this.messageExtras),
|
|
320
320
|
(s[cr.LANGUAGE] = this.language),
|
|
321
|
-
(s[cr.
|
|
321
|
+
(s[cr.Ns] = this.altImageText),
|
|
322
322
|
s)
|
|
323
323
|
: s;
|
|
324
324
|
}
|
|
@@ -79,11 +79,11 @@ export default class ModalMessage extends InAppMessage {
|
|
|
79
79
|
qt() {
|
|
80
80
|
return super.qt(dt.aE);
|
|
81
81
|
}
|
|
82
|
-
static
|
|
82
|
+
static ha(r) {
|
|
83
83
|
return new ModalMessage(
|
|
84
84
|
r[cr.rE],
|
|
85
85
|
r[cr.mE],
|
|
86
|
-
r[cr.
|
|
86
|
+
r[cr.Is],
|
|
87
87
|
r[cr.FE],
|
|
88
88
|
r[cr.HE],
|
|
89
89
|
r[cr.URI],
|
|
@@ -91,7 +91,7 @@ export default class ModalMessage extends InAppMessage {
|
|
|
91
91
|
r[cr.BE],
|
|
92
92
|
r[cr.lE],
|
|
93
93
|
r[cr.bE],
|
|
94
|
-
r[cr.
|
|
94
|
+
r[cr.Bs],
|
|
95
95
|
r[cr.gE],
|
|
96
96
|
r[cr.YE],
|
|
97
97
|
r[cr.KE],
|
|
@@ -110,7 +110,7 @@ export default class ModalMessage extends InAppMessage {
|
|
|
110
110
|
r[cr.CSS],
|
|
111
111
|
r[cr.JE],
|
|
112
112
|
r[cr.LANGUAGE],
|
|
113
|
-
r[cr.
|
|
113
|
+
r[cr.Ns],
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -90,12 +90,12 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
90
90
|
qt() {
|
|
91
91
|
return super.qt(dt.sE);
|
|
92
92
|
}
|
|
93
|
-
static
|
|
93
|
+
static ha(t) {
|
|
94
94
|
return new SlideUpMessage(
|
|
95
95
|
t[cr.rE],
|
|
96
96
|
t[cr.mE],
|
|
97
97
|
t[cr.GE],
|
|
98
|
-
t[cr.
|
|
98
|
+
t[cr.Is],
|
|
99
99
|
t[cr.FE],
|
|
100
100
|
t[cr.HE],
|
|
101
101
|
t[cr.URI],
|
|
@@ -103,7 +103,7 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
103
103
|
t[cr.BE],
|
|
104
104
|
t[cr.lE],
|
|
105
105
|
t[cr.bE],
|
|
106
|
-
t[cr.
|
|
106
|
+
t[cr.Bs],
|
|
107
107
|
t[cr.YE],
|
|
108
108
|
t[cr.KE],
|
|
109
109
|
t[cr.XE],
|
|
@@ -115,7 +115,7 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
115
115
|
t[cr.CSS],
|
|
116
116
|
t[cr.JE],
|
|
117
117
|
t[cr.LANGUAGE],
|
|
118
|
-
t[cr.
|
|
118
|
+
t[cr.Ns],
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export default class Jt {
|
|
2
2
|
constructor(t, s, i, h, l) {
|
|
3
3
|
(this.triggerId = t),
|
|
4
|
-
(this.
|
|
5
|
-
(this.
|
|
6
|
-
(this.
|
|
7
|
-
(this.
|
|
4
|
+
(this.ua = s),
|
|
5
|
+
(this.ia = i),
|
|
6
|
+
(this.ma = h),
|
|
7
|
+
(this.ca = l),
|
|
8
8
|
(this.triggerId = t),
|
|
9
|
-
(this.
|
|
10
|
-
(this.
|
|
11
|
-
(this.
|
|
12
|
-
(this.
|
|
9
|
+
(this.ua = s),
|
|
10
|
+
(this.ia = i),
|
|
11
|
+
(this.ma = h),
|
|
12
|
+
(this.ca = l);
|
|
13
13
|
}
|
|
14
14
|
static fromJson(t, s, i, h, l) {
|
|
15
15
|
return null == t || null == t.trigger_id
|
|
@@ -7,9 +7,9 @@ export function automaticallyShowInAppMessages() {
|
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
rs();
|
|
9
9
|
const s = je.ra();
|
|
10
|
-
if (null == s.
|
|
10
|
+
if (null == s.Gn()) {
|
|
11
11
|
const r = subscribeToInAppMessage((s) => showInAppMessage(s));
|
|
12
|
-
s.
|
|
12
|
+
s.Nn(r);
|
|
13
13
|
}
|
|
14
|
-
return s.
|
|
14
|
+
return s.Gn();
|
|
15
15
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { isURIJavascriptOrData as tt } from "../../util/url-utils.js";
|
|
14
14
|
import { KeyCodes as Ce } from "../../util/key-codes.js";
|
|
15
15
|
import { setupInAppMessageUI as rs } from "../../ui/js/index.js";
|
|
16
|
-
import { logger as
|
|
16
|
+
import { logger as b } from "../../../shared-lib/index.js";
|
|
17
17
|
import { toRgba as ke } from "../../util/color-utils.js";
|
|
18
18
|
import { isIFrame as St } from "../utils/in-app-message-utils.js";
|
|
19
19
|
import Je from "../../l10n/l10n-manager-factory.js";
|
|
@@ -29,7 +29,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
29
29
|
if ((rs(), null == e)) return !1;
|
|
30
30
|
if (e instanceof ControlMessage)
|
|
31
31
|
return (
|
|
32
|
-
|
|
32
|
+
b.info(
|
|
33
33
|
"User received control for a multivariate test, logging to Braze servers.",
|
|
34
34
|
),
|
|
35
35
|
logInAppMessageImpression(e),
|
|
@@ -41,7 +41,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
41
41
|
const o = e instanceof HtmlMessage;
|
|
42
42
|
if (o && !e.trusted && !r.dr())
|
|
43
43
|
return (
|
|
44
|
-
|
|
44
|
+
b.error(
|
|
45
45
|
'HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.',
|
|
46
46
|
),
|
|
47
47
|
!1
|
|
@@ -49,14 +49,14 @@ export function showInAppMessage(e, t, s) {
|
|
|
49
49
|
if ((null == t && (t = document.body), e.zo())) {
|
|
50
50
|
if (t.querySelectorAll(".ab-modal-interactions").length > 0)
|
|
51
51
|
return (
|
|
52
|
-
|
|
52
|
+
b.info(
|
|
53
53
|
`Cannot show in-app message ${e.message} because another message is being shown.`,
|
|
54
54
|
),
|
|
55
55
|
!1
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
if (no.
|
|
59
|
-
const t = no.
|
|
58
|
+
if (no.da()) {
|
|
59
|
+
const t = no.ga();
|
|
60
60
|
if (
|
|
61
61
|
(t === Ue.PORTRAIT && e.orientation === De.LANDSCAPE) ||
|
|
62
62
|
(t === Ue.LANDSCAPE && e.orientation === De.PORTRAIT)
|
|
@@ -64,7 +64,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
64
64
|
const s = t === Ue.PORTRAIT ? "portrait" : "landscape",
|
|
65
65
|
o = e.orientation === De.PORTRAIT ? "portrait" : "landscape";
|
|
66
66
|
return (
|
|
67
|
-
|
|
67
|
+
b.info(
|
|
68
68
|
`Not showing ${o} in-app message ${e.message} because the screen is currently ${s}`,
|
|
69
69
|
),
|
|
70
70
|
!1
|
|
@@ -83,7 +83,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
83
83
|
} else e.clickAction === Le.URI && (t = tt(e.uri));
|
|
84
84
|
if (t)
|
|
85
85
|
return (
|
|
86
|
-
|
|
86
|
+
b.error(
|
|
87
87
|
'Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.',
|
|
88
88
|
),
|
|
89
89
|
!1
|
|
@@ -95,7 +95,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
95
95
|
(i.className += be(e)),
|
|
96
96
|
e.language && !o && (i.lang = e.language),
|
|
97
97
|
e.Bo() && (i.id = e.htmlId),
|
|
98
|
-
r.er(U.
|
|
98
|
+
r.er(U.ja) && (i.style.zIndex = (r.er(U.ja) + 1).toString()),
|
|
99
99
|
t.appendChild(i),
|
|
100
100
|
e.Mo())
|
|
101
101
|
) {
|
|
@@ -114,7 +114,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
114
114
|
if (
|
|
115
115
|
((s.className = "ab-page-blocker"),
|
|
116
116
|
e.Mo() || (s.style.backgroundColor = ke(e.frameColor)),
|
|
117
|
-
r.er(U.
|
|
117
|
+
r.er(U.ja) && (s.style.zIndex = r.er(U.ja).toString()),
|
|
118
118
|
i.appendChild(s),
|
|
119
119
|
!r.er(U.oh))
|
|
120
120
|
) {
|
|
@@ -161,13 +161,13 @@ export function showInAppMessage(e, t, s) {
|
|
|
161
161
|
"function" == typeof s && s();
|
|
162
162
|
},
|
|
163
163
|
(e) => {
|
|
164
|
-
|
|
164
|
+
b.info(e);
|
|
165
165
|
},
|
|
166
|
-
r.er(U.
|
|
167
|
-
r.er(U.
|
|
166
|
+
r.er(U.ba),
|
|
167
|
+
r.er(U.ja),
|
|
168
168
|
r.er(U.sr),
|
|
169
169
|
t,
|
|
170
|
-
Je.ra().
|
|
170
|
+
Je.ra().wa(),
|
|
171
171
|
);
|
|
172
172
|
return (o || n) && (i.appendChild(a), e.eh(i)), !0;
|
|
173
173
|
}
|
package/src/Push/push-manager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isArray as g, isEqual as oi } from "../util/code-utils.js";
|
|
2
2
|
import ui from "../models/push-token.js";
|
|
3
|
-
import { logger as
|
|
3
|
+
import { logger as b, EncodingUtils as ai } from "../../shared-lib/index.js";
|
|
4
4
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
5
5
|
import { User } from "../User/index.js";
|
|
6
6
|
import It from "./utils/push-utils.js";
|
|
@@ -16,7 +16,7 @@ export default class na {
|
|
|
16
16
|
(this.h = u),
|
|
17
17
|
(this.ou = a),
|
|
18
18
|
(this.uu = h),
|
|
19
|
-
(this.
|
|
19
|
+
(this.j = c),
|
|
20
20
|
(this.iu = i),
|
|
21
21
|
(this.tu = t),
|
|
22
22
|
(this.eu = e),
|
|
@@ -26,7 +26,7 @@ export default class na {
|
|
|
26
26
|
(this.h = u),
|
|
27
27
|
(this.ou = a || !1),
|
|
28
28
|
(this.uu = h || !1),
|
|
29
|
-
(this.
|
|
29
|
+
(this.j = c),
|
|
30
30
|
(this.hu = It.cu()),
|
|
31
31
|
(this.fu = It.lu());
|
|
32
32
|
}
|
|
@@ -38,11 +38,11 @@ export default class na {
|
|
|
38
38
|
.then((i) => {
|
|
39
39
|
i
|
|
40
40
|
? this.bu(t, e, s, r)
|
|
41
|
-
: (
|
|
41
|
+
: (b.error("Failed to unsubscribe device from push."),
|
|
42
42
|
"function" == typeof r && r(!1));
|
|
43
43
|
})
|
|
44
44
|
.catch((i) => {
|
|
45
|
-
|
|
45
|
+
b.error("Push unsubscription error: " + i),
|
|
46
46
|
"function" == typeof r && r(!1);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
@@ -71,7 +71,7 @@ export default class na {
|
|
|
71
71
|
(n = btoa(String.fromCharCode.apply(null, i))),
|
|
72
72
|
(o = btoa(String.fromCharCode.apply(null, t)));
|
|
73
73
|
} catch (i) {
|
|
74
|
-
|
|
74
|
+
b.error(hi(i));
|
|
75
75
|
}
|
|
76
76
|
const a = ((i) => {
|
|
77
77
|
let t;
|
|
@@ -94,7 +94,7 @@ export default class na {
|
|
|
94
94
|
ku(i, t) {
|
|
95
95
|
var e;
|
|
96
96
|
null === (e = this.iu) || void 0 === e || e.wu(!1),
|
|
97
|
-
|
|
97
|
+
b.info(i),
|
|
98
98
|
"function" == typeof t && t(!1);
|
|
99
99
|
}
|
|
100
100
|
Pu(i, t, e, s) {
|
|
@@ -129,7 +129,7 @@ export default class na {
|
|
|
129
129
|
s,
|
|
130
130
|
)
|
|
131
131
|
: "granted" === t.permission &&
|
|
132
|
-
(
|
|
132
|
+
(b.info("Device successfully subscribed to push."),
|
|
133
133
|
this.yu(t.deviceToken, new Date(), e));
|
|
134
134
|
}
|
|
135
135
|
requestPermission(i, t, e) {
|
|
@@ -142,7 +142,7 @@ export default class na {
|
|
|
142
142
|
case "denied":
|
|
143
143
|
return void ("function" == typeof e && e());
|
|
144
144
|
default:
|
|
145
|
-
|
|
145
|
+
b.error("Received unexpected permission result " + s);
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
let r = !1;
|
|
@@ -165,14 +165,14 @@ export default class na {
|
|
|
165
165
|
i.pushManager
|
|
166
166
|
.subscribe(r)
|
|
167
167
|
.then((i) => {
|
|
168
|
-
|
|
168
|
+
b.info("Device successfully subscribed to push."),
|
|
169
169
|
this.yu(i, new Date(), e);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
172
|
It.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),
|
|
176
176
|
"function" == typeof s && s(!0));
|
|
177
177
|
});
|
|
178
178
|
}
|
|
@@ -185,7 +185,7 @@ export default class na {
|
|
|
185
185
|
i &&
|
|
186
186
|
"function" == typeof i.update &&
|
|
187
187
|
i.update().catch((i) => {
|
|
188
|
-
|
|
188
|
+
b.info("ServiceWorker update failed: " + i);
|
|
189
189
|
}),
|
|
190
190
|
i
|
|
191
191
|
),
|
|
@@ -194,11 +194,11 @@ export default class na {
|
|
|
194
194
|
}
|
|
195
195
|
Su(i) {
|
|
196
196
|
this.ou ||
|
|
197
|
-
(i.unregister(),
|
|
197
|
+
(i.unregister(), b.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
199
|
subscribe(i, t) {
|
|
200
200
|
if (!It.isPushSupported())
|
|
201
|
-
return
|
|
201
|
+
return b.info(na.Au), void ("function" == typeof t && t(!1));
|
|
202
202
|
if (this.hu) {
|
|
203
203
|
if (!this.ou && null != window.location) {
|
|
204
204
|
let i = this.su;
|
|
@@ -212,9 +212,9 @@ export default class na {
|
|
|
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.h && !this.h.ju() && 0 === this.h.
|
|
215
|
+
if (this.h && !this.h.ju() && 0 === this.h.Qt())
|
|
216
216
|
return (
|
|
217
|
-
|
|
217
|
+
b.info(
|
|
218
218
|
"Waiting for VAPID key from server config before subscribing to push.",
|
|
219
219
|
),
|
|
220
220
|
void this.h.xu(() => {
|
|
@@ -222,7 +222,7 @@ export default class na {
|
|
|
222
222
|
})
|
|
223
223
|
);
|
|
224
224
|
const e = () => {
|
|
225
|
-
|
|
225
|
+
b.info("Permission for push notifications was denied."),
|
|
226
226
|
"function" == typeof t && t(!1);
|
|
227
227
|
},
|
|
228
228
|
r = () => {
|
|
@@ -230,7 +230,7 @@ export default class na {
|
|
|
230
230
|
It.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 t && t(!0);
|
|
235
235
|
},
|
|
236
236
|
n = It.isPushPermissionGranted(),
|
|
@@ -244,7 +244,7 @@ export default class na {
|
|
|
244
244
|
.then((e) => {
|
|
245
245
|
if (null == e)
|
|
246
246
|
return (
|
|
247
|
-
|
|
247
|
+
b.error(
|
|
248
248
|
"No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush.",
|
|
249
249
|
),
|
|
250
250
|
void ("function" == typeof t && t(!0))
|
|
@@ -264,7 +264,7 @@ export default class na {
|
|
|
264
264
|
let n,
|
|
265
265
|
u = null,
|
|
266
266
|
a = null;
|
|
267
|
-
if ((this.
|
|
267
|
+
if ((this.j && (n = this.j.St(s.It.Uu)), n && !g(n))) {
|
|
268
268
|
let i;
|
|
269
269
|
try {
|
|
270
270
|
i = ui._u(n).Wu;
|
|
@@ -285,51 +285,51 @@ export default class na {
|
|
|
285
285
|
r.options.applicationServerKey.byteLength > 0 &&
|
|
286
286
|
!oi(o, new Uint8Array(r.options.applicationServerKey))
|
|
287
287
|
? (r.options.applicationServerKey.byteLength > 12
|
|
288
|
-
?
|
|
288
|
+
? b.info(
|
|
289
289
|
"Device was already subscribed to push using a different VAPID provider, creating new subscription.",
|
|
290
290
|
)
|
|
291
|
-
:
|
|
291
|
+
: b.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
294
|
this.pu(r, e, o, i, t))
|
|
295
295
|
: r.expirationTime &&
|
|
296
296
|
new Date(r.expirationTime).valueOf() <=
|
|
297
297
|
new Date().valueOf()
|
|
298
|
-
? (
|
|
298
|
+
? (b.info(
|
|
299
299
|
"Push subscription is expired, creating new subscription.",
|
|
300
300
|
),
|
|
301
301
|
this.pu(r, e, o, i, t))
|
|
302
302
|
: n && g(n)
|
|
303
303
|
? this.pu(r, e, o, i, t)
|
|
304
304
|
: null == a
|
|
305
|
-
? (
|
|
305
|
+
? (b.info(
|
|
306
306
|
"No push subscription creation date found, creating new subscription.",
|
|
307
307
|
),
|
|
308
308
|
this.pu(r, e, o, i, t))
|
|
309
309
|
: a.valueOf() <= new Date().valueOf()
|
|
310
|
-
? (
|
|
310
|
+
? (b.info(
|
|
311
311
|
"Push subscription older than 6 months, creating new subscription.",
|
|
312
312
|
),
|
|
313
313
|
this.pu(r, e, o, i, t))
|
|
314
|
-
: (
|
|
314
|
+
: (b.info(
|
|
315
315
|
"Device already subscribed to push, sending existing subscription to backend.",
|
|
316
316
|
),
|
|
317
317
|
this.yu(r, u, i));
|
|
318
318
|
} else this.bu(e, o, i, t);
|
|
319
319
|
})
|
|
320
320
|
.catch((i) => {
|
|
321
|
-
|
|
321
|
+
b.error("Error checking current push subscriptions: " + i);
|
|
322
322
|
});
|
|
323
323
|
})
|
|
324
324
|
.catch((i) => {
|
|
325
|
-
|
|
325
|
+
b.error("ServiceWorker registration failed: " + i);
|
|
326
326
|
});
|
|
327
327
|
};
|
|
328
328
|
this.requestPermission(o, r, e);
|
|
329
329
|
} else if (this.fu) {
|
|
330
330
|
if (null == this.nu || "" === this.nu)
|
|
331
331
|
return (
|
|
332
|
-
|
|
332
|
+
b.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))
|
|
@@ -340,7 +340,7 @@ export default class na {
|
|
|
340
340
|
}
|
|
341
341
|
unsubscribe(i, t) {
|
|
342
342
|
if (!It.isPushSupported())
|
|
343
|
-
return
|
|
343
|
+
return b.info(na.Au), void ("function" == typeof i && i());
|
|
344
344
|
this.hu
|
|
345
345
|
? navigator.serviceWorker.getRegistration(this.su).then((e) => {
|
|
346
346
|
e
|
|
@@ -353,33 +353,33 @@ export default class na {
|
|
|
353
353
|
.unsubscribe()
|
|
354
354
|
.then((s) => {
|
|
355
355
|
s
|
|
356
|
-
? (
|
|
356
|
+
? (b.info(
|
|
357
357
|
"Device successfully unsubscribed from push.",
|
|
358
358
|
),
|
|
359
359
|
"function" == typeof i && i())
|
|
360
|
-
: (
|
|
360
|
+
: (b.error(
|
|
361
361
|
"Failed to unsubscribe device from push.",
|
|
362
362
|
),
|
|
363
363
|
"function" == typeof t && t()),
|
|
364
364
|
this.Su(e);
|
|
365
365
|
})
|
|
366
366
|
.catch((i) => {
|
|
367
|
-
|
|
367
|
+
b.error("Push unsubscription error: " + i),
|
|
368
368
|
"function" == typeof t && t();
|
|
369
369
|
}))
|
|
370
|
-
: (
|
|
370
|
+
: (b.info("Device already unsubscribed from push."),
|
|
371
371
|
"function" == typeof i && i());
|
|
372
372
|
})
|
|
373
373
|
.catch((i) => {
|
|
374
|
-
|
|
374
|
+
b.error("Error unsubscribing from push: " + i),
|
|
375
375
|
"function" == typeof t && t();
|
|
376
376
|
})
|
|
377
|
-
: (
|
|
377
|
+
: (b.info("Device already unsubscribed from push."),
|
|
378
378
|
"function" == typeof i && i());
|
|
379
379
|
})
|
|
380
380
|
: this.fu &&
|
|
381
381
|
(this.vu(),
|
|
382
|
-
|
|
382
|
+
b.info("Device unsubscribed from push."),
|
|
383
383
|
"function" == typeof i && i());
|
|
384
384
|
}
|
|
385
385
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
3
|
+
import ui from "../models/push-token.js";
|
|
4
|
+
import l from "../util/net.js";
|
|
5
|
+
import h from "../util/request-header-utils.js";
|
|
6
|
+
export function unregisterPushTokenOnServer() {
|
|
7
|
+
if (!r.rr()) return;
|
|
8
|
+
const e = r.m();
|
|
9
|
+
if (!e) return;
|
|
10
|
+
const t = r.p(),
|
|
11
|
+
n = null == t ? void 0 : t.St(s.It.Uu);
|
|
12
|
+
if (!n || "object" != typeof n || Array.isArray(n)) return;
|
|
13
|
+
const o = ui._u(n);
|
|
14
|
+
if (!o.endpoint) return;
|
|
15
|
+
const i = e.Z({}, !0);
|
|
16
|
+
i.push_token = o.endpoint;
|
|
17
|
+
const a = e.tt(i, h.it.qa);
|
|
18
|
+
e.et(
|
|
19
|
+
i,
|
|
20
|
+
(n = -1) => {
|
|
21
|
+
r.rr() &&
|
|
22
|
+
(h.nt(t, h.it.qa, new Date().valueOf()),
|
|
23
|
+
-1 !== n && a.push(["X-Braze-Req-Tokens-Remaining", n.toString()]),
|
|
24
|
+
l.ot({
|
|
25
|
+
url: `${e.ht()}/push/unregister`,
|
|
26
|
+
data: i,
|
|
27
|
+
headers: a,
|
|
28
|
+
lt: (r) => {
|
|
29
|
+
e.ut(i, r, a) && e.ct();
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
},
|
|
33
|
+
h.it.qa,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import ra from "./push-manager-factory.js";
|
|
3
|
+
import { unregisterPushTokenOnServer as gr } from "./unregister-push-token-on-server.js";
|
|
3
4
|
export function unregisterPush(e, n) {
|
|
4
|
-
if (r.rr()) return ra.ra().unsubscribe(e, n);
|
|
5
|
+
if (r.rr()) return gr(), ra.ra().unsubscribe(e, n);
|
|
5
6
|
}
|