(params: {
organizationId: string
totalCreditsConsumed: number
uniqueUsers: number
repositoryCount: number
averageCreditsPerUser: number
topRepository: string
timeframe: 'daily' | 'weekly' | 'monthly'
logger: Logger
})
| 317 | * Tracks organization usage metrics for analytics |
| 318 | */ |
| 319 | export async function trackOrganizationUsageMetrics(params: { |
| 320 | organizationId: string |
| 321 | totalCreditsConsumed: number |
| 322 | uniqueUsers: number |
| 323 | repositoryCount: number |
| 324 | averageCreditsPerUser: number |
| 325 | topRepository: string |
| 326 | timeframe: 'daily' | 'weekly' | 'monthly' |
| 327 | logger: Logger |
| 328 | }): Promise<void> { |
| 329 | const { |
| 330 | organizationId, |
| 331 | totalCreditsConsumed, |
| 332 | uniqueUsers, |
| 333 | repositoryCount, |
| 334 | averageCreditsPerUser, |
| 335 | topRepository, |
| 336 | timeframe, |
| 337 | logger, |
| 338 | } = params |
| 339 | |
| 340 | try { |
| 341 | logger.info( |
| 342 | { |
| 343 | organizationId, |
| 344 | totalCreditsConsumed, |
| 345 | uniqueUsers, |
| 346 | repositoryCount, |
| 347 | averageCreditsPerUser, |
| 348 | topRepository, |
| 349 | timeframe, |
| 350 | }, |
| 351 | 'Organization usage metrics tracked', |
| 352 | ) |
| 353 | |
| 354 | // Track analytics event |
| 355 | trackEvent({ |
| 356 | event: AnalyticsEvent.CREDIT_GRANT, |
| 357 | userId: organizationId, |
| 358 | properties: { |
| 359 | type: 'usage_metrics', |
| 360 | timeframe, |
| 361 | totalCreditsConsumed, |
| 362 | uniqueUsers, |
| 363 | repositoryCount, |
| 364 | }, |
| 365 | logger, |
| 366 | }) |
| 367 | |
| 368 | // TODO: Store metrics in time-series database for dashboards |
| 369 | // TODO: Generate usage reports |
| 370 | // TODO: Identify usage patterns and optimization opportunities |
| 371 | } catch (error) { |
| 372 | const obj: any = { |
| 373 | ...params, |
| 374 | error: getErrorObject(error), |
| 375 | } |
| 376 | delete obj.logger |
nothing calls this directly
no test coverage detected