@sentry/browser

  • Version 7.36.0
  • Published
  • 458 kB
  • 5 dependencies
  • MIT license

Install

npm i @sentry/browser
yarn add @sentry/browser
pnpm add @sentry/browser

Overview

Official Sentry SDK for browsers

Index

Variables

variable chromeStackLineParser

const chromeStackLineParser: StackLineParser;

    variable defaultIntegrations

    const defaultIntegrations: any[];

      variable defaultStackLineParsers

      const defaultStackLineParsers: StackLineParser[];

        variable defaultStackParser

        const defaultStackParser: any;

          variable geckoStackLineParser

          const geckoStackLineParser: StackLineParser;

            variable Integrations

            const Integrations: {
            GlobalHandlers: typeof BrowserIntegrations.GlobalHandlers;
            TryCatch: typeof BrowserIntegrations.TryCatch;
            Breadcrumbs: typeof BrowserIntegrations.Breadcrumbs;
            LinkedErrors: typeof BrowserIntegrations.LinkedErrors;
            HttpContext: typeof BrowserIntegrations.HttpContext;
            Dedupe: typeof BrowserIntegrations.Dedupe;
            FunctionToString: any;
            InboundFilters: any;
            };

              variable opera10StackLineParser

              const opera10StackLineParser: StackLineParser;

                variable opera11StackLineParser

                const opera11StackLineParser: StackLineParser;

                  variable WINDOW

                  const WINDOW: any;

                    variable winjsStackLineParser

                    const winjsStackLineParser: StackLineParser;

                      Functions

                      function close

                      close: (timeout?: number) => PromiseLike<boolean>;
                      • Call close() on the current client, if there is one. See Client.close.

                        Parameter timeout

                        Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this parameter will cause the client to wait until all events are sent before disabling itself.

                        Returns

                        A promise which resolves to true if the queue successfully drains before the timeout, or false if it doesn't (or if there's no client defined).

                      function eventFromException

                      eventFromException: (
                      stackParser: StackParser,
                      exception: unknown,
                      hint?: EventHint,
                      attachStacktrace?: boolean
                      ) => PromiseLike<Event>;
                      • Creates an Event from all inputs to captureException and non-primitive inputs to captureMessage.

                      function eventFromMessage

                      eventFromMessage: (
                      stackParser: StackParser,
                      message: string,
                      level?: Severity | SeverityLevel,
                      hint?: EventHint,
                      attachStacktrace?: boolean
                      ) => PromiseLike<Event>;
                      • Builds and Event from a Message

                      function flush

                      flush: (timeout?: number) => PromiseLike<boolean>;
                      • Call flush() on the current client, if there is one. See Client.flush.

                        Parameter timeout

                        Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause the client to wait until all events are sent before resolving the promise.

                        Returns

                        A promise which resolves to true if the queue successfully drains before the timeout, or false if it doesn't (or if there's no client defined).

                      function forceLoad

                      forceLoad: () => void;
                      • This function is here to be API compatible with the loader.

                      function init

                      init: (options?: BrowserOptions) => void;
                      • The Sentry Browser SDK Client.

                        To use this SDK, call the init function as early as possible when loading the web page. To set context information or send manual events, use the provided methods.

                        Example 1

                        import { init } from '@sentry/browser';
                        init({
                        dsn: '__DSN__',
                        // ...
                        });

                        Example 2

                        import { configureScope } from '@sentry/browser';
                        configureScope((scope: Scope) => {
                        scope.setExtra({ battery: 0.7 });
                        scope.setTag({ user_mode: 'admin' });
                        scope.setUser({ id: '4711' });
                        });

                        Example 3

                        import { addBreadcrumb } from '@sentry/browser';
                        addBreadcrumb({
                        message: 'My Breadcrumb',
                        // ...
                        });

                        Example 4

                        import * as Sentry from '@sentry/browser';
                        Sentry.captureMessage('Hello, world!');
                        Sentry.captureException(new Error('Good bye'));
                        Sentry.captureEvent({
                        message: 'Manual',
                        stacktrace: [
                        // ...
                        ],
                        });

                        See Also

                      function lastEventId

                      lastEventId: () => string | undefined;
                      • This is the getter for lastEventId.

                        Returns

                        The last event id of a captured event.

                      function makeFetchTransport

                      makeFetchTransport: (
                      options: BrowserTransportOptions,
                      nativeFetch?: FetchImpl
                      ) => Transport;
                      • Creates a Transport that uses the Fetch API to send events to Sentry.

                      function makeXHRTransport

                      makeXHRTransport: (options: BrowserTransportOptions) => Transport;
                      • Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.

                      function onLoad

                      onLoad: (callback: () => void) => void;
                      • This function is here to be API compatible with the loader.

                      function showReportDialog

                      showReportDialog: (options?: ReportDialogOptions, hub?: Hub) => void;
                      • Present the user with a report dialog.

                        Parameter options

                        Everything is optional, we try to fetch all info need from the global scope.

                      function wrap

                      wrap: (fn: (...args: any) => any) => any;
                      • Wrap code within a try/catch block so the SDK is able to capture errors.

                        Parameter fn

                        A function to wrap.

                        Returns

                        The result of wrapped function call.

                      Classes

                      class Breadcrumbs implements Integration {}
                      • Default Breadcrumbs instrumentations TODO: Deprecated - with v6, this will be renamed to Instrument

                      constructor(options?: Partial<BreadcrumbsOptions>);
                      static id: string;
                      name: string;
                      readonly options: Readonly<BreadcrumbsOptions>;
                      • Options of the breadcrumbs integration.

                      addSentryBreadcrumb: (event: Event) => void;
                      • Adds a breadcrumb for Sentry events or transactions if this option is enabled.

                      setupOnce: () => void;
                      • Instrument browser built-ins w/ breadcrumb capturing - Console API - DOM API (click/typing) - XMLHttpRequest API - Fetch API - History API

                      class BrowserClient

                      class BrowserClient extends BaseClient<BrowserClientOptions> {}
                      • The Sentry Browser SDK Client.

                        See Also

                        • BrowserOptions for documentation on configuration options.

                        • SentryClient for usage documentation.

                      constructor

                      constructor(options: ClientOptions<BrowserTransportOptions>);
                      • Creates a new Browser SDK instance.

                        Parameter options

                        Configuration options for this SDK.

                      method eventFromException

                      eventFromException: (exception: unknown, hint?: EventHint) => PromiseLike<Event>;

                      method eventFromMessage

                      eventFromMessage: (
                      message: string,
                      level?: Severity | SeverityLevel,
                      hint?: EventHint
                      ) => PromiseLike<Event>;

                      method sendEvent

                      sendEvent: (event: Event, hint?: EventHint) => void;

                      class Dedupe

                      class Dedupe implements Integration {}
                      • Deduplication filter

                      property id

                      static id: string;

                      property name

                      name: string;

                      method setupOnce

                      setupOnce: (
                      addGlobalEventProcessor: (callback: EventProcessor) => void,
                      getCurrentHub: () => Hub
                      ) => void;

                      class GlobalHandlers

                      class GlobalHandlers implements Integration {}
                      • Global handlers

                      constructor

                      constructor(options?: GlobalHandlersIntegrations);
                      • JSDoc

                      property id

                      static id: string;

                      property name

                      name: string;

                      method setupOnce

                      setupOnce: () => void;

                      class HttpContext

                      class HttpContext implements Integration {}
                      • HttpContext integration collects information about HTTP request headers

                      property id

                      static id: string;

                      property name

                      name: string;

                      method setupOnce

                      setupOnce: () => void;

                      class LinkedErrors

                      class LinkedErrors implements Integration {}
                      • Adds SDK info to an event.

                      constructor

                      constructor(options?: Partial<LinkedErrorsOptions>);

                      property id

                      static id: string;

                      property name

                      readonly name: string;

                      method setupOnce

                      setupOnce: () => void;

                      class TryCatch

                      class TryCatch implements Integration {}
                      • Wrap timer functions and event targets to catch errors and provide better meta data

                      constructor

                      constructor(options?: Partial<TryCatchOptions>);

                      property id

                      static id: string;

                      property name

                      name: string;

                      method setupOnce

                      setupOnce: () => void;
                      • Wrap timer functions and event targets to catch errors and provide better metadata.

                      Interfaces

                      interface ReportDialogOptions

                      interface ReportDialogOptions {}
                      • All properties the report dialog supports

                      property dsn

                      dsn?: DsnLike;

                        property errorFormEntry

                        errorFormEntry?: string;

                          property errorGeneric

                          errorGeneric?: string;

                            property eventId

                            eventId?: string;

                              property labelClose

                              labelClose?: string;

                                property labelComments

                                labelComments?: string;

                                  property labelEmail

                                  labelEmail?: string;

                                    property labelName

                                    labelName?: string;

                                      property labelSubmit

                                      labelSubmit?: string;

                                        property lang

                                        lang?: string;

                                          property subtitle

                                          subtitle?: string;

                                            property subtitle2

                                            subtitle2?: string;

                                              property successMessage

                                              successMessage?: string;

                                                property title

                                                title?: string;

                                                  property user

                                                  user?: {
                                                  email?: string;
                                                  name?: string;
                                                  };

                                                    method onLoad

                                                    onLoad: (this: void) => void;
                                                    • Callback after reportDialog showed up

                                                    index signature

                                                    [key: string]: any;

                                                      Type Aliases

                                                      type BrowserOptions

                                                      type BrowserOptions = Options<BrowserTransportOptions> & BrowserClientReplayOptions;
                                                      • Configuration options for the Sentry Browser SDK.

                                                        See Also

                                                        • @sentry/types Options for more information.

                                                      Package Files (14)

                                                      Dependencies (5)

                                                      Dev Dependencies (19)

                                                      Peer Dependencies (0)

                                                      No peer dependencies.

                                                      Badge

                                                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@sentry/browser.

                                                      • Markdown
                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@sentry/browser)
                                                      • HTML
                                                        <a href="https://www.jsdocs.io/package/@sentry/browser"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>