Namespace: sentry
Namespaces
Enumerations
Classes
Interfaces
- AnrIntegrationOptions
- Breadcrumb
- BreadcrumbHint
- DebugSession
- Event
- EventHint
- Exception
- LocalVariablesIntegrationOptions
- NodeOptions
- Request
- SdkInfo
- Session
- Span
- StackFrame
- Stacktrace
- Thread
- Transaction
- User
References
trpcMiddleware
Re-exports trpcMiddleware
Type Aliases
AddRequestDataToEventOptions
Ƭ AddRequestDataToEventOptions: Object
Options deciding what parts of the request to use when enhancing an event
Type declaration
Name | Type | Description |
---|---|---|
deps? |
{ cookie : { parse : (cookieStr : string ) => Record <string , string > } ; url : { parse : (urlStr : string ) => { query : string | null } } } |
Injected platform-specific dependencies |
deps.cookie |
{ parse : (cookieStr : string ) => Record <string , string > } |
- |
deps.cookie.parse |
(cookieStr : string ) => Record <string , string > |
- |
deps.url |
{ parse : (urlStr : string ) => { query : string | null } } |
- |
deps.url.parse |
(urlStr : string ) => { query : string | null } |
- |
include? |
{ ip? : boolean ; request? : boolean | typeof DEFAULT_REQUEST_INCLUDES [number ][] ; transaction? : boolean | TransactionNamingScheme ; user? : boolean | typeof DEFAULT_USER_INCLUDES [number ][] } |
Flags controlling whether each type of data should be added to the event |
include.ip? |
boolean |
- |
include.request? |
boolean | typeof DEFAULT_REQUEST_INCLUDES [number ][] |
- |
include.transaction? |
boolean | TransactionNamingScheme |
- |
include.user? |
boolean | typeof DEFAULT_USER_INCLUDES [number ][] |
- |
PolymorphicRequest
Ƭ PolymorphicRequest: BaseRequest
& BrowserRequest
& NodeRequest
& ExpressRequest
& KoaRequest
& NextjsRequest
A Request
type compatible with Node, Express, browser, etc., because everything is optional
SeverityLevel
Ƭ SeverityLevel: "fatal"
| "error"
| "warning"
| "log"
| "info"
| "debug"
SpanStatusType
Ƭ SpanStatusType: "ok"
| "deadline_exceeded"
| "unauthenticated"
| "permission_denied"
| "not_found"
| "resource_exhausted"
| "invalid_argument"
| "unimplemented"
| "unavailable"
| "internal_error"
| "unknown_error"
| "cancelled"
| "already_exists"
| "failed_precondition"
| "aborted"
| "out_of_range"
| "data_loss"
TransactionNamingScheme
Ƭ TransactionNamingScheme: "path"
| "methodPath"
| "handler"
Variables
DEFAULT_USER_INCLUDES
• Const
DEFAULT_USER_INCLUDES: string
[]
Integrations
• Const
Integrations: Object
Type declaration
Name | Type |
---|---|
Anr |
IntegrationClass & (options? : Partial <AnrIntegrationOptions >) => Integration & { setup : (client : Client <ClientOptions <BaseTransportOptions >>) => void } |
Apollo |
typeof TracingIntegrations.Apollo |
Console |
IntegrationClass |
Context |
IntegrationClass & (options? : { app? : boolean ; cloudResource? : boolean ; culture? : boolean ; device? : boolean | { cpu? : boolean ; memory? : boolean } ; os? : boolean }) => Integration |
ContextLines |
IntegrationClass & (options? : { frameContextLines? : number }) => Integration |
Express |
typeof TracingIntegrations.Express |
FunctionToString |
IntegrationClass |
GraphQL |
typeof TracingIntegrations.GraphQL |
Hapi |
IntegrationClass |
Http |
typeof Http |
InboundFilters |
IntegrationClass & (options? : Partial <{ allowUrls : (string | RegExp )[] ; denyUrls : (string | RegExp )[] ; disableErrorDefaults : boolean ; disableTransactionDefaults : boolean ; ignoreErrors : (string | RegExp )[] ; ignoreInternal : boolean ; ignoreTransactions : (string | RegExp )[] }>) => Integration |
LinkedErrors |
IntegrationClass & (options? : { key? : string ; limit? : number }) => Integration |
LocalVariables |
IntegrationClass & (options? : LocalVariablesIntegrationOptions , session? : DebugSession ) => Integration |
Modules |
IntegrationClass |
Mongo |
typeof TracingIntegrations.Mongo |
Mysql |
typeof TracingIntegrations.Mysql |
OnUncaughtException |
IntegrationClass & (options? : Partial <{ exitEvenIfOtherHandlersAreRegistered : boolean ; onFatalError? : (this : void , firstError : Error , secondError? : Error ) => void }>) => Integration |
OnUnhandledRejection |
IntegrationClass & (options? : Partial <{ mode : "warn" | "none" | "strict" }>) => Integration |
Postgres |
typeof TracingIntegrations.Postgres |
Prisma |
typeof TracingIntegrations.Prisma |
RequestData |
IntegrationClass & (options? : { include? : { cookies? : boolean ; data? : boolean ; headers? : boolean ; ip? : boolean ; query_string? : boolean ; url? : boolean ; user? : boolean | { email? : … | … ; id? : … | … ; username? : … | … } } ; transactionNamingScheme? : TransactionNamingScheme }) => Integration |
Spotlight |
IntegrationClass & (options? : Partial <{ sidecarUrl? : string }>) => Integration |
Undici |
typeof Undici |
SDK_VERSION
• Const
SDK_VERSION: "7.114.0"
SEMANTIC_ATTRIBUTE_SENTRY_OP
• Const
SEMANTIC_ATTRIBUTE_SENTRY_OP: "sentry.op"
Use this attribute to represent the operation of a span.
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN
• Const
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN: "sentry.origin"
Use this attribute to represent the origin of a span.
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE
• Const
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE: "sentry.sample_rate"
Use this attribute to represent the sample rate used for a span.
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE
• Const
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE: "sentry.source"
Use this attribute to represent the source of a span. Should be one of: custom, url, route, view, component, task, unknown
cron
• Const
cron: Object
Methods to instrument cron libraries for Sentry check-ins
Type declaration
Name | Type |
---|---|
instrumentCron |
typeof instrumentCron |
instrumentNodeCron |
typeof instrumentNodeCron |
instrumentNodeSchedule |
typeof instrumentNodeSchedule |
defaultIntegrations
• Const
defaultIntegrations: IntegrationFnResult
[]
Deprecated
Use getDefaultIntegrations(options)
instead.
hapiErrorPlugin
• Const
hapiErrorPlugin: Object
Type declaration
Name | Type |
---|---|
name |
string |
register |
(serverArg : Record <any , any >) => Promise <void > |
version |
string |
metrics
• Const
metrics: Object
Type declaration
Name | Type | Description |
---|---|---|
MetricsAggregator |
IntegrationClass |
Deprecated Use metrics.metricsAggregratorIntegration() instead. |
distribution |
typeof distribution |
- |
gauge |
typeof gauge |
- |
increment |
typeof increment |
- |
metricsAggregatorIntegration |
() => IntegrationFnResult |
- |
set |
typeof set |
- |
Functions
addBreadcrumb
▸ addBreadcrumb(breadcrumb
, hint?
): ReturnType
<Hub
["addBreadcrumb"
]>
Records a new breadcrumb which will be attached to future events.
Breadcrumbs will be added to subsequent events to provide more context on user’s actions prior to an error or crash.
Parameters
Name | Type | Description |
---|---|---|
breadcrumb |
Breadcrumb |
The breadcrumb to record. |
hint? |
BreadcrumbHint |
- |
Returns
ReturnType
<Hub
["addBreadcrumb"
]>
addEventProcessor
▸ addEventProcessor(callback
): void
Add an event processor to the current client. This event processor will run for all events processed by this client.
Parameters
Name | Type |
---|---|
callback |
EventProcessor |
Returns
void
addGlobalEventProcessor
▸ addGlobalEventProcessor(callback
): void
Add a EventProcessor to be kept globally.
Parameters
Name | Type |
---|---|
callback |
EventProcessor |
Returns
void
Deprecated
Use addEventProcessor
instead. Global event processors will be removed in v8.
addIntegration
▸ addIntegration(integration
): void
Add an integration to the current hub’s client.
Parameters
Name | Type |
---|---|
integration |
Integration |
Returns
void
addRequestDataToEvent
▸ addRequestDataToEvent(event
, req
, options?
): Event
Add data from the given request to the given event
Parameters
Name | Type | Description |
---|---|---|
event |
Event |
The event to which the request data will be added |
req |
PolymorphicRequest |
Request object |
options? |
AddRequestDataToEventOptions |
- |
Returns
The mutated Event
object
anrIntegration
▸ anrIntegration(options?
): IntegrationFnResult
& AnrInternal
Parameters
Name | Type |
---|---|
options? |
Partial <AnrIntegrationOptions > |
Returns
IntegrationFnResult
& AnrInternal
autoDiscoverNodePerformanceMonitoringIntegrations
▸ autoDiscoverNodePerformanceMonitoringIntegrations(): Integration
[]
Automatically detects and returns integrations that will work with your dependencies.
Returns
Integration
[]
captureCheckIn
▸ captureCheckIn(checkIn
, upsertMonitorConfig?
): string
Create a cron monitor check in and send it to Sentry.
Parameters
Name | Type | Description |
---|---|---|
checkIn |
CheckIn |
An object that describes a check in. |
upsertMonitorConfig? |
MonitorConfig |
An optional object that describes a monitor config. Use this if you want to create a monitor automatically when sending a check in. |
Returns
string
captureConsoleIntegration
▸ captureConsoleIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
CaptureConsoleOptions |
Returns
IntegrationFnResult
captureEvent
▸ captureEvent(event
, hint?
): string
Captures a manually created event and sends it to Sentry.
Parameters
Name | Type | Description |
---|---|---|
event |
Event |
- |
hint? |
EventHint |
Optional additional data to attach to the Sentry event. |
Returns
string
the id of the captured event.
captureException
▸ captureException(exception
, hint?
): string
Captures an exception event and sends it to Sentry.
Parameters
Name | Type | Description |
---|---|---|
exception |
any |
The exception to capture. |
hint? |
ExclusiveEventHintOrCaptureContext |
Optional additional data to attach to the Sentry event. |
Returns
string
the id of the captured Sentry event.
captureMessage
▸ captureMessage(message
, captureContext?
): string
Captures a message event and sends it to Sentry.
Parameters
Name | Type | Description |
---|---|---|
message |
string |
- |
captureContext? |
SeverityLevel | Severity | CaptureContext |
Define the level of the message or pass in additional data to attach to the message. |
Returns
string
the id of the captured message.
captureSession
▸ captureSession(end?
): void
Sends the current session on the scope to Sentry
Parameters
Name | Type | Description |
---|---|---|
end? |
boolean |
If set the session will be marked as exited and removed from the scope. Defaults to false . |
Returns
void
close
▸ close(timeout?
): Promise
<boolean
>
Call close()
on the current client, if there is one. See Client.close.
Parameters
Name | Type | Description |
---|---|---|
timeout? |
number |
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
Promise
<boolean
>
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).
configureScope
▸ configureScope(callback
): ReturnType
<Hub
["configureScope"
]>
Callback to set context information onto the scope.
Parameters
Name | Type | Description |
---|---|---|
callback |
(scope : Scope ) => void |
Callback function that receives Scope. |
Returns
ReturnType
<Hub
["configureScope"
]>
Deprecated
Use getCurrentScope() directly.
consoleIntegration
▸ consoleIntegration(): IntegrationFnResult
Returns
IntegrationFnResult
contextLinesIntegration
▸ contextLinesIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
ContextLinesOptions |
Returns
IntegrationFnResult
continueTrace
▸ continueTrace(«destructured»
): Partial
<TransactionContext
>
Continue a trace from sentry-trace
and baggage
values.
These values can be obtained from incoming request headers,
or in the browser from <meta name="sentry-trace">
and <meta name="baggage">
HTML tags.
Parameters
Name | Type |
---|---|
«destructured» |
Object |
› baggage |
undefined | null | string | number | boolean | string [] |
› sentryTrace |
undefined | string |
Returns
Partial
<TransactionContext
>
Deprecated
Use the version of this function taking a callback as second parameter instead:
Sentry.continueTrace(sentryTrace: '...', baggage: '...' }, () => {
// ...
})
▸ continueTrace<V
>(«destructured»
, callback
): V
Continue a trace from sentry-trace
and baggage
values.
These values can be obtained from incoming request headers, or in the browser from <meta name="sentry-trace">
and <meta name="baggage">
HTML tags.
Spans started with startSpan
, startSpanManual
and startInactiveSpan
, within the callback will automatically
be attached to the incoming trace.
Deprecation notice: In the next major version of the SDK the provided callback will not receive a transaction context argument.
Type parameters
Name |
---|
V |
Parameters
Name | Type |
---|---|
«destructured» |
Object |
› baggage |
undefined | null | string | number | boolean | string [] |
› sentryTrace |
undefined | string |
callback |
(transactionContext : Partial <TransactionContext >) => V |
Returns
V
createGetModuleFromFilename
▸ createGetModuleFromFilename(basePath?
, isWindows?
): (filename
: string
| undefined
) => string
| undefined
Creates a function that gets the module name from a filename
Parameters
Name | Type |
---|---|
basePath? |
string |
isWindows? |
boolean |
Returns
fn
▸ (filename
): string
| undefined
Parameters
Name | Type |
---|---|
filename |
string | undefined |
Returns
string
| undefined
createTransport
▸ createTransport(options
, makeRequest
, buffer?
): Transport
Creates an instance of a Sentry Transport
Parameters
Name | Type |
---|---|
options |
InternalBaseTransportOptions |
makeRequest |
TransportRequestExecutor |
buffer? |
PromiseBuffer <void | TransportMakeRequestResponse > |
Returns
Transport
debugIntegration
▸ debugIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
DebugOptions |
Returns
IntegrationFnResult
dedupeIntegration
▸ dedupeIntegration(): IntegrationFnResult
Returns
IntegrationFnResult
deepReadDirSync
▸ deepReadDirSync(targetDir
): string
[]
Recursively read the contents of a directory.
Parameters
Name | Type | Description |
---|---|---|
targetDir |
string |
Absolute or relative path of the directory to scan. All returned paths will be relative to this directory. |
Returns
string
[]
Array holding all relative paths
Deprecated
This function will be removed in the next major version.
defaultStackParser
▸ defaultStackParser(stack
, skipFirst?
): StackFrame
[]
Node.js stack parser
Parameters
Name | Type |
---|---|
stack |
string |
skipFirst? |
number |
Returns
enableAnrDetection
▸ enableAnrDetection(options
): Promise
<void
>
Parameters
Name | Type |
---|---|
options |
Partial <LegacyOptions > |
Returns
Promise
<void
>
Deprecated
Use the Anr
integration instead.
import * as Sentry from '@sentry/node';
Sentry.init({
dsn: '__DSN__',
integrations: [new Sentry.Integrations.Anr({ captureStackTrace: true })],
});
endSession
▸ endSession(): void
End the session on the current isolation scope.
Returns
void
extraErrorDataIntegration
▸ extraErrorDataIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
Partial <ExtraErrorDataOptions > |
Returns
IntegrationFnResult
extractRequestData
▸ extractRequestData(req
, options?
): ExtractedNodeRequestData
Normalize data from the request object, accounting for framework differences.
Parameters
Name | Type | Description |
---|---|---|
req |
PolymorphicRequest |
The request object from which to extract data |
options? |
Object |
- |
options.deps? |
InjectedNodeDeps |
Injected, platform-specific dependencies |
options.include? |
string [] |
An optional array of keys to include in the normalized data. Defaults to DEFAULT_REQUEST_INCLUDES if not provided. |
Returns
ExtractedNodeRequestData
An object containing normalized request data
extractTraceparentData
▸ extractTraceparentData(traceparent?
): TraceparentData
| undefined
The extractTraceparentData
function and TRACEPARENT_REGEXP
constant used
to be declared in this file. It was later moved into @sentry/utils
as part of a
move to remove @sentry/tracing
dependencies from @sentry/node
(extractTraceparentData
is the only tracing function used by @sentry/node
).
These exports are kept here for backwards compatability’s sake.
See https://github.com/getsentry/sentry-javascript/issues/4642 for more details.
Parameters
Name | Type |
---|---|
traceparent? |
string |
Returns
TraceparentData
| undefined
Deprecated
Import this function from @sentry/utils
instead
flush
▸ flush(...args
): Promise
<ReturnType
<typeof sentry.flush
> | void
>
Parameters
Name | Type |
---|---|
...args |
[timeout?: number] |
Returns
Promise
<ReturnType
<typeof sentry.flush
> | void
>
functionToStringIntegration
▸ functionToStringIntegration(): IntegrationFnResult
Patch toString calls to return proper name for wrapped functions.
Sentry.init({
integrations: [
functionToStringIntegration(),
],
});
Returns
IntegrationFnResult
getActiveSpan
▸ getActiveSpan(): Span
| undefined
Returns the currently active span.
Returns
Span
| undefined
getActiveTransaction
▸ getActiveTransaction<T
>(maybeHub?
): T
| undefined
Grabs active transaction off scope.
Type parameters
Name | Type |
---|---|
T |
extends Transaction |
Parameters
Name | Type |
---|---|
maybeHub? |
Hub |
Returns
T
| undefined
Deprecated
You should not rely on the transaction, but just use startSpan()
APIs instead.
getClient
▸ getClient<C
>(): C
| undefined
Get the currently active client.
Type parameters
Name | Type |
---|---|
C |
extends Client <ClientOptions <BaseTransportOptions >> |
Returns
C
| undefined
getCurrentHub
▸ getCurrentHub(): Hub
Returns the default hub instance.
If a hub is already registered in the global carrier but this module contains a more recent version, it replaces the registered version. Otherwise, the currently registered hub will be returned.
Returns
Deprecated
Use the respective replacement method directly instead.
getCurrentScope
▸ getCurrentScope(): Scope
Get the currently active scope.
Returns
getDefaultIntegrations
▸ getDefaultIntegrations(_options
): Integration
[]
Get the default integrations for the Node SDK.
Parameters
Name | Type |
---|---|
_options |
Options <BaseTransportOptions > |
Returns
Integration
[]
getGlobalScope
▸ getGlobalScope(): ScopeInterface
Get the global scope. This scope is applied to all events.
Returns
ScopeInterface
getIsolationScope
▸ getIsolationScope(): Scope
Get the currently active isolation scope. The isolation scope is active for the current exection context, meaning that it will remain stable for the same Hub.
Returns
getModuleFromFilename
▸ getModuleFromFilename(filename
): undefined
| string
Parameters
Name | Type |
---|---|
filename |
undefined | string |
Returns
undefined
| string
Deprecated
use createGetModuleFromFilename
instead.
getSentryRelease
▸ getSentryRelease(fallback?
): string
| undefined
Returns a release dynamically from environment variables.
Parameters
Name | Type |
---|---|
fallback? |
string |
Returns
string
| undefined
getSpanStatusFromHttpCode
▸ getSpanStatusFromHttpCode(httpStatus
): SpanStatusType
Converts a HTTP status code into a SpanStatusType.
Parameters
Name | Type | Description |
---|---|---|
httpStatus |
number |
The HTTP response status code. |
Returns
The span status or unknown_error.
hapiIntegration
▸ hapiIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
HapiOptions |
Returns
IntegrationFnResult
httpClientIntegration
▸ httpClientIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
Partial <HttpClientOptions > |
Returns
IntegrationFnResult
httpIntegration
▸ httpIntegration(options?
): IntegrationFnResult
The http module integration instruments Node’s internal http module. It creates breadcrumbs, spans for outgoing
http requests, and attaches trace data when tracing is enabled via its tracing
option.
By default, this will always create breadcrumbs, and will create spans if tracing is enabled.
Parameters
Name | Type |
---|---|
options? |
HttpIntegrationOptions |
Returns
IntegrationFnResult
inboundFiltersIntegration
▸ inboundFiltersIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
Partial <InboundFiltersOptions > |
Returns
IntegrationFnResult
init
▸ init(...args
): void
Parameters
Name | Type |
---|---|
...args |
[options?: NodeOptions] |
Returns
void
isInitialized
▸ isInitialized(): boolean
Returns true if Sentry has been properly initialized.
Returns
boolean
lastEventId
▸ lastEventId(): string
| undefined
This is the getter for lastEventId.
Returns
string
| undefined
The last event id of a captured event.
Deprecated
This function will be removed in the next major version of the Sentry SDK.
linkedErrorsIntegration
▸ linkedErrorsIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
LinkedErrorsOptions |
Returns
IntegrationFnResult
localVariablesIntegration
▸ localVariablesIntegration(options?
, session?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
LocalVariablesIntegrationOptions |
session? |
DebugSession |
Returns
IntegrationFnResult
makeMain
▸ makeMain(hub
): Hub
Replaces the current main hub with the passed one on the global object
Parameters
Name | Type |
---|---|
hub |
Hub |
Returns
The old replaced hub
Deprecated
Use setCurrentClient()
instead.
makeNodeTransport
▸ makeNodeTransport(options
): Transport
Creates a Transport that uses native the native ‘http’ and ‘https’ modules to send events to Sentry.
Parameters
Name | Type |
---|---|
options |
NodeTransportOptions |
Returns
Transport
modulesIntegration
▸ modulesIntegration(): IntegrationFnResult
Returns
IntegrationFnResult
nativeNodeFetchintegration
▸ nativeNodeFetchintegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
Partial <UndiciOptions > |
Returns
IntegrationFnResult
nodeContextIntegration
▸ nodeContextIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
ContextOptions |
Returns
IntegrationFnResult
onUncaughtExceptionIntegration
▸ onUncaughtExceptionIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
Partial <OnUncaughtExceptionOptions > |
Returns
IntegrationFnResult
onUnhandledRejectionIntegration
▸ onUnhandledRejectionIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
Partial <OnUnhandledRejectionOptions > |
Returns
IntegrationFnResult
parameterize
▸ parameterize(strings
, ...values
): ParameterizedString
Tagged template function which returns paramaterized representation of the message
For example: parameterizeThis is a log statement with ${x} and ${y} params
, would return:
“sentry_template_string”: ‘This is a log statement with %s and %s params’,
“sentry_template_values”: [‘first’, ‘second’]
Parameters
Name | Type | Description |
---|---|---|
strings |
TemplateStringsArray |
An array of string values splitted between expressions |
...values |
string [] |
Expressions extracted from template string |
Returns
ParameterizedString
String with template information in sentry_template_string and sentry_template_values properties
reportingObserverIntegration
▸ reportingObserverIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
ReportingObserverOptions |
Returns
IntegrationFnResult
requestDataIntegration
▸ requestDataIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
RequestDataIntegrationOptions |
Returns
IntegrationFnResult
rewriteFramesIntegration
▸ rewriteFramesIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
RewriteFramesOptions |
Returns
IntegrationFnResult
runWithAsyncContext
▸ runWithAsyncContext<T
>(callback
, options?
): T
Runs the supplied callback in its own async context. Async Context strategies are defined per SDK.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
callback |
() => T |
The callback to run in its own async context |
options? |
RunWithAsyncContextOptions |
Options to pass to the async context strategy |
Returns
T
The result of the callback
sessionTimingIntegration
▸ sessionTimingIntegration(): IntegrationFnResult
Returns
IntegrationFnResult
setContext
▸ setContext(name
, context
): ReturnType
<Hub
["setContext"
]>
Sets context data with the given name.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
of the context |
context |
null | { [key: string] : any ; } |
Any kind of data. This data will be normalized. |
Returns
ReturnType
<Hub
["setContext"
]>
setCurrentClient
▸ setCurrentClient(client
): void
Make the given client the current client.
Parameters
Name | Type |
---|---|
client |
Client <ClientOptions <BaseTransportOptions >> |
Returns
void
setExtra
▸ setExtra(key
, extra
): ReturnType
<Hub
["setExtra"
]>
Set key:value that will be sent as extra data with the event.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
String of extra |
extra |
unknown |
Any kind of data. This data will be normalized. |
Returns
ReturnType
<Hub
["setExtra"
]>
setExtras
▸ setExtras(extras
): ReturnType
<Hub
["setExtras"
]>
Set an object that will be merged sent as extra data with the event.
Parameters
Name | Type | Description |
---|---|---|
extras |
Extras |
Extras object to merge into current context. |
Returns
ReturnType
<Hub
["setExtras"
]>
setHttpStatus
▸ setHttpStatus(span
, httpStatus
): void
Sets the Http status attributes on the current span based on the http code. Additionally, the span’s status is updated, depending on the http code.
Parameters
Name | Type |
---|---|
span |
Span |
httpStatus |
number |
Returns
void
setMeasurement
▸ setMeasurement(name
, value
, unit
): void
Adds a measurement to the current active transaction.
Parameters
Name | Type |
---|---|
name |
string |
value |
number |
unit |
MeasurementUnit |
Returns
void
setTag
▸ setTag(key
, value
): ReturnType
<Hub
["setTag"
]>
Set key:value that will be sent as tags data with the event.
Can also be used to unset a tag, by passing undefined
.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
String key of tag |
value |
Primitive |
Value of tag |
Returns
ReturnType
<Hub
["setTag"
]>
setTags
▸ setTags(tags
): ReturnType
<Hub
["setTags"
]>
Set an object that will be merged sent as tags data with the event.
Parameters
Name | Type | Description |
---|---|---|
tags |
Object |
Tags context object to merge into current context. |
Returns
ReturnType
<Hub
["setTags"
]>
setUser
▸ setUser(user
): ReturnType
<Hub
["setUser"
]>
Updates user context information for future events.
Parameters
Name | Type | Description |
---|---|---|
user |
null | User |
User context object to be set in the current context. Pass null to unset the user. |
Returns
ReturnType
<Hub
["setUser"
]>
spanStatusfromHttpCode
▸ spanStatusfromHttpCode(httpStatus
): SpanStatusType
Converts a HTTP status code into a SpanStatusType.
Parameters
Name | Type | Description |
---|---|---|
httpStatus |
number |
The HTTP response status code. |
Returns
The span status or unknown_error.
Deprecated
Use spanStatusFromHttpCode instead. This export will be removed in v8 as the signature contains a typo.
spotlightIntegration
▸ spotlightIntegration(options?
): IntegrationFnResult
Parameters
Name | Type |
---|---|
options? |
Partial <SpotlightConnectionOptions > |
Returns
IntegrationFnResult
startActiveSpan
▸ startActiveSpan<T
>(context
, callback
): T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
context |
StartSpanOptions |
callback |
(span : undefined | Span ) => T |
Returns
T
Deprecated
Use startSpan instead.
startInactiveSpan
▸ startInactiveSpan(context
): Span
| undefined
Creates a span. This span is not set as active, so will not get automatic instrumentation spans
as children or be able to be accessed via Sentry.getSpan()
.
If you want to create a span that is set as active, use startSpan.
Note that if you have not enabled tracing extensions via addTracingExtensions
or you didn’t set tracesSampleRate
or tracesSampler
, this function will not generate spans
and the span
returned from the callback will be undefined.
Parameters
Name | Type |
---|---|
context |
StartSpanOptions |
Returns
Span
| undefined
startSession
▸ startSession(context?
): Session
Start a session on the current isolation scope.
Parameters
Name | Type | Description |
---|---|---|
context? |
Partial <Session > |
(optional) additional properties to be applied to the returned session object |
Returns
the new active session
startSpan
▸ startSpan<T
>(context
, callback
): T
Wraps a function with a transaction/span and finishes the span after the function is done.
The created span is the active span and will be used as parent by other spans created inside the function
and can be accessed via Sentry.getSpan()
, as long as the function is executed while the scope is active.
If you want to create a span that is not set as active, use startInactiveSpan.
Note that if you have not enabled tracing extensions via addTracingExtensions
or you didn’t set tracesSampleRate
, this function will not generate spans
and the span
returned from the callback will be undefined.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
context |
StartSpanOptions |
callback |
(span : undefined | Span ) => T |
Returns
T
startSpanManual
▸ startSpanManual<T
>(context
, callback
): T
Similar to Sentry.startSpan
. Wraps a function with a transaction/span, but does not finish the span
after the function is done automatically. You’ll have to call span.end()
manually.
The created span is the active span and will be used as parent by other spans created inside the function
and can be accessed via Sentry.getActiveSpan()
, as long as the function is executed while the scope is active.
Note that if you have not enabled tracing extensions via addTracingExtensions
or you didn’t set tracesSampleRate
, this function will not generate spans
and the span
returned from the callback will be undefined.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
context |
StartSpanOptions |
callback |
(span : undefined | Span , finish : () => void ) => T |
Returns
T
startTransaction
▸ startTransaction(context
, customSamplingContext?
): ReturnType
<Hub
["startTransaction"
]>
Starts a new Transaction
and returns it. This is the entry point to manual tracing instrumentation.
A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a
new child span within the transaction or any span, call the respective .startChild()
method.
Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded.
The transaction must be finished with a call to its .end()
method, at which point the transaction with all its
finished child spans will be sent to Sentry.
NOTE: This function should only be used for manual instrumentation. Auto-instrumentation should call
startTransaction
directly on the hub.
Parameters
Name | Type | Description |
---|---|---|
context |
TransactionContext |
Properties of the new Transaction . |
customSamplingContext? |
CustomSamplingContext |
Information given to the transaction sampling function (along with context-dependent default values). See Options.tracesSampler. |
Returns
ReturnType
<Hub
["startTransaction"
]>
The transaction which was just started
Deprecated
Use startSpan()
, startSpanManual()
or startInactiveSpan()
instead.
trace
▸ trace<T
>(context
, callback
, onError?
, afterFinish?
): T
Wraps a function with a transaction/span and finishes the span after the function is done.
Note that if you have not enabled tracing extensions via addTracingExtensions
or you didn’t set tracesSampleRate
, this function will not generate spans
and the span
returned from the callback will be undefined.
This function is meant to be used internally and may break at any time. Use at your own risk.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
context |
TransactionContext |
callback |
(span? : Span ) => T |
onError? |
(error : unknown , span? : Span ) => void |
afterFinish? |
() => void |
Returns
T
Deprecated
Use startSpan
instead.
withActiveSpan
▸ withActiveSpan<T
>(span
, callback
): T
Forks the current scope and sets the provided span as active span in the context of the provided callback.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
span |
Span |
Spans started in the context of the provided callback will be children of this span. |
callback |
(scope : Scope ) => T |
Execution context in which the provided span will be active. Is passed the newly forked scope. |
Returns
T
the value returned from the provided callback function.
withIsolationScope
▸ withIsolationScope<T
>(callback
): T
Attempts to fork the current isolation scope and the current scope based on the current async context strategy. If no async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the case, for example, in the browser).
Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.
This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in “normal” applications directly because it comes with pitfalls. Use at your own risk!
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
callback |
(isolationScope : Scope ) => T |
The callback in which the passed isolation scope is active. (Note: In environments without async context strategy, the currently active isolation scope may change within execution of the callback.) |
Returns
T
The same value that callback
returns.
withMonitor
▸ withMonitor<T
>(monitorSlug
, callback
, upsertMonitorConfig?
): T
Wraps a callback with a cron monitor check in. The check in will be sent to Sentry when the callback finishes.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
monitorSlug |
string |
The distinct slug of the monitor. |
callback |
() => T |
- |
upsertMonitorConfig? |
MonitorConfig |
An optional object that describes a monitor config. Use this if you want to create a monitor automatically when sending a check in. |
Returns
T
withScope
▸ withScope<T
>(callback
): T
Creates a new scope with and executes the given operation within. The scope is automatically removed once the operation finishes or throws.
This is essentially a convenience function for:
pushScope();
callback();
popScope();
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
callback |
(scope : Scope ) => T |
Returns
T
▸ withScope<T
>(scope
, callback
): T
Set the given scope as the active scope in the callback.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
scope |
undefined | Scope |
callback |
(scope : Scope ) => T |
Returns
T