@braze/web-sdk 5.3.1 → 5.4.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 +20 -4
- package/package.json +1 -1
- package/shared-lib/event-types.js +10 -10
- package/shared-lib/indexed-db-adapter.js +1 -1
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +9 -8
- package/src/Card/display/card-display.js +59 -58
- package/src/Core/index.js +1 -0
- package/src/Core/is-initialized.js +4 -0
- 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 +78 -76
- 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 +47 -45
- 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-factory.js +2 -1
- package/src/Push/push-manager.js +80 -92
- package/src/Push/utils/push-utils.js +12 -12
- package/src/User/user-manager.js +3 -3
- package/src/User/user.js +19 -19
- package/src/common/event-logger.js +4 -4
- package/src/common/feed-display.js +25 -24
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +15 -5
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +54 -52
- package/src/managers/device-manager.js +19 -19
- package/src/managers/network-manager.js +100 -100
- package/src/managers/server-config-manager.js +7 -7
- package/src/managers/session-manager.js +4 -4
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +18 -18
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +10 -10
- package/src/models/device.js +3 -3
- package/src/models/server-config.js +7 -7
- package/src/request-controller.js +77 -77
- 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 +9 -9
- package/src/triggers/models/in-app-message-click-data.js +8 -8
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +39 -39
- package/src/triggers/models/trigger.js +12 -12
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +15 -15
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +21 -21
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/component-utils.js +15 -14
- 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 +8 -8
- package/src/util/user-agent-parser.js +3 -3
- package/src/util/validation-utils.js +17 -17
- package/src/util/window-utils.js +1 -1
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
|
}
|
|
@@ -47,7 +47,7 @@ export default class bt {
|
|
|
47
47
|
u
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
Pn(t, s, i, e, u) {
|
|
51
51
|
this.nu("push_token", t, !1, !0),
|
|
52
52
|
this.nu("custom_push_public_key", i, !1, !0),
|
|
53
53
|
this.nu("custom_push_user_auth", e, !1, !0),
|
|
@@ -57,7 +57,7 @@ export default class bt {
|
|
|
57
57
|
l = new ti(t, s, i, e, u);
|
|
58
58
|
this.u.k(o.C.In, l.Y()), n.setItem(h.ss.cu, h.ie, !0);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
Sn(t) {
|
|
61
61
|
if (
|
|
62
62
|
(this.nu("push_token", null, !1, !0),
|
|
63
63
|
this.nu("custom_push_public_key", null, !1, !0),
|
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,
|
|
@@ -273,11 +273,11 @@ export default class User {
|
|
|
273
273
|
!1)
|
|
274
274
|
: this.zi.Hn(t, User.Kn.UNSUBSCRIBED).L;
|
|
275
275
|
}
|
|
276
|
-
|
|
277
|
-
this.wt.
|
|
276
|
+
Pn(t, e, r, s, n) {
|
|
277
|
+
this.wt.Pn(t, e, r, s, n), this.zi.Mn();
|
|
278
278
|
}
|
|
279
|
-
|
|
280
|
-
this.wt.
|
|
279
|
+
Sn(t) {
|
|
280
|
+
this.wt.Sn(t);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
(User.Genders = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger as r } from "../../shared-lib/index.js";
|
|
2
2
|
import e from "../managers/braze-instance.js";
|
|
3
|
-
import
|
|
3
|
+
import ve from "../models/braze-event.js";
|
|
4
4
|
import t from "../models/request-result.js";
|
|
5
5
|
const s = {
|
|
6
6
|
q: (o, n, s) => {
|
|
@@ -14,10 +14,10 @@ const s = {
|
|
|
14
14
|
),
|
|
15
15
|
d
|
|
16
16
|
);
|
|
17
|
-
const u = m.
|
|
17
|
+
const u = m.xo();
|
|
18
18
|
return (
|
|
19
19
|
d.ge.push(
|
|
20
|
-
new
|
|
20
|
+
new ve(
|
|
21
21
|
s || (null === (i = e.er()) || void 0 === i ? void 0 : i.getUserId()),
|
|
22
22
|
o,
|
|
23
23
|
new Date().valueOf(),
|
|
@@ -26,7 +26,7 @@ const s = {
|
|
|
26
26
|
),
|
|
27
27
|
),
|
|
28
28
|
(d.L =
|
|
29
|
-
(null === (l = e.l()) || void 0 === l ? void 0 : l.
|
|
29
|
+
(null === (l = e.l()) || void 0 === l ? void 0 : l.zo(d.ge)) || !1),
|
|
30
30
|
d
|
|
31
31
|
);
|
|
32
32
|
},
|
|
@@ -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
|
|
15
|
-
import
|
|
14
|
+
import { KeyCodes as mt } from "../util/key-codes.js";
|
|
15
|
+
import ue 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";
|
|
@@ -41,11 +41,12 @@ export function destroyFeedHtml(e) {
|
|
|
41
41
|
delete scrollListeners[o]);
|
|
42
42
|
}
|
|
43
43
|
export function generateFeedBody(e, t) {
|
|
44
|
-
const o =
|
|
44
|
+
const o = ue.m(),
|
|
45
|
+
s = document.createElement("div");
|
|
45
46
|
if (
|
|
46
|
-
((
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
((s.className = "ab-feed-body"),
|
|
48
|
+
s.setAttribute("aria-label", "Feed"),
|
|
49
|
+
s.setAttribute("role", "feed"),
|
|
49
50
|
null == e.lastUpdated)
|
|
50
51
|
) {
|
|
51
52
|
const e = document.createElement("div");
|
|
@@ -53,27 +54,27 @@ export function generateFeedBody(e, t) {
|
|
|
53
54
|
const t = document.createElement("i");
|
|
54
55
|
(t.className = "fa fa-spinner fa-spin fa-4x ab-initial-spinner"),
|
|
55
56
|
e.appendChild(t),
|
|
56
|
-
|
|
57
|
+
s.appendChild(e);
|
|
57
58
|
} else {
|
|
58
|
-
let
|
|
59
|
+
let n = !1;
|
|
59
60
|
const logCardClick = (t) => e.logCardClick(t);
|
|
60
|
-
for (const
|
|
61
|
-
const
|
|
62
|
-
!
|
|
63
|
-
? (
|
|
61
|
+
for (const i of e.cards) {
|
|
62
|
+
const a = i instanceof ControlCard;
|
|
63
|
+
!a || e.dr()
|
|
64
|
+
? (s.appendChild(_e(i, logCardClick, t, o.wo())), (n = n || !a))
|
|
64
65
|
: r.error(
|
|
65
66
|
"Received a control card for a legacy news feed. Control cards are only supported with content cards.",
|
|
66
67
|
);
|
|
67
68
|
}
|
|
68
|
-
if (!
|
|
69
|
+
if (!n) {
|
|
69
70
|
const e = document.createElement("div");
|
|
70
71
|
(e.className = "ab-no-cards-message"),
|
|
71
|
-
(e.innerHTML =
|
|
72
|
+
(e.innerHTML = o.get("NO_CARDS_MESSAGE") || ""),
|
|
72
73
|
e.setAttribute("role", "article"),
|
|
73
|
-
|
|
74
|
+
s.appendChild(e);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
|
-
return
|
|
77
|
+
return s;
|
|
77
78
|
}
|
|
78
79
|
export function detectFeedImpressions(e, t) {
|
|
79
80
|
if (null != e && null != t) {
|
|
@@ -123,7 +124,7 @@ export function refreshFeed(e, t) {
|
|
|
123
124
|
const o = t.querySelectorAll(".ab-initial-spinner")[0];
|
|
124
125
|
if (null != o) {
|
|
125
126
|
const e = document.createElement("span");
|
|
126
|
-
(e.innerHTML =
|
|
127
|
+
(e.innerHTML = ue.m().get("FEED_TIMEOUT_MESSAGE") || ""),
|
|
127
128
|
null != o.parentNode &&
|
|
128
129
|
(o.parentNode.appendChild(e), o.parentNode.removeChild(o));
|
|
129
130
|
}
|
|
@@ -152,7 +153,7 @@ export function feedToHtml(e, t, o) {
|
|
|
152
153
|
destroyFeedHtml(s), e.stopPropagation();
|
|
153
154
|
};
|
|
154
155
|
r.addEventListener("keydown", (e) => {
|
|
155
|
-
(e.keyCode !==
|
|
156
|
+
(e.keyCode !== mt.Fo && e.keyCode !== mt.To) || i(e);
|
|
156
157
|
}),
|
|
157
158
|
(r.onclick = i);
|
|
158
159
|
const a = document.createElement("i");
|
|
@@ -165,7 +166,7 @@ export function feedToHtml(e, t, o) {
|
|
|
165
166
|
refreshFeed(e, s), t.stopPropagation();
|
|
166
167
|
};
|
|
167
168
|
a.addEventListener("keydown", (e) => {
|
|
168
|
-
(e.keyCode !==
|
|
169
|
+
(e.keyCode !== mt.Fo && e.keyCode !== mt.To) || d(e);
|
|
169
170
|
}),
|
|
170
171
|
(a.onclick = d),
|
|
171
172
|
n.appendChild(a),
|
|
@@ -186,8 +187,8 @@ export function updateFeedCards(e, t, o, s, n) {
|
|
|
186
187
|
if (e instanceof Card) {
|
|
187
188
|
if (e.url && Z.test(e.url)) {
|
|
188
189
|
const t = W(e.url);
|
|
189
|
-
if (
|
|
190
|
-
r.error(
|
|
190
|
+
if (jt(t)) {
|
|
191
|
+
r.error(vt(bt.Li, "Content Card"));
|
|
191
192
|
continue;
|
|
192
193
|
}
|
|
193
194
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import e, { OPTIONS as L } from "../managers/braze-instance.js";
|
|
2
2
|
import X from "../util/browser-detector.js";
|
|
3
3
|
import nr from "./l10n-manager.js";
|
|
4
|
-
const
|
|
4
|
+
const ue = {
|
|
5
5
|
t: !1,
|
|
6
6
|
i: null,
|
|
7
7
|
m: () => {
|
|
8
|
-
if ((
|
|
8
|
+
if ((ue.o(), !ue.i)) {
|
|
9
9
|
let r = X.language,
|
|
10
10
|
t = !1;
|
|
11
|
-
e.nn(L.zn) && ((r = e.nn(L.zn)), (t = !0)), (
|
|
11
|
+
e.nn(L.zn) && ((r = e.nn(L.zn)), (t = !0)), (ue.i = new nr(r, t));
|
|
12
12
|
}
|
|
13
|
-
return
|
|
13
|
+
return ue.i;
|
|
14
14
|
},
|
|
15
15
|
o: () => {
|
|
16
|
-
|
|
16
|
+
ue.t || (e.g(ue), (ue.t = !0));
|
|
17
17
|
},
|
|
18
18
|
destroy: () => {
|
|
19
|
-
(
|
|
19
|
+
(ue.i = null), (ue.t = !1);
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
-
export default
|
|
22
|
+
export default ue;
|
package/src/l10n/l10n-manager.js
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
import { logger as r } from "../../shared-lib/index.js";
|
|
2
2
|
import xt from "../common/translations.js";
|
|
3
3
|
export default class nr {
|
|
4
|
-
constructor(t,
|
|
4
|
+
constructor(t, e = !1) {
|
|
5
5
|
if (
|
|
6
6
|
((this.language = t),
|
|
7
7
|
null != t && (t = t.toLowerCase()),
|
|
8
8
|
null != t && null == xt[t])
|
|
9
9
|
) {
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const e = t.indexOf("-");
|
|
11
|
+
e > 0 && (t = t.substring(0, e));
|
|
12
12
|
}
|
|
13
13
|
if (null == xt[t]) {
|
|
14
|
-
const
|
|
14
|
+
const a =
|
|
15
15
|
"Braze does not yet have a localization for language " +
|
|
16
16
|
t +
|
|
17
17
|
", defaulting to English. Please contact us if you are willing and able to help us translate our SDK into this language.";
|
|
18
|
-
|
|
18
|
+
e ? r.error(a) : r.info(a), (t = "en");
|
|
19
19
|
}
|
|
20
20
|
this.language = t;
|
|
21
21
|
}
|
|
22
22
|
get(t) {
|
|
23
23
|
return xt[this.language][t];
|
|
24
24
|
}
|
|
25
|
+
wo() {
|
|
26
|
+
switch (this.language) {
|
|
27
|
+
case "ar":
|
|
28
|
+
case "he":
|
|
29
|
+
case "fa":
|
|
30
|
+
return "rtl";
|
|
31
|
+
default:
|
|
32
|
+
return "ltr";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
25
35
|
}
|
|
@@ -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";
|
|
@@ -7,38 +7,38 @@ import {
|
|
|
7
7
|
isArray as j,
|
|
8
8
|
keys as to,
|
|
9
9
|
validateValueIsFromEnum as J,
|
|
10
|
-
values as
|
|
10
|
+
values as Rt,
|
|
11
11
|
} from "../util/code-utils.js";
|
|
12
|
-
import
|
|
12
|
+
import Pt from "./network-manager.js";
|
|
13
13
|
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 zt, logger as r } from "../../shared-lib/index.js";
|
|
26
26
|
import _t from "../models/identifier.js";
|
|
27
27
|
const L = {
|
|
28
28
|
Eo: "allowCrawlerActivity",
|
|
29
29
|
_o: "baseUrl",
|
|
30
30
|
Io: "noCookies",
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
So: "devicePropertyAllowlist",
|
|
32
|
+
ka: "disablePushTokenMaintenance",
|
|
33
|
+
Ao: "enableLogging",
|
|
34
34
|
No: "enableSdkAuthentication",
|
|
35
|
-
|
|
35
|
+
_a: "manageServiceWorkerExternally",
|
|
36
36
|
Oo: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
Ro: "sessionTimeoutInSeconds",
|
|
38
|
+
Po: "appVersion",
|
|
39
39
|
Lo: "appVersionNumber",
|
|
40
40
|
wa: "serviceWorkerLocation",
|
|
41
|
-
|
|
41
|
+
Ma: "safariWebsitePushId",
|
|
42
42
|
zn: "localization",
|
|
43
43
|
bo: "contentSecurityNonce",
|
|
44
44
|
Do: "allowUserSuppliedJavascript",
|
|
@@ -49,14 +49,15 @@ const L = {
|
|
|
49
49
|
Lh: "requireExplicitInAppMessageDismissal",
|
|
50
50
|
Mo: "doNotLoadFontAwesome",
|
|
51
51
|
Uo: "deviceId",
|
|
52
|
-
|
|
52
|
+
ya: "serviceWorkerScope",
|
|
53
|
+
Wo: "sdkFlavor",
|
|
53
54
|
};
|
|
54
55
|
class Vt {
|
|
55
56
|
constructor() {
|
|
56
57
|
(this.rn = ""),
|
|
57
|
-
(this.
|
|
58
|
+
(this.Bo = ""),
|
|
58
59
|
(this.Vo = void 0),
|
|
59
|
-
(this.
|
|
60
|
+
(this.Ko = null),
|
|
60
61
|
(this.on = null),
|
|
61
62
|
(this.qt = null),
|
|
62
63
|
(this.zi = null),
|
|
@@ -65,7 +66,7 @@ class Vt {
|
|
|
65
66
|
(this.u = null),
|
|
66
67
|
(this.wt = null),
|
|
67
68
|
(this.Go = ""),
|
|
68
|
-
(this.
|
|
69
|
+
(this.isInitialized = !1),
|
|
69
70
|
(this.$o = !1),
|
|
70
71
|
(this.qo = new T()),
|
|
71
72
|
(this.Jo = new T()),
|
|
@@ -73,7 +74,7 @@ class Vt {
|
|
|
73
74
|
(this.Yo = []),
|
|
74
75
|
(this.Ho = []),
|
|
75
76
|
(this._e = []),
|
|
76
|
-
(this.
|
|
77
|
+
(this.Bo = "5.4.0");
|
|
77
78
|
}
|
|
78
79
|
Xo(t) {
|
|
79
80
|
this.qo.It(t);
|
|
@@ -85,8 +86,8 @@ class Vt {
|
|
|
85
86
|
if (this.so())
|
|
86
87
|
return r.info("Braze has already been initialized with an API key."), !0;
|
|
87
88
|
this.options = i || {};
|
|
88
|
-
let s = this.nn(L.
|
|
89
|
-
const e = ut(eo.
|
|
89
|
+
let s = this.nn(L.Ao);
|
|
90
|
+
const e = ut(eo.Zo());
|
|
90
91
|
if (
|
|
91
92
|
(e && "true" === e.brazeLogging && (s = !0),
|
|
92
93
|
r.init(s),
|
|
@@ -107,7 +108,7 @@ class Vt {
|
|
|
107
108
|
(n.href = h),
|
|
108
109
|
"/" === n.pathname && (n = `${n}api/v3`),
|
|
109
110
|
(this.Go = n.toString()),
|
|
110
|
-
X.
|
|
111
|
+
X.Qo && !this.nn(L.Eo))
|
|
111
112
|
)
|
|
112
113
|
return (
|
|
113
114
|
r.info("Ignoring activity from crawler bot " + navigator.userAgent),
|
|
@@ -116,7 +117,7 @@ class Vt {
|
|
|
116
117
|
);
|
|
117
118
|
const a = this.nn(L.Io) || !1;
|
|
118
119
|
if (
|
|
119
|
-
((this.u =
|
|
120
|
+
((this.u = Wt.Wh(t, a)), a && this.u.Vh(t), new Q.ee(null, !0).br(o.se))
|
|
120
121
|
)
|
|
121
122
|
return (
|
|
122
123
|
r.info("Ignoring all activity due to previous opt out"),
|
|
@@ -124,16 +125,16 @@ class Vt {
|
|
|
124
125
|
!1
|
|
125
126
|
);
|
|
126
127
|
for (const t of to(this.options))
|
|
127
|
-
-1 ===
|
|
128
|
+
-1 === Rt(zt).indexOf(t) &&
|
|
128
129
|
r.warn(`Ignoring unknown initialization option '${t}'.`);
|
|
129
130
|
const l = ["mparticle", "wordpress", "tealium"];
|
|
130
|
-
if (null != this.nn(L.
|
|
131
|
-
const t = this.nn(L.
|
|
131
|
+
if (null != this.nn(L.Wo)) {
|
|
132
|
+
const t = this.nn(L.Wo);
|
|
132
133
|
-1 !== l.indexOf(t)
|
|
133
134
|
? (this.Vo = t)
|
|
134
135
|
: r.error("Invalid sdk flavor passed: " + t);
|
|
135
136
|
}
|
|
136
|
-
let u = this.nn(
|
|
137
|
+
let u = this.nn(zt.So);
|
|
137
138
|
if (null != u)
|
|
138
139
|
if (j(u)) {
|
|
139
140
|
const t = [];
|
|
@@ -150,31 +151,31 @@ class Vt {
|
|
|
150
151
|
"devicePropertyAllowlist must be an array. Defaulting to all properties.",
|
|
151
152
|
),
|
|
152
153
|
(u = null);
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
const t = new _t(
|
|
154
|
+
const c = this.nn(L.Uo);
|
|
155
|
+
if (c) {
|
|
156
|
+
const t = new _t(c);
|
|
156
157
|
this.u.uu(o.iu.Uo, t);
|
|
157
158
|
}
|
|
158
159
|
(this.on = new Ot(this.u, u)),
|
|
159
160
|
(this.yt = new Dt(this.u)),
|
|
160
|
-
(this.wt = new
|
|
161
|
-
(this.ri = new Mt(this.u, this.wt, this.yt, this.nn(L.
|
|
162
|
-
const
|
|
161
|
+
(this.wt = new kt(this.yt, this.u)),
|
|
162
|
+
(this.ri = new Mt(this.u, this.wt, this.yt, this.nn(L.Ro)));
|
|
163
|
+
const f = new T();
|
|
163
164
|
return (
|
|
164
|
-
(this.
|
|
165
|
-
this.$t(
|
|
166
|
-
(this.qt = new
|
|
165
|
+
(this.Ko = new qt(this.u, this.nn(L.No), f)),
|
|
166
|
+
this.$t(f),
|
|
167
|
+
(this.qt = new Pt(
|
|
167
168
|
this.on,
|
|
168
169
|
this.u,
|
|
169
|
-
this.
|
|
170
|
+
this.Ko,
|
|
170
171
|
this.wt,
|
|
171
172
|
this.ri,
|
|
172
173
|
this.yt,
|
|
173
174
|
this.rn,
|
|
174
175
|
this.Go,
|
|
175
|
-
this.
|
|
176
|
+
this.Bo,
|
|
176
177
|
this.Vo || "",
|
|
177
|
-
this.nn(L.
|
|
178
|
+
this.nn(L.Po),
|
|
178
179
|
this.nn(L.Lo),
|
|
179
180
|
)),
|
|
180
181
|
(this.zi = new Lt(
|
|
@@ -188,11 +189,11 @@ class Vt {
|
|
|
188
189
|
(t) => {
|
|
189
190
|
if (this.so()) for (const i of this.gr()) i.Ns(t);
|
|
190
191
|
},
|
|
191
|
-
this.
|
|
192
|
+
this.Ko,
|
|
192
193
|
this.qt,
|
|
193
194
|
)),
|
|
194
195
|
this.zi.initialize(),
|
|
195
|
-
a || this.u.
|
|
196
|
+
a || this.u.Kh(),
|
|
196
197
|
r.info(
|
|
197
198
|
`Initialized for the Braze backend at "${this.nn(
|
|
198
199
|
L._o,
|
|
@@ -201,24 +202,25 @@ class Vt {
|
|
|
201
202
|
et.o(),
|
|
202
203
|
this.yt.ji(() => {
|
|
203
204
|
var t;
|
|
204
|
-
this.
|
|
205
|
+
this.isInitialized &&
|
|
205
206
|
(null === (t = this.yt) || void 0 === t ? void 0 : t.ci()) &&
|
|
206
207
|
import("../FeatureFlags/refresh-feature-flags.js").then((t) => {
|
|
207
|
-
if (!this.
|
|
208
|
+
if (!this.isInitialized) return;
|
|
208
209
|
(0, t.default)();
|
|
209
210
|
});
|
|
210
211
|
}),
|
|
211
212
|
this.zi.mr(() => {
|
|
212
213
|
var t;
|
|
213
|
-
this.
|
|
214
|
+
this.isInitialized &&
|
|
214
215
|
(null === (t = this.yt) || void 0 === t ? void 0 : t.ci()) &&
|
|
215
216
|
import("../FeatureFlags/refresh-feature-flags.js").then((t) => {
|
|
216
|
-
if (!this.
|
|
217
|
+
if (!this.isInitialized) return;
|
|
217
218
|
(0, t.default)(void 0, void 0, !0);
|
|
218
219
|
});
|
|
219
220
|
}),
|
|
220
221
|
this.qo.Dt(this.options),
|
|
221
|
-
(this.
|
|
222
|
+
(this.isInitialized = !0),
|
|
223
|
+
window.dispatchEvent(new CustomEvent("braze.initialized")),
|
|
222
224
|
!0
|
|
223
225
|
);
|
|
224
226
|
}
|
|
@@ -233,7 +235,7 @@ class Vt {
|
|
|
233
235
|
(this._e = []),
|
|
234
236
|
null != this.zi && this.zi.destroy(),
|
|
235
237
|
(this.zi = null),
|
|
236
|
-
(this.
|
|
238
|
+
(this.Ko = null),
|
|
237
239
|
(this.on = null),
|
|
238
240
|
(this.qt = null),
|
|
239
241
|
(this.yt = null),
|
|
@@ -241,19 +243,19 @@ class Vt {
|
|
|
241
243
|
(this.wt = null),
|
|
242
244
|
(this.options = {}),
|
|
243
245
|
(this.Vo = void 0),
|
|
244
|
-
(this.
|
|
246
|
+
(this.isInitialized = !1),
|
|
245
247
|
(this.$o = !1),
|
|
246
248
|
t && (this.u = null);
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
X() {
|
|
250
|
-
return !this
|
|
252
|
+
return !this.$h() && (!!this.so() || (console.warn(_), !1));
|
|
251
253
|
}
|
|
252
254
|
ba() {
|
|
253
255
|
return this.rn;
|
|
254
256
|
}
|
|
255
257
|
Sr() {
|
|
256
|
-
return this.
|
|
258
|
+
return this.Ko;
|
|
257
259
|
}
|
|
258
260
|
Hs() {
|
|
259
261
|
return this.Go;
|
|
@@ -314,13 +316,13 @@ class Vt {
|
|
|
314
316
|
this.$o = t;
|
|
315
317
|
}
|
|
316
318
|
so() {
|
|
317
|
-
return this.
|
|
319
|
+
return this.isInitialized;
|
|
318
320
|
}
|
|
319
|
-
|
|
321
|
+
$h() {
|
|
320
322
|
return this.$o;
|
|
321
323
|
}
|
|
322
324
|
Ds() {
|
|
323
|
-
return this.
|
|
325
|
+
return this.Bo;
|
|
324
326
|
}
|
|
325
327
|
}
|
|
326
328
|
const e = new Vt();
|