Skip to content

Commit 67c025b

Browse files
committed
v0.2
1 parent 2677577 commit 67c025b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/analytics-db.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,24 @@ class OptimizedAnalyticsCollector {
130130
this.securityBatch = [];
131131

132132
try {
133+
// Map legacy event types to new enum values
134+
const mapLegacyEventType = (eventType: string): 'AUTH_FAILURE' | 'INVALID_TOKEN' | 'SUSPICIOUS_ACTIVITY' => {
135+
switch (eventType.toLowerCase()) {
136+
case 'auth_failure':
137+
return 'AUTH_FAILURE';
138+
case 'invalid_token':
139+
return 'INVALID_TOKEN';
140+
case 'suspicious_activity':
141+
return 'SUSPICIOUS_ACTIVITY';
142+
default:
143+
return 'SUSPICIOUS_ACTIVITY'; // Default fallback
144+
}
145+
};
146+
133147
await prisma.analyticsSecurity.createMany({
134148
data: batch.map(event => ({
135149
timestamp: event.timestamp,
136-
eventType: event.eventType as 'AUTH_FAILURE' | 'INVALID_TOKEN' | 'SUSPICIOUS_ACTIVITY',
150+
eventType: mapLegacyEventType(event.eventType),
137151
severity: 'medium', // Default severity for legacy events
138152
ipAddress: event.ipAddress,
139153
userAgent: event.userAgent,

0 commit comments

Comments
 (0)