Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const core = require('@sentry/core'); const debugBuild = require('../debug-build.js'); const INTEGRATION_NAME = "Spotlight"; const _spotlightIntegration = ((options = {}) => { const sidecarUrl = options.sidecarUrl || "http://localhost:8969/stream"; return { name: INTEGRATION_NAME, setup(client) { debugBuild.DEBUG_BUILD && core.debug.log("[Spotlight] Using Sidecar URL", sidecarUrl); setupSidecarForwarding(client, sidecarUrl); } }; }); const spotlightIntegration = core.defineIntegration(_spotlightIntegration); function setupSidecarForwarding(client, sidecarUrl) { const parsedUrl = parseSidecarUrl(sidecarUrl); if (!parsedUrl) { return; } let failCount = 0; client.on("beforeEnvelope", (envelope) => { if (failCount > 3) { debugBuild.DEBUG_BUILD && core.debug.warn("[Spotlight] Disabled Sentry -> Spotlight forwarding due to too many failed requests"); return; } const body = core.serializeEnvelope(envelope); core.suppressTracing(() => { fetch(parsedUrl.href, { method: "POST", body, headers: { "Content-Type": "application/x-sentry-envelope" } }).then( (res) => { res.text().catch(() => { }); if (res.status >= 200 && res.status < 400) { failCount = 0; } }, () => { failCount++; debugBuild.DEBUG_BUILD && core.debug.warn("[Spotlight] Failed to send envelope to Spotlight Sidecar"); } ); }); }); } function parseSidecarUrl(url) { try { return new URL(url); } catch { debugBuild.DEBUG_BUILD && core.debug.warn(`[Spotlight] Invalid sidecar URL: ${url}`); return void 0; } } exports.INTEGRATION_NAME = INTEGRATION_NAME; exports.spotlightIntegration = spotlightIntegration; //# sourceMappingURL=spotlight.js.map