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

@@ -1275,5 +1275,15 @@
"environment": "Environment",
"header": "Global Environment Variables",
"revert": "Revert"
},
"telemetry": {
"label": "Telemetry",
"settingsTitle": "Share Anonymous Usage Information",
"settingsDescription": "<p>Node-RED would like to send anonymous usage data back to the Node-RED team. This information helps us to understand how it is used.</p><p>For full information on what information is collected and how it is used, please see the <a href=\"https://nodered.org/docs/telemetry\" target=\"_blank\">telemetry documentation</a>.</p>",
"settingsDescription2": "<p>You can change this setting at any time in the editor settings.</p>",
"enableLabel": "Yes, send my usage data",
"disableLabel": "No, do not send my usage data",
"updateAvailable": "Update available",
"updateAvailableDesc": "Node-RED __version__ is now available"
}
}

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();