UNPKG

4.99 kBTypeScriptView Raw
1import { Integrations as CoreIntegrations } from '@sentry/core';
2import { Event, ExtractedNodeRequestData, StackParser } from '@sentry/types';
3import { AddRequestDataToEventOptions, CrossPlatformRequest } from '@sentry/utils';
4import { NodeClient } from './client';
5import { Console, ContextLines, Http, LinkedErrors, OnUncaughtException, OnUnhandledRejection } from './integrations';
6import { NodeOptions } from './types';
7export declare const defaultIntegrations: (Console | Http | OnUncaughtException | OnUnhandledRejection | ContextLines | LinkedErrors | CoreIntegrations.InboundFilters | CoreIntegrations.FunctionToString)[];
8/**
9 * The Sentry Node SDK Client.
10 *
11 * To use this SDK, call the {@link init} function as early as possible in the
12 * main entry module. To set context information or send manual events, use the
13 * provided methods.
14 *
15 * @example
16 * ```
17 *
18 * const { init } = require('@sentry/node');
19 *
20 * init({
21 * dsn: '__DSN__',
22 * // ...
23 * });
24 * ```
25 *
26 * @example
27 * ```
28 *
29 * const { configureScope } = require('@sentry/node');
30 * configureScope((scope: Scope) => {
31 * scope.setExtra({ battery: 0.7 });
32 * scope.setTag({ user_mode: 'admin' });
33 * scope.setUser({ id: '4711' });
34 * });
35 * ```
36 *
37 * @example
38 * ```
39 *
40 * const { addBreadcrumb } = require('@sentry/node');
41 * addBreadcrumb({
42 * message: 'My Breadcrumb',
43 * // ...
44 * });
45 * ```
46 *
47 * @example
48 * ```
49 *
50 * const Sentry = require('@sentry/node');
51 * Sentry.captureMessage('Hello, world!');
52 * Sentry.captureException(new Error('Good bye'));
53 * Sentry.captureEvent({
54 * message: 'Manual',
55 * stacktrace: [
56 * // ...
57 * ],
58 * });
59 * ```
60 *
61 * @see {@link NodeOptions} for documentation on configuration options.
62 */
63export declare function init(options?: NodeOptions): void;
64/**
65 * This is the getter for lastEventId.
66 *
67 * @returns The last event id of a captured event.
68 */
69export declare function lastEventId(): string | undefined;
70/**
71 * Call `flush()` on the current client, if there is one. See {@link Client.flush}.
72 *
73 * @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause
74 * the client to wait until all events are sent before resolving the promise.
75 * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
76 * doesn't (or if there's no client defined).
77 */
78export declare function flush(timeout?: number): Promise<boolean>;
79/**
80 * Call `close()` on the current client, if there is one. See {@link Client.close}.
81 *
82 * @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this
83 * parameter will cause the client to wait until all events are sent before disabling itself.
84 * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
85 * doesn't (or if there's no client defined).
86 */
87export declare function close(timeout?: number): Promise<boolean>;
88/**
89 * Function that takes an instance of NodeClient and checks if autoSessionTracking option is enabled for that client
90 */
91export declare function isAutoSessionTrackingEnabled(client?: NodeClient): boolean;
92/**
93 * Returns a release dynamically from environment variables.
94 */
95export declare function getSentryRelease(fallback?: string): string | undefined;
96/** Node.js stack parser */
97export declare const defaultStackParser: StackParser;
98/**
99 * Add data from the given request to the given event
100 *
101 * (Note that there is no sister function to this one in `@sentry/browser`, because the whole point of this wrapper is
102 * to pass along injected dependencies, which isn't necessary in a browser context. Isomorphic packages like
103 * `@sentry/nextjs` should export directly from `@sentry/utils` in their browser index file.)
104 *
105 * @param event The event to which the request data will be added
106 * @param req Request object
107 * @param options.include Flags to control what data is included
108 * @hidden
109 */
110export declare function addRequestDataToEvent(event: Event, req: CrossPlatformRequest, options?: Omit<AddRequestDataToEventOptions, 'deps'>): Event;
111/**
112 * Normalize data from the request object, accounting for framework differences.
113 *
114 * (Note that there is no sister function to this one in `@sentry/browser`, because the whole point of this wrapper is
115 * to inject dependencies, which isn't necessary in a browser context. Isomorphic packages like `@sentry/nextjs` should
116 * export directly from `@sentry/utils` in their browser index file.)
117 *
118 * @param req The request object from which to extract data
119 * @param options.keys An optional array of keys to include in the normalized data. Defaults to DEFAULT_REQUEST_KEYS if
120 * not provided.
121 * @returns An object containing normalized request data
122 */
123export declare function extractRequestData(req: CrossPlatformRequest, options?: {
124 include?: string[];
125}): ExtractedNodeRequestData;
126//# sourceMappingURL=sdk.d.ts.map
\No newline at end of file