UNPKG

@sentry/browser

Version:
30 lines (29 loc) • 1.29 kB
let _sentry_core = require("@sentry/core"); // src/diagnose-sdk.ts /** * A function to diagnose why the SDK might not be successfully sending data. * * Possible return values wrapped in a Promise: * - `"no-client-active"` - There was no active client when the function was called. This possibly means that the SDK was not initialized yet. * - `"sentry-unreachable"` - The Sentry SaaS servers were not reachable. This likely means that there is an ad blocker active on the page or that there are other connection issues. * * If the function doesn't detect an issue it resolves to `undefined`. */ async function diagnoseSdkConnectivity() { const client = (0, _sentry_core.getClient)(); if (!client) return "no-client-active"; if (!client.getDsn()) return "no-dsn-configured"; const url = client.getOptions().tunnel || "https://o447951.ingest.sentry.io/api/4509632503087104/envelope/?sentry_version=7&sentry_key=c1dfb07d783ad5325c245c1fd3725390&sentry_client=sentry.javascript.browser%2F1.33.7"; try { await (0, _sentry_core.suppressTracing)(() => fetch(url, { body: "{}", method: "POST", mode: "cors", credentials: "omit" })); } catch { return "sentry-unreachable"; } } exports.diagnoseSdkConnectivity = diagnoseSdkConnectivity; //# sourceMappingURL=diagnose-sdk.js.map