shared env var to disable telemetry in cli and webapp

This commit is contained in:
nicktrn
2024-04-26 17:59:35 +01:00
parent ca97d89566
commit 8330f404ec
3 changed files with 13 additions and 1 deletions
+1
View File
@@ -37,6 +37,7 @@ const EnvironmentSchema = z.object({
POSTHOG_PROJECT_KEY: z.string().optional(),
TELEMETRY_TRIGGER_API_KEY: z.string().optional(),
TELEMETRY_TRIGGER_API_URL: z.string().optional(),
TRIGGER_TELEMETRY_DISABLED: z.string().optional(),
HIGHLIGHT_PROJECT_ID: z.string().optional(),
AUTH_GITHUB_CLIENT_ID: z.string().optional(),
AUTH_GITHUB_CLIENT_SECRET: z.string().optional(),
@@ -21,6 +21,11 @@ class Telemetry {
#triggerClient: TriggerClient | undefined = undefined;
constructor({ postHogApiKey, trigger }: Options) {
if (env.TRIGGER_TELEMETRY_DISABLED !== undefined) {
console.log("📉 Telemetry disabled");
return;
}
if (postHogApiKey) {
this.#posthogClient = new PostHog(postHogApiKey, { host: "https://eu.posthog.com" });
} else {
+7 -1
View File
@@ -9,9 +9,15 @@ import {
SEMRESATTRS_SERVICE_NAME,
SEMRESATTRS_SERVICE_VERSION,
} from "@opentelemetry/semantic-conventions";
import { logger } from "../utilities/logger";
function initializeTracing(): NodeTracerProvider | undefined {
if (process.argv.includes("--skip-telemetry") || process.env.TRIGGER_DEV_SKIP_TELEMETRY) {
if (
process.argv.includes("--skip-telemetry") ||
process.env.TRIGGER_DEV_SKIP_TELEMETRY || // only for backwards compat
process.env.TRIGGER_TELEMETRY_DISABLED
) {
logger.debug("📉 Telemetry disabled");
return;
}