diff --git a/hooks/posttooluse-telemetry.mjs b/hooks/posttooluse-telemetry.mjs index e37def8d..7ce79d7f 100755 --- a/hooks/posttooluse-telemetry.mjs +++ b/hooks/posttooluse-telemetry.mjs @@ -25,7 +25,7 @@ async function main() { } const toolName = input.tool_name || ""; const toolInput = input.tool_input || {}; - const sessionId = input.session_id || ""; + const sessionId = input.session_id || input.conversation_id || ""; if (!sessionId) { process.stdout.write("{}"); process.exit(0); diff --git a/hooks/src/posttooluse-telemetry.mts b/hooks/src/posttooluse-telemetry.mts index f554002e..9dc827bb 100644 --- a/hooks/src/posttooluse-telemetry.mts +++ b/hooks/src/posttooluse-telemetry.mts @@ -28,7 +28,7 @@ async function main(): Promise { const toolName = (input.tool_name as string) || ""; const toolInput = (input.tool_input as Record) || {}; - const sessionId = (input.session_id as string) || ""; + const sessionId = (input.session_id as string) || (input.conversation_id as string) || ""; if (!sessionId) { process.stdout.write("{}"); diff --git a/hooks/src/telemetry.mts b/hooks/src/telemetry.mts index 0d615fa3..9ff3ae1a 100644 --- a/hooks/src/telemetry.mts +++ b/hooks/src/telemetry.mts @@ -1,4 +1,7 @@ import { randomUUID } from "node:crypto"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { homedir } from "node:os"; const MAX_VALUE_BYTES = 100_000; const TRUNCATION_SUFFIX = "[TRUNCATED]"; @@ -45,7 +48,17 @@ async function send(sessionId: string, events: TelemetryEvent[]): Promise } export function isTelemetryEnabled(): boolean { - return process.env.VERCEL_PLUGIN_TELEMETRY === "on"; + if (process.env.VERCEL_PLUGIN_TELEMETRY === "on") return true; + + // Fallback: read the preference file directly in case the env var + // wasn't propagated to this process (new session, env file not sourced yet) + try { + const prefPath = join(homedir(), ".claude", "vercel-plugin-telemetry-preference"); + const pref = readFileSync(prefPath, "utf-8").trim(); + return pref === "enabled"; + } catch { + return false; + } } export async function trackEvent(sessionId: string, key: string, value: string): Promise { diff --git a/hooks/telemetry.mjs b/hooks/telemetry.mjs index 836d3e00..85e2a43c 100644 --- a/hooks/telemetry.mjs +++ b/hooks/telemetry.mjs @@ -1,5 +1,8 @@ // hooks/src/telemetry.mts import { randomUUID } from "crypto"; +import { readFileSync } from "fs"; +import { join } from "path"; +import { homedir } from "os"; var MAX_VALUE_BYTES = 1e5; var TRUNCATION_SUFFIX = "[TRUNCATED]"; var BRIDGE_ENDPOINT = "https://telemetry.vercel.com/api/vercel-plugin/v1/events"; @@ -32,7 +35,14 @@ async function send(sessionId, events) { } } function isTelemetryEnabled() { - return process.env.VERCEL_PLUGIN_TELEMETRY === "on"; + if (process.env.VERCEL_PLUGIN_TELEMETRY === "on") return true; + try { + const prefPath = join(homedir(), ".claude", "vercel-plugin-telemetry-preference"); + const pref = readFileSync(prefPath, "utf-8").trim(); + return pref === "enabled"; + } catch { + return false; + } } async function trackEvent(sessionId, key, value) { if (!isTelemetryEnabled()) return; diff --git a/package.json b/package.json index 17f246cc..7b9f6ed2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "vercel-plugin", + "version": "0.2.2", "private": true, "bin": { "vercel-plugin": "src/cli/index.ts" diff --git a/vercel.json b/vercel.json index 2edc621f..05d34790 100644 --- a/vercel.json +++ b/vercel.json @@ -1,3 +1,4 @@ { - "outputDirectory": "generated" + "outputDirectory": "generated", + "cleanUrls": true }