-
Notifications
You must be signed in to change notification settings - Fork 150
feat: opt in telemetry through fuelup #821
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
kayagokalp
wants to merge
6
commits into
master
Choose a base branch
from
kayagokalp/fuelupopt-in
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,87 @@ | ||
| use crate::fmt::{bold, colored_bold}; | ||
| use crate::telemetry::{get_telemetry_status, set_telemetry_status, TelemetryStatus}; | ||
| use anyhow::Result; | ||
| use clap::Parser; | ||
| use tracing::info; | ||
|
|
||
| #[derive(Debug, Parser)] | ||
| pub enum TelemetryCommand { | ||
| /// Show the current telemetry status | ||
| Status, | ||
| /// Enable telemetry (opt-in) | ||
| Enable, | ||
| /// Disable telemetry (opt-out) | ||
| Disable, | ||
| } | ||
|
|
||
| pub fn exec(command: TelemetryCommand) -> Result<()> { | ||
| match command { | ||
| TelemetryCommand::Status => show_status(), | ||
| TelemetryCommand::Enable => enable(), | ||
| TelemetryCommand::Disable => disable(), | ||
| } | ||
| } | ||
|
|
||
| fn show_status() -> Result<()> { | ||
| match get_telemetry_status()? { | ||
| Some(TelemetryStatus::Enabled) => { | ||
| info!( | ||
| "Telemetry is {}", | ||
| colored_bold(ansiterm::Color::Green, "enabled") | ||
| ); | ||
| info!(""); | ||
| info!("Telemetry helps improve the Fuel toolchain by collecting usage data."); | ||
| info!("To disable, run: {}", bold("fuelup telemetry disable")); | ||
| } | ||
| Some(TelemetryStatus::Disabled) => { | ||
| info!( | ||
| "Telemetry is {}", | ||
| colored_bold(ansiterm::Color::Yellow, "disabled") | ||
| ); | ||
| info!(""); | ||
| info!("Telemetry is currently disabled. No usage data will be collected."); | ||
| info!("To enable, run: {}", bold("fuelup telemetry enable")); | ||
| } | ||
| None => { | ||
| info!( | ||
| "Telemetry status is {}", | ||
| colored_bold(ansiterm::Color::Yellow, "not set") | ||
| ); | ||
| info!(""); | ||
| info!("Telemetry preference has not been set. It will be disabled by default."); | ||
| info!("To enable, run: {}", bold("fuelup telemetry enable")); | ||
| info!("To disable, run: {}", bold("fuelup telemetry disable")); | ||
| } | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn enable() -> Result<()> { | ||
| set_telemetry_status(TelemetryStatus::Enabled)?; | ||
| info!( | ||
| "Telemetry has been {}", | ||
| colored_bold(ansiterm::Color::Green, "enabled") | ||
| ); | ||
| info!(""); | ||
| info!("Thank you for helping improve the Fuel toolchain!"); | ||
| info!( | ||
| "To disable at any time, run: {}", | ||
| bold("fuelup telemetry disable") | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn disable() -> Result<()> { | ||
| set_telemetry_status(TelemetryStatus::Disabled)?; | ||
| info!( | ||
| "Telemetry has been {}", | ||
| colored_bold(ansiterm::Color::Yellow, "disabled") | ||
| ); | ||
| info!(""); | ||
| info!("Telemetry will no longer collect usage data."); | ||
| info!( | ||
| "To enable at any time, run: {}", | ||
| bold("fuelup telemetry enable") | ||
| ); | ||
| Ok(()) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell script missing case pattern for "nO" input
Low Severity
The case statement handling the telemetry prompt response explicitly enumerates case variations of "no" (
"n" | "N" | "no" | "No" | "NO") but is missing"nO". If a user typesnO, it falls through to the default*case and enables telemetry, contrary to the user's intent to decline. The Rust implementation handles this correctly by converting input to lowercase before matching.