@@ -68,12 +68,17 @@ export abstract class BaseTransport implements Transport {
6868 /**
6969 * @inheritDoc
7070 */
71- public recordLostEvent ( type : Outcome , category : SentryRequestType ) : void {
71+ public recordLostEvent ( reason : Outcome , category : SentryRequestType ) : void {
7272 if ( ! this . options . sendClientReport ) {
7373 return ;
7474 }
75- const key = `${ type } :${ CATEGORY_MAPPING [ category ] } ` ;
76- logger . log ( `Adding ${ key } outcome` ) ;
75+ // We want to track each category (event, transaction, session) separately
76+ // but still keep the distinction between different type of outcomes.
77+ // We could use nested maps, but it's much easier to read and type this way.
78+ // A correct type for map-based implementation if we want to go that route
79+ // would be `Partial<Record<SentryRequestType, Partial<Record<Outcome, number>>>>`
80+ const key = `${ CATEGORY_MAPPING [ category ] } :${ reason } }` ;
81+ logger . log ( `Adding outcome: ${ key } ` ) ;
7782 this . _outcomes [ key ] = ( this . _outcomes [ key ] ?? 0 ) + 1 ;
7883 }
7984
@@ -91,6 +96,7 @@ export abstract class BaseTransport implements Transport {
9196 }
9297
9398 const outcomes = this . _outcomes ;
99+ this . _outcomes = { } ;
94100
95101 // Nothing to send
96102 if ( ! Object . keys ( outcomes ) . length ) {
@@ -118,8 +124,6 @@ export abstract class BaseTransport implements Transport {
118124 const envelope = `${ itemHeaders } \n${ item } ` ;
119125
120126 navigator . sendBeacon ( url , envelope ) ;
121-
122- this . _outcomes = { } ;
123127 }
124128
125129 /**
0 commit comments