From 15399cbe8efeadf1195f773aafdb115efd3a99a8 Mon Sep 17 00:00:00 2001 From: Ephraim Duncan <55143799+ephraimduncan@users.noreply.github.com> Date: Mon, 9 Mar 2026 00:24:24 +0000 Subject: [PATCH] feat: auto-disable telemetry when license key is configured (#2562) --- .../docs/self-hosting/configuration/environment.mdx | 2 ++ .../lib/server-only/telemetry/telemetry-client.ts | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/docs/content/docs/self-hosting/configuration/environment.mdx b/apps/docs/content/docs/self-hosting/configuration/environment.mdx index a1548c32c..960008449 100644 --- a/apps/docs/content/docs/self-hosting/configuration/environment.mdx +++ b/apps/docs/content/docs/self-hosting/configuration/environment.mdx @@ -271,6 +271,8 @@ Documenso uses a PostgreSQL-based job queue by default. Jobs (email delivery, do | ----------------------------- | -------------------------------------------- | ------- | | `DOCUMENSO_DISABLE_TELEMETRY` | Set to `true` to disable anonymous telemetry | `false` | +Telemetry also auto-disables when `NEXT_PRIVATE_DOCUMENSO_LICENSE_KEY` is configured. + Telemetry collects only: app version, installation ID, and node ID. No personal data is collected. --- diff --git a/packages/lib/server-only/telemetry/telemetry-client.ts b/packages/lib/server-only/telemetry/telemetry-client.ts index 1caf24d96..e2c11f180 100644 --- a/packages/lib/server-only/telemetry/telemetry-client.ts +++ b/packages/lib/server-only/telemetry/telemetry-client.ts @@ -10,9 +10,11 @@ import { getSiteSetting } from '../site-settings/get-site-setting'; import { SITE_SETTINGS_TELEMETRY_ID } from '../site-settings/schemas/telemetry'; import { upsertSiteSetting } from '../site-settings/upsert-site-setting'; +const HAS_LICENSE_KEY = !!process.env.NEXT_PRIVATE_DOCUMENSO_LICENSE_KEY; + const TELEMETRY_KEY = process.env.NEXT_PRIVATE_TELEMETRY_KEY; const TELEMETRY_HOST = process.env.NEXT_PRIVATE_TELEMETRY_HOST; -const TELEMETRY_DISABLED = !!process.env.DOCUMENSO_DISABLE_TELEMETRY; +const TELEMETRY_DISABLED = !!process.env.DOCUMENSO_DISABLE_TELEMETRY || HAS_LICENSE_KEY; const NODE_ID_FILENAME = '.documenso-node-id'; const HEARTBEAT_INTERVAL_MS = 60 * 60 * 1000; // 1 hour @@ -43,9 +45,12 @@ export class TelemetryClient { */ public static async start(): Promise { if (TELEMETRY_DISABLED) { - console.log( - '[Telemetry] Telemetry is disabled. To enable, remove the DOCUMENSO_DISABLE_TELEMETRY environment variable.', - ); + if (!HAS_LICENSE_KEY) { + console.log( + '[Telemetry] Telemetry is disabled. To enable, remove the DOCUMENSO_DISABLE_TELEMETRY environment variable.', + ); + } + return; }