livekit-client 1.15.5 → 1.15.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +14 -1
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +561 -328
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.umd.js +1 -1
  8. package/dist/livekit-client.umd.js.map +1 -1
  9. package/dist/src/api/SignalClient.d.ts +5 -1
  10. package/dist/src/api/SignalClient.d.ts.map +1 -1
  11. package/dist/src/index.d.ts +2 -2
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/dist/src/logger.d.ts +19 -3
  14. package/dist/src/logger.d.ts.map +1 -1
  15. package/dist/src/options.d.ts +1 -0
  16. package/dist/src/options.d.ts.map +1 -1
  17. package/dist/src/room/PCTransport.d.ts +5 -1
  18. package/dist/src/room/PCTransport.d.ts.map +1 -1
  19. package/dist/src/room/PCTransportManager.d.ts +5 -1
  20. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  21. package/dist/src/room/RTCEngine.d.ts +8 -0
  22. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  23. package/dist/src/room/Room.d.ts +2 -0
  24. package/dist/src/room/Room.d.ts.map +1 -1
  25. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  26. package/dist/src/room/participant/Participant.d.ts +9 -1
  27. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  28. package/dist/src/room/participant/RemoteParticipant.d.ts +2 -1
  29. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  30. package/dist/src/room/participant/publishUtils.d.ts +2 -1
  31. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  32. package/dist/src/room/timers.d.ts +4 -5
  33. package/dist/src/room/timers.d.ts.map +1 -1
  34. package/dist/src/room/track/LocalAudioTrack.d.ts +2 -1
  35. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  36. package/dist/src/room/track/LocalTrack.d.ts +2 -1
  37. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  38. package/dist/src/room/track/LocalTrackPublication.d.ts +2 -1
  39. package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
  40. package/dist/src/room/track/LocalVideoTrack.d.ts +2 -1
  41. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  42. package/dist/src/room/track/RemoteAudioTrack.d.ts +2 -1
  43. package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
  44. package/dist/src/room/track/RemoteTrack.d.ts +2 -1
  45. package/dist/src/room/track/RemoteTrack.d.ts.map +1 -1
  46. package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -1
  47. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  48. package/dist/src/room/track/RemoteVideoTrack.d.ts +2 -1
  49. package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
  50. package/dist/src/room/track/Track.d.ts +10 -1
  51. package/dist/src/room/track/Track.d.ts.map +1 -1
  52. package/dist/src/room/track/TrackPublication.d.ts +7 -1
  53. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  54. package/dist/src/room/track/create.d.ts.map +1 -1
  55. package/dist/src/room/track/options.d.ts +8 -3
  56. package/dist/src/room/track/options.d.ts.map +1 -1
  57. package/dist/src/room/track/utils.d.ts +1 -0
  58. package/dist/src/room/track/utils.d.ts.map +1 -1
  59. package/dist/src/room/types.d.ts +4 -0
  60. package/dist/src/room/types.d.ts.map +1 -1
  61. package/dist/src/room/utils.d.ts +1 -0
  62. package/dist/src/room/utils.d.ts.map +1 -1
  63. package/dist/ts4.2/src/api/SignalClient.d.ts +5 -1
  64. package/dist/ts4.2/src/index.d.ts +2 -2
  65. package/dist/ts4.2/src/logger.d.ts +19 -3
  66. package/dist/ts4.2/src/options.d.ts +1 -0
  67. package/dist/ts4.2/src/room/PCTransport.d.ts +5 -1
  68. package/dist/ts4.2/src/room/PCTransportManager.d.ts +5 -1
  69. package/dist/ts4.2/src/room/RTCEngine.d.ts +8 -0
  70. package/dist/ts4.2/src/room/Room.d.ts +2 -0
  71. package/dist/ts4.2/src/room/participant/Participant.d.ts +9 -1
  72. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +2 -1
  73. package/dist/ts4.2/src/room/participant/publishUtils.d.ts +2 -1
  74. package/dist/ts4.2/src/room/timers.d.ts +4 -5
  75. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +2 -1
  76. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +2 -1
  77. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +2 -1
  78. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +2 -1
  79. package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +2 -1
  80. package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +2 -1
  81. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +2 -1
  82. package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +2 -1
  83. package/dist/ts4.2/src/room/track/Track.d.ts +10 -1
  84. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +7 -1
  85. package/dist/ts4.2/src/room/track/options.d.ts +8 -3
  86. package/dist/ts4.2/src/room/track/utils.d.ts +1 -0
  87. package/dist/ts4.2/src/room/types.d.ts +4 -0
  88. package/dist/ts4.2/src/room/utils.d.ts +1 -0
  89. package/package.json +15 -15
  90. package/src/api/SignalClient.ts +43 -21
  91. package/src/index.ts +2 -1
  92. package/src/logger.ts +32 -8
  93. package/src/options.ts +2 -0
  94. package/src/room/PCTransport.ts +29 -8
  95. package/src/room/PCTransportManager.ts +29 -9
  96. package/src/room/RTCEngine.ts +71 -34
  97. package/src/room/Room.ts +94 -30
  98. package/src/room/participant/LocalParticipant.ts +163 -47
  99. package/src/room/participant/Participant.ts +26 -3
  100. package/src/room/participant/RemoteParticipant.ts +23 -15
  101. package/src/room/participant/publishUtils.test.ts +2 -2
  102. package/src/room/participant/publishUtils.ts +7 -4
  103. package/src/room/track/LocalAudioTrack.ts +8 -7
  104. package/src/room/track/LocalTrack.ts +27 -20
  105. package/src/room/track/LocalTrackPublication.ts +3 -2
  106. package/src/room/track/LocalVideoTrack.ts +31 -13
  107. package/src/room/track/RemoteAudioTrack.ts +4 -3
  108. package/src/room/track/RemoteTrack.ts +4 -1
  109. package/src/room/track/RemoteTrackPublication.ts +21 -13
  110. package/src/room/track/RemoteVideoTrack.ts +5 -4
  111. package/src/room/track/Track.ts +32 -2
  112. package/src/room/track/TrackPublication.ts +18 -3
  113. package/src/room/track/create.ts +4 -3
  114. package/src/room/track/options.ts +12 -5
  115. package/src/room/track/utils.ts +23 -1
  116. package/src/room/types.ts +5 -0
  117. package/src/room/utils.ts +5 -0
