遥测

Better Auth 收集匿名使用数据以帮助我们改进项目。这是可选的,透明的,并且默认关闭。

【Better Auth collects anonymous usage data to help us improve the project. This is optional, transparent, and disabled by default.】

为什么要收集遥测数据?

【Why is telemetry collected?】

自 v1.3.5 起,如果启用,Better Auth 会收集有关一般使用情况的匿名遥测数据。

【Since v1.3.5, Better Auth collects anonymous telemetry data about general usage if enabled.】

遥测数据帮助我们了解 Better Auth 在不同环境中的使用情况,从而改进性能、优先开发功能,并更有效地修复问题。这些数据指导我们在性能优化、功能开发和漏洞修复方面的决策。所有数据的收集都是完全匿名的,并注重隐私,用户可以随时选择退出。我们努力使所收集的数据尽可能透明。

【Telemetry data helps us understand how Better Auth is being used across different environments so we can improve performance, prioritize features, and fix issues more effectively. It guides our decisions on performance optimizations, feature development, and bug fixes. All data is collected completely anonymously and with privacy in mind, and users can opt out at any time. We strive to keep what we collect as transparent as possible.】

正在收集什么?

【What is being collected?】

以下数据点可能会被报告。所有信息都是匿名的,仅用于汇总分析。

【The following data points may be reported. Everything is anonymous and intended for aggregate insights only.】

  • 匿名标识符:一个不可逆的哈希值,由你的项目(package.json 名称和可选的 baseURL)生成。这使我们能够在不知道你身份的情况下,对每个项目的事件进行去重。
  • 运行时{ name: "node" | "bun" | "deno", version }
  • 环境:可选值为 developmentproductiontestci
  • 框架(如果检测到):像 Next.js、Nuxt、Remix、Astro、SvelteKit 等框架的 { name, version }
  • 数据库(如果检测到):用于 PostgreSQL、MySQL、SQLite、Prisma、Drizzle、MongoDB 等集成的 { name, version }
  • 系统信息:平台、操作系统版本、架构、CPU 数量/型号/速度、总内存,以及诸如 isDockerisWSLisTTY 的标志。
  • 包管理器{ name, version },来源于 npm 用户代理。
  • 已编辑的身份验证配置快照:由 getTelemetryAuthConfig 生成的 betterAuth 选项的简化、隐私保护视图。

我们还会从命令行接口收集匿名遥测数据:

【We also collect anonymous telemetry from the CLI:】

  • CLI 生成 (cli_generate):结果 generated | overwritten | appended | no_changes | aborted 以及已删除敏感信息的配置。
  • CLI 迁移 (cli_migrate):结果 migrated | no_changes | aborted | unsupported_adapter,以及适配器 ID(在相关情况下)和已编辑的配置。

你可以通过在运行项目时设置 BETTER_AUTH_TELEMETRY_DEBUG=1 环境变量,或者在你的认证配置中设置 telemetry: { debug: true } 来本地审查遥测。在此调试模式下,遥测事件仅记录到控制台。

auth.ts
export const auth = betterAuth({
  telemetry: { 
    debug: true
  } 
});

我的数据如何受到保护?

【How is my data protected?】

所有收集的数据都是完全匿名的,仅用于汇总分析。无法追溯到任何个人来源,并且仅由少数核心 Better Auth 维护人员访问,用于指导路线图决策。

【All collected data is fully anonymous and only useful in aggregate. It cannot be traced back to any individual source and is accessible only to a small group of core Better Auth maintainers to guide roadmap decisions.】

  • 无个人身份信息或秘密:我们不收集电子邮件、用户名、令牌、秘密、客户端ID、客户端密钥或数据库URL。
  • 没有完整配置:我们从不发送你的完整 betterAuth 配置。取而代之的是,我们只发送一个经过简化和编辑的快照,其中包含非敏感的开关和计数。
  • 按设计编辑:请参见 Better Auth 源码中的 detect-auth-config.ts,了解包含内容的具体形式。它故意将敏感值转换为布尔值、计数或通用标识符。

我如何启用它?

【How can I enable it?】

你可以在身份验证配置中启用遥测收集,或通过设置环境变量来启用。

【You can enable telemetry collection in your auth config or by setting an environment variable.】

  • 通过你的身份验证配置。

    auth.ts
    export const auth = betterAuth({
      telemetry: { 
        enabled: true
      } 
    });
  • 通过环境变量。

    .env
    # Enable telemetry
    BETTER_AUTH_TELEMETRY=1
    
    # Disable telemetry
    BETTER_AUTH_TELEMETRY=0

何时发送遥测?

【When is telemetry sent?】

  • betterAuth 初始化时(类型:"init")。
  • 关于命令行操作:如上所述的 generatemigrate

在测试中(NODE_ENV=test),遥测会自动被禁用,除非被内部工具明确覆盖。

【Telemetry is disabled automatically in tests (NODE_ENV=test) unless explicitly overridden by internal tooling.】

On this page