Skip to content

Commit dd2b414

Browse files
authored
Merge pull request compiler-explorer#1570 from mattgodbolt/analytixfix
[WIP] Analytics maybe fix
2 parents 0e45d1f + f3f4096 commit dd2b414

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

static/main.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ function setupSettings(hub) {
100100
return currentSettings;
101101
}
102102

103+
function hasCookieConsented(options) {
104+
return jsCookie.get(options.policies.cookies.key) === options.policies.cookies.hash;
105+
}
106+
103107
function setupButtons(options) {
104108
var alertSystem = new Alert();
105109

@@ -117,14 +121,12 @@ function setupButtons(options) {
117121
}
118122
});
119123
}
120-
var hasCookieConsented = function () {
121-
return jsCookie.get(options.policies.cookies.key) === options.policies.cookies.hash;
122-
};
124+
123125
if (options.policies.cookies.enabled) {
124126
var getCookieTitle = function () {
125127
return 'Cookies & related technologies policy<br><p>Current consent status: <span style="color:' +
126-
(hasCookieConsented() ? 'green' : 'red') + '">' +
127-
(hasCookieConsented() ? 'Granted' : 'Denied') + '</span></p>';
128+
(hasCookieConsented(options) ? 'green' : 'red') + '">' +
129+
(hasCookieConsented(options) ? 'Granted' : 'Denied') + '</span></p>';
128130
};
129131
$('#cookies').click(function () {
130132
alertSystem.ask(getCookieTitle(), $(require('./policies/cookies.html')), {
@@ -225,6 +227,8 @@ function initPolicies(options) {
225227
if (options.policies.cookies.enabled && storedCookieConsent !== '' &&
226228
options.policies.cookies.hash !== storedCookieConsent) {
227229
simpleCooks.show();
230+
} else if (options.policies.cookies.enabled && hasCookieConsented(options)) {
231+
analytics.initialise();
228232
}
229233
}
230234

0 commit comments

Comments
 (0)