livekit-client 1.15.6 → 1.15.8

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 +556 -348
  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 +5 -4
  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 +5 -4
  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 +2 -2
  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 +91 -60
  98. package/src/room/participant/LocalParticipant.ts +165 -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 +23 -19
  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
 
@@ -1116,45 +1142,18 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1116
1142
 
1117
1143
  try {
1118
1144
  // unpublish & republish tracks
1119
- const localPubs: LocalTrackPublication[] = [];
1120
- this.localParticipant.tracks.forEach((pub) => {
1121
- if (pub.track) {
1122
- localPubs.push(pub);
1123
- }
1124
- });
1125
-
1126
- await Promise.all(
1127
- localPubs.map(async (pub) => {
1128
- const track = pub.track!;
1129
- this.localParticipant.unpublishTrack(track, false);
1130
- if (!track.isMuted) {
1131
- if (
1132
- (track instanceof LocalAudioTrack || track instanceof LocalVideoTrack) &&
1133
- track.source !== Track.Source.ScreenShare &&
1134
- track.source !== Track.Source.ScreenShareAudio &&
1135
- !track.isUserProvided
1136
- ) {
1137
- // we need to restart the track before publishing, often a full reconnect
1138
- // is necessary because computer had gone to sleep.
1139
- log.debug('restarting existing track', {
1140
- track: pub.trackSid,
1141
- });
1142
- await track.restartTrack();
1143
- }
1144
- log.debug('publishing new track', {
1145
- track: pub.trackSid,
1146
- });
1147
- await this.localParticipant.publishTrack(track, pub.options);
1148
- }
1149
- }),
1150
- );
1145
+ await this.localParticipant.republishAllTracks(undefined, true);
1151
1146
  } catch (error) {
1152
- log.error('error trying to re-publish tracks after reconnection', { error });
1147
+ this.log.error('error trying to re-publish tracks after reconnection', {
1148
+ ...this.logContext,
1149
+ error,
1150
+ });
1153
1151
  }
1154
1152
 
1155
1153
  try {
1156
1154
  await this.engine.waitForRestarted();
1157
- log.debug(`fully reconnected to server`, {
1155
+ this.log.debug(`fully reconnected to server`, {
1156
+ ...this.logContext,
1158
1157
  region: joinResponse.serverRegion,
1159
1158
  });
1160
1159
  } catch {
@@ -1411,7 +1410,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1411
1410
  };
1412
1411
 
1413
1412
  private handleAudioPlaybackFailed = (e: any) => {
1414
- log.warn('could not playback audio', e);
1413
+ this.log.warn('could not playback audio', { ...this.logContext, error: e });
1415
1414
  if (!this.canPlaybackAudio) {
1416
1415
  return;
1417
1416
  }
@@ -1480,7 +1479,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1480
1479
  try {
1481
1480
  await this.audioContext.resume();
1482
1481
  } catch (e: any) {
1483
- log.warn(e);
1482
+ this.log.warn('Could not resume audio context', { ...this.logContext, error: e });
1484
1483
  }
1485
1484
  }
1486
1485
 
@@ -1502,7 +1501,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1502
1501
  if (info) {
1503
1502
  participant = RemoteParticipant.fromParticipantInfo(this.engine.client, info);
1504
1503
  } else {
1505
- participant = new RemoteParticipant(this.engine.client, id, '', undefined, undefined);
1504
+ participant = new RemoteParticipant(this.engine.client, id, '', undefined, undefined, {
1505
+ loggerContextCb: () => this.logContext,
1506
+ loggerName: this.options.loggerName,
1507
+ });
1506
1508
  }
1507
1509
  if (this.options.expWebAudioMix) {
1508
1510
  participant.setAudioContext(this.audioContext);
@@ -1510,7 +1512,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1510
1512
  if (this.options.audioOutput?.deviceId) {
1511
1513
  participant
1512
1514
  .setAudioOutput(this.options.audioOutput)
1513
- .catch((e) => log.warn(`Could not set audio output: ${e.message}`));
1515
+ .catch((e) => this.log.warn(`Could not set audio output: ${e.message}`, this.logContext));
1514
1516
  }
1515
1517
  return participant;
1516
1518
  }
@@ -1643,7 +1645,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1643
1645
  !this.engine.verifyTransport()
1644
1646
  ) {
1645
1647
  consecutiveFailures++;
1646
- log.warn('detected connection state mismatch', { numFailures: consecutiveFailures });
1648
+ this.log.warn('detected connection state mismatch', {
1649
+ ...this.logContext,
1650
+ numFailures: consecutiveFailures,
1651
+ });
1647
1652
  if (consecutiveFailures >= 3) {
1648
1653
  this.recreateEngine();
1649
1654
  this.handleDisconnect(
@@ -1799,7 +1804,11 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1799
1804
  true,
1800
1805
  true,
1801
1806
  ),
1807
+ undefined,
1808
+ false,
1809
+ { loggerName: this.options.loggerName, loggerContextCb: () => this.logContext },
1802
1810
  ),
1811
+ { loggerName: this.options.loggerName, loggerContextCb: () => this.logContext },
1803
1812
  );
1804
1813
  // @ts-ignore
1805
1814
  this.localParticipant.addTrackPublication(camPub);
@@ -1817,7 +1826,12 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1817
1826
  publishOptions.useRealTracks
1818
1827
  ? (await navigator.mediaDevices.getUserMedia({ audio: true })).getAudioTracks()[0]
1819
1828
  : getEmptyAudioStreamTrack(),
1829
+ undefined,
1830
+ false,
1831
+ this.audioContext,
1832
+ { loggerName: this.options.loggerName, loggerContextCb: () => this.logContext },
1820
1833
  ),
1834
+ { loggerName: this.options.loggerName, loggerContextCb: () => this.logContext },
1821
1835
  );
1822
1836
  // @ts-ignore
1823
1837
  this.localParticipant.addTrackPublication(audioPub);
@@ -1870,12 +1884,29 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1870
1884
  ): boolean {
1871
1885
  // active speaker updates are too spammy
1872
1886
  if (event !== RoomEvent.ActiveSpeakersChanged) {
1873
- log.debug(`room event ${event}`, { event, args });
1887
+ // only extract logContext from arguments in order to avoid logging the whole object tree
1888
+ const minimizedArgs = mapArgs(args).filter((arg: unknown) => arg !== undefined);
1889
+ this.log.debug(`room event ${event}`, { ...this.logContext, event, args: minimizedArgs });
1874
1890
  }
1875
1891
  return super.emit(event, ...args);
1876
1892
  }
1877
1893
  }
1878
1894
 
1895
+ function mapArgs(args: unknown[]): any {
1896
+ return args.map((arg: unknown) => {
1897
+ if (!arg) {
1898
+ return;
1899
+ }
1900
+ if (Array.isArray(arg)) {
1901
+ return mapArgs(arg);
1902
+ }
1903
+ if (typeof arg === 'object') {
1904
+ return 'logContext' in arg && arg.logContext;
1905
+ }
1906
+ return arg;
1907
+ });
1908
+ }
1909
+
1879
1910
  export default Room;
1880
1911
 
1881
1912
  export type RoomEventCallbacks = {