Repository navigation
Expand file tree
/
Copy pathclient.ts
More file actions
73 lines (61 loc) · 2.17 KB
/
Copy pathclient.ts
File metadata and controls
73 lines (61 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as domain from 'domain';
import { BaseClient, SDK_VERSION } from '@sentry/core';
import { CaptureContext, SentryEvent, Options, ScopeLike, SentryGlobal } from '@sentry/types';
import { getCarrier } from '@sentry/minimal';
import { eventFromException, eventFromMessage } from '@sentry/eventbuilder-node';
/**
* Configuration options for the Sentry Node SDK.
* @see NodeClient for more information.
*/
export interface NodeOptions extends Options {
/** Sets an optional server name (device name) */
serverName?: string;
/** Maximum time in milliseconds to wait to drain the request queue, before the process is allowed to exit. */
shutdownTimeout?: number;
/** Sets the number of context lines for each frame when loading a file. */
frameContextLines?: number;
/** Callback that is executed when a fatal global error occurs. */
onFatalError?(error: Error): void;
}
/**
* The Sentry Node SDK Client.
*
* @see NodeOptions for documentation on configuration options.
* @see SentryClient for usage documentation.
*/
export class NodeClient extends BaseClient<NodeOptions> {
/**
* Creates a new Node SDK instance.
* @param options Configuration options for this SDK.
*/
public constructor(options: NodeOptions) {
options._internal = options._internal || {};
options._internal.sdk = options._internal.sdk || {
name: 'sentry.javascript.node',
packages: [
{
name: 'npm:@sentry/node',
version: SDK_VERSION,
},
],
version: SDK_VERSION,
};
super(options);
}
public getScope(): ScopeLike {
const activeDomain = ((domain as unknown) as { active: SentryGlobal }).active;
if (activeDomain) {
const domainScope = getCarrier(activeDomain).scope;
if (domainScope) {
return domainScope;
}
}
return this._scope;
}
protected _eventFromException(exception: unknown, captureContext: CaptureContext): SentryEvent {
return eventFromException(this.options, exception, captureContext);
}
protected _eventFromMessage(message: string, captureContext: CaptureContext): SentryEvent {
return eventFromMessage(this.options, message, captureContext);
}
}