Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"prepare": "npm run build",
"clean": "shx rm -rf dist",
"test": "npm run build && node test/run-all-tests.js",
"test:integration": "npm run build && node test/integration/run-all-integration-tests.js",
"test:debug": "node --inspect test/run-all-tests.js",
"validate:tools": "npm run build && node scripts/validate-tools-sync.js",
"link:local": "npm run build && npm link",
Expand Down
19 changes: 19 additions & 0 deletions src/utils/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ let uniqueUserId = 'unknown';
const TELEMETRY_PROXY_URL = 'https://dc-telemetry-proxy-83847352264.europe-west1.run.app/mp/collect';
const TELEMETRY_PROXY_TOKEN = 'Od44UB_fTrVfGPGRPLr5QdVgFhuKdiGaBmvazTdxVdQ';

/**
* Hard kill-switch for telemetry via environment variable.
*
* Independent of the persisted `telemetryEnabled` config so that tests, CI and
* one-off runs can suppress all analytics without mutating the user's config.
* Set DESKTOP_COMMANDER_DISABLE_TELEMETRY to 1/true/yes/on to disable.
*/
export function isTelemetryDisabledByEnv(): boolean {
const raw = process.env.DESKTOP_COMMANDER_DISABLE_TELEMETRY;
if (!raw) return false;
return ['1', 'true', 'yes', 'on'].includes(raw.trim().toLowerCase());
}


/**
* Sanitizes error objects to remove potentially sensitive information like file paths
Expand Down Expand Up @@ -60,6 +73,11 @@ export function sanitizeError(error: any): { message: string, code?: string } {
*/
export const captureBase = async (captureURL: string, event: string, properties?: any) => {
try {
// Env kill-switch takes precedence over config (tests/CI).
if (isTelemetryDisabledByEnv()) {
return;
}

// Check if telemetry is enabled in config (defaults to true if not set)
const telemetryEnabled = await configManager.getValue('telemetryEnabled');

Expand Down Expand Up @@ -366,6 +384,7 @@ const buildEventProperties = async (properties?: any) => {
*/
const sendToTelemetryProxy = async (event: string, eventProperties: any) => {
try {
if (isTelemetryDisabledByEnv()) return;
const telemetryEnabled = await configManager.getValue('telemetryEnabled');
if (isTelemetryDisabledValue(telemetryEnabled)) return;

Expand Down
Loading
Loading