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

Function shouldTrackAnalyticsEvent

common/src/util/analytics-sampling.ts:143–163  ·  view source on GitHub ↗
(params: {
  event: AnalyticsEvent
  distinctId?: string
  properties?: AnalyticsProperties
})

Source from the content-addressed store, hash-verified

141}
142
143export function shouldTrackAnalyticsEvent(params: {
144 event: AnalyticsEvent
145 distinctId?: string
146 properties?: AnalyticsProperties
147}): boolean {
148 if (isFullTelemetryEnabled(params)) {
149 return true
150 }
151
152 const rate = getEventSampleRate(params.event, params.properties)
153 if (rate >= 1) {
154 return true
155 }
156 if (rate <= 0) {
157 return false
158 }
159
160 const bucket =
161 hashString(`${params.event}:${getSamplingKey(params)}`) / 0xffffffff
162 return bucket < rate
163}
164
165function valueKind(value: unknown): string {
166 if (Array.isArray(value)) {

Callers 3

trackEventFunction · 0.90
trackSdkRuntimeEventFunction · 0.90

Calls 4

isFullTelemetryEnabledFunction · 0.85
getEventSampleRateFunction · 0.85
hashStringFunction · 0.85
getSamplingKeyFunction · 0.85

Tested by

no test coverage detected