-
Notifications
You must be signed in to change notification settings - Fork 34
Make usage telemetry opt-in and scrub network/path data #250
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import argparse | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from typing import Optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| from timecapsulesmb.identity import default_bootstrap_path, load_install_identity, set_telemetry_enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def main(argv: Optional[list[str]] = None) -> int: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| parser = argparse.ArgumentParser(description="Enable or disable anonymous usage telemetry.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| group = parser.add_mutually_exclusive_group() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| group.add_argument("--enable", action="store_true", help="Enable telemetry") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| group.add_argument("--disable", action="store_true", help="Disable telemetry") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| group.add_argument("--status", action="store_true", help="Only report the current setting") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| args = parser.parse_args(argv) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| path = default_bootstrap_path() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if args.status: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| identity = load_install_identity(path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"telemetry: {'enabled' if identity.telemetry_enabled else 'disabled'}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not args.enable and not args.disable: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| parser.error("select --enable, --disable, or --status") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of manually checking if none of the arguments were provided on lines 23-24, you can make the mutually exclusive group required by passing
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| identity = set_telemetry_enabled(bool(args.enable), path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"telemetry: {'enabled' if identity.telemetry_enabled else 'disabled'}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
In the current implementation,
ensure_install_id(bootstrap_path)is called on line 441 before prompting the user for their telemetry choice on line 443.If the user interrupts the bootstrap process (e.g., via
Ctrl+C/KeyboardInterrupt) during the telemetry prompt, the.bootstrapfile will have already been written with a generatedINSTALL_IDandTELEMETRY=false. On any subsequent run,first_runwill evaluate toFalse, meaning the user will never be prompted again, and telemetry will remain silently disabled without their explicit choice.By checking
first_runand prompting the user before writing the bootstrap file, we ensure that an interrupted first run can be safely retried and prompted again on the next run.