Skip to content

Commit b6c1764

Browse files
Attempt to fix OneTrust+Segment setup. (#1373)
1 parent a5023d5 commit b6c1764

File tree

2 files changed

+33
-36
lines changed

2 files changed

+33
-36
lines changed

pages/_document.js

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,7 @@ export default function StreamlitDocument() {
1111
charset="UTF-8"
1212
data-domain-script="01990a3a-a865-7092-a22e-9094bfac985a"
1313
></script>
14-
<script type="text/javascript">
15-
{`
16-
function OptanonWrapper() { }
17-
18-
function getCookie(name) {
19-
var value = "; " + document.cookie;
20-
var parts = value.split("; " + name + "=");
21-
if (parts.length == 2) {
22-
return true;
23-
}
24-
}
25-
26-
function reloadOTBanner() {
27-
var otConsentSdk = document.getElementById("onetrust-consent-sdk");
28-
if (otConsentSdk) {
29-
otConsentSdk.remove();
30-
}
31-
32-
if (window.OneTrust != null) {
33-
OneTrust.Init();
34-
35-
setTimeout(function() {
36-
OneTrust.LoadBanner();
37-
38-
var toggleDisplay = document.getElementsByClassName("ot-sdk-show-settings");
39-
for (var i = 0; i < toggleDisplay.length; i++) {
40-
toggleDisplay[i].onclick = function(event) {
41-
event.stopImmediatePropagation();
42-
window.OneTrust.ToggleInfoDisplay();
43-
};
44-
}
45-
}, 1000);
46-
}
47-
}
48-
`}
49-
</script>
14+
<script src="/scripts/onetrustsetup.js"></script>
5015
{/* Segment's OneTrust Consent Wrapper */}
5116
<script src="https://cdn.jsdelivr.net/npm/@segment/analytics-consent-wrapper-onetrust@latest/dist/umd/analytics-onetrust.umd.js"></script>
5217
{/* Segment Analytics Snippet */}

public/scripts/onetrustsetup.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function OptanonWrapper() { }
2+
3+
function getCookie(name) {
4+
var value = "; " + document.cookie;
5+
var parts = value.split("; " + name + "=");
6+
if (parts.length == 2) {
7+
return true;
8+
}
9+
}
10+
11+
function reloadOTBanner() {
12+
var otConsentSdk = document.getElementById("onetrust-consent-sdk");
13+
if (otConsentSdk) {
14+
otConsentSdk.remove();
15+
}
16+
17+
if (window.OneTrust != null) {
18+
OneTrust.Init();
19+
20+
setTimeout(function() {
21+
OneTrust.LoadBanner();
22+
23+
var toggleDisplay = document.getElementsByClassName("ot-sdk-show-settings");
24+
for (var i = 0; i < toggleDisplay.length; i++) {
25+
toggleDisplay[i].onclick = function(event) {
26+
event.stopImmediatePropagation();
27+
window.OneTrust.ToggleInfoDisplay();
28+
};
29+
}
30+
}, 1000);
31+
}
32+
}

0 commit comments

Comments
 (0)