feat: add UI usage analytics tracking
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m9s
CI / docker (push) Successful in 1m14s
CI / deploy (push) Successful in 46s
CI / deploy-feature (push) Has been skipped

Tracks authenticated UI user requests to understand usage patterns:
- New ClickHouse usage_events table with 90-day TTL
- UsageTrackingInterceptor captures method, path, duration, user
- Path normalization groups dynamic segments ({id}, {hash})
- Buffered writes via WriteBuffer + periodic flush
- Admin endpoint GET /api/v1/admin/usage with groupBy=endpoint|user|hour
- Skips agent requests, health checks, and data ingestion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-01 17:53:32 +02:00
parent ce4abaf862
commit aa2d203f4e
10 changed files with 351 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
package com.cameleer3.server.core.analytics;
import java.time.Instant;
public record UsageEvent(
Instant timestamp,
String username,
String method,
String path,
String normalized,
int statusCode,
long durationMs,
String queryParams
) {}

View File

@@ -0,0 +1,7 @@
package com.cameleer3.server.core.analytics;
public record UsageStats(
String key,
long count,
long avgDurationMs
) {}

View File

@@ -0,0 +1,6 @@
package com.cameleer3.server.core.analytics;
public interface UsageTracker {
void track(UsageEvent event);
}