@sentry/browser
- Version 7.54.0
- Published
- 680 kB
- 6 dependencies
- MIT 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
Type Aliases
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 captureUserFeedback
captureUserFeedback: (feedback: UserFeedback) => void;
Captures user feedback and sends it to Sentry.
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 createUserFeedbackEnvelope
createUserFeedbackEnvelope: ( feedback: UserFeedback, { metadata, tunnel, dsn, }: { metadata: SdkMetadata | undefined; tunnel: string | undefined; dsn: DsnComponents | undefined; }) => EventEnvelope;
Creates an envelope from a user feedback.
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 tocaptureMessage
.
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, 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 lastEventId
lastEventId: () => string | undefined;
This is the getter for lastEventId.
Returns
The last event id of a captured event.
function makeBrowserOfflineTransport
makeBrowserOfflineTransport: <T extends InternalBaseTransportOptions>( createTransport: (options: T) => Transport) => (options: T & BrowserOfflineTransportOptions) => Transport;
Creates a transport that uses IndexedDb to store events when offline.
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 onProfilingStartRouteTransaction
onProfilingStartRouteTransaction: ( transaction: Transaction | undefined) => Transaction | undefined;
Safety wrapper for startTransaction for the unlikely case that transaction starts before tracing is imported - if that happens we want to avoid throwing an error from profiling code. see https://github.com/getsentry/sentry-javascript/issues/4731.
Modifiers
@experimental
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
class Breadcrumbs implements Integration {}
Default Breadcrumbs instrumentations TODO: Deprecated - with v6, this will be renamed to
Instrument
constructor
constructor(options?: Partial<BreadcrumbsOptions>);
property id
static id: string;
property name
name: string;
property options
readonly options: Readonly<BreadcrumbsOptions>;
Options of the breadcrumbs integration.
method addSentryBreadcrumb
addSentryBreadcrumb: (event: SentryEvent) => void;
Adds a breadcrumb for Sentry events or transactions if this option is enabled.
method setupOnce
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 captureUserFeedback
captureUserFeedback: (feedback: UserFeedback) => void;
Sends user feedback to Sentry.
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 BrowserProfilingIntegration
class BrowserProfilingIntegration implements Integration {}
Browser profiling integration. Stores any event that has contexts["profile"]["profile_id"] This exists because we do not want to await async profiler.stop calls as transaction.finish is called in a synchronous context. Instead, we handle sending the profile async from the promise callback and rely on being able to pull the event from the cache when we need to construct the envelope. This makes the integration less reliable as we might be dropping profiles when the cache is full.
Modifiers
@experimental
property name
readonly name: string;
method handleGlobalEvent
handleGlobalEvent: (event: Event) => Event;
method setupOnce
setupOnce: (addGlobalEventProcessor: (callback: EventProcessor) => void) => void;
class Dedupe
class Dedupe implements Integration {}
Deduplication filter
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
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 (18)
- types/client.d.ts
- types/eventbuilder.d.ts
- types/helpers.d.ts
- types/index.d.ts
- types/integrations/breadcrumbs.d.ts
- types/integrations/dedupe.d.ts
- types/integrations/globalhandlers.d.ts
- types/integrations/httpcontext.d.ts
- types/integrations/linkederrors.d.ts
- types/integrations/trycatch.d.ts
- types/profiling/hubextensions.d.ts
- types/profiling/integration.d.ts
- types/sdk.d.ts
- types/stack-parsers.d.ts
- types/transports/fetch.d.ts
- types/transports/offline.d.ts
- types/transports/xhr.d.ts
- types/userfeedback.d.ts
Dependencies (6)
Dev Dependencies (21)
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 4574 ms. - Missing or incorrect documentation? Open an issue for this package.