Add telemetry consent dialog

This commit is contained in:
Nick O'Leary
2025-04-23 17:34:52 +01:00
parent bd244027c6
commit 36f533f390
2 changed files with 45 additions and 6 deletions

View File

@@ -672,14 +672,43 @@ var RED = (function() {
setTimeout(function() {
loader.end();
checkFirstRun(function() {
if (showProjectWelcome) {
RED.projects.showStartup();
}
});
checkTelemetry(function () {
checkFirstRun(function() {
if (showProjectWelcome) {
RED.projects.showStartup();
}
});
})
},100);
}
function checkTelemetry(done) {
const telemetrySettings = RED.settings.telemetryEnabled;
// Can only get telemetry permission from a user with permission to modify settings
if (RED.user.hasPermission("settings.write") && telemetrySettings === undefined) {
function completeTelemetry(enable) {
RED.settings.set("telemetryEnabled", enable)
dialog.close()
done()
}
const dialog = RED.popover.dialog({
title: RED._("telemetry.settingsTitle"),
content: `${RED._("telemetry.settingsDescription")}${RED._("telemetry.settingsDescription2")}`,
closeButton: false,
buttons: [
{
text: RED._("telemetry.enableLabel"),
click: () => completeTelemetry(true)
},
{
text: RED._("telemetry.disableLabel"),
click: () => completeTelemetry(false)
}
]
})
} else {
done()
}
}
function checkFirstRun(done) {
if (RED.settings.theme("tours") === false) {
done();