@@ -31,9 +31,10 @@ import * as consoleApiSource from '../../generated/consoleApiSource';
3131import { RecorderApp } from './recorder/recorderApp' ;
3232import { CallMetadata , internalCallMetadata , SdkObject } from '../instrumentation' ;
3333import { Point } from '../../common/types' ;
34- import { CallLog , EventData , Mode , Source , UIState } from './recorder/recorderTypes' ;
34+ import { CallLog , CallLogStatus , EventData , Mode , Source , UIState } from './recorder/recorderTypes' ;
3535import { isUnderTest , monotonicTime } from '../../utils/utils' ;
3636import { InMemorySnapshotter } from '../snapshot/inMemorySnapshotter' ;
37+ import { metadataToCallLog } from './recorder/recorderUtils' ;
3738
3839type BindingSource = { frame : Frame , page : Page } ;
3940
@@ -56,7 +57,7 @@ export class RecorderSupplement {
5657 private _recorderSources : Source [ ] ;
5758 private _userSources = new Map < string , Source > ( ) ;
5859 private _snapshotter : InMemorySnapshotter ;
59- private _hoveredSnapshot : { callLogId : number , phase : 'before' | 'after' | 'in ' } | undefined ;
60+ private _hoveredSnapshot : { callLogId : number , phase : 'before' | 'after' | 'action ' } | undefined ;
6061 private _snapshots = new Set < string > ( ) ;
6162 private _allMetadatas = new Map < number , CallMetadata > ( ) ;
6263
@@ -209,7 +210,7 @@ export class RecorderSupplement {
209210 if ( this . _hoveredSnapshot ) {
210211 const metadata = this . _allMetadatas . get ( this . _hoveredSnapshot . callLogId ) ! ;
211212 snapshotUrl = `${ metadata . pageId } ?name=${ this . _hoveredSnapshot . phase } @${ this . _hoveredSnapshot . callLogId } ` ;
212- actionPoint = this . _hoveredSnapshot . phase === 'in ' ? metadata ?. point : undefined ;
213+ actionPoint = this . _hoveredSnapshot . phase === 'action ' ? metadata ?. point : undefined ;
213214 } else {
214215 for ( const [ metadata , sdkObject ] of this . _currentCallsMetadata ) {
215216 if ( source . page === sdkObject . attribution . page ) {
@@ -401,7 +402,7 @@ export class RecorderSupplement {
401402 this . _generator . signal ( pageAlias , page . mainFrame ( ) , { name : 'dialog' , dialogAlias : String ( ++ this . _lastDialogOrdinal ) } ) ;
402403 }
403404
404- _captureSnapshot ( sdkObject : SdkObject , metadata : CallMetadata , phase : 'before' | 'after' | 'in ' ) {
405+ _captureSnapshot ( sdkObject : SdkObject , metadata : CallMetadata , phase : 'before' | 'after' | 'action ' ) {
405406 if ( sdkObject . attribution . page ) {
406407 const snapshotName = `${ phase } @${ metadata . id } ` ;
407408 this . _snapshots . add ( snapshotName ) ;
@@ -428,7 +429,7 @@ export class RecorderSupplement {
428429 async onAfterCall ( sdkObject : SdkObject , metadata : CallMetadata ) : Promise < void > {
429430 if ( this . _mode === 'recording' )
430431 return ;
431- await this . _captureSnapshot ( sdkObject , metadata , 'after' ) ;
432+ this . _captureSnapshot ( sdkObject , metadata , 'after' ) ;
432433 if ( ! metadata . error )
433434 this . _currentCallsMetadata . delete ( metadata ) ;
434435 this . _pausedCallsMetadata . delete ( metadata ) ;
@@ -473,49 +474,24 @@ export class RecorderSupplement {
473474 async onBeforeInputAction ( sdkObject : SdkObject , metadata : CallMetadata ) : Promise < void > {
474475 if ( this . _mode === 'recording' )
475476 return ;
476- await this . _captureSnapshot ( sdkObject , metadata , 'in ' ) ;
477+ this . _captureSnapshot ( sdkObject , metadata , 'action ' ) ;
477478 if ( this . _pauseOnNextStatement )
478479 await this . pause ( metadata ) ;
479480 }
480481
481- async updateCallLog ( metadatas : CallMetadata [ ] ) : Promise < void > {
482+ updateCallLog ( metadatas : CallMetadata [ ] ) {
482483 if ( this . _mode === 'recording' )
483484 return ;
484485 const logs : CallLog [ ] = [ ] ;
485486 for ( const metadata of metadatas ) {
486487 if ( ! metadata . method )
487488 continue ;
488- const title = metadata . apiName || metadata . method ;
489- let status : 'done' | 'in-progress' | 'paused' | 'error' = 'done' ;
489+ let status : CallLogStatus = 'done' ;
490490 if ( this . _currentCallsMetadata . has ( metadata ) )
491491 status = 'in-progress' ;
492492 if ( this . _pausedCallsMetadata . has ( metadata ) )
493493 status = 'paused' ;
494- if ( metadata . error )
495- status = 'error' ;
496- const params = {
497- url : metadata . params ?. url ,
498- selector : metadata . params ?. selector ,
499- } ;
500- let duration = metadata . endTime ? metadata . endTime - metadata . startTime : undefined ;
501- if ( typeof duration === 'number' && metadata . pauseStartTime && metadata . pauseEndTime ) {
502- duration -= ( metadata . pauseEndTime - metadata . pauseStartTime ) ;
503- duration = Math . max ( duration , 0 ) ;
504- }
505- logs . push ( {
506- id : metadata . id ,
507- messages : metadata . log ,
508- title,
509- status,
510- error : metadata . error ,
511- params,
512- duration,
513- snapshots : {
514- before : showBeforeSnapshot ( metadata ) && this . _snapshots . has ( `before@${ metadata . id } ` ) ,
515- in : showInSnapshot ( metadata ) && this . _snapshots . has ( `in@${ metadata . id } ` ) ,
516- after : showAfterSnapshot ( metadata ) && this . _snapshots . has ( `after@${ metadata . id } ` ) ,
517- }
518- } ) ;
494+ logs . push ( metadataToCallLog ( metadata , status , this . _snapshots ) ) ;
519495 }
520496 this . _recorderApp ?. updateCallLogs ( logs ) ;
521497 }
@@ -548,15 +524,3 @@ function shouldPauseOnCall(sdkObject: SdkObject, metadata: CallMetadata): boolea
548524function shouldPauseOnStep ( sdkObject : SdkObject , metadata : CallMetadata ) : boolean {
549525 return metadata . method === 'goto' || metadata . method === 'close' ;
550526}
551-
552- function showBeforeSnapshot ( metadata : CallMetadata ) : boolean {
553- return metadata . method === 'close' ;
554- }
555-
556- function showInSnapshot ( metadata : CallMetadata ) : boolean {
557- return [ 'click' , 'dblclick' , 'check' , 'uncheck' , 'fill' , 'press' ] . includes ( metadata . method ) ;
558- }
559-
560- function showAfterSnapshot ( metadata : CallMetadata ) : boolean {
561- return [ 'goto' , 'click' , 'dblclick' , 'dblclick' , 'check' , 'uncheck' , 'fill' , 'press' ] . includes ( metadata . method ) ;
562- }
0 commit comments