Skip to main content

Crate rustauth_telemetry

Crate rustauth_telemetry 

Source
Expand description

Telemetry collection compatible with Better Auth @better-auth/telemetry (v1.6.9).

§Environment variables

All telemetry-related variables use the RUSTAUTH_* prefix:

PurposeVariable
Master switchRUSTAUTH_TELEMETRY
Debug logging (prints JSON instead of POST)RUSTAUTH_TELEMETRY_DEBUG
Collector URLRUSTAUTH_TELEMETRY_ENDPOINT

§Enablement precedence

RUSTAUTH_TELEMETRY is a master switch that takes precedence over TelemetryOptions::enabled:

  • RUSTAUTH_TELEMETRY=false (or 0) is a hard opt-out: telemetry stays off even when application code sets TelemetryOptions::enabled(true).
  • RUSTAUTH_TELEMETRY=true (or 1) is an opt-in that enables telemetry on its own, regardless of the options value.
  • When the variable is unset, TelemetryOptions decides (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.toml when CARGO_MANIFEST_DIR (or cwd) is available; override with TelemetryContext or [TelemetryTestHooks].
  • get_telemetry_auth_config emits Better Auth-shaped JSON from modeled RustAuthOptions branches; physical table/column names are redacted in telemetry output.
  • Runtime is reported as rust (not Node/Bun/Deno).
  • System metrics cpuModel, cpuSpeed, and memory stay null without a platform sysinfo dependency.
  • HTTP: JSON POST uses reqwest when the http feature is enabled (default).
  • OAuth/social providers: the socialProviders config branch is populated only when the oauth feature is enabled (direct consumers must pass features = ["oauth"]; the umbrella rustauth telemetry feature 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§

TelemetryPublisher
Live telemetry handle (Self::publish is 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).