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

Function isFullTelemetryEnabled

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

Source from the content-addressed store, hash-verified

70}
71
72export function isFullTelemetryEnabled(params: {
73 distinctId?: string
74 properties?: AnalyticsProperties
75}): boolean {
76 if (isTruthyEnv(process.env.CODEBUFF_FULL_TELEMETRY)) {
77 return true
78 }
79
80 const ids = splitEnvList(
81 process.env.CODEBUFF_FULL_TELEMETRY_IDS ??
82 process.env.CODEBUFF_FULL_TELEMETRY_USER_IDS,
83 )
84 if (ids.size === 0) {
85 return false
86 }
87
88 const candidates = [
89 params.distinctId,
90 getPropertyUserId(params.properties),
91 getStringProperty(params.properties, 'userEmail'),
92 getStringProperty(params.properties, 'email'),
93 ].filter(
94 (value): value is string =>
95 typeof value === 'string' && value.length > 0,
96 )
97
98 return candidates.some((candidate) => ids.has(candidate))
99}
100
101function getEventSampleRate(
102 event: AnalyticsEvent,

Callers 3

sendAnalyticsAndLogFunction · 0.90

Calls 4

isTruthyEnvFunction · 0.85
splitEnvListFunction · 0.85
getPropertyUserIdFunction · 0.85
getStringPropertyFunction · 0.85

Tested by

no test coverage detected