@@ -102,7 +102,6 @@ export class Replayer {
102102 private emitter : Emitter = mitt ( ) ;
103103
104104 private inactiveEndTimestamp : number | null ;
105- private nextUserInteractionEvent : eventWithTime | null ;
106105
107106 // tslint:disable-next-line: variable-name
108107 private legacy_missingNodeRetryMap : missingNodeMap = { } ;
@@ -247,17 +246,21 @@ export class Replayer {
247246 }
248247 // Preprocessing to get all active/inactive segments in a session
249248 const allIntervals : Array < SessionInterval > = [ ] ;
250- const firstEvent = this . service . state . context . events [ 0 ] ;
249+ const metadata = this . getMetaData ( ) ;
251250 const userInteractionEvents = [
252- firstEvent ,
251+ { timestamp : metadata . startTime } ,
253252 ...this . service . state . context . events . filter ( ( ev ) =>
254253 this . isUserInteraction ( ev ) ,
255254 ) ,
255+ { timestamp : metadata . endTime } ,
256256 ] ;
257257 for ( let i = 1 ; i < userInteractionEvents . length ; i ++ ) {
258258 const currentInterval = userInteractionEvents [ i - 1 ] ;
259259 const _event = userInteractionEvents [ i ] ;
260- if ( _event . timestamp ! - currentInterval . timestamp ! > SKIP_TIME_THRESHOLD ) {
260+ if (
261+ _event . timestamp ! - currentInterval . timestamp ! >
262+ SKIP_TIME_THRESHOLD
263+ ) {
261264 allIntervals . push ( {
262265 startTime : currentInterval . timestamp ! ,
263266 endTime : _event . timestamp ! ,
@@ -292,13 +295,13 @@ export class Replayer {
292295 startTime : currentInterval . startTime ,
293296 endTime : allIntervals [ allIntervals . length - 1 ] . endTime ,
294297 duration :
295- allIntervals [ allIntervals . length - 1 ] . endTime - currentInterval . startTime ,
298+ allIntervals [ allIntervals . length - 1 ] . endTime -
299+ currentInterval . startTime ,
296300 active : allIntervals [ allIntervals . length - 1 ] . active ,
297301 } ) ;
298302 }
299303 // Merges inactive segments that are less than a threshold into surrounding active sessions
300304 // TODO: Change this from a 3n pass to n
301- const metadata = this . getMetaData ( ) ;
302305 currentInterval = mergedIntervals [ 0 ] ;
303306 for ( let i = 1 ; i < mergedIntervals . length ; i ++ ) {
304307 if (
@@ -1447,7 +1450,7 @@ export class Replayer {
14471450 }
14481451
14491452 private backToNormal ( ) {
1450- this . nextUserInteractionEvent = null ;
1453+ this . inactiveEndTimestamp = null ;
14511454 if ( this . speedService . state . matches ( 'normal' ) ) {
14521455 return ;
14531456 }
0 commit comments