feat: add UI usage analytics tracking
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:
@@ -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
|
||||
) {}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.cameleer3.server.core.analytics;
|
||||
|
||||
public record UsageStats(
|
||||
String key,
|
||||
long count,
|
||||
long avgDurationMs
|
||||
) {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.cameleer3.server.core.analytics;
|
||||
|
||||
public interface UsageTracker {
|
||||
|
||||
void track(UsageEvent event);
|
||||
}
|
||||
Reference in New Issue
Block a user