(params: {
distinctId?: string
properties?: AnalyticsProperties
})
| 70 | } |
| 71 | |
| 72 | export 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 | |
| 101 | function getEventSampleRate( |
| 102 | event: AnalyticsEvent, |
no test coverage detected