File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments