nexus/packages/shared/src/telemetry/events.ts
dotta 34044cdfce feat: implement app-side telemetry sender
Add the shared telemetry sender, wire the CLI/server emit points,
and cover the config and completion behavior with tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-02 10:47:29 -05:00

49 lines
1.3 KiB
TypeScript

import type { TelemetryClient } from "./client.js";
export function trackInstallStarted(client: TelemetryClient, dims: { setupMode: string }): void {
client.track("install.started", dims);
}
export function trackInstallCompleted(
client: TelemetryClient,
dims: { setupMode: string; dbMode: string; deploymentMode: string },
): void {
client.track("install.completed", dims);
}
export function trackCompanyImported(
client: TelemetryClient,
dims: { sourceType: string; sourceRef: string; isPrivate: boolean },
): void {
const ref = dims.isPrivate ? client.hashPrivateRef(dims.sourceRef) : dims.sourceRef;
client.track("company.imported", {
sourceType: dims.sourceType,
sourceRef: ref,
sourceRefHashed: dims.isPrivate,
});
}
export function trackAgentFirstHeartbeat(
client: TelemetryClient,
dims: { adapterType: string },
): void {
client.track("agent.first_heartbeat", dims);
}
export function trackAgentTaskCompleted(
client: TelemetryClient,
dims: { adapterType: string },
): void {
client.track("agent.task_completed", dims);
}
export function trackErrorHandlerCrash(
client: TelemetryClient,
dims: { errorName: string; route: string; method: string },
): void {
client.track("error.handler_crash", {
errorName: dims.errorName,
route: dims.route,
method: dims.method,
});
}