11import ISessionMeta from '@secret-agent/core-interfaces/ISessionMeta' ;
22import IConfigureSessionOptions from '@secret-agent/core-interfaces/IConfigureSessionOptions' ;
33import { IJsPath } from 'awaited-dom/base/AwaitedPath' ;
4+ import { loggerSessionIdNames } from '@secret-agent/commons/Logger' ;
45import CoreCommandQueue from './CoreCommandQueue' ;
56import CoreEventHeap from './CoreEventHeap' ;
67import CoreTab from './CoreTab' ;
@@ -10,6 +11,7 @@ import CoreClientConnection from '../connections/CoreClientConnection';
1011export default class CoreSession implements IJsPathEventTarget {
1112 public tabsById = new Map < string , CoreTab > ( ) ;
1213 public sessionId : string ;
14+ public sessionName : string ;
1315 public sessionsDataLocation : string ;
1416 public replayApiServer : string ;
1517 public commandQueue : CoreCommandQueue ;
@@ -22,17 +24,23 @@ export default class CoreSession implements IJsPathEventTarget {
2224 protected readonly meta : ISessionMeta ;
2325 private readonly connection : CoreClientConnection ;
2426
25- constructor ( sessionMeta : ISessionMeta , connection : CoreClientConnection ) {
26- const { sessionId, sessionsDataLocation, replayApiServer } = sessionMeta ;
27+ constructor (
28+ sessionMeta : ISessionMeta & { sessionName : string } ,
29+ connection : CoreClientConnection ,
30+ ) {
31+ const { sessionId, sessionsDataLocation, replayApiServer, sessionName } = sessionMeta ;
2732 this . sessionId = sessionId ;
33+ this . sessionName = sessionName ;
2834 this . sessionsDataLocation = sessionsDataLocation ;
2935 this . replayApiServer = replayApiServer ;
3036 this . meta = {
3137 sessionId,
3238 } ;
3339 this . connection = connection ;
34- this . commandQueue = new CoreCommandQueue ( this . meta , connection ) ;
40+ loggerSessionIdNames . set ( sessionId , sessionName ) ;
41+ this . commandQueue = new CoreCommandQueue ( { sessionId, sessionName } , connection ) ;
3542 this . eventHeap = new CoreEventHeap ( this . meta , connection ) ;
43+
3644 this . addTab ( sessionMeta ) ;
3745 }
3846
@@ -59,7 +67,10 @@ export default class CoreSession implements IJsPathEventTarget {
5967
6068 public addTab ( tabMeta : ISessionMeta ) : void {
6169 if ( ! this . tabsById . has ( tabMeta . tabId ) ) {
62- this . tabsById . set ( tabMeta . tabId , new CoreTab ( tabMeta , this . connection ) ) ;
70+ this . tabsById . set (
71+ tabMeta . tabId ,
72+ new CoreTab ( { ...tabMeta , sessionName : this . sessionName } , this . connection ) ,
73+ ) ;
6374 }
6475 }
6576
@@ -70,6 +81,7 @@ export default class CoreSession implements IJsPathEventTarget {
7081 public async close ( ) : Promise < void > {
7182 await this . commandQueue . run ( 'closeSession' ) ;
7283 process . nextTick ( ( ) => this . connection . closeSession ( this ) ) ;
84+ loggerSessionIdNames . delete ( this . sessionId ) ;
7385 }
7486
7587 public async addEventListener (
0 commit comments