@sentry/browser

  • Version 6.12.0
  • Published
  • 2.78 MB
  • 4 dependencies
  • BSD-3-Clause license

Install

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

Overview

Official Sentry SDK for browsers

Index

Variables

variable defaultIntegrations

const defaultIntegrations: any[];

    variable Integrations

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

      variable SDK_NAME

      const SDK_NAME: string;

        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: (
        options: any,
        exception: unknown,
        hint?: any
        ) => PromiseLike<Event>;
        • Builds and Event from a Exception

        function eventFromMessage

        eventFromMessage: (
        options: any,
        message: string,
        level?: any,
        hint?: any
        ) => 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 injectReportDialog

        injectReportDialog: (options?: ReportDialogOptions) => void;
        • Injects the Report Dialog script

        function lastEventId

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

          Returns

          The last event id of a captured event.

        function onLoad

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

        function showReportDialog

        showReportDialog: (options?: ReportDialogOptions) => 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 BrowserClient

        class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {}
        • The Sentry Browser SDK Client.

          See Also

          • BrowserOptions for documentation on configuration options.

          • SentryClient for usage documentation.

        constructor

        constructor(options?: BrowserOptions);
        • Creates a new Browser SDK instance.

          Parameter options

          Configuration options for this SDK.

        method showReportDialog

        showReportDialog: (options?: ReportDialogOptions) => void;
        • Show a report dialog to the user to send feedback to a specific event.

          Parameter options

          Set individual options for the dialog

        Interfaces

        interface BrowserOptions

        interface BrowserOptions extends Options {}
        • Configuration options for the Sentry Browser SDK.

          See Also

          • BrowserClient for more information.

        property allowUrls

        allowUrls?: Array<string | RegExp>;
        • A pattern for error URLs which should exclusively be sent to Sentry. This is the opposite of Options.denyUrls. By default, all errors will be sent.

        property blacklistUrls

        blacklistUrls?: Array<string | RegExp>;

        property denyUrls

        denyUrls?: Array<string | RegExp>;
        • A pattern for error URLs which should not be sent to Sentry. To allow certain errors instead, use Options.allowUrls. By default, all errors will be sent.

        property whitelistUrls

        whitelistUrls?: Array<string | RegExp>;

        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: () => void;
                                      • Callback after reportDialog showed up

                                      index signature

                                      [key: string]: any;

                                        Namespaces

                                        namespace Transports

                                        module 'dist/transports/index.d.ts' {}

                                          class BaseTransport

                                          abstract class BaseTransport implements Transport {}
                                          • Base Transport class implementation

                                          constructor

                                          constructor(options: any);

                                            property options

                                            options: any;

                                              property url

                                              url: string;
                                              • Deprecated

                                              method close

                                              close: (timeout?: number) => PromiseLike<boolean>;

                                              method sendEvent

                                              sendEvent: (_: any) => PromiseLike<SentryResponse>;

                                              class FetchTransport

                                              class FetchTransport extends BaseTransport {}
                                              • fetch based transport

                                              constructor

                                              constructor(
                                              options: any,
                                              fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>
                                              );

                                                method sendEvent

                                                sendEvent: (event: any) => PromiseLike<Response>;

                                                method sendSession

                                                sendSession: (session: any) => PromiseLike<Response>;

                                                class XHRTransport

                                                class XHRTransport extends BaseTransport {}
                                                • XHR based transport

                                                method sendEvent

                                                sendEvent: (event: any) => PromiseLike<Response>;

                                                method sendSession

                                                sendSession: (session: any) => PromiseLike<Response>;

                                                Package Files (11)

                                                Dependencies (4)

                                                Dev Dependencies (30)

                                                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>