package/src/room/Room.ts CHANGED
@@ -4,7 +4,7 @@ import type TypedEmitter from 'typed-emitter';
4
4
  import 'webrtc-adapter';
5
5
  import { EncryptionEvent } from '../e2ee';
6
6
  import { E2EEManager } from '../e2ee/E2eeManager';
7
- import log from '../logger';
7
+ import log, { LoggerNames, getLogger } from '../logger';
8
8
  import type {
9
9
  InternalRoomConnectOptions,
10
10
  InternalRoomOptions,
@@ -151,6 +151,8 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
151
151
 
152
152
  private isVideoPlaybackBlocked: boolean = false;
153
153
 
154
+ private log = log;
155
+
154
156
  /**
155
157
  * Creates a new Room, the primary construct for a LiveKit session.
156
158
  * @param options
@@ -163,6 +165,8 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
163
165
  this.identityToSid = new Map();
164
166
  this.options = { ...roomOptionDefaults, ...options };
165
167
 
168
+ this.log = getLogger(this.options.loggerName ?? LoggerNames.Room);
169
+
166
170
  this.options.audioCaptureDefaults = {
167
171
  ...audioDefaults,
168
172
  ...options?.audioCaptureDefaults,
@@ -198,7 +202,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
198
202
  this.switchActiveDevice(
199
203
  'audiooutput',
200
204
  unwrapConstraint(this.options.audioOutput.deviceId),
201
- ).catch((e) => log.warn(`Could not set audio output: ${e.message}`));
205
+ ).catch((e) => this.log.warn(`Could not set audio output: ${e.message}`, this.logContext));
202
206
  }
203
207
 
204
208
  if (this.options.e2ee) {
@@ -239,6 +243,14 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
239
243
  }
240
244
  }
241
245
 
246
+ private get logContext() {
247
+ return {
248
+ room: this.name,
249
+ roomSid: this.sid,
250
+ identity: this.localParticipant.identity,
251
+ };
252
+ }
253
+
242
254
  /**
243
255
  * if the current room has a participant with `recorder: true` in its JWT grant
244
256
  **/
@@ -362,7 +374,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
362
374
  if (this.state !== ConnectionState.Disconnected) {
363
375
  return;
364
376
  }
365
- log.debug(`prepareConnection to ${url}`);
377
+ this.log.debug(`prepareConnection to ${url}`, this.logContext);
366
378
  try {
367
379
  if (isCloud(new URL(url)) && token) {
368
380
  this.regionUrlProvider = new RegionUrlProvider(url, token);
@@ -372,13 +384,13 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
372
384
  if (regionUrl && this.state === ConnectionState.Disconnected) {
373
385
  this.regionUrl = regionUrl;
374
386
  await fetch(toHttpUrl(regionUrl), { method: 'HEAD' });
375
- log.debug(`prepared connection to ${regionUrl}`);
387
+ this.log.debug(`prepared connection to ${regionUrl}`, this.logContext);
376
388
  }
377
389
  } else {
378
390
  await fetch(toHttpUrl(url), { method: 'HEAD' });
379
391
  }
380
392
  } catch (e) {
381
- log.warn('could not prepare connection', { error: e });
393
+ this.log.warn('could not prepare connection', { ...this.logContext, error: e });
382
394
  }
383
395
  }
