feat(telemetry): grab env and distinct_id from Sentry session (#9801)

At present, our primary indicator as to whether telemetry is active is
whether we have a Sentry session. For our analytics events however, we
currently require passing in the Firezone ID and API url again. This
makes it difficult to send analytics events from areas of the code that
don't have this information available.

To still allow for that, we integrate the `analytics` module more
tightly with the Sentry session. This allows us to drop two parameters
from the `$identify` event and also means we now respect the
`NO_TELEMETRY` setting for these events except for `new_session`. This
event is sent regardless because it allows us to track, how many on-prem
installations of Firezone are out there.
This commit is contained in:
Thomas Eizinger
2025-07-10 22:05:08 +02:00
committed by GitHub
parent 704ff9fd7a
commit 04499da11e
9 changed files with 84 additions and 102 deletions

View File

@@ -179,13 +179,6 @@ fn main() -> Result<()> {
None => device_id::get_or_create().context("Could not get `firezone_id` from CLI, could not read it from disk, could not generate it and save it to disk")?.id,
};
analytics::identify(
firezone_id.clone(),
cli.api_url.to_string(),
RELEASE.to_owned(),
None,
);
let mut telemetry = Telemetry::default();
if cli.is_telemetry_allowed() {
rt.block_on(telemetry.start(
@@ -194,6 +187,8 @@ fn main() -> Result<()> {
firezone_telemetry::HEADLESS_DSN,
firezone_id.clone(),
));
analytics::identify(RELEASE.to_owned(), None);
}
tracing::info!(arch = std::env::consts::ARCH, version = VERSION);