Expand description
Telemetry collection compatible with Better Auth @better-auth/telemetry (v1.6.9).
§Environment variables
All telemetry-related variables use the RUSTAUTH_* prefix:
| Purpose | Variable |
|---|---|
| Master switch | RUSTAUTH_TELEMETRY |
| Debug logging (prints JSON instead of POST) | RUSTAUTH_TELEMETRY_DEBUG |
| Collector URL | RUSTAUTH_TELEMETRY_ENDPOINT |
§Enablement precedence
RUSTAUTH_TELEMETRY is a master switch that takes precedence over
TelemetryOptions::enabled:
RUSTAUTH_TELEMETRY=false(or0) is a hard opt-out: telemetry stays off even when application code setsTelemetryOptions::enabled(true).RUSTAUTH_TELEMETRY=true(or1) is an opt-in that enables telemetry on its own, regardless of the options value.- When the variable is unset,
TelemetryOptionsdecides (disabled by default).
Regardless of the switch, telemetry is also suppressed under tests (unless
TelemetryContext::skip_test_check is set).
Unless RUSTAUTH_TELEMETRY_ENDPOINT is set or TelemetryContext::custom_track is provided, the publisher is a no-op: nothing is sent over the network. The maintainer of RustAuth does not receive telemetry by default; whoever deploys the app chooses the endpoint (their own collector, internal analytics, etc.) or wires custom_track.
§Intentional gaps vs upstream
- Framework and database are inferred from the host
Cargo.tomlwhenCARGO_MANIFEST_DIR(or cwd) is available; override withTelemetryContextor [TelemetryTestHooks]. get_telemetry_auth_configemits Better Auth-shaped JSON from modeledRustAuthOptionsbranches; physical table/column names are redacted in telemetry output.- Runtime is reported as
rust(not Node/Bun/Deno). - System metrics
cpuModel,cpuSpeed, andmemorystaynullwithout a platform sysinfo dependency. - HTTP: JSON POST uses
reqwestwhen thehttpfeature is enabled (default). - OAuth/social providers: the
socialProvidersconfig branch is populated only when theoauthfeature is enabled (direct consumers must passfeatures = ["oauth"]; the umbrellarustauthtelemetryfeature enables it).
Parity summary: UPSTREAM.md.
Re-exports§
pub use types::CustomTrackFn;pub use types::TelemetryContext;pub use types::TelemetryEvent;pub use types::TelemetryHttpError;pub use types::TelemetryHttpTransport;
Modules§
- types
- Telemetry types shared with the Better Auth telemetry payload shape.
Structs§
- Telemetry
Publisher - Live telemetry handle (
Self::publishis a no-op when telemetry is disabled).
Constants§
- VERSION
- Current crate version.
Functions§
- create_
telemetry - Creates a telemetry publisher (possibly a hard no-op when neither endpoint nor custom track exist).