Skip to content

Commit 4e5d87e

Browse files
committed
Add usage telemetry question to admin init command
1 parent f92344f commit 4e5d87e

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

lib/commands/init/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,27 @@ async function promptSettingsFile(opts) {
9494
return responses;
9595
}
9696

97+
async function promptTelemetry() {
98+
heading("Share Anonymouse Usage Information");
99+
100+
const responses = await prompt([
101+
{
102+
type: 'select',
103+
name: 'telemetryEnabled',
104+
// initial: "Yes",
105+
message: `Node-RED would like to send anonymous usage data back to the Node-RED team.
106+
This information helps us to understand how it is used.
107+
For full information on what information is collected and how it is used,
108+
please see https://nodered.org/docs/telemetry`,
109+
choices: ['Yes, send my usage data', 'No, do not send my usage data'],
110+
result(value) {
111+
return /Yes/.test(value)
112+
}
113+
}
114+
])
115+
return responses
116+
}
117+
97118
async function promptUser() {
98119
const responses = await prompt([
99120
{
@@ -279,6 +300,9 @@ async function command(argv, result) {
279300

280301
const fileSettings = await promptSettingsFile({userDir});
281302

303+
const telemetryResponses = await promptTelemetry()
304+
config.telemetryEnabled = telemetryResponses.telemetryEnabled ? 'true' : 'false'
305+
282306
const securityResponses = await promptSecurity();
283307
if (securityResponses.adminAuth) {
284308
let adminAuth = {

lib/commands/init/resources/settings.js.mustache

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ module.exports = {
276276
* Runtime Settings
277277
* - lang
278278
* - runtimeState
279+
* - telemetry
279280
* - diagnostics
280281
* - logging
281282
* - contextStorage
@@ -313,6 +314,23 @@ module.exports = {
313314
enabled: false,
314315
/** show or hide runtime stop/start options in the node-red editor. Must be set to `false` to hide */
315316
ui: false,
317+
},
318+
telemetry: {
319+
/**
320+
* By default, telemetry is disabled until the user provides consent the first
321+
* time they open the editor.
322+
*
323+
* The following property can be uncommented and set to true/false to enable/disable
324+
* telemetry without seeking further consent in the editor.
325+
* The user can override this setting via the user settings dialog within the editor
326+
*/
327+
{{^telemetryEnabled}}//enabled: true,{{/telemetryEnabled}}
328+
{{#telemetryEnabled}}enabled: {{telemetryEnabled}},{{/telemetryEnabled}}
329+
/**
330+
* If telemetry is enabled, the editor will notify the user if a new version of Node-RED
331+
* is available. Set the following property to false to disable this notification.
332+
*/
333+
// updateNotification: true
316334
},
317335
/** Configure the logging output */
318336
logging: {

0 commit comments

Comments
 (0)