MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getEventSampleRate

Function getEventSampleRate

common/src/util/analytics-sampling.ts:101–118  ·  view source on GitHub ↗
(
  event: AnalyticsEvent,
  properties: AnalyticsProperties,
)

Source from the content-addressed store, hash-verified

99}
100
101function getEventSampleRate(
102 event: AnalyticsEvent,
103 properties: AnalyticsProperties,
104): number {
105 const level = getStringProperty(properties, 'level')?.toLowerCase()
106 if (
107 event === AnalyticsEvent.CLI_LOG &&
108 (level === 'error' || level === 'fatal')
109 ) {
110 return 1
111 }
112
113 if (ALWAYS_TRACK_EVENTS.has(event)) {
114 return 1
115 }
116
117 return SAMPLED_EVENT_RATES[event] ?? 1
118}
119
120function hashString(input: string): number {
121 let hash = 2166136261

Callers 1

Calls 1

getStringPropertyFunction · 0.85

Tested by

no test coverage detected