@sentry/browser
Version:
Official Sentry SDK for browsers
32 lines (28 loc) • 1.32 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const core = require('@sentry/core');
const debugBuild = require('../debug-build.js');
function resolveBrowserTunnelOption(options) {
const { tunnel, dsn, transportOptions } = options;
if (!tunnel || typeof tunnel === "string") {
return { tunnel, transportOptions };
}
const tunnelOptions = tunnel === true ? {} : tunnel;
const dsnComponents = dsn && core.makeDsn(dsn);
const tunnelPath = tunnelOptions.path ?? (dsnComponents && core.getTunnelPath(dsnComponents));
if (!tunnelPath) {
return { tunnel: void 0, transportOptions };
}
const basePath = core._INTERNAL_normalizeTunnelBasePath(tunnelOptions.basePath);
const resolvedTunnel = `${basePath}${tunnelPath}${tunnelOptions.trailingSlash ? "/" : ""}`;
debugBuild.DEBUG_BUILD && core.debug.log(`Tunneling events to "${resolvedTunnel}"`);
return {
tunnel: resolvedTunnel,
transportOptions: {
...transportOptions,
// CSRF protection (SvelteKit, Astro) rejects the default `text/plain` POST to the tunnel as a form submission.
headers: { "Content-Type": "application/x-sentry-envelope", ...transportOptions?.headers }
}
};
}
exports.resolveBrowserTunnelOption = resolveBrowserTunnelOption;
//# sourceMappingURL=managedTunnel.js.map