Skip to content

Commit 152ae90

Browse files
authored
fix(client): deduplicate mic.capture_report trace emissions (#2189)
Reduces trace noise from `mic.capture_report` by only tracing when the `capturesAudio` value actually changes, rather than on every periodic emission during sustained silence. The internal `dispatchEvent` continues firing on every callback so downstream consumers are unaffected. ### 📝 Implementation notes - Added a `lastCapturesAudio` variable scoped to each no-audio detector instance inside `MicrophoneManager.setup()` - `tracer.trace('mic.capture_report', ...)` is now gated on `capturesAudio !== lastCapturesAudio` - `streamClient.dispatchEvent(event)` remains unconditional - The variable naturally resets when the detector is torn down on device switch or mic disable/re-enable, so the first emission from a new detector always traces
1 parent 649aea2 commit 152ae90

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/client/src/devices/MicrophoneManager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export class MicrophoneManager extends AudioDeviceManager<MicrophoneManagerState
158158
const devices = await firstValueFrom(this.listDevices());
159159
const label = devices.find((d) => d.deviceId === deviceId)?.label;
160160

161+
let lastCapturesAudio: boolean | undefined;
161162
this.noAudioDetectorCleanup = createNoAudioDetector(mediaStream, {
162163
noAudioThresholdMs: this.silenceThresholdMs,
163164
emitIntervalMs: this.silenceThresholdMs,
@@ -169,7 +170,12 @@ export class MicrophoneManager extends AudioDeviceManager<MicrophoneManagerState
169170
deviceId,
170171
label,
171172
};
172-
this.call.tracer.trace('mic.capture_report', event);
173+
174+
if (capturesAudio !== lastCapturesAudio) {
175+
lastCapturesAudio = capturesAudio;
176+
this.call.tracer.trace('mic.capture_report', event);
177+
}
178+
173179
this.call.streamClient.dispatchEvent(event);
174180
},
175181
});

0 commit comments

Comments
 (0)