MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / _INTERNAL_flushLogsBuffer

Function _INTERNAL_flushLogsBuffer

packages/core/src/logs/internal.ts:189–212  ·  view source on GitHub ↗
(client: Client, maybeLogBuffer?: Array<SerializedLog>)

Source from the content-addressed store, hash-verified

187 * the stable Sentry SDK API and can be changed or removed without warning.
188 */
189export function _INTERNAL_flushLogsBuffer(client: Client, maybeLogBuffer?: Array<SerializedLog>): void {
190 const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
191 if (logBuffer.length === 0) {
192 return;
193 }
194
195 const clientOptions = client.getOptions();
196 const envelope = createLogEnvelope(
197 logBuffer,
198 clientOptions._metadata,
199 clientOptions.tunnel,
200 client.getDsn(),
201 client.getDataCollectionOptions().userInfo,
202 );
203
204 // Clear the log buffer after envelopes have been constructed.
205 _getBufferMap().set(client, []);
206
207 client.emit('flushLogs');
208
209 // sendEnvelope should not throw
210 // eslint-disable-next-line @typescript-eslint/no-floating-promises
211 client.sendEnvelope(envelope);
212}
213
214/**
215 * Returns the log buffer for a given client.

Callers 7

internal.test.tsFile · 0.90
closeFunction · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.85

Calls 6

createLogEnvelopeFunction · 0.90
_INTERNAL_getLogBufferFunction · 0.85
_getBufferMapFunction · 0.70
getOptionsMethod · 0.65
setMethod · 0.65
emitMethod · 0.65

Tested by

no test coverage detected