MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / sendSession

Function sendSession

packages/core/src/client.ts:575–603  ·  view source on GitHub ↗

* Send a session or session aggregrates to Sentry.

(session: Session | SessionAggregates)

Source from the content-addressed store, hash-verified

573 * Send a session or session aggregrates to Sentry.
574 */
575 public sendSession(session: Session | SessionAggregates): void {
576 // Backfill release and environment on session
577 const { release: clientReleaseOption, environment: clientEnvironmentOption = DEFAULT_ENVIRONMENT } = this._options;
578 if ('aggregates' in session) {
579 const sessionAttrs = session.attrs || {};
580 if (!sessionAttrs.release && !clientReleaseOption) {
581 DEBUG_BUILD && debug.warn(MISSING_RELEASE_FOR_SESSION_ERROR);
582 return;
583 }
584 sessionAttrs.release = sessionAttrs.release || clientReleaseOption;
585 sessionAttrs.environment = sessionAttrs.environment || clientEnvironmentOption;
586 session.attrs = sessionAttrs;
587 } else {
588 if (!session.release && !clientReleaseOption) {
589 DEBUG_BUILD && debug.warn(MISSING_RELEASE_FOR_SESSION_ERROR);
590 return;
591 }
592 session.release = session.release || clientReleaseOption;
593 session.environment = session.environment || clientEnvironmentOption;
594 }
595
596 this.emit('beforeSendSession', session);
597
598 const env = createSessionEnvelope(session, this._dsn, this._options._metadata, this._options.tunnel);
599
600 // sendEnvelope should not throw
601 // eslint-disable-next-line @typescript-eslint/no-floating-promises
602 this.sendEnvelope(env);
603 }
604
605 /**
606 * Record on the client that an event got dropped (ie, an event that will not be sent to Sentry).

Callers

nothing calls this directly

Calls 3

createSessionEnvelopeFunction · 0.90
warnMethod · 0.65
emitMethod · 0.65

Tested by

no test coverage detected