-
Notifications
You must be signed in to change notification settings - Fork 529
feat: add anonymous installation ping to install scripts #6220
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
wolfv
wants to merge
6
commits into
prefix-dev:main
Choose a base branch
from
wolfv:add-install-ping
base: main
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
f044d1f
feat: add anonymous installation ping to install scripts
wolfv f7dac31
docs: document installation ping opt-out
wolfv f247c7d
docs: drop link to external do-not-track site
wolfv d324608
feat: send anonymous ping after self-update
wolfv 91531b6
feat: encode ping metadata into Scarf Page parameter
wolfv a0fbb35
reuse client
wolfv 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,45 @@ fn user_agent() -> String { | |
| format!("pixi {}", consts::PIXI_VERSION) | ||
| } | ||
|
|
||
| /// Send a best-effort anonymous ping after a successful self-update, tagging | ||
| /// the OS, architecture and target version. It never blocks or fails the | ||
| /// update (short timeout, all errors ignored) and is skipped when | ||
| /// `PIXI_NO_TELEMETRY` or `DO_NOT_TRACK` is set. | ||
| async fn send_update_ping( | ||
| client: &reqwest_middleware::ClientWithMiddleware, | ||
| target_version: Option<&Version>, | ||
| ) { | ||
| if std::env::var_os("PIXI_NO_TELEMETRY").is_some() || std::env::var_os("DO_NOT_TRACK").is_some() | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| let version = target_version | ||
| .map(|v| v.to_string()) | ||
| .unwrap_or_else(|| "latest".to_string()); | ||
|
|
||
| // Encode the metadata as a synthetic page URL. Scarf reports on the `Page` | ||
| // dimension (normally inferred from the referrer), so each event/version/ | ||
| // platform combination shows up as its own page in the dashboard. | ||
| let page = format!( | ||
| "https://pixi.sh/ping/self-update/{}/{}-{}", | ||
| version, | ||
| std::env::consts::OS, | ||
| std::env::consts::ARCH, | ||
| ); | ||
|
|
||
| let _ = client | ||
| .get(consts::INSTALL_PING_URL) | ||
| .query(&[ | ||
| ("x-pxid", consts::INSTALL_PING_PXID), | ||
| ("Page", page.as_str()), | ||
| ]) | ||
| .header("User-Agent", user_agent()) | ||
|
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. this is already the default on the passed in client. |
||
| .timeout(std::time::Duration::from_secs(3)) | ||
| .send() | ||
| .await; | ||
| } | ||
|
|
||
| fn default_archive_name() -> Option<String> { | ||
| if cfg!(target_os = "macos") { | ||
| if cfg!(target_arch = "x86_64") { | ||
|
|
@@ -410,6 +449,9 @@ pub async fn execute(args: Args, global_options: &GlobalOptions) -> miette::Resu | |
| tracing::warn!(fetch_release_warning); | ||
| } | ||
|
|
||
| // Best-effort anonymous ping; must not affect the update result. | ||
| send_update_ping(&client, target_version.as_ref()).await; | ||
|
|
||
| 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.
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.
Should we add a comment to tell we explicitly dont care if this fails?