@@ -24,11 +24,11 @@ import { getRequestInfo } from './vendor/getRequestInfo';
2424
2525const  clientToAggregatesMap  =  new  Map < 
2626  Client , 
27-   {  [ timestampRoundedToSeconds : string ] : {  exited : number ;  crashed : number  }  } 
27+   {  [ timestampRoundedToSeconds : string ] : {  exited : number ;  crashed : number ;   errored :  number  }  } 
2828> ( ) ; 
2929
3030interface  RequestSession  { 
31-   status : 'ok'  |  'crashed' ; 
31+   status : 'ok'  |  'errored'    |   ' crashed'; 
3232} 
3333
3434type  Http  =  typeof  http ; 
@@ -186,20 +186,20 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
186186              |  undefined ; 
187187
188188            if  ( client  &&  requestSession )  { 
189+               DEBUG_BUILD  &&  logger . debug ( `Recorded request session with status: ${ requestSession . status }  ` ) ; 
190+ 
189191              const  roundedDate  =  new  Date ( ) ; 
190192              roundedDate . setSeconds ( 0 ,  0 ) ; 
191193              const  dateBucketKey  =  roundedDate . toISOString ( ) ; 
192194
193195              const  existingClientAggregate  =  clientToAggregatesMap . get ( client ) ; 
196+               const  bucket  =  existingClientAggregate ?. [ dateBucketKey ]  ||  {  exited : 0 ,  crashed : 0 ,  errored : 0  } ; 
197+               bucket [ ( {  ok : 'exited' ,  crashed : 'crashed' ,  errored : 'errored'  }  as  const ) [ requestSession . status ] ] ++ ; 
198+ 
194199              if  ( existingClientAggregate )  { 
195-                 DEBUG_BUILD  &&  logger . debug ( `Recorded request session with status: ${ requestSession . status }  ` ) ; 
196-                 const  bucket  =  existingClientAggregate [ dateBucketKey ]  ||  {  crashed : 0 ,  exited : 0  } ; 
197-                 bucket [ requestSession . status  ===  'ok'  ? 'exited'  : 'crashed' ] ++ ; 
198200                existingClientAggregate [ dateBucketKey ]  =  bucket ; 
199201              }  else  { 
200202                DEBUG_BUILD  &&  logger . debug ( 'Opened new request session aggregate.' ) ; 
201-                 const  bucket  =  {  crashed : 0 ,  exited : 0  } ; 
202-                 bucket [ requestSession . status  ===  'ok'  ? 'exited'  : 'crashed' ] ++ ; 
203203                const  newClientAggregate  =  {  [ dateBucketKey ] : bucket  } ; 
204204                clientToAggregatesMap . set ( client ,  newClientAggregate ) ; 
205205
@@ -225,8 +225,7 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
225225                const  timeout  =  setTimeout ( ( )  =>  { 
226226                  DEBUG_BUILD  &&  logger . debug ( 'Sending request session aggregate due to flushing schedule' ) ; 
227227                  flushPendingClientAggregates ( ) ; 
228-                   // TODO: Increase to 60s 
229-                 } ,  5_000 ) . unref ( ) ; 
228+                 } ,  60_000 ) . unref ( ) ; 
230229              } 
231230            } 
232231          } ) ; 
0 commit comments