Skip to content

The Open Source DocuSign Alternative.

feat: auto-disable telemetry when license key is configured (#2562)

Ephraim Duncan15399cbe8efe
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<void> {
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;
}