-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add telemetry and cli features (#2964)
* users may opt-out at any time * provide a CLI interface for checking current telemetry status, toggling participation * measure tasks that the Stencil CLI performs today, anonymize data, and send to Ionic for aggregation
- Loading branch information
1 parent
bdd9d6f
commit 1381cc7
Showing
17 changed files
with
743 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { getCompilerSystem, getLogger, getStencilCLIConfig } from './state/stencil-cli-config'; | ||
import { checkTelemetry, disableTelemetry, enableTelemetry } from './telemetry/telemetry'; | ||
|
||
export const taskTelemetry = async () => { | ||
const logger = getLogger(); | ||
const prompt = logger.dim(getCompilerSystem().details.platform === 'windows' ? '>' : '$'); | ||
const isEnabling = getStencilCLIConfig().flags.args.includes('on'); | ||
const isDisabling = getStencilCLIConfig().flags.args.includes('off'); | ||
const INFORMATION = `Opt in or our of telemetry. Information about the data we collect is available on our website: ${logger.bold( | ||
'https://stenciljs.com/telemetry', | ||
)}`; | ||
const THANK_YOU = `Thank you for helping to make Stencil better! 💖`; | ||
const ENABLED_MESSAGE = `${logger.green('Enabled')}. ${THANK_YOU}\n\n`; | ||
const DISABLED_MESSAGE = `${logger.red('Disabled')}\n\n`; | ||
const hasTelemetry = await checkTelemetry(); | ||
|
||
if (isEnabling) { | ||
const result = await enableTelemetry(); | ||
result | ||
? console.log(`\n ${logger.bold('Telemetry is now ') + ENABLED_MESSAGE}`) | ||
: console.log(`Something went wrong when enabling Telemetry.`); | ||
return; | ||
} | ||
|
||
if (isDisabling) { | ||
const result = await disableTelemetry(); | ||
result | ||
? console.log(`\n ${logger.bold('Telemetry is now ') + DISABLED_MESSAGE}`) | ||
: console.log(`Something went wrong when disabling Telemetry.`); | ||
return; | ||
} | ||
|
||
console.log(` ${logger.bold('Telemetry:')} ${logger.dim(INFORMATION)}`); | ||
|
||
console.log(`\n ${logger.bold('Status')}: ${hasTelemetry ? ENABLED_MESSAGE : DISABLED_MESSAGE}`); | ||
|
||
console.log(` ${prompt} ${logger.green('stencil telemetry [off|on]')} | ||
${logger.cyan('off')} ${logger.dim('.............')} Disable sharing anonymous usage data | ||
${logger.cyan('on')} ${logger.dim('..............')} Enable sharing anonymous usage data | ||
`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { isInteractive } from './helpers'; | ||
import { checkTelemetry } from './telemetry'; | ||
|
||
/** | ||
* Used to determine if tracking should occur. | ||
* @param ci whether or not the process is running in a Continuous Integration (CI) environment | ||
* @returns true if telemetry should be sent, false otherwise | ||
*/ | ||
export async function shouldTrack(ci?: boolean) { | ||
return !ci && isInteractive() && (await checkTelemetry()); | ||
} |
Oops, something went wrong.