Skip to content

Add usage telemetry question to admin init command #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/commands/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@ 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 would like to send anonymous usage data back to the Node-RED team.
This information helps us to understand how it is used.
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([
{
Expand Down Expand Up @@ -279,6 +302,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 = {
Expand Down
18 changes: 18 additions & 0 deletions lib/commands/init/resources/settings.js.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ module.exports = {
* Runtime Settings
* - lang
* - runtimeState
* - telemetry
* - diagnostics
* - logging
* - contextStorage
Expand Down Expand Up @@ -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: {
Expand Down