spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / telemetry-noun.d.ts
57 lines · 1.7 KBRaw
1/**
2 * The `$.telemetry` noun as this plugin calls it, declared for a build of
3 * this folder on its own; no module imports it.
4 *
5 * The telemetry plugin adds the noun in the engine.create fold on internal
6 * builds and nowhere else: where no plugin provides it the calls throw and
7 * record/ drops the row. The engine's repository leaves this file out.
8 *
9 * @entry
10 */
11declare module 'claude-code' {
12 /**
13 * How one use of a feature went: as hoped, degraded, or failed outright.
14 */
15 type DiffTelemetryMarkKind = 'ok' | 'sad' | 'bad'
16
17 /**
18 * A string property: the value and the list it is chosen from.
19 */
20 type DiffTelemetryChoice = { value: string; of: readonly string[] }
21
22 /**
23 * One property value a row may carry.
24 */
25 type DiffTelemetryProp = number | boolean | DiffTelemetryChoice
26
27 /**
28 * What `$.telemetry.log` takes: the event's name after the prefix, and
29 * its properties by snake_case key.
30 */
31 type DiffTelemetryLogEntry = {
32 event: string
33 props?: Readonly<Record<string, DiffTelemetryProp>>
34 }
35
36 /**
37 * What `$.telemetry.mark` takes: the feature, how it went, why when not
38 * ok, and the properties the row carries beside them by snake_case key.
39 */
40 type DiffTelemetryMarkEntry = {
41 feature: string
42 kind: DiffTelemetryMarkKind
43 reason?: string
44 props?: Readonly<Record<string, DiffTelemetryProp>>
45 }
46
47 interface EngineInterface {
48 /**
49 * A plugin's analytics, one first-party row per call; present only
50 * where the telemetry plugin is seated.
51 */
52 telemetry: {
53 log: (entry: DiffTelemetryLogEntry) => Promise<void>
54 mark: (entry: DiffTelemetryMarkEntry) => Promise<void>
55 }
56 }
57}