384
396
 
@@ -388,7 +400,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
388
400
 
389
401
  if (this.state === ConnectionState.Connected) {
390
402
  // when the state is reconnecting or connected, this function returns immediately
391
- log.info(`already connected to room ${this.name}`);
403
+ this.log.info(`already connected to room ${this.name}`, this.logContext);
392
404
  unlockDisconnect();
393
405
  return Promise.resolve();
394
406
  }
@@ -413,7 +425,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
413
425
  // if initial connection fails, this will speed up picking regional url
414
426
  // on subsequent runs
415
427
  this.regionUrlProvider.fetchRegionSettings().catch((e) => {
416
- log.warn('could not fetch region settings', { error: e });
428
+ this.log.warn('could not fetch region settings', { ...this.logContext, error: e });
417
429
  });
418
430
  }
419
431
 
@@ -460,8 +472,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
460
472
  }
461
473
  }
462
474
  if (nextUrl) {
463
- log.info(
475
+ this.log.info(
464
476
  `Initial connection failed with ConnectionError: ${e.message}. Retrying with another region: ${nextUrl}`,
477
+ this.logContext,
465
478
  );
466
479
  await connectFn(resolve, reject, nextUrl);
467
480
  } else {
@@ -517,10 +530,15 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
517
530
  serverInfo = { version: joinResponse.serverVersion, region: joinResponse.serverRegion };
518
531
  }
519
532
 
520
- log.debug(
533
+ this.log.debug(
521
534
  `connected to Livekit Server ${Object.entries(serverInfo)
522
535
  .map(([key, value]) => `${key}: ${value}`)
523
536
  .join(', ')}`,
537
+ {
538
+ room: joinResponse.room?.name,
539
+ roomSid: joinResponse.room?.sid,
540
+ identity: joinResponse.participant?.identity,
541
+ },
524
542
  );
525
543
 
526
544
  if (!joinResponse.serverVersion) {
@@ -528,7 +546,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
528
546
  }
529
547
 
530
548
  if (joinResponse.serverVersion === '0.15.1' && this.options.dynacast) {
531
- log.debug('disabling dynacast due to server version');
549
+ this.log.debug('disabling dynacast due to server version', this.logContext);
532
550
  // dynacast has a bug in 0.15.1, so we cannot use it then
533
551
  roomOptions.dynacast = false;
534
552
  }
@@ -561,7 +579,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
561
579
  abortController: AbortController,
562
580
  ) => {
563
581
  if (this.state === ConnectionState.Reconnecting) {
564
- log.info('Reconnection attempt replaced by new connection attempt');
582
+ this.log.info('Reconnection attempt replaced by new connection attempt', this.logContext);
565
583
  // make sure we close and recreate the existing engine in order to get rid of any potentially ongoing reconnection attempts
566
584
  this.recreateEngine();
567
585
  } else {
@@ -608,7 +626,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
608
626
  resultingError.reason = err.reason;
609
627
  resultingError.status = err.status;
610
628
  }
611
- log.debug(`error trying to establish signal connection`, { error: err });
629
+ this.log.debug(`error trying to establish signal connection`, {
630
+ ...this.logContext,
631
+ error: err,
632
+ });
612
633
  throw resultingError;
613
634
  }
614
635
 
@@ -651,16 +672,18 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
651
672
  const unlock = await this.disconnectLock.lock();
652
673
  try {
653
674
  if (this.state === ConnectionState.Disconnected) {
654
- log.debug('already disconnected');
675
+ this.log.debug('already disconnected', this.logContext);
655
676
  return;
656
677
  }
657
- log.info('disconnect from room', { identity: this.localParticipant.identity });
678
+ this.log.info('disconnect from room', {
679
+ ...this.logContext,
680
+ });
658
681
  if (
659
682
  this.state === ConnectionState.Connecting ||
660
683
  this.state === ConnectionState.Reconnecting
661
684
  ) {
662
685
  // try aborting pending connection attempt
663
- log.warn('abort connection attempt');
686
+ this.log.warn('abort connection attempt', this.logContext);
664
687
  this.abortController?.abort();
665
688
  // in case the abort controller didn't manage to cancel the connection attempt, reject the connect promise explicitly
666
689
  this.connectFuture?.reject?.(new ConnectionError('Client initiated disconnect'));
@@ -886,8 +909,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
886
909
  if (e.name === 'NotAllowedError') {
887
910
  this.handleVideoPlaybackFailed();
888
911
  } else {
889
- log.warn(
912
+ this.log.warn(
890
913
  'Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler',
914
+ this.logContext,
891
915
  );
892
916
  }
893
917
  });
@@ -1052,7 +1076,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1052
1076
  return;
1053
1077
  }
1054
1078
  if (this.state === ConnectionState.Disconnected) {
1055
- log.warn('skipping incoming track after Room disconnected');
1079
+ this.log.warn('skipping incoming track after Room disconnected', this.logContext);
1056
1080
  return;
1057
1081
  }
1058
1082
  const parts = unpackStreamId(stream.id);
@@ -1064,15 +1088,16 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1064
1088
  if (streamId && streamId.startsWith('TR')) trackId = streamId;
1065
1089
 
1066
1090
  if (participantId === this.localParticipant.sid) {
1067
- log.warn('tried to create RemoteParticipant for local participant');
1091
+ this.log.warn('tried to create RemoteParticipant for local participant', this.logContext);
1068
1092
  return;
1069
1093
  }
1070
1094
 
1071
1095
  const participant = this.participants.get(participantId) as RemoteParticipant | undefined;
1072
1096
 
1073
1097
  if (!participant) {
1074
- log.error(
1098
+ this.log.error(
1075
1099
  `Tried to add a track for a participant, that's not present. Sid: ${participantId}`,
1100
+ this.logContext,
1076
1101
  );
1077
1102
  return;
1078
1103
  }
@@ -1107,7 +1132,8 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1107
1132
  };
1108
1133
 
1109
1134
  private handleSignalRestarted = async (joinResponse: JoinResponse) => {
1110
- log.debug(`signal reconnected to server`, {
1135
+ this.log.debug(`signal reconnected to server, region ${joinResponse.serverRegion}`, {
1136
+ ...this.logContext,
1111
1137
  region: joinResponse.serverRegion,
1112
1138
  });
1113
1139
 
@@ -1136,12 +1162,14 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1136
1162
  ) {
1137
1163
  // we need to restart the track before publishing, often a full reconnect
1138
1164
  // is necessary because computer had gone to sleep.
1139
- log.debug('restarting existing track', {
1165
+ this.log.debug('restarting existing track', {
1166
+ ...this.logContext,
1140
1167
  track: pub.trackSid,
1141
1168
  });
1142
1169
  await track.restartTrack();
1143
1170
  }
1144
- log.debug('publishing new track', {
1171
+ this.log.debug('publishing new track', {
1172
+ ...this.logContext,
1145
1173
  track: pub.trackSid,
1146
1174
  });
1147
1175
  await this.localParticipant.publishTrack(track, pub.options);
@@ -1149,12 +1177,16 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1149
1177
  }),
1150
1178
  );
1151
1179
  } catch (error) {
1152
- log.error('error trying to re-publish tracks after reconnection', { error });
1180
+ this.log.error('error trying to re-publish tracks after reconnection', {
1181
+ ...this.logContext,
1182
+ error,
1183
+ });
1153
1184
  }
1154
1185
 
1155
1186
  try {
1156
1187
  await this.engine.waitForRestarted();
1157
- log.debug(`fully reconnected to server`, {
1188
+ this.log.debug(`fully reconnected to server`, {
1189
+ ...this.logContext,
1158
1190
  region: joinResponse.serverRegion,
1159
1191
  });
1160
1192
  } catch {
@@ -1411,7 +1443,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1411
1443
  };
1412
1444
 
1413
1445
  private handleAudioPlaybackFailed = (e: any) => {
1414
- log.warn('could not playback audio', e);
1446
+ this.log.warn('could not playback audio', { ...this.logContext, error: e });
1415
1447
  if (!this.canPlaybackAudio) {
1416
1448
  return;
1417
1449
  }
@@ -1480,7 +1512,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1480
1512
  try {
1481
1513
  await this.audioContext.resume();
1482
1514
  } catch (e: any) {
1483
- log.warn(e);
1515
+ this.log.warn('Could not resume audio context', { ...this.logContext, error: e });
1484
1516
  }
1485
1517
  }
1486
1518
 
@@ -1502,7 +1534,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1502
1534
  if (info) {
1503
1535
  participant = RemoteParticipant.fromParticipantInfo(this.engine.client, info);
1504
1536
  } else {
1505
- participant = new RemoteParticipant(this.engine.client, id, '', undefined, undefined);
1537
+ participant = new RemoteParticipant(this.engine.client, id, '', undefined, undefined, {
1538
+ loggerContextCb: () => this.logContext,
1539
+ loggerName: this.options.loggerName,
1540
+ });
1506
1541
  }
1507
1542
  if (this.options.expWebAudioMix) {
1508
1543
  participant.setAudioContext(this.audioContext);
@@ -1510,7 +1545,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1510
1545
  if (this.options.audioOutput?.deviceId) {
1511
1546
  participant
1512
1547
  .setAudioOutput(this.options.audioOutput)
1513
- .catch((e) => log.warn(`Could not set audio output: ${e.message}`));
1548
+ .catch((e) => this.log.warn(`Could not set audio output: ${e.message}`, this.logContext));
1514
1549
  }
1515
1550
  return participant;
1516
1551
  }
@@ -1643,7 +1678,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1643
1678
  !this.engine.verifyTransport()
1644
1679
  ) {
1645
1680
  consecutiveFailures++;
1646
- log.warn('detected connection state mismatch', { numFailures: consecutiveFailures });
1681
+ this.log.warn('detected connection state mismatch', {
1682
+ ...this.logContext,
1683
+ numFailures: consecutiveFailures,
1684
+ });
1647
1685
  if (consecutiveFailures >= 3) {
1648
1686
  this.recreateEngine();
1649
1687
  this.handleDisconnect(
@@ -1799,7 +1837,11 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1799
1837
  true,
1800
1838
  true,
1801
1839
  ),
1840
+ undefined,
1841
+ false,
1842
+ { loggerName: this.options.loggerName, loggerContextCb: () => this.logContext },
1802
1843
  ),
1844
+ { loggerName: this.options.loggerName, loggerContextCb: () => this.logContext },
1803
1845
  );
1804
1846
  // @ts-ignore
1805
1847
  this.localParticipant.addTrackPublication(camPub);
@@ -1817,7 +1859,12 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1817
1859
  publishOptions.useRealTracks
1818
1860
  ? (await navigator.mediaDevices.getUserMedia({ audio: true })).getAudioTracks()[0]
1819
1861
  : getEmptyAudioStreamTrack(),
1862
+ undefined,
1863
+ false,
1864
+ this.audioContext,
1865
+ { loggerName: this.options.loggerName, loggerContextCb: () => this.logContext },
1820
1866
  ),
1867
+ { loggerName: this.options.loggerName, loggerContextCb: () => this.logContext },
1821
1868
  );
1822
1869
  // @ts-ignore
1823
1870
  this.localParticipant.addTrackPublication(audioPub);
@@ -1870,12 +1917,29 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1870
1917
  ): boolean {
1871
1918
  // active speaker updates are too spammy
1872
1919
  if (event !== RoomEvent.ActiveSpeakersChanged) {
1873
- log.debug(`room event ${event}`, { event, args });
1920
+ // only extract logContext from arguments in order to avoid logging the whole object tree
1921
+ const minimizedArgs = mapArgs(args).filter((arg: unknown) => arg !== undefined);
1922
+ this.log.debug(`room event ${event}`, { ...this.logContext, event, args: minimizedArgs });
1874
1923
  }
1875
1924
  return super.emit(event, ...args);
1876
1925
  }
1877
1926
  }
1878
1927
 
1928
+ function mapArgs(args: unknown[]): any {
1929
+ return args.map((arg: unknown) => {
1930
+ if (!arg) {
1931
+ return;
1932
+ }
1933
+ if (Array.isArray(arg)) {
1934
+ return mapArgs(arg);
1935
+ }
1936
+ if (typeof arg === 'object') {
1937
+ return 'logContext' in arg && arg.logContext;
1938
+ }
1939
+ return arg;
1940
+ });
1941
+ }
1942
+
1879
1943
  export default Room;
1880
1944
 
1881
1945
  export type RoomEventCallbacks = {