diff --git a/packages/browser/src/backend.ts b/packages/browser/src/backend.ts index 3780ca4556ba..61db57e4ac1d 100644 --- a/packages/browser/src/backend.ts +++ b/packages/browser/src/backend.ts @@ -15,20 +15,20 @@ export interface BrowserOptions extends Options { * This is the opposite of {@link Options.denyUrls}. * By default, all errors will be sent. */ - allowUrls?: Array; + allowUrls?: Array | undefined; /** * A pattern for error URLs which should not be sent to Sentry. * To allow certain errors instead, use {@link Options.allowUrls}. * By default, all errors will be sent. */ - denyUrls?: Array; + denyUrls?: Array | undefined; /** @deprecated use {@link Options.allowUrls} instead. */ - whitelistUrls?: Array; + whitelistUrls?: Array | undefined; /** @deprecated use {@link Options.denyUrls} instead. */ - blacklistUrls?: Array; + blacklistUrls?: Array | undefined; } /** @@ -39,13 +39,17 @@ export class BrowserBackend extends BaseBackend { /** * @inheritDoc */ - public eventFromException(exception: unknown, hint?: EventHint): PromiseLike { + public eventFromException(exception: unknown, hint?: EventHint | undefined): PromiseLike { return eventFromException(this._options, exception, hint); } /** * @inheritDoc */ - public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike { + public eventFromMessage( + message: string, + level: Severity = Severity.Info, + hint?: EventHint | undefined, + ): PromiseLike { return eventFromMessage(this._options, message, level, hint); } diff --git a/packages/core/src/basebackend.ts b/packages/core/src/basebackend.ts index eb7e598a02ad..7f8b9c44519e 100644 --- a/packages/core/src/basebackend.ts +++ b/packages/core/src/basebackend.ts @@ -76,14 +76,18 @@ export abstract class BaseBackend implements Backend { * @inheritDoc */ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types - public eventFromException(_exception: any, _hint?: EventHint): PromiseLike { + public eventFromException(_exception: any, _hint?: EventHint | undefined): PromiseLike { throw new SentryError('Backend has to implement `eventFromException` method'); } /** * @inheritDoc */ - public eventFromMessage(_message: string, _level?: Severity, _hint?: EventHint): PromiseLike { + public eventFromMessage( + _message: string, + _level?: Severity | undefined, + _hint?: EventHint | undefined, + ): PromiseLike { throw new SentryError('Backend has to implement `eventFromMessage` method'); } diff --git a/packages/node/src/backend.ts b/packages/node/src/backend.ts index 8220d690ceb4..0a878cf15b9e 100644 --- a/packages/node/src/backend.ts +++ b/packages/node/src/backend.ts @@ -24,7 +24,7 @@ export class NodeBackend extends BaseBackend { * @inheritDoc */ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types - public eventFromException(exception: any, hint?: EventHint): PromiseLike { + public eventFromException(exception: any, hint?: EventHint | undefined): PromiseLike { // eslint-disable-next-line @typescript-eslint/no-explicit-any let ex: any = exception; const providedMechanism: Mechanism | undefined = @@ -73,7 +73,11 @@ export class NodeBackend extends BaseBackend { /** * @inheritDoc */ - public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike { + public eventFromMessage( + message: string, + level: Severity = Severity.Info, + hint?: EventHint | undefined, + ): PromiseLike { const event: Event = { event_id: hint && hint.event_id, level, diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index d9fec7f4c13e..8741f81d47e3 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -6,23 +6,23 @@ import { Options } from '@sentry/types'; */ export interface NodeOptions extends Options { /** Sets an optional server name (device name) */ - serverName?: string; + serverName?: string | undefined; /** Maximum time in milliseconds to wait to drain the request queue, before the process is allowed to exit. */ - shutdownTimeout?: number; + shutdownTimeout?: number | undefined; /** Set a HTTP proxy that should be used for outbound requests. */ - httpProxy?: string; + httpProxy?: string | undefined; /** Set a HTTPS proxy that should be used for outbound requests. */ - httpsProxy?: string; + httpsProxy?: string | undefined; /** HTTPS proxy certificates path */ - caCerts?: string; + caCerts?: string | undefined; /** Sets the number of context lines for each frame when loading a file. */ - frameContextLines?: number; + frameContextLines?: number | undefined; /** Callback that is executed when a fatal global error occurs. */ - onFatalError?(error: Error): void; + onFatalError?(error: Error): void | undefined; } diff --git a/packages/types/src/options.ts b/packages/types/src/options.ts index 9b42c48ed0e8..3b8269cd5230 100644 --- a/packages/types/src/options.ts +++ b/packages/types/src/options.ts @@ -12,88 +12,88 @@ export interface Options { /** * Enable debug functionality in the SDK itself */ - debug?: boolean; + debug?: boolean | undefined; /** * Specifies whether this SDK should activate and send events to Sentry. * Disabling the SDK reduces all overhead from instrumentation, collecting * breadcrumbs and capturing events. Defaults to true. */ - enabled?: boolean; + enabled?: boolean | undefined; /** * The Dsn used to connect to Sentry and identify the project. If omitted, the * SDK will not send any data to Sentry. */ - dsn?: string; + dsn?: string | undefined; /** * If this is set to false, default integrations will not be added, otherwise this will internally be set to the * recommended default integrations. * TODO: We should consider changing this to `boolean | Integration[]` */ - defaultIntegrations?: false | Integration[]; + defaultIntegrations?: false | Integration[] | undefined; /** * List of integrations that should be installed after SDK was initialized. * Accepts either a list of integrations or a function that receives * default integrations and returns a new, updated list. */ - integrations?: Integration[] | ((integrations: Integration[]) => Integration[]); + integrations?: Integration[] | ((integrations: Integration[]) => Integration[]) | undefined; /** * A pattern for error messages which should not be sent to Sentry. * By default, all errors will be sent. */ - ignoreErrors?: Array; + ignoreErrors?: Array | undefined; /** * Transport object that should be used to send events to Sentry */ - transport?: TransportClass; + transport?: TransportClass | undefined; /** * Options for the default transport that the SDK uses. */ - transportOptions?: TransportOptions; + transportOptions?: TransportOptions | undefined; /** * A URL to an envelope tunnel endpoint. An envelope tunnel is an HTTP endpoint * that accepts Sentry envelopes for forwarding. This can be used to force data * through a custom server independent of the type of data. */ - tunnel?: string; + tunnel?: string | undefined; /** * The release identifier used when uploading respective source maps. Specify * this value to allow Sentry to resolve the correct source maps when * processing events. */ - release?: string; + release?: string | undefined; /** The current environment of your application (e.g. "production"). */ - environment?: string; + environment?: string | undefined; /** Sets the distribution for all events */ - dist?: string; + dist?: string | undefined; /** * The maximum number of breadcrumbs sent with events. Defaults to 100. * Values over 100 will be ignored and 100 used instead. */ - maxBreadcrumbs?: number; + maxBreadcrumbs?: number | undefined; /** Console logging verbosity for the SDK Client. */ - logLevel?: LogLevel; + logLevel?: LogLevel | undefined; /** A global sample rate to apply to all events (0 - 1). */ - sampleRate?: number; + sampleRate?: number | undefined; /** Attaches stacktraces to pure capture message / log integrations */ - attachStacktrace?: boolean; + attachStacktrace?: boolean | undefined; /** Maxium number of chars a single value can have before it will be truncated. */ - maxValueLength?: number; + maxValueLength?: number | undefined; /** * Maximum number of levels that normalization algorithm will traverse in objects and arrays. @@ -104,7 +104,7 @@ export interface Options { * - `extra` * Defaults to `3`. Set to `0` to disable. */ - normalizeDepth?: number; + normalizeDepth?: number | undefined; /** * Controls how many milliseconds to wait before shutting down. The default is @@ -113,7 +113,7 @@ export interface Options { * high can cause the application to block for users with network connectivity * problems. */ - shutdownTimeout?: number; + shutdownTimeout?: number | undefined; /** * Sample rate to determine trace sampling. @@ -124,31 +124,33 @@ export interface Options { * Tracing is enabled if either this or `tracesSampler` is defined. If both are defined, `tracesSampleRate` is * ignored. */ - tracesSampleRate?: number; + tracesSampleRate?: number | undefined; /** * A flag enabling Sessions Tracking feature. * By default, Sessions Tracking is enabled. */ - autoSessionTracking?: boolean; + autoSessionTracking?: boolean | undefined; /** * Initial data to populate scope. */ - initialScope?: CaptureContext; + initialScope?: CaptureContext | undefined; /** * Set of metadata about the SDK that can be internally used to enhance envelopes and events, * and provide additional data about every request. * */ - _metadata?: SdkMetadata; + _metadata?: SdkMetadata | undefined; /** * Options which are in beta, or otherwise not guaranteed to be stable. */ - _experiments?: { - [key: string]: any; - }; + _experiments?: + | { + [key: string]: any; + } + | undefined; /** * Function to compute tracing sample rate dynamically and filter unwanted traces. @@ -162,7 +164,7 @@ export interface Options { * @returns A sample rate between 0 and 1 (0 drops the trace, 1 guarantees it will be sent). Returning `true` is * equivalent to returning 1 and returning `false` is equivalent to returning 0. */ - tracesSampler?(samplingContext: SamplingContext): number | boolean; + tracesSampler?: undefined | ((samplingContext: SamplingContext) => number | boolean); /** * A callback invoked during event submission, allowing to optionally modify @@ -176,7 +178,7 @@ export interface Options { * @param hint May contain additional information about the original exception. * @returns A new event that will be sent | null. */ - beforeSend?(event: Event, hint?: EventHint): PromiseLike | Event | null; + beforeSend?: undefined | ((event: Event, hint?: EventHint) => PromiseLike | Event | null); /** * A callback invoked when adding a breadcrumb, allowing to optionally modify @@ -189,5 +191,5 @@ export interface Options { * @param breadcrumb The breadcrumb as created by the SDK. * @returns The breadcrumb that will be added | null. */ - beforeBreadcrumb?(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb | null; + beforeBreadcrumb?: undefined | ((breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => Breadcrumb | null); }