-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathoptions.ts
308 lines (269 loc) · 11.1 KB
/
options.ts
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
import type { Breadcrumb, BreadcrumbHint } from './breadcrumb';
import type { ErrorEvent, Event, EventHint, TransactionEvent } from './event';
import type { Instrumenter } from './instrumenter';
import type { Integration } from './integration';
import type { CaptureContext } from './scope';
import type { SdkMetadata } from './sdkmetadata';
import type { StackLineParser, StackParser } from './stacktrace';
import type { SamplingContext } from './transaction';
import type { BaseTransportOptions, Transport } from './transport';
export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOptions> {
/**
* Enable debug functionality in the SDK itself
*/
debug?: boolean;
/**
* Specifies whether this SDK should send events to Sentry.
* Defaults to true.
*/
enabled?: boolean;
/** Attaches stacktraces to pure capture message / log integrations */
attachStacktrace?: boolean;
/**
* A flag enabling Sessions Tracking feature.
* By default, Sessions Tracking is enabled.
*/
autoSessionTracking?: boolean;
/**
* Send SDK Client Reports.
* By default, Client Reports are enabled.
*/
sendClientReports?: boolean;
/**
* The Dsn used to connect to Sentry and identify the project. If omitted, the
* SDK will not send any data to Sentry.
*/
dsn?: string;
/**
* 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;
/** The current environment of your application (e.g. "production"). */
environment?: string;
/** Sets the distribution for all events */
dist?: string;
/**
* List of integrations that should be installed after SDK was initialized.
*/
integrations: Integration[];
/**
* The instrumenter to use. Defaults to `sentry`.
* When not set to `sentry`, auto-instrumentation inside of Sentry will be disabled,
* in favor of using external auto instrumentation.
*
* NOTE: Any option except for `sentry` is highly experimental and subject to change!
*/
instrumenter?: Instrumenter;
/**
* A function that takes transport options and returns the Transport object which is used to send events to Sentry.
* The function is invoked internally when the client is initialized.
*/
transport: (transportOptions: TO) => Transport;
/**
* A stack parser implementation
* By default, a stack parser is supplied for all supported platforms
*/
stackParser: StackParser;
/**
* Options for the default transport that the SDK uses.
*/
transportOptions?: Partial<TO>;
/**
* Sample rate to determine trace sampling.
*
* 0.0 = 0% chance of a given trace being sent (send no traces) 1.0 = 100% chance of a given trace being sent (send
* all traces)
*
* Tracing is enabled if either this or `tracesSampler` is defined. If both are defined, `tracesSampleRate` is
* ignored.
*/
tracesSampleRate?: number;
/**
* If this is enabled, transactions and trace data will be generated and captured.
* This will set the `tracesSampleRate` to the recommended default of `1.0` if `tracesSampleRate` is undefined.
* Note that `tracesSampleRate` and `tracesSampler` take precedence over this option.
*/
enableTracing?: boolean;
/**
* Initial data to populate scope.
*/
initialScope?: CaptureContext;
/**
* The maximum number of breadcrumbs sent with events. Defaults to 100.
* Sentry has a maximum payload size of 1MB and any events exceeding that payload size will be dropped.
*/
maxBreadcrumbs?: number;
/**
* A global sample rate to apply to all events.
*
* 0.0 = 0% chance of a given event being sent (send no events) 1.0 = 100% chance of a given event being sent (send
* all events)
*/
sampleRate?: number;
/** Maximum number of chars a single value can have before it will be truncated. */
maxValueLength?: number;
/**
* Maximum number of levels that normalization algorithm will traverse in objects and arrays.
* Used when normalizing an event before sending, on all of the listed attributes:
* - `breadcrumbs.data`
* - `user`
* - `contexts`
* - `extra`
* Defaults to `3`. Set to `0` to disable.
*/
normalizeDepth?: number;
/**
* Maximum number of properties or elements that the normalization algorithm will output in any single array or object included in the normalized event.
* Used when normalizing an event before sending, on all of the listed attributes:
* - `breadcrumbs.data`
* - `user`
* - `contexts`
* - `extra`
* Defaults to `1000`
*/
normalizeMaxBreadth?: number;
/**
* Controls how many milliseconds to wait before shutting down. The default is
* SDK-specific but typically around 2 seconds. Setting this too low can cause
* problems for sending events from command line applications. Setting it too
* high can cause the application to block for users with network connectivity
* problems.
*/
shutdownTimeout?: number;
/**
* A pattern for error messages which should not be sent to Sentry.
* By default, all errors will be sent.
*/
ignoreErrors?: Array<string | RegExp>;
/**
* A pattern for transaction names which should not be sent to Sentry.
* By default, all transactions will be sent.
*/
ignoreTransactions?: Array<string | RegExp>;
/**
* 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;
/**
* Controls if potentially sensitive data should be sent to Sentry by default.
* Note that this only applies to data that the SDK is sending by default
* but not data that was explicitly set (e.g. by calling `Sentry.setUser()`).
*
* Defaults to `false`.
*
* NOTE: This option currently controls only a few data points in a selected
* set of SDKs. The goal for this option is to eventually control all sensitive
* data the SDK sets by default. However, this would be a breaking change so
* until the next major update this option only controls data points which were
* added in versions above `7.9.0`.
*/
sendDefaultPii?: boolean;
/**
* 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;
/**
* Options which are in beta, or otherwise not guaranteed to be stable.
*/
_experiments?: {
[key: string]: any;
};
/**
* A pattern for error URLs which should exclusively be sent to Sentry.
* This is the opposite of {@link Options.denyUrls}.
* By default, all errors will be sent.
*
* Requires the use of the `InboundFilters` integration.
*/
allowUrls?: Array<string | RegExp>;
/**
* 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.
*
* Requires the use of the `InboundFilters` integration.
*/
denyUrls?: Array<string | RegExp>;
/**
* Function to compute tracing sample rate dynamically and filter unwanted traces.
*
* Tracing is enabled if either this or `tracesSampleRate` is defined. If both are defined, `tracesSampleRate` is
* ignored.
*
* Will automatically be passed a context object of default and optional custom data. See
* {@link Transaction.samplingContext} and {@link Hub.startTransaction}.
*
* @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;
// TODO (v8): Narrow the response type to `ErrorEvent` - this is technically a breaking change.
/**
* An event-processing callback for error and message events, guaranteed to be invoked after all other event
* processors, which allows an event to be modified or dropped.
*
* Note that you must return a valid event from this callback. If you do not wish to modify the event, simply return
* it at the end. Returning `null` will cause the event to be dropped.
*
* @param event The error or message event generated by the SDK.
* @param hint Event metadata useful for processing.
* @returns A new event that will be sent | null.
*/
beforeSend?: (event: ErrorEvent, hint: EventHint) => PromiseLike<Event | null> | Event | null;
// TODO (v8): Narrow the response type to `TransactionEvent` - this is technically a breaking change.
/**
* An event-processing callback for transaction events, guaranteed to be invoked after all other event
* processors. This allows an event to be modified or dropped before it's sent.
*
* Note that you must return a valid event from this callback. If you do not wish to modify the event, simply return
* it at the end. Returning `null` will cause the event to be dropped.
*
* @param event The error or message event generated by the SDK.
* @param hint Event metadata useful for processing.
* @returns A new event that will be sent | null.
*/
beforeSendTransaction?: (event: TransactionEvent, hint: EventHint) => PromiseLike<Event | null> | Event | null;
/**
* A callback invoked when adding a breadcrumb, allowing to optionally modify
* it before adding it to future events.
*
* Note that you must return a valid breadcrumb from this callback. If you do
* not wish to modify the breadcrumb, simply return it at the end.
* Returning null will cause the breadcrumb to be dropped.
*
* @param breadcrumb The breadcrumb as created by the SDK.
* @returns The breadcrumb that will be added | null.
*/
beforeBreadcrumb?: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => Breadcrumb | null;
}
/** Base configuration options for every SDK. */
export interface Options<TO extends BaseTransportOptions = BaseTransportOptions>
extends Omit<Partial<ClientOptions<TO>>, 'integrations' | 'transport' | 'stackParser'> {
/**
* If this is set to false, default integrations will not be added, otherwise this will internally be set to the
* recommended default integrations.
*/
defaultIntegrations?: false | Integration[];
/**
* 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[]);
/**
* A function that takes transport options and returns the Transport object which is used to send events to Sentry.
* The function is invoked internally during SDK initialization.
* By default, the SDK initializes its default transports.
*/
transport?: (transportOptions: TO) => Transport;
/**
* A stack parser implementation or an array of stack line parsers
* By default, a stack parser is supplied for all supported browsers
*/
stackParser?: StackParser | StackLineParser[];
}