diff --git a/CHANGELOG.md b/CHANGELOG.md index 0473547..d7b24b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 4.1.0 + + - Add telemetry consent to init command @knolleary + ### 4.0.2 - Update dependencies @knolleary diff --git a/lib/commands/init/index.js b/lib/commands/init/index.js index ca3a7e0..6f7701e 100644 --- a/lib/commands/init/index.js +++ b/lib/commands/init/index.js @@ -94,6 +94,30 @@ async function promptSettingsFile(opts) { return responses; } +async function promptTelemetry() { + heading("Share Anonymouse Usage Information"); + + const responses = await prompt([ + { + type: 'select', + name: 'telemetryEnabled', + // initial: "Yes", + message: `Node-RED can notify you when there is a new version available. +This ensures you keep up to date with the latest features and fixes. +This requires sending anonymised data back to the Node-RED team. +It does not include any details of your flows or users. +For full information on what information is collected and how it is used, +please see https://nodered.org/docs/telemetry +`, + choices: ['Yes, send my usage data', 'No, do not send my usage data'], + result(value) { + return /Yes/.test(value) + } + } + ]) + return responses +} + async function promptUser() { const responses = await prompt([ { @@ -279,6 +303,9 @@ async function command(argv, result) { const fileSettings = await promptSettingsFile({userDir}); + const telemetryResponses = await promptTelemetry() + config.telemetryEnabled = telemetryResponses.telemetryEnabled ? 'true' : 'false' + const securityResponses = await promptSecurity(); if (securityResponses.adminAuth) { let adminAuth = { diff --git a/lib/commands/init/resources/settings.js.mustache b/lib/commands/init/resources/settings.js.mustache index 8b66161..e103531 100644 --- a/lib/commands/init/resources/settings.js.mustache +++ b/lib/commands/init/resources/settings.js.mustache @@ -276,6 +276,7 @@ module.exports = { * Runtime Settings * - lang * - runtimeState + * - telemetry * - diagnostics * - logging * - contextStorage @@ -313,6 +314,23 @@ module.exports = { enabled: false, /** show or hide runtime stop/start options in the node-red editor. Must be set to `false` to hide */ ui: false, + }, + telemetry: { + /** + * By default, telemetry is disabled until the user provides consent the first + * time they open the editor. + * + * The following property can be uncommented and set to true/false to enable/disable + * telemetry without seeking further consent in the editor. + * The user can override this setting via the user settings dialog within the editor + */ + {{^telemetryEnabled}}//enabled: true,{{/telemetryEnabled}} + {{#telemetryEnabled}}enabled: {{telemetryEnabled}},{{/telemetryEnabled}} + /** + * If telemetry is enabled, the editor will notify the user if a new version of Node-RED + * is available. Set the following property to false to disable this notification. + */ + // updateNotification: true }, /** Configure the logging output */ logging: { diff --git a/package.json b/package.json index 508aeeb..a5a1729 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-admin", - "version": "4.0.2", + "version": "4.1.0", "description": "The Node-RED admin command line interface", "homepage": "https://nodered.org", "bugs": {