UNPKG

@sentry/node

Version:

Sentry Node SDK using OpenTelemetry for performance instrumentation

34 lines (31 loc) • 1.03 kB
import { defineIntegration, startSession, getIsolationScope, endSession, closeSession } from '@sentry/core'; const INTEGRATION_NAME = "ProcessSession"; const processSessionIntegration = defineIntegration(() => { return { name: INTEGRATION_NAME, setup(client) { startSession(); const processIsolationScope = getIsolationScope(); process.on("beforeExit", () => { const session = getIsolationScope().getSession(); if (session?.status === "ok") { endSession(); } }); const unsubscribe = client.on("startRequestSession", () => { unsubscribe(); const session = processIsolationScope.getSession(); if (!session) { return; } if (!session.init && session.status === "ok") { closeSession(session); client.captureSession(session); } processIsolationScope.setSession(); }); } }; }); export { processSessionIntegration }; //# sourceMappingURL=processSession.js.map