MCPcopy Index your code
hub / github.com/codeaashu/claude-code / logEventImpl

Function logEventImpl

src/services/analytics/sink.ts:48–72  ·  view source on GitHub ↗

* Log an event (synchronous implementation)

(eventName: string, metadata: LogEventMetadata)

Source from the content-addressed store, hash-verified

46 * Log an event (synchronous implementation)
47 */
48function logEventImpl(eventName: string, metadata: LogEventMetadata): void {
49 // Check if this event should be sampled
50 const sampleResult = shouldSampleEvent(eventName)
51
52 // If sample result is 0, the event was not selected for logging
53 if (sampleResult === 0) {
54 return
55 }
56
57 // If sample result is a positive number, add it to metadata
58 const metadataWithSampleRate =
59 sampleResult !== null
60 ? { ...metadata, sample_rate: sampleResult }
61 : metadata
62
63 if (shouldTrackDatadog()) {
64 // Datadog is a general-access backend — strip _PROTO_* keys
65 // (unredacted PII-tagged values meant only for the 1P privileged column).
66 void trackDatadogEvent(eventName, stripProtoFields(metadataWithSampleRate))
67 }
68
69 // 1P receives the full payload including _PROTO_* — the exporter
70 // destructures and routes those keys to proto fields itself.
71 logEventTo1P(eventName, metadataWithSampleRate)
72}
73
74/**
75 * Log an event (asynchronous implementation)

Callers 1

logEventAsyncImplFunction · 0.85

Calls 5

shouldSampleEventFunction · 0.85
shouldTrackDatadogFunction · 0.85
trackDatadogEventFunction · 0.85
stripProtoFieldsFunction · 0.85
logEventTo1PFunction · 0.85

Tested by

no test coverage detected