@sentry/browser
- Version 6.19.7
- Published
- 3.88 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
Functions
Classes
Interfaces
Namespaces
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, orfalse
if it doesn't (or if there's no client defined).
function eventFromException
eventFromException: ( exception: unknown, hint?: EventHint, attachStacktrace?: boolean) => PromiseLike<Event>;
Creates an Event from all inputs to
captureException
and non-primitive inputs tocaptureMessage
.
function eventFromMessage
eventFromMessage: ( message: string, level?: Severity, 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, orfalse
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
BrowserOptions for documentation on configuration options.
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>;
Deprecated
use Options.denyUrls instead.
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>;
Deprecated
use Options.allowUrls instead.
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 'types/transports/index.d.ts' {}
function makeNewFetchTransport
makeNewFetchTransport: ( options: FetchTransportOptions, nativeFetch?: FetchImpl) => NewTransport;
Creates a Transport that uses the Fetch API to send events to Sentry.
function makeNewXHRTransport
makeNewXHRTransport: (options: XHRTransportOptions) => NewTransport;
Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
class BaseTransport
abstract class BaseTransport implements Transport {}
Base Transport class implementation
constructor
constructor(options: TransportOptions);
property options
options: TransportOptions;
property url
url: string;
Deprecated
method close
close: (timeout?: number) => PromiseLike<boolean>;
method recordLostEvent
recordLostEvent: (reason: Outcome, category: SentryRequestType) => void;
method sendEvent
sendEvent: (event: Event) => PromiseLike<SentryResponse>;
method sendSession
sendSession: (session: Session) => PromiseLike<SentryResponse>;
class FetchTransport
class FetchTransport extends BaseTransport {}
fetch
based transport
constructor
constructor( options: TransportOptions, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
class XHRTransport
class XHRTransport extends BaseTransport {}
XHR
based transport
Package Files (13)
Dependencies (4)
Dev Dependencies (20)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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[](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>
- Updated .
Package analyzed in 4620 ms. - Missing or incorrect documentation? Open an issue for this package.