@sentry/browser
- Version 7.108.0
- Published
- 739 kB
- 7 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
- breadcrumbsIntegration()
- browserApiErrorsIntegration()
- browserProfilingIntegration()
- captureUserFeedback()
- createUserFeedbackEnvelope()
- dedupeIntegration()
- eventFromException()
- eventFromMessage()
- exceptionFromError()
- forceLoad()
- getDefaultIntegrations()
- globalHandlersIntegration()
- httpContextIntegration()
- init()
- linkedErrorsIntegration()
- makeBrowserOfflineTransport()
- makeFetchTransport()
- makeXHRTransport()
- onLoad()
- onProfilingStartRouteTransaction()
- wrap()
Classes
Interfaces
Type Aliases
Variables
variable Breadcrumbs
const Breadcrumbs: any;
Default Breadcrumbs instrumentations
Deprecated
Use
breadcrumbsIntegration()
instead.
variable BrowserProfilingIntegration
const BrowserProfilingIntegration: IntegrationClass<any>;
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
Deprecated
Use
browserProfilingIntegration()
instead.
variable chromeStackLineParser
const chromeStackLineParser: StackLineParser;
variable Dedupe
const Dedupe: IntegrationClass<any>;
Deduplication filter.
Deprecated
Use
dedupeIntegration()
instead.
variable defaultIntegrations
const defaultIntegrations: any[];
Deprecated
Use
getDefaultIntegrations(options)
instead.
variable defaultStackLineParsers
const defaultStackLineParsers: StackLineParser[];
variable defaultStackParser
const defaultStackParser: any;
variable geckoStackLineParser
const geckoStackLineParser: StackLineParser;
variable GlobalHandlers
const GlobalHandlers: any;
Global handlers.
Deprecated
Use
globalHandlersIntegration()
instead.
variable HttpContext
const HttpContext: IntegrationClass<any>;
HttpContext integration collects information about HTTP request headers.
Deprecated
Use
httpContextIntegration()
instead.
variable Integrations
const Integrations: { GlobalHandlers: any; TryCatch: any; Breadcrumbs: any; LinkedErrors: any; HttpContext: any; Dedupe: any; FunctionToString: any; InboundFilters: any;};
Deprecated
Import the integration function directly, e.g.
inboundFiltersIntegration()
instead of `new Integrations.InboundFilter().
variable LinkedErrors
const LinkedErrors: any;
Aggregrate linked errors in an event.
Deprecated
Use
linkedErrorsIntegration()
instead.
variable opera10StackLineParser
const opera10StackLineParser: StackLineParser;
variable opera11StackLineParser
const opera11StackLineParser: StackLineParser;
variable showReportDialog
const showReportDialog: ShowReportDialogFunction;
variable TryCatch
const TryCatch: any;
Wrap timer functions and event targets to catch errors and provide better meta data.
Deprecated
Use
browserApiErrorsIntegration()
instead.
variable WINDOW
const WINDOW: any;
variable winjsStackLineParser
const winjsStackLineParser: StackLineParser;
Functions
function breadcrumbsIntegration
breadcrumbsIntegration: ( options?: Partial<BreadcrumbsOptions> | undefined) => any;
function browserApiErrorsIntegration
browserApiErrorsIntegration: ( options?: Partial<TryCatchOptions> | undefined) => any;
function browserProfilingIntegration
browserProfilingIntegration: () => any;
function captureUserFeedback
captureUserFeedback: (feedback: UserFeedback) => void;
Captures user feedback and sends it to Sentry.
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 dedupeIntegration
dedupeIntegration: () => any;
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: ParameterizedString, level?: Severity | SeverityLevel, hint?: EventHint, attachStacktrace?: boolean) => PromiseLike<Event>;
Builds and Event from a Message
function exceptionFromError
exceptionFromError: (stackParser: StackParser, ex: Error) => Exception;
This function creates an exception from a JavaScript Error
function forceLoad
forceLoad: () => void;
This function is here to be API compatible with the loader.
function getDefaultIntegrations
getDefaultIntegrations: (_options: Options) => Integration[];
Get the default integrations for the browser SDK.
function globalHandlersIntegration
globalHandlersIntegration: ( options?: Partial<GlobalHandlersIntegrations> | undefined) => any;
function httpContextIntegration
httpContextIntegration: () => any;
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 linkedErrorsIntegration
linkedErrorsIntegration: (options?: LinkedErrorsOptions | undefined) => any;
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 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.
Deprecated
This function will be removed in v8. It is not part of Sentry's official API and it's easily replaceable by using a try/catch block and calling Sentry.captureException.
Classes
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: any);
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: ParameterizedString, level?: Severity | SeverityLevel, hint?: EventHint) => PromiseLike<Event>;
Interfaces
interface ReportDialogOptions
interface ReportDialogOptions {}
All properties the report dialog supports
Deprecated
This type will be removed in the next major version of the Sentry SDK.
showReportDialog
will still be around, however theeventId
option will now be required.
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 onClose
onClose: (this: void) => void;
Callback after reportDialog closed
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 & BrowserClientProfilingOptions;
Configuration options for the Sentry Browser SDK.
See Also
@sentry/types Options for more information.
type BrowserProfilingIntegration
type BrowserProfilingIntegration = typeof BrowserProfilingIntegration;
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 (7)
Dev Dependencies (22)
- @sentry-internal/integration-shims
- @types/md5
- btoa
- chai
- chokidar
- fake-indexeddb
- karma
- karma-chai
- karma-chrome-launcher
- karma-firefox-launcher
- karma-mocha
- karma-mocha-reporter
- karma-rollup-preprocessor
- karma-sinon
- karma-typescript
- karma-typescript-es6-transform
- karma-webkit-launcher
- mocha
- node-fetch
- playwright
- sinon
- webpack
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[![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>
- Updated .
Package analyzed in 3332 ms. - Missing or incorrect documentation? Open an issue for this package.