@braze/web-sdk 5.3.0 → 5.3.2
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 +1 -1
- package/package.json +1 -1
- package/shared-lib/event-types.js +3 -3
- package/shared-lib/logger.js +2 -2
- package/src/InAppMessage/display/html-message-display-utils.js +172 -0
- package/src/InAppMessage/display/html-message-to-html.js +54 -219
- package/src/InAppMessage/display/in-app-message-to-html.js +21 -21
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +56 -56
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +2 -2
- package/src/InAppMessage/models/html-message.js +2 -2
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +26 -26
- package/src/InAppMessage/models/modal-message.js +2 -2
- 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 +10 -10
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -18
- 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.js +10 -10
- package/src/Push/utils/push-utils.js +10 -10
- package/src/User/user-manager.js +1 -1
- package/src/User/user.js +15 -15
- package/src/common/feed-display.js +8 -8
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +13 -13
- package/src/managers/device-manager.js +2 -2
- package/src/managers/network-manager.js +17 -17
- package/src/managers/server-config-manager.js +3 -3
- package/src/managers/storage-manager-factory.js +3 -3
- package/src/managers/storage-manager.js +1 -1
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +2 -2
- package/src/models/server-config.js +7 -7
- package/src/request-controller.js +3 -3
- package/src/triggers/models/custom-event-data.js +2 -2
- package/src/triggers/models/custom-event-property-data.js +4 -4
- package/src/triggers/models/filter-set.js +3 -3
- package/src/triggers/models/filter.js +6 -6
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/trigger-condition.js +38 -38
- package/src/triggers/models/trigger.js +12 -12
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +12 -12
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/component-utils.js +2 -2
- package/src/util/date-utils.js +2 -2
- package/src/util/dom-utils.js +3 -3
- package/src/util/net.js +2 -2
- package/src/util/request-header-utils.js +1 -1
- package/src/util/validation-utils.js +17 -17
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
WindowUtils as eo,
|
|
12
12
|
} from "../../util/window-utils.js";
|
|
13
13
|
import { isURIJavascriptOrData as R } from "../../util/url-utils.js";
|
|
14
|
-
import { KeyCodes as
|
|
14
|
+
import { KeyCodes as mt } from "../../util/key-codes.js";
|
|
15
15
|
import { setupInAppMessageUI as ss } from "../../ui/js/index.js";
|
|
16
16
|
import { logger as r } from "../../../shared-lib/index.js";
|
|
17
17
|
import { toRgba as ie } from "../../util/color-utils.js";
|
|
@@ -39,7 +39,7 @@ export function showInAppMessage(t, s, o) {
|
|
|
39
39
|
),
|
|
40
40
|
!1
|
|
41
41
|
);
|
|
42
|
-
if ((null == s && (s = document.body), t
|
|
42
|
+
if ((null == s && (s = document.body), t.$e())) {
|
|
43
43
|
if (s.querySelectorAll(".ab-modal-interactions").length > 0)
|
|
44
44
|
return (
|
|
45
45
|
r.info(
|
|
@@ -92,14 +92,14 @@ export function showInAppMessage(t, s, o) {
|
|
|
92
92
|
((n.className = "ab-iam-root v3"),
|
|
93
93
|
(n.className += me(t)),
|
|
94
94
|
n.setAttribute("role", "complementary"),
|
|
95
|
-
t.
|
|
95
|
+
t.Ce() && (n.id = t.htmlId),
|
|
96
96
|
e.nn(L.jo) && (n.style.zIndex = (e.nn(L.jo) + 1).toString()),
|
|
97
97
|
s.appendChild(n),
|
|
98
|
-
t.
|
|
98
|
+
t.ve())
|
|
99
99
|
) {
|
|
100
100
|
const s = document.createElement("style");
|
|
101
101
|
(s.innerHTML = t.css),
|
|
102
|
-
(s.id = t.
|
|
102
|
+
(s.id = t.we()),
|
|
103
103
|
null != e.nn(L.bo) && s.setAttribute("nonce", e.nn(L.bo)),
|
|
104
104
|
document.getElementsByTagName("head")[0].appendChild(s);
|
|
105
105
|
}
|
|
@@ -112,11 +112,11 @@ export function showInAppMessage(t, s, o) {
|
|
|
112
112
|
});
|
|
113
113
|
},
|
|
114
114
|
(s) => {
|
|
115
|
-
if (t
|
|
115
|
+
if (t.$e() && t.do()) {
|
|
116
116
|
const o = document.createElement("div");
|
|
117
117
|
if (
|
|
118
118
|
((o.className = "ab-page-blocker"),
|
|
119
|
-
t.
|
|
119
|
+
t.ve() || (o.style.backgroundColor = ie(t.frameColor)),
|
|
120
120
|
e.nn(L.jo) && (o.style.zIndex = e.nn(L.jo).toString()),
|
|
121
121
|
n.appendChild(o),
|
|
122
122
|
!e.nn(L.Lh))
|
|
@@ -124,7 +124,7 @@ export function showInAppMessage(t, s, o) {
|
|
|
124
124
|
const e = new Date().valueOf();
|
|
125
125
|
o.onclick = (o) => {
|
|
126
126
|
new Date().valueOf() - e > InAppMessage.fh &&
|
|
127
|
-
(t.
|
|
127
|
+
(t.Cr(s), o.stopPropagation());
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
n.appendChild(s), s.focus(), t.Oh(n);
|
|
@@ -153,13 +153,13 @@ export function showInAppMessage(t, s, o) {
|
|
|
153
153
|
It(s) &&
|
|
154
154
|
s.contentWindow &&
|
|
155
155
|
s.contentWindow.addEventListener("keydown", function (t) {
|
|
156
|
-
t.keyCode ===
|
|
156
|
+
t.keyCode === mt.mh && e.closeMessage();
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
logInAppMessageImpression(t),
|
|
160
160
|
t.dismissType === InAppMessage.DismissType.AUTO_DISMISS &&
|
|
161
161
|
setTimeout(() => {
|
|
162
|
-
n.contains(s) && t.
|
|
162
|
+
n.contains(s) && t.Cr(s);
|
|
163
163
|
}, t.duration),
|
|
164
164
|
"function" == typeof o && o();
|
|
165
165
|
},
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
export const isIFrame = (
|
|
2
|
-
export function nodeScriptReplace(o) {
|
|
3
|
-
var n;
|
|
4
|
-
if ("SCRIPT" === o.tagName)
|
|
5
|
-
null === (n = o.parentNode) ||
|
|
6
|
-
void 0 === n ||
|
|
7
|
-
n.replaceChild(
|
|
8
|
-
(function (o) {
|
|
9
|
-
const n = document.createElement("script");
|
|
10
|
-
n.text = o.innerHTML;
|
|
11
|
-
for (const e of o.attributes) n.setAttribute(e.name, e.value);
|
|
12
|
-
return n;
|
|
13
|
-
})(o),
|
|
14
|
-
o,
|
|
15
|
-
);
|
|
16
|
-
else for (const n of o.childNodes) nodeScriptReplace(n);
|
|
17
|
-
return o;
|
|
18
|
-
}
|
|
1
|
+
export const isIFrame = (e) => null !== e && "IFRAME" === e.tagName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import yt from "./utils/push-utils.js";
|
|
3
3
|
export function isPushPermissionGranted() {
|
|
4
|
-
if (e.X()) return
|
|
4
|
+
if (e.X()) return yt.isPushPermissionGranted();
|
|
5
5
|
}
|
package/src/Push/push-manager.js
CHANGED
|
@@ -4,7 +4,7 @@ import { logger as r, EncodingUtils as ei } from "../../shared-lib/index.js";
|
|
|
4
4
|
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
5
5
|
import { User } from "../User/index.js";
|
|
6
6
|
import { WindowUtils as eo } from "../util/window-utils.js";
|
|
7
|
-
import
|
|
7
|
+
import yt from "./utils/push-utils.js";
|
|
8
8
|
import { getErrorMessage as si } from "../util/error-utils.js";
|
|
9
9
|
export default class ea {
|
|
10
10
|
constructor(i, t, e, s, r, n, o, u, a, c) {
|
|
@@ -27,8 +27,8 @@ export default class ea {
|
|
|
27
27
|
(this.cn = u || !1),
|
|
28
28
|
(this.hn = a || !1),
|
|
29
29
|
(this.u = c),
|
|
30
|
-
(this.ln =
|
|
31
|
-
(this.pn =
|
|
30
|
+
(this.ln = yt.dn()),
|
|
31
|
+
(this.pn = yt.bn());
|
|
32
32
|
}
|
|
33
33
|
mn() {
|
|
34
34
|
return this.hn;
|
|
@@ -169,7 +169,7 @@ export default class ea {
|
|
|
169
169
|
this.gn(i, new Date(), e);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
|
-
|
|
172
|
+
yt.isPushBlocked()
|
|
173
173
|
? (r.info("Permission for push notifications was denied."),
|
|
174
174
|
"function" == typeof s && s(!1))
|
|
175
175
|
: (r.error("Push subscription failed: " + i),
|
|
@@ -197,7 +197,7 @@ export default class ea {
|
|
|
197
197
|
(i.unregister(), r.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
199
|
subscribe(i, t) {
|
|
200
|
-
if (!
|
|
200
|
+
if (!yt.isPushSupported())
|
|
201
201
|
return r.info(ea.Nn), void ("function" == typeof t && t(!1));
|
|
202
202
|
if (this.ln) {
|
|
203
203
|
if (!this.cn && null != window.location) {
|
|
@@ -219,7 +219,7 @@ export default class ea {
|
|
|
219
219
|
void ("function" == typeof t && t(!0))
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
|
-
if (
|
|
222
|
+
if (yt.isPushBlocked())
|
|
223
223
|
return void this.Sn(
|
|
224
224
|
"Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
|
|
225
225
|
t,
|
|
@@ -239,13 +239,13 @@ export default class ea {
|
|
|
239
239
|
},
|
|
240
240
|
s = () => {
|
|
241
241
|
let i = "Permission for push notifications was ignored.";
|
|
242
|
-
|
|
242
|
+
yt.isPushBlocked() &&
|
|
243
243
|
(i +=
|
|
244
244
|
" The browser has automatically blocked further permission requests for a period (probably 1 week)."),
|
|
245
245
|
r.info(i),
|
|
246
246
|
"function" == typeof t && t(!0);
|
|
247
247
|
},
|
|
248
|
-
n =
|
|
248
|
+
n = yt.isPushPermissionGranted(),
|
|
249
249
|
u = () => {
|
|
250
250
|
!n &&
|
|
251
251
|
this.sn &&
|
|
@@ -351,10 +351,10 @@ export default class ea {
|
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
unsubscribe(i, t) {
|
|
354
|
-
if (!
|
|
354
|
+
if (!yt.isPushSupported())
|
|
355
355
|
return r.info(ea.Nn), void ("function" == typeof t && t());
|
|
356
356
|
this.ln
|
|
357
|
-
? navigator.serviceWorker.getRegistration().then((e) => {
|
|
357
|
+
? navigator.serviceWorker.getRegistration(this.un).then((e) => {
|
|
358
358
|
e
|
|
359
359
|
? e.pushManager
|
|
360
360
|
.getSubscription()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const yt = {
|
|
2
2
|
dn: () =>
|
|
3
3
|
"serviceWorker" in navigator &&
|
|
4
4
|
"undefined" != typeof ServiceWorkerRegistration &&
|
|
@@ -9,28 +9,28 @@ const vt = {
|
|
|
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: () => yt.dn() || yt.bn(),
|
|
13
13
|
isPushBlocked: () => {
|
|
14
14
|
const i =
|
|
15
|
-
|
|
15
|
+
yt.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
|
n =
|
|
21
|
-
|
|
21
|
+
yt.isPushSupported() &&
|
|
22
22
|
(!("Notification" in window) || null == window.Notification);
|
|
23
23
|
return i || n;
|
|
24
24
|
},
|
|
25
25
|
isPushPermissionGranted: () =>
|
|
26
|
-
|
|
26
|
+
yt.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
|
-
!
|
|
31
|
+
Qi: () =>
|
|
32
|
+
!yt.isPushBlocked() &&
|
|
33
|
+
yt.isPushSupported() &&
|
|
34
|
+
!yt.isPushPermissionGranted(),
|
|
35
35
|
};
|
|
36
|
-
export default
|
|
36
|
+
export default yt;
|
package/src/User/user-manager.js
CHANGED
|
@@ -4,7 +4,7 @@ import ti from "../models/push-token.js";
|
|
|
4
4
|
import { logger as r, IndexedDBAdapter as A } from "../../shared-lib/index.js";
|
|
5
5
|
import { STORAGE_KEYS as o } 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.yt = t), (this.u = s), (this.yt = t), (this.u = s);
|
|
10
10
|
}
|
package/src/User/user.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isArray as j,
|
|
3
|
-
isDate as
|
|
4
|
-
isObject as
|
|
3
|
+
isDate as Nt,
|
|
4
|
+
isObject as Ct,
|
|
5
5
|
validateValueIsFromEnum as J,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
7
|
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
8
8
|
import {
|
|
9
|
-
isValidEmail as
|
|
10
|
-
validateCustomAttributeArrayType as
|
|
11
|
-
validateCustomAttributeKey as
|
|
9
|
+
isValidEmail as St,
|
|
10
|
+
validateCustomAttributeArrayType as At,
|
|
11
|
+
validateCustomAttributeKey as Ut,
|
|
12
12
|
validateCustomProperties as ot,
|
|
13
13
|
validateCustomString as rt,
|
|
14
|
-
validatePropertyType as
|
|
14
|
+
validatePropertyType as Ft,
|
|
15
15
|
validateStandardString as P,
|
|
16
16
|
} from "../util/validation-utils.js";
|
|
17
|
-
import { SET_CUSTOM_USER_ATTRIBUTE_STRING as
|
|
18
|
-
import { toValidBackendTimeString as
|
|
17
|
+
import { SET_CUSTOM_USER_ATTRIBUTE_STRING as $t } from "../common/constants.js";
|
|
18
|
+
import { toValidBackendTimeString as Bt } from "../util/date-utils.js";
|
|
19
19
|
export default class User {
|
|
20
20
|
constructor(t, e) {
|
|
21
21
|
(this.wt = t), (this.zi = e), (this.wt = t), (this.zi = 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 || St(t)
|
|
51
51
|
? this.wt.nu("email", t)
|
|
52
52
|
: (r.error(
|
|
53
53
|
`Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
|
|
@@ -165,11 +165,11 @@ export default class User {
|
|
|
165
165
|
: this.zi.setLastKnownLocation(this.wt.getUserId(), t, e, n, s, i).L);
|
|
166
166
|
}
|
|
167
167
|
setCustomUserAttribute(t, e, r) {
|
|
168
|
-
if (!
|
|
168
|
+
if (!Ut(t)) return !1;
|
|
169
169
|
const s = (e) => {
|
|
170
170
|
const [r] = ot(
|
|
171
171
|
e,
|
|
172
|
-
|
|
172
|
+
$t,
|
|
173
173
|
"attribute value",
|
|
174
174
|
`set custom user attribute "${t}"`,
|
|
175
175
|
"custom user attribute",
|
|
@@ -177,17 +177,17 @@ export default class User {
|
|
|
177
177
|
return r;
|
|
178
178
|
};
|
|
179
179
|
if (j(e)) {
|
|
180
|
-
const [r, n] =
|
|
180
|
+
const [r, n] = At(t, e);
|
|
181
181
|
if (!r && !n && 0 !== e.length) return !1;
|
|
182
182
|
if (r || 0 === e.length) return this.zi.Fn(i.$n, t, e).L;
|
|
183
183
|
for (const t of e) if (!s(t)) return !1;
|
|
184
|
-
} else if (
|
|
184
|
+
} else if (Ct(e)) {
|
|
185
185
|
if (!s(e)) return !1;
|
|
186
186
|
if (r) return this.zi.Fn(i.Bn, t, e).L;
|
|
187
187
|
} else {
|
|
188
|
-
if (!(void 0 !== e &&
|
|
188
|
+
if (!(void 0 !== e && Ft(e))) return !1;
|
|
189
189
|
if (
|
|
190
|
-
(
|
|
190
|
+
(Nt(e) && (e = Bt(e)),
|
|
191
191
|
"string" == typeof e &&
|
|
192
192
|
!rt(
|
|
193
193
|
e,
|
|
@@ -11,16 +11,16 @@ import { bottomIsInView as he, topIsInView as Se } from "../util/dom-utils.js";
|
|
|
11
11
|
import { Card, ControlCard } from "../Card/index.js";
|
|
12
12
|
import { cardToHtml as _e } from "../Card/display/card-display.js";
|
|
13
13
|
import { isArray as j } from "../util/code-utils.js";
|
|
14
|
-
import { KeyCodes as
|
|
14
|
+
import { KeyCodes as mt } from "../util/key-codes.js";
|
|
15
15
|
import je from "../l10n/l10n-manager-factory.js";
|
|
16
16
|
import { removeSubscription } from "../Core/remove-subscription.js";
|
|
17
17
|
import { logger as r, Guid as p } from "../../shared-lib/index.js";
|
|
18
18
|
import { BRAZE_ACTION_URI_REGEX as Z } from "../util/validation-utils.js";
|
|
19
19
|
import {
|
|
20
|
-
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as
|
|
21
|
-
ineligibleBrazeActionURLErrorMessage as
|
|
20
|
+
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as bt,
|
|
21
|
+
ineligibleBrazeActionURLErrorMessage as vt,
|
|
22
22
|
getDecodedBrazeAction as W,
|
|
23
|
-
containsUnknownBrazeAction as
|
|
23
|
+
containsUnknownBrazeAction as jt,
|
|
24
24
|
} from "../util/braze-actions.js";
|
|
25
25
|
export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE =
|
|
26
26
|
"data-last-requested-refresh";
|
|
@@ -152,7 +152,7 @@ export function feedToHtml(e, t, o) {
|
|
|
152
152
|
destroyFeedHtml(s), e.stopPropagation();
|
|
153
153
|
};
|
|
154
154
|
r.addEventListener("keydown", (e) => {
|
|
155
|
-
(e.keyCode !==
|
|
155
|
+
(e.keyCode !== mt.Fo && e.keyCode !== mt.To) || i(e);
|
|
156
156
|
}),
|
|
157
157
|
(r.onclick = i);
|
|
158
158
|
const a = document.createElement("i");
|
|
@@ -165,7 +165,7 @@ export function feedToHtml(e, t, o) {
|
|
|
165
165
|
refreshFeed(e, s), t.stopPropagation();
|
|
166
166
|
};
|
|
167
167
|
a.addEventListener("keydown", (e) => {
|
|
168
|
-
(e.keyCode !==
|
|
168
|
+
(e.keyCode !== mt.Fo && e.keyCode !== mt.To) || d(e);
|
|
169
169
|
}),
|
|
170
170
|
(a.onclick = d),
|
|
171
171
|
n.appendChild(a),
|
|
@@ -186,8 +186,8 @@ export function updateFeedCards(e, t, o, s, n) {
|
|
|
186
186
|
if (e instanceof Card) {
|
|
187
187
|
if (e.url && Z.test(e.url)) {
|
|
188
188
|
const t = W(e.url);
|
|
189
|
-
if (
|
|
190
|
-
r.error(
|
|
189
|
+
if (jt(t)) {
|
|
190
|
+
r.error(vt(bt.Li, "Content Card"));
|
|
191
191
|
continue;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { STORAGE_KEYS as o } from "./storage-manager.js";
|
|
2
2
|
import T from "./subscription-manager.js";
|
|
3
3
|
import { logger as r, IndexedDBAdapter as A } from "../../shared-lib/index.js";
|
|
4
|
-
export default class
|
|
4
|
+
export default class qt {
|
|
5
5
|
constructor(t, i, s) {
|
|
6
6
|
(this.u = t),
|
|
7
7
|
(this.Jn = i),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import qt from "./auth-manager.js";
|
|
2
2
|
import y from "../common/base-provider.js";
|
|
3
3
|
import X from "../util/browser-detector.js";
|
|
4
4
|
import Ot from "./device-manager.js";
|
|
@@ -14,15 +14,15 @@ import Lt from "../request-controller.js";
|
|
|
14
14
|
import Dt from "./server-config-manager.js";
|
|
15
15
|
import Mt from "./session-manager.js";
|
|
16
16
|
import Q, { STORAGE_KEYS as o } from "./storage-manager.js";
|
|
17
|
-
import
|
|
17
|
+
import Wt from "./storage-manager-factory.js";
|
|
18
18
|
import T from "./subscription-manager.js";
|
|
19
19
|
import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
|
|
20
|
-
import
|
|
20
|
+
import kt from "../User/user-manager.js";
|
|
21
21
|
import { User } from "../User/index.js";
|
|
22
22
|
import { parseQueryStringKeyValues as ut } from "../util/url-utils.js";
|
|
23
23
|
import { WindowUtils as eo } from "../util/window-utils.js";
|
|
24
24
|
import { BRAZE_MUST_BE_INITIALIZED_ERROR as _ } from "../common/constants.js";
|
|
25
|
-
import { SupportedOptions as
|
|
25
|
+
import { SupportedOptions as Vt, logger as r } from "../../shared-lib/index.js";
|
|
26
26
|
import _t from "../models/identifier.js";
|
|
27
27
|
const L = {
|
|
28
28
|
Eo: "allowCrawlerActivity",
|
|
@@ -51,7 +51,7 @@ const L = {
|
|
|
51
51
|
Uo: "deviceId",
|
|
52
52
|
Bo: "sdkFlavor",
|
|
53
53
|
};
|
|
54
|
-
class
|
|
54
|
+
class zt {
|
|
55
55
|
constructor() {
|
|
56
56
|
(this.rn = ""),
|
|
57
57
|
(this.Wo = ""),
|
|
@@ -73,7 +73,7 @@ class Vt {
|
|
|
73
73
|
(this.Yo = []),
|
|
74
74
|
(this.Ho = []),
|
|
75
75
|
(this._e = []),
|
|
76
|
-
(this.Wo = "5.3.
|
|
76
|
+
(this.Wo = "5.3.2");
|
|
77
77
|
}
|
|
78
78
|
Xo(t) {
|
|
79
79
|
this.qo.It(t);
|
|
@@ -116,7 +116,7 @@ class Vt {
|
|
|
116
116
|
);
|
|
117
117
|
const a = this.nn(L.Io) || !1;
|
|
118
118
|
if (
|
|
119
|
-
((this.u =
|
|
119
|
+
((this.u = Wt.Qo(t, a)), a && this.u.Wh(t), new Q.ee(null, !0).br(o.se))
|
|
120
120
|
)
|
|
121
121
|
return (
|
|
122
122
|
r.info("Ignoring all activity due to previous opt out"),
|
|
@@ -124,7 +124,7 @@ class Vt {
|
|
|
124
124
|
!1
|
|
125
125
|
);
|
|
126
126
|
for (const t of to(this.options))
|
|
127
|
-
-1 === Pt(
|
|
127
|
+
-1 === Pt(Vt).indexOf(t) &&
|
|
128
128
|
r.warn(`Ignoring unknown initialization option '${t}'.`);
|
|
129
129
|
const l = ["mparticle", "wordpress", "tealium"];
|
|
130
130
|
if (null != this.nn(L.Bo)) {
|
|
@@ -133,7 +133,7 @@ class Vt {
|
|
|
133
133
|
? (this.Vo = t)
|
|
134
134
|
: r.error("Invalid sdk flavor passed: " + t);
|
|
135
135
|
}
|
|
136
|
-
let u = this.nn(
|
|
136
|
+
let u = this.nn(Vt.Ao);
|
|
137
137
|
if (null != u)
|
|
138
138
|
if (j(u)) {
|
|
139
139
|
const t = [];
|
|
@@ -157,11 +157,11 @@ class Vt {
|
|
|
157
157
|
}
|
|
158
158
|
(this.on = new Ot(this.u, u)),
|
|
159
159
|
(this.yt = new Dt(this.u)),
|
|
160
|
-
(this.wt = new
|
|
160
|
+
(this.wt = new kt(this.yt, this.u)),
|
|
161
161
|
(this.ri = new Mt(this.u, this.wt, this.yt, this.nn(L.Po)));
|
|
162
162
|
const c = new T();
|
|
163
163
|
return (
|
|
164
|
-
(this.zo = new
|
|
164
|
+
(this.zo = new qt(this.u, this.nn(L.No), c)),
|
|
165
165
|
this.$t(c),
|
|
166
166
|
(this.qt = new Rt(
|
|
167
167
|
this.on,
|
|
@@ -323,5 +323,5 @@ class Vt {
|
|
|
323
323
|
return this.Wo;
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
const e = new
|
|
327
|
-
export { e as default,
|
|
326
|
+
const e = new zt();
|
|
327
|
+
export { e as default, zt as BrazeSdkInstance, L as OPTIONS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import X from "../util/browser-detector.js";
|
|
2
|
-
import
|
|
2
|
+
import Gt from "../models/device.js";
|
|
3
3
|
import DeviceProperties from "../Core/device-properties.js";
|
|
4
4
|
import _t from "../models/identifier.js";
|
|
5
5
|
import { logger as r, Guid as p } from "../../shared-lib/index.js";
|
|
@@ -17,7 +17,7 @@ export default class Ot {
|
|
|
17
17
|
ce(t = !0) {
|
|
18
18
|
let e = this.u.tu(o.iu.Uo);
|
|
19
19
|
null == e && ((e = new _t(p.W())), t && this.u.uu(o.iu.Uo, e));
|
|
20
|
-
const r = new
|
|
20
|
+
const r = new Gt(e.eu);
|
|
21
21
|
for (let t = 0; t < this.ka.length; t++) {
|
|
22
22
|
switch (this.ka[t]) {
|
|
23
23
|
case DeviceProperties.BROWSER:
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Xt from "../models/backend-errors.js";
|
|
2
2
|
import ue from "../models/braze-event.js";
|
|
3
3
|
import {
|
|
4
4
|
convertMsToSeconds as h,
|
|
5
|
-
convertSecondsToMs as
|
|
5
|
+
convertSecondsToMs as Kt,
|
|
6
6
|
} from "../util/date-utils.js";
|
|
7
7
|
import s from "../common/event-logger.js";
|
|
8
8
|
import { isArray as j, isEqual as ii } from "../util/code-utils.js";
|
|
9
9
|
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
10
10
|
import { STORAGE_KEYS as o } from "./storage-manager.js";
|
|
11
11
|
import D from "../util/request-header-utils.js";
|
|
12
|
-
import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as
|
|
13
|
-
import { getAlias as
|
|
12
|
+
import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Ht } from "../common/constants.js";
|
|
13
|
+
import { getAlias as Yt } from "./utils.js";
|
|
14
14
|
export default class Rt {
|
|
15
15
|
constructor(t, e, i, s, r, n, o, h, a, u, l, c) {
|
|
16
16
|
(this.on = t),
|
|
@@ -42,7 +42,7 @@ export default class Rt {
|
|
|
42
42
|
}
|
|
43
43
|
Js(t, e = !1, i = !1) {
|
|
44
44
|
const s = this.on.ce(!i),
|
|
45
|
-
r = s.
|
|
45
|
+
r = s.Zi(),
|
|
46
46
|
n = this.u.j(o.C.Ca);
|
|
47
47
|
ii(n, r) || (t.device = r),
|
|
48
48
|
(t.api_key = this.rn),
|
|
@@ -64,7 +64,7 @@ export default class Rt {
|
|
|
64
64
|
null != e && (t.user_id = e);
|
|
65
65
|
}
|
|
66
66
|
if (!t.user_id && !this.zo.Fh()) {
|
|
67
|
-
const e =
|
|
67
|
+
const e = Yt(this.u);
|
|
68
68
|
e && (t.alias = e);
|
|
69
69
|
}
|
|
70
70
|
return t;
|
|
@@ -100,28 +100,28 @@ export default class Rt {
|
|
|
100
100
|
let n,
|
|
101
101
|
o = h;
|
|
102
102
|
switch (o) {
|
|
103
|
-
case
|
|
103
|
+
case Xt.Zh:
|
|
104
104
|
return (
|
|
105
105
|
(n = "Received successful response with empty body."),
|
|
106
106
|
s.q(i.qs, { e: n }),
|
|
107
107
|
r.info(n),
|
|
108
108
|
!1
|
|
109
109
|
);
|
|
110
|
-
case
|
|
110
|
+
case Xt.Ra:
|
|
111
111
|
return (
|
|
112
112
|
(n = "Received successful response with invalid JSON"),
|
|
113
113
|
s.q(i.qs, { e: n + ": " + e.response }),
|
|
114
114
|
r.info(n),
|
|
115
115
|
!1
|
|
116
116
|
);
|
|
117
|
-
case
|
|
117
|
+
case Xt.qa:
|
|
118
118
|
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Go}`;
|
|
119
119
|
break;
|
|
120
|
-
case
|
|
120
|
+
case Xt.Aa:
|
|
121
121
|
o =
|
|
122
122
|
"Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
|
|
123
123
|
break;
|
|
124
|
-
case
|
|
124
|
+
case Xt.Ba:
|
|
125
125
|
o = "No device identifier. Please contact support@braze.com";
|
|
126
126
|
}
|
|
127
127
|
r.error("Backend error: " + o);
|
|
@@ -135,7 +135,7 @@ export default class Rt {
|
|
|
135
135
|
const n = [],
|
|
136
136
|
o = (t) => t || "",
|
|
137
137
|
h = o(this.wt.getUserId());
|
|
138
|
-
let a = this.
|
|
138
|
+
let a = this.Yi(t, e);
|
|
139
139
|
const u = [],
|
|
140
140
|
l = [];
|
|
141
141
|
let c,
|
|
@@ -143,7 +143,7 @@ export default class Rt {
|
|
|
143
143
|
if (i.length > 0) {
|
|
144
144
|
const t = [];
|
|
145
145
|
for (const e of i) {
|
|
146
|
-
if (((c = e.
|
|
146
|
+
if (((c = e.Zi()), this.zo.Fh())) {
|
|
147
147
|
if (h && !c.user_id) {
|
|
148
148
|
d || (d = {}), d.events || (d.events = []), d.events.push(c);
|
|
149
149
|
continue;
|
|
@@ -177,7 +177,7 @@ export default class Rt {
|
|
|
177
177
|
const e = [];
|
|
178
178
|
for (const i of t) {
|
|
179
179
|
const t = ue.fromJson(i);
|
|
180
|
-
(t.time =
|
|
180
|
+
(t.time = Kt(t.time)), e.push(t);
|
|
181
181
|
}
|
|
182
182
|
this.u.xo(e);
|
|
183
183
|
}
|
|
@@ -190,19 +190,19 @@ export default class Rt {
|
|
|
190
190
|
qr(t) {
|
|
191
191
|
return s.q(i.Ea, { n: t });
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
Yi(t, e, i) {
|
|
194
194
|
const s = {};
|
|
195
195
|
t && (s.feed = !0), e && (s.triggers = !0);
|
|
196
196
|
const r = null != i ? i : this.wt.getUserId();
|
|
197
197
|
if ((r && (s.user_id = r), !s.user_id && !this.zo.Fh())) {
|
|
198
|
-
const t =
|
|
198
|
+
const t = Yt(this.u);
|
|
199
199
|
t && (s.alias = t);
|
|
200
200
|
}
|
|
201
201
|
return (s.config = { config_time: this.yt.ii() }), { respond_with: s };
|
|
202
202
|
}
|
|
203
203
|
Ka(t) {
|
|
204
204
|
const e = new Date().valueOf();
|
|
205
|
-
let i =
|
|
205
|
+
let i = Ht.toString();
|
|
206
206
|
const s = D.Pa(this.u, t);
|
|
207
207
|
if (-1 !== s) {
|
|
208
208
|
i = (e - s).toString();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { STORAGE_KEYS as o } from "./storage-manager.js";
|
|
2
2
|
import T from "./subscription-manager.js";
|
|
3
|
-
import
|
|
3
|
+
import Jt from "../models/server-config.js";
|
|
4
4
|
import s from "../common/event-logger.js";
|
|
5
5
|
import { EventTypes as i } from "../../shared-lib/index.js";
|
|
6
6
|
export default class Dt {
|
|
@@ -16,7 +16,7 @@ export default class Dt {
|
|
|
16
16
|
ll() {
|
|
17
17
|
if (null == this.rl) {
|
|
18
18
|
const t = this.u.j(o.C.ul);
|
|
19
|
-
this.rl = null != t ?
|
|
19
|
+
this.rl = null != t ? Jt.qn(t) : new Jt();
|
|
20
20
|
}
|
|
21
21
|
return this.rl;
|
|
22
22
|
}
|
|
@@ -28,7 +28,7 @@ export default class Dt {
|
|
|
28
28
|
const e = t.config;
|
|
29
29
|
if (e.time > this.ll().hl) {
|
|
30
30
|
const t = (t) => (null == t ? this.ll().ol : t),
|
|
31
|
-
i = new
|
|
31
|
+
i = new Jt(
|
|
32
32
|
e.time,
|
|
33
33
|
e.events_blacklist,
|
|
34
34
|
e.attributes_blacklist,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Q, { STORAGE_KEYS as o } from "./storage-manager.js";
|
|
2
2
|
import { logger as r } from "../../shared-lib/index.js";
|
|
3
|
-
const
|
|
3
|
+
const Wt = {
|
|
4
4
|
Qo: function (e, t = !1) {
|
|
5
5
|
let a = !1;
|
|
6
6
|
try {
|
|
@@ -24,7 +24,7 @@ const Bt = {
|
|
|
24
24
|
} catch (e) {
|
|
25
25
|
r.info("Local Storage not supported!");
|
|
26
26
|
}
|
|
27
|
-
const n =
|
|
27
|
+
const n = Wt.oc(),
|
|
28
28
|
c = new Q.tc(e, n && !t, a);
|
|
29
29
|
let l;
|
|
30
30
|
return (l = a ? new Q.rc(e) : new Q.ac()), new Q(c, l);
|
|
@@ -39,4 +39,4 @@ const Bt = {
|
|
|
39
39
|
);
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
-
export default
|
|
42
|
+
export default Wt;
|