MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / trackWithContext

Method trackWithContext

packages/telemetry/src/client.ts:78–104  ·  view source on GitHub ↗
(
    event: string,
    properties: TelemetryProperties = {},
    context: TelemetryContextIds,
  )

Source from the content-addressed store, hash-verified

76 }
77
78 trackWithContext(
79 event: string,
80 properties: TelemetryProperties = {},
81 context: TelemetryContextIds,
82 ): void {
83 if (this.disabled) return;
84 const record: PendingTelemetryEvent = {
85 event_id: randomUUID().replaceAll('-', ''),
86 device_id: context.deviceId === undefined ? this.deviceId : context.deviceId,
87 session_id: context.sessionId === undefined ? this.sessionId : context.sessionId,
88 event,
89 timestamp: Date.now() / 1000,
90 properties: sanitizeProperties(properties),
91 contextOverrides: {
92 deviceId: context.deviceId !== undefined,
93 sessionId: context.sessionId !== undefined,
94 },
95 };
96 if (this.sink !== null) {
97 this.sink.accept(toTelemetryEvent(record));
98 return;
99 }
100 this.queue.push(record);
101 if (this.queue.length > MAX_QUEUE_SIZE) {
102 this.queue = this.queue.slice(this.queue.length - MAX_QUEUE_SIZE);
103 }
104 }
105
106 getSink(): EventSink | null {
107 return this.sink;

Callers 2

trackMethod · 0.95
trackMethod · 0.80

Calls 5

sanitizePropertiesFunction · 0.85
toTelemetryEventFunction · 0.85
acceptMethod · 0.80
nowMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected