UNPKG

@sentry/browser

Version:
124 lines (123 loc) • 4.29 kB
import { BrowserClient } from "./client.js"; import { breadcrumbsIntegration } from "./integrations/breadcrumbs.js"; import { browserApiErrorsIntegration } from "./integrations/browserapierrors.js"; import { browserSessionIntegration } from "./integrations/browsersession.js"; import { cultureContextIntegration } from "./integrations/culturecontext.js"; import { globalHandlersIntegration } from "./integrations/globalhandlers.js"; import { httpContextIntegration } from "./integrations/httpcontext.js"; import { linkedErrorsIntegration } from "./integrations/linkederrors.js"; import { spotlightBrowserIntegration } from "./integrations/spotlight.js"; import { defaultStackParser } from "./stack-parsers.js"; import { makeFetchTransport } from "./transports/fetch.js"; import { normalizeStringifyValue } from "./normalizeStringifyValue.js"; import { checkAndWarnIfIsEmbeddedBrowserExtension } from "./utils/detectBrowserExtension.js"; import { resolveBrowserTunnelOption } from "./utils/managedTunnel.js"; import { _INTERNAL_captureOptionsSetByUser, consoleIntegration, conversationIdIntegration, dedupeIntegration, eventFiltersIntegration, functionToStringIntegration, getIntegrationsToSetup, initAndBind, setNormalizeStringifier, stackParserFromStackParserOptions } from "@sentry/core"; // src/sdk.ts /** Get the default integrations for the browser SDK. */ function getDefaultIntegrations(_options) { /** * Note: Please make sure this stays in sync with Angular SDK, which re-exports * `getDefaultIntegrations` but with an adjusted set of integrations. */ return [ eventFiltersIntegration(), functionToStringIntegration(), conversationIdIntegration(), browserApiErrorsIntegration(), breadcrumbsIntegration(), consoleIntegration(), globalHandlersIntegration(), linkedErrorsIntegration(), dedupeIntegration(), httpContextIntegration(), cultureContextIntegration(), browserSessionIntegration() ]; } /** * The Sentry Browser SDK Client. * * To use this SDK, call the {@link init} function as early as possible when * loading the web page. To set context information or send manual events, use * the provided methods. * * @example * * ``` * * import { init } from '@sentry/browser'; * * init({ * dsn: '__DSN__', * // ... * }); * ``` * * @example * ``` * * import { addBreadcrumb } from '@sentry/browser'; * addBreadcrumb({ * message: 'My Breadcrumb', * // ... * }); * ``` * * @example * * ``` * * import * as Sentry from '@sentry/browser'; * Sentry.captureMessage('Hello, world!'); * Sentry.captureException(new Error('Good bye')); * Sentry.captureEvent({ * message: 'Manual', * stacktrace: [ * // ... * ], * }); * ``` * * @see {@link BrowserOptions} for documentation on configuration options. */ function init(userOptions = {}) { const options = _INTERNAL_captureOptionsSetByUser(userOptions); const shouldDisableBecauseIsBrowserExtenstion = !options.skipBrowserExtensionCheck && checkAndWarnIfIsEmbeddedBrowserExtension(); let defaultIntegrations = options.defaultIntegrations == null ? getDefaultIntegrations(options) : options.defaultIntegrations; /*! rollup-include-development-only */ if (options.spotlight) { if (!defaultIntegrations) defaultIntegrations = []; const args = typeof options.spotlight === "string" ? { sidecarUrl: options.spotlight } : void 0; defaultIntegrations.push(spotlightBrowserIntegration(args)); } /*! rollup-include-development-only-end */ const integrations = getIntegrationsToSetup({ integrations: options.integrations, defaultIntegrations }); const clientOptions = { ...options, ...resolveBrowserTunnelOption(options), enabled: shouldDisableBecauseIsBrowserExtenstion ? false : options.enabled, stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser), integrations, transport: options.transport || makeFetchTransport }; setNormalizeStringifier(normalizeStringifyValue); return initAndBind(BrowserClient, clientOptions); } /** * This function is here to be API compatible with the loader. * @hidden */ function forceLoad() {} /** * This function is here to be API compatible with the loader. * @hidden */ function onLoad(callback) { callback(); } export { forceLoad, getDefaultIntegrations, init, onLoad }; //# sourceMappingURL=sdk.js.map