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
2 changes: 1 addition & 1 deletion hooks/posttooluse-telemetry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion hooks/src/posttooluse-telemetry.mts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function main(): Promise<void> {

const toolName = (input.tool_name as string) || "";
const toolInput = (input.tool_input as Record<string, unknown>) || {};
const sessionId = (input.session_id as string) || "";
const sessionId = (input.session_id as string) || (input.conversation_id as string) || "";

if (!sessionId) {
process.stdout.write("{}");
Expand Down
15 changes: 14 additions & 1 deletion hooks/src/telemetry.mts
Original file line number Diff line number Diff line change
@@ -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]";
Expand Down Expand Up @@ -45,7 +48,17 @@ async function send(sessionId: string, events: TelemetryEvent[]): Promise<void>
}

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<void> {
Expand Down
12 changes: 11 additions & 1 deletion hooks/telemetry.mjs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "vercel-plugin",
"version": "0.2.2",
"private": true,
"bin": {
"vercel-plugin": "src/cli/index.ts"
Expand Down
3 changes: 2 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"outputDirectory": "generated"
"outputDirectory": "generated",
"cleanUrls": true
}
Loading