@braze/web-sdk 6.1.0 → 6.3.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 +3 -3
- package/package.json +1 -1
- package/shared-lib/logger.js +2 -2
- package/src/managers/braze-instance.js +1 -1
- package/src/models/server-config.js +2 -2
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/browser-detector.js +23 -21
- package/src/util/client-hints-parser.js +2 -2
- package/src/util/device-constants.js +5 -4
- package/src/util/html-display-utils.js +4 -1
- package/src/util/user-agent-parser.js +25 -23
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v6.
|
|
2
|
+
* Type definitions for @braze/web-sdk v6.3.0
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2025 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
@@ -2138,7 +2138,7 @@ export function openSession(): void;
|
|
|
2138
2138
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2139
2139
|
*
|
|
2140
2140
|
* ```
|
|
2141
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk/6.
|
|
2141
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk/6.3/service-worker.js');
|
|
2142
2142
|
* ```
|
|
2143
2143
|
*
|
|
2144
2144
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2561,7 +2561,7 @@ export type InitializationOptions = {
|
|
|
2561
2561
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2562
2562
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2563
2563
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2564
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk/6.
|
|
2564
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk/6.3/service-worker.js');` or by including the content
|
|
2565
2565
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2566
2566
|
*/
|
|
2567
2567
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
package/shared-lib/logger.js
CHANGED
|
@@ -24,13 +24,13 @@ const E = {
|
|
|
24
24
|
},
|
|
25
25
|
warn: function (n) {
|
|
26
26
|
if (E.zg) {
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v6.
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v6.3.0)";
|
|
28
28
|
null != E.vd ? E.vd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function (n) {
|
|
32
32
|
if (E.zg) {
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v6.
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v6.3.0)";
|
|
34
34
|
null != E.vd ? E.vd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -38,7 +38,7 @@ export default class ni {
|
|
|
38
38
|
}
|
|
39
39
|
dt() {
|
|
40
40
|
return {
|
|
41
|
-
s: "6.
|
|
41
|
+
s: "6.3.0",
|
|
42
42
|
l: this.ol,
|
|
43
43
|
e: this.bl,
|
|
44
44
|
a: this.fl,
|
|
@@ -54,7 +54,7 @@ export default class ni {
|
|
|
54
54
|
static qn(t) {
|
|
55
55
|
let i = t.l;
|
|
56
56
|
return (
|
|
57
|
-
"6.
|
|
57
|
+
"6.3.0" !== t.s && (i = 0),
|
|
58
58
|
new ni(i, t.e, t.a, t.p, t.m, t.v, t.c, t.f, t.grl, t.b)
|
|
59
59
|
);
|
|
60
60
|
}
|
package/src/ui/js/attach-css.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import r, { OPTIONS as z } from "../../managers/braze-instance.js";
|
|
2
2
|
export function attachCSS(n, t, o) {
|
|
3
3
|
const c = n || document.querySelector("head"),
|
|
4
|
-
e = `ab-${t}-css-definitions-${"6.
|
|
4
|
+
e = `ab-${t}-css-definitions-${"6.3.0".replace(/\./g, "-")}`;
|
|
5
5
|
if (!c) return;
|
|
6
6
|
const s = c.ownerDocument || document;
|
|
7
7
|
if (null == s.getElementById(e)) {
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import ai from "./client-hints-parser.js";
|
|
2
|
-
import
|
|
3
|
-
import { Browsers as
|
|
2
|
+
import gi from "./user-agent-parser.js";
|
|
3
|
+
import { Browsers as oi, OperatingSystems as so } from "./device-constants.js";
|
|
4
4
|
class di {
|
|
5
5
|
constructor() {
|
|
6
|
-
|
|
7
|
-
(
|
|
6
|
+
let t;
|
|
7
|
+
(t =
|
|
8
|
+
navigator.userAgent.toLowerCase().includes(oi.Sg.toLowerCase()) ||
|
|
9
|
+
!navigator.userAgentData
|
|
10
|
+
? gi
|
|
11
|
+
: ai),
|
|
12
|
+
(this.vg = new t()),
|
|
8
13
|
(this.userAgent = navigator.userAgent),
|
|
9
|
-
(this.browser = this.
|
|
10
|
-
(this.version = this.
|
|
14
|
+
(this.browser = this.vg.ef()),
|
|
15
|
+
(this.version = this.vg.ff()),
|
|
11
16
|
(this.OS = null),
|
|
12
17
|
this.Ja().then((t) => (this.OS = t));
|
|
13
18
|
const i = navigator;
|
|
@@ -18,10 +23,10 @@ class di {
|
|
|
18
23
|
i.systemLanguage ||
|
|
19
24
|
""
|
|
20
25
|
).toLowerCase()),
|
|
21
|
-
(this.Pa = di.
|
|
26
|
+
(this.Pa = di.xg(this.userAgent));
|
|
22
27
|
}
|
|
23
28
|
bE() {
|
|
24
|
-
return this.browser ===
|
|
29
|
+
return this.browser === oi.Bg;
|
|
25
30
|
}
|
|
26
31
|
Ka() {
|
|
27
32
|
return this.OS || null;
|
|
@@ -29,15 +34,13 @@ class di {
|
|
|
29
34
|
Ja() {
|
|
30
35
|
return this.OS
|
|
31
36
|
? Promise.resolve(this.OS)
|
|
32
|
-
: this.
|
|
37
|
+
: this.vg.Ja(di.Og).then((t) => ((this.OS = t), t));
|
|
33
38
|
}
|
|
34
|
-
static
|
|
39
|
+
static xg(t) {
|
|
35
40
|
t = t.toLowerCase();
|
|
36
41
|
const i = [
|
|
37
|
-
"
|
|
38
|
-
"bingbot",
|
|
42
|
+
"bot",
|
|
39
43
|
"slurp",
|
|
40
|
-
"duckduckbot",
|
|
41
44
|
"baiduspider",
|
|
42
45
|
"yandex",
|
|
43
46
|
"facebookexternalhit",
|
|
@@ -46,12 +49,9 @@ class di {
|
|
|
46
49
|
"https://github.com/prerender/prerender",
|
|
47
50
|
"aolbuild",
|
|
48
51
|
"bingpreview",
|
|
49
|
-
"msnbot",
|
|
50
|
-
"adsbot",
|
|
51
52
|
"mediapartners-google",
|
|
52
53
|
"teoma",
|
|
53
54
|
"taiko",
|
|
54
|
-
"petalbot",
|
|
55
55
|
"facebookexternalhit",
|
|
56
56
|
"facebookcatalog",
|
|
57
57
|
"meta-webindexer",
|
|
@@ -63,9 +63,9 @@ class di {
|
|
|
63
63
|
return !1;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
di.
|
|
67
|
-
{ string: navigator.platform, cf: "Win", identity: so.
|
|
68
|
-
{ string: navigator.platform, cf: "Mac", identity: so.
|
|
66
|
+
di.Og = [
|
|
67
|
+
{ string: navigator.platform, cf: "Win", identity: so.kg },
|
|
68
|
+
{ string: navigator.platform, cf: "Mac", identity: so.Pg },
|
|
69
69
|
{ string: navigator.platform, cf: "BlackBerry", identity: "BlackBerry" },
|
|
70
70
|
{ string: navigator.platform, cf: "FreeBSD", identity: "FreeBSD" },
|
|
71
71
|
{ string: navigator.platform, cf: "OpenBSD", identity: "OpenBSD" },
|
|
@@ -81,12 +81,14 @@ di.kg = [
|
|
|
81
81
|
{ string: navigator.platform, cf: "Pike v", identity: so.co },
|
|
82
82
|
{ string: navigator.userAgent, cf: ["Web0S"], identity: "WebOS" },
|
|
83
83
|
{ string: navigator.userAgent, cf: "Tizen", identity: "Tizen" },
|
|
84
|
+
{ string: navigator.userAgent, cf: "Coolita", identity: "Other Smart TV" },
|
|
85
|
+
{ string: navigator.userAgent, cf: "WhaleTV", identity: "Other Smart TV" },
|
|
84
86
|
{
|
|
85
87
|
string: navigator.platform,
|
|
86
88
|
cf: ["Linux armv7l", "Android"],
|
|
87
|
-
identity: so.
|
|
89
|
+
identity: so.Dg,
|
|
88
90
|
},
|
|
89
|
-
{ string: navigator.userAgent, cf: ["Android"], identity: so.
|
|
91
|
+
{ string: navigator.userAgent, cf: ["Android"], identity: so.Dg },
|
|
90
92
|
{ string: navigator.platform, cf: "Linux", identity: "Linux" },
|
|
91
93
|
];
|
|
92
94
|
const ro = new di();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ge from "./base-device-parser.js";
|
|
2
|
-
import { Browsers as
|
|
2
|
+
import { Browsers as oi } from "./device-constants.js";
|
|
3
3
|
export default class ai extends ge {
|
|
4
4
|
constructor() {
|
|
5
5
|
if (
|
|
@@ -41,7 +41,7 @@ export default class ai extends ge {
|
|
|
41
41
|
s = this.userAgentData.brands;
|
|
42
42
|
if (s && s.length)
|
|
43
43
|
for (const r of s) {
|
|
44
|
-
const s = this.vc(
|
|
44
|
+
const s = this.vc(oi),
|
|
45
45
|
i = r.brand.match(s);
|
|
46
46
|
if (i && i.length > 0) {
|
|
47
47
|
(t.browser = i[0]), (t.version = r.version);
|
|
@@ -2,12 +2,13 @@ export const Browsers = {
|
|
|
2
2
|
rO: "Chrome",
|
|
3
3
|
eO: "Edge",
|
|
4
4
|
oO: "Opera",
|
|
5
|
-
|
|
5
|
+
Bg: "Safari",
|
|
6
6
|
OO: "Firefox",
|
|
7
|
+
Sg: "ChatGPTBrowser",
|
|
7
8
|
};
|
|
8
9
|
export const OperatingSystems = {
|
|
9
|
-
|
|
10
|
+
Dg: "Android",
|
|
10
11
|
co: "iOS",
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
Pg: "Mac",
|
|
13
|
+
kg: "Windows",
|
|
13
14
|
};
|
|
@@ -3,6 +3,7 @@ import { getUser as ao } from "../Core/get-user.js";
|
|
|
3
3
|
import { BRAZE_MUST_BE_INITIALIZED_ERROR as w } from "../common/constants.js";
|
|
4
4
|
import r from "../managers/braze-instance.js";
|
|
5
5
|
import { keys as C } from "../util/code-utils.js";
|
|
6
|
+
import User from "../User/user.js";
|
|
6
7
|
export const buildBrazeBridge = (t, e) => {
|
|
7
8
|
const o = { display: {}, web: {} },
|
|
8
9
|
requestPushPermission = function () {
|
|
@@ -123,7 +124,9 @@ export const buildBrazeBridge = (t, e) => {
|
|
|
123
124
|
},
|
|
124
125
|
y = o.web;
|
|
125
126
|
for (const t of C(l)) y[t] = p(t);
|
|
126
|
-
return
|
|
127
|
+
return (
|
|
128
|
+
(o.NotificationSubscriptionTypes = User.NotificationSubscriptionTypes), o
|
|
129
|
+
);
|
|
127
130
|
};
|
|
128
131
|
export const applyNonceToDynamicallyCreatedTags = (t, e, r) => {
|
|
129
132
|
const o = `([\\w]+)\\s*=\\s*document.createElement\\(['"]${r}['"]\\)`,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import ge from "./base-device-parser.js";
|
|
2
|
-
import { Browsers as
|
|
3
|
-
export default class
|
|
2
|
+
import { Browsers as oi, OperatingSystems as so } from "./device-constants.js";
|
|
3
|
+
export default class gi extends ge {
|
|
4
4
|
constructor() {
|
|
5
|
-
super(), (this.fd =
|
|
5
|
+
super(), (this.fd = gi.gc(navigator.userAgent || ""));
|
|
6
6
|
}
|
|
7
7
|
ef() {
|
|
8
8
|
return this.fd[0] || "Unknown Browser";
|
|
@@ -13,10 +13,10 @@ export default class oi extends ge {
|
|
|
13
13
|
Ja(r) {
|
|
14
14
|
for (let n = 0; n < r.length; n++) {
|
|
15
15
|
const e = r[n].string;
|
|
16
|
-
let i =
|
|
16
|
+
let i = gi.nf(e, r[n]);
|
|
17
17
|
if (i)
|
|
18
18
|
return (
|
|
19
|
-
i === so.
|
|
19
|
+
i === so.Pg && navigator.maxTouchPoints > 1 && (i = so.co),
|
|
20
20
|
Promise.resolve(i)
|
|
21
21
|
);
|
|
22
22
|
}
|
|
@@ -26,7 +26,7 @@ export default class oi extends ge {
|
|
|
26
26
|
let n,
|
|
27
27
|
e =
|
|
28
28
|
r.match(
|
|
29
|
-
/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i,
|
|
29
|
+
/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chatgptbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i,
|
|
30
30
|
) || [];
|
|
31
31
|
if (-1 !== r.indexOf("(Web0S; Linux/SmartTV)"))
|
|
32
32
|
return ["LG Smart TV", null];
|
|
@@ -40,38 +40,40 @@ export default class oi extends ge {
|
|
|
40
40
|
if (-1 !== r.indexOf("PhilipsTV")) return ["Philips Smart TV", null];
|
|
41
41
|
if (r.match(/\b(Roku)\b/)) return ["Roku", null];
|
|
42
42
|
if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null];
|
|
43
|
+
if (e[1] === oi.rO) {
|
|
44
|
+
if (r.includes(oi.Sg)) return [oi.Sg, e[2]];
|
|
45
|
+
if (
|
|
46
|
+
((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
|
|
47
|
+
null != n)
|
|
48
|
+
)
|
|
49
|
+
return (
|
|
50
|
+
(n = n.slice(1)),
|
|
51
|
+
(n[0] = n[0].replace("OPR", oi.oO)),
|
|
52
|
+
(n[0] = n[0].replace("EdgA", oi.eO)),
|
|
53
|
+
"Edg" === n[0] && (n[0] = oi.eO),
|
|
54
|
+
[n[0], n[1]]
|
|
55
|
+
);
|
|
56
|
+
}
|
|
43
57
|
if (
|
|
44
|
-
e[1] ===
|
|
45
|
-
((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
|
|
46
|
-
null != n)
|
|
47
|
-
)
|
|
48
|
-
return (
|
|
49
|
-
(n = n.slice(1)),
|
|
50
|
-
(n[0] = n[0].replace("OPR", gi.oO)),
|
|
51
|
-
(n[0] = n[0].replace("EdgA", gi.eO)),
|
|
52
|
-
"Edg" === n[0] && (n[0] = gi.eO),
|
|
53
|
-
[n[0], n[1]]
|
|
54
|
-
);
|
|
55
|
-
if (
|
|
56
|
-
e[1] === gi.xg &&
|
|
58
|
+
e[1] === oi.Bg &&
|
|
57
59
|
((n = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != n)
|
|
58
60
|
)
|
|
59
61
|
return (
|
|
60
|
-
(n = n.slice(1)), (n[0] = n[0].replace("EdgiOS",
|
|
62
|
+
(n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", oi.eO)), [n[0], n[1]]
|
|
61
63
|
);
|
|
62
64
|
if (
|
|
63
65
|
((e = e[2] ? [e[1], e[2]] : [null, null]),
|
|
64
|
-
e[0] ===
|
|
66
|
+
e[0] === oi.Bg &&
|
|
65
67
|
null != (n = r.match(/version\/(\.?\d+(\.\d+)*)/i)) &&
|
|
66
68
|
e.splice(1, 1, n[1]),
|
|
67
69
|
null != (n = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) &&
|
|
68
70
|
e.splice(1, 1, n[2]),
|
|
69
|
-
e[0] ===
|
|
71
|
+
e[0] === oi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
|
|
70
72
|
)
|
|
71
73
|
return ["Opera Mini", n[1] || ""];
|
|
72
74
|
if (e[0]) {
|
|
73
75
|
const r = e[0].toLowerCase();
|
|
74
|
-
"crios" === r && (e[0] =
|
|
76
|
+
"crios" === r && (e[0] = oi.rO),
|
|
75
77
|
"tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)),
|
|
76
78
|
"samsungbrowser" === r && (e[0] = "Samsung Browser");
|
|
77
79
|
}
|