Skip to content

Commit 05be1f7

Browse files
chore: DOC-1516 change to text/plain (#5009)
* chore: DOC-1516 change to text/plain * chore: move to scripts * chore: removed headtags and migrated to scripts * chore: add head tags for preloading user-centrick scripts * docs: update comments (cherry picked from commit e48e4d9)
1 parent 8ca1758 commit 05be1f7

File tree

2 files changed

+175
-92
lines changed

2 files changed

+175
-92
lines changed

docusaurus.config.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,51 +51,26 @@ const config = {
5151
},
5252
staticDirectories: ["static", "static/assets/docs/images", "static/assets", "static/img/"],
5353
headTags: [
54-
{
55-
tagName: "script",
56-
attributes: {
57-
type: "text/plain",
58-
"data-usercentrics": "FullStory",
59-
src: "/scripts/fullstory.js",
60-
},
61-
},
6254
{
6355
tagName: "link",
6456
attributes: {
6557
rel: "preconnect",
6658
href: "https://api.usercentrics.eu",
6759
},
6860
},
69-
{
70-
tagName: "link",
71-
attributes: {
72-
rel: "preload",
73-
href: "https://app.usercentrics.eu/browser-ui/latest/loader.js",
74-
as: "script",
75-
},
76-
},
77-
{
78-
tagName: "script",
79-
attributes: {
80-
src: "https://app.usercentrics.eu/browser-ui/latest/loader.js",
81-
"data-settings-id": "0IhiFXOBwy0Z2U",
82-
id: "usercentrics-cmp",
83-
async: "true",
84-
},
85-
},
8661
{
8762
tagName: "link",
8863
attributes: {
8964
rel: "preconnect",
90-
href: "https://www.googletagmanager.com",
65+
href: "https://app.usercentrics.eu",
9166
},
9267
},
9368
{
94-
tagName: "script",
69+
tagName: "link",
9570
attributes: {
96-
type: "text/javascript",
97-
"data-usercentrics": "Google Tag Manager",
98-
src: "/scripts/googleTagManager.js",
71+
rel: "preload",
72+
href: "app.usercentrics.eu/browser-ui/latest/loader.js",
73+
as: "script",
9974
},
10075
},
10176
],
@@ -258,11 +233,38 @@ const config = {
258233
},
259234
],
260235
].filter(Boolean),
236+
/* IMPORTANT
237+
Any script added below must have the "data-usercentrics" attribute with the name of the script as the value.
238+
We also need to notify marketing about the script being added so that they can update the Usercentrics CMP.
239+
Marketing needs to know what to label the script as, for example Analytics, Marketing, etc. And, if it's essential or not.
240+
Essential scripts are always loaded, non-essential scripts are loaded based on user consent.
241+
This is used to identify the script for Usercentrics CMP.
242+
Scripts also need to have the type attribute set to "text/plain" to prevent them from being executed by the browser in the event that the user has not given consent to the script.
243+
The exception to the text/plain rule is the Usercentrics CMP script which must be loaded as a script tag.
244+
To learn more about attributes and values, visit https://docs.usercentrics.com/#/direct-implementation-guide?id=change-script-type-textjavascript-becomes-textplain
245+
*/
261246
scripts: [
262247
{
263248
src: `https://w.appzi.io/w.js?token=${process.env.APPZI_TOKEN}`,
264249
defer: true,
265250
},
251+
{
252+
src: "/scripts/fullstory.js",
253+
type: "text/plain",
254+
"data-usercentrics": "FullStory",
255+
},
256+
{
257+
type: "text/plain",
258+
src: "/scripts/googleTagManager.js",
259+
"data-usercentrics": "Google Tag Manager",
260+
},
261+
{
262+
src: "https://app.usercentrics.eu/browser-ui/latest/loader.js",
263+
id: "usercentrics-cmp",
264+
async: "true",
265+
"data-settings-id": "0IhiFXOBwy0Z2U",
266+
type: "text/javascript",
267+
},
266268
],
267269
themes: ["docusaurus-theme-openapi-docs"],
268270
customFields: {

static/scripts/fullstory.js

Lines changed: 143 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,149 @@
1-
window["_fs_debug"] = false;
21
window["_fs_host"] = "fullstory.com";
32
window["_fs_script"] = "edge.fullstory.com/s/fs.js";
43
window["_fs_org"] = "11NJ6J";
54
window["_fs_namespace"] = "FS";
6-
(function (m, n, e, t, l, o, g, y) {
7-
if (e in m) {
8-
if (m.console && m.console.log) {
9-
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');
5+
!(function (m, n, e, t, l, o, g, y) {
6+
var s,
7+
f,
8+
a = (function (h) {
9+
return (
10+
!(h in m) ||
11+
(m.console &&
12+
m.console.log &&
13+
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].'),
14+
!1)
15+
);
16+
})(e);
17+
function p(b) {
18+
var h,
19+
d = [];
20+
function j() {
21+
h &&
22+
(d.forEach(function (b) {
23+
var d;
24+
try {
25+
d = b[h[0]] && b[h[0]](h[1]);
26+
} catch (h) {
27+
return void (b[3] && b[3](h));
28+
}
29+
d && d.then ? d.then(b[2], b[3]) : b[2] && b[2](d);
30+
}),
31+
(d.length = 0));
1032
}
11-
return;
33+
function r(b) {
34+
return function (d) {
35+
h || ((h = [b, d]), j());
36+
};
37+
}
38+
return (
39+
b(r(0), r(1)),
40+
{
41+
then: function (b, h) {
42+
return p(function (r, i) {
43+
d.push([b, h, r, i]), j();
44+
});
45+
},
46+
}
47+
);
1248
}
13-
g = m[e] = function (a, b, s) {
14-
g.q ? g.q.push([a, b, s]) : g._api(a, b, s);
15-
};
16-
g.q = [];
17-
o = n.createElement(t);
18-
o.async = 1;
19-
o.crossOrigin = "anonymous";
20-
o.src = "https://" + window["_fs_script"];
21-
y = n.getElementsByTagName(t)[0];
22-
y.parentNode.insertBefore(o, y);
23-
g.identify = function (i, v, s) {
24-
g(l, { uid: i }, s);
25-
if (v) g(l, v, s);
26-
};
27-
g.setUserVars = function (v, s) {
28-
g(l, v, s);
29-
};
30-
g.event = function (i, v, s) {
31-
g("event", { n: i, p: v }, s);
32-
};
33-
g.anonymize = function () {
34-
g.identify(!!0);
35-
};
36-
g.shutdown = function () {
37-
g("rec", !1);
38-
};
39-
g.restart = function () {
40-
g("rec", !0);
41-
};
42-
g.log = function (a, b) {
43-
g("log", [a, b]);
44-
};
45-
g.consent = function (a) {
46-
g("consent", !arguments.length || a);
47-
};
48-
g.identifyAccount = function (i, v) {
49-
o = "account";
50-
v = v || {};
51-
v.acctId = i;
52-
g(o, v);
53-
};
54-
g.clearUserCookie = function () {};
55-
g.setVars = function (n, p) {
56-
g("setVars", [n, p]);
57-
};
58-
g._w = {};
59-
y = "XMLHttpRequest";
60-
g._w[y] = m[y];
61-
y = "fetch";
62-
g._w[y] = m[y];
63-
if (m[y])
64-
m[y] = function () {
65-
return g._w[y].apply(this, arguments);
66-
};
67-
g._v = "1.3.0";
68-
})(window, document, window["_fs_namespace"], "script", "user");
49+
a &&
50+
((g = m[e] =
51+
(function () {
52+
var b = function (b, d, j, r) {
53+
function i(i, c) {
54+
h(b, d, j, i, c, r);
55+
}
56+
r = r || 2;
57+
var c,
58+
u = /Async$/;
59+
return u.test(b)
60+
? ((b = b.replace(u, "")), "function" == typeof Promise ? new Promise(i) : p(i))
61+
: h(b, d, j, c, c, r);
62+
};
63+
function h(h, d, j, r, i, c) {
64+
return b._api ? b._api(h, d, j, r, i, c) : (b.q && b.q.push([h, d, j, r, i, c]), null);
65+
}
66+
return (b.q = []), b;
67+
})()),
68+
(y = function (b) {
69+
function h(h) {
70+
"function" == typeof h[4] && h[4](new Error(b));
71+
}
72+
var d = g.q;
73+
if (d) {
74+
for (var j = 0; j < d.length; j++) h(d[j]);
75+
(d.length = 0), (d.push = h);
76+
}
77+
}),
78+
(function () {
79+
((o = n.createElement(t)).async = !0),
80+
(o.crossOrigin = "anonymous"),
81+
(o.src = "https://" + l),
82+
(o.onerror = function () {
83+
y("Error loading " + l);
84+
});
85+
var b = n.getElementsByTagName(t)[0];
86+
b && b.parentNode ? b.parentNode.insertBefore(o, b) : n.head.appendChild(o);
87+
})(),
88+
(function () {
89+
function b() {}
90+
function h(b, h, d) {
91+
g(b, h, d, 1);
92+
}
93+
function d(b, d, j) {
94+
h("setProperties", { type: b, properties: d }, j);
95+
}
96+
function j(b, h) {
97+
d("user", b, h);
98+
}
99+
function r(b, h, d) {
100+
j(
101+
{
102+
uid: b,
103+
},
104+
d
105+
),
106+
h && j(h, d);
107+
}
108+
(g.identify = r),
109+
(g.setUserVars = j),
110+
(g.identifyAccount = b),
111+
(g.clearUserCookie = b),
112+
(g.setVars = d),
113+
(g.event = function (b, d, j) {
114+
h(
115+
"trackEvent",
116+
{
117+
name: b,
118+
properties: d,
119+
},
120+
j
121+
);
122+
}),
123+
(g.anonymize = function () {
124+
r(!1);
125+
}),
126+
(g.shutdown = function () {
127+
h("shutdown");
128+
}),
129+
(g.restart = function () {
130+
h("restart");
131+
}),
132+
(g.log = function (b, d) {
133+
h("log", { level: b, msg: d });
134+
}),
135+
(g.consent = function (b) {
136+
h("setIdentity", { consent: !arguments.length || b });
137+
});
138+
})(),
139+
(s = "fetch"),
140+
(f = "XMLHttpRequest"),
141+
(g._w = {}),
142+
(g._w[f] = m[f]),
143+
(g._w[s] = m[s]),
144+
m[s] &&
145+
(m[s] = function () {
146+
return g._w[s].apply(this, arguments);
147+
}),
148+
(g._v = "2.0.0"));
149+
})(window, document, window._fs_namespace, "script", window._fs_script);

0 commit comments

Comments
 (0)