Skip to content

Commit 508121f

Browse files
connor4312benvinegar
authored andcommitted
Update raven option typings (#811)
* Update raven option typings * Update typings for showReportDialog
1 parent 834ff76 commit 508121f

File tree

1 file changed

+92
-31
lines changed

1 file changed

+92
-31
lines changed

typescript/raven.d.ts

+92-31
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,80 @@ declare var Raven: RavenStatic;
66

77
export = Raven;
88

9-
interface RavenOptions {
10-
/** The log level associated with this event. Default: error */
11-
level?: string;
9+
interface BreadcrumbSettings {
10+
/* Whether to collect XHR calls, defaults to true */
11+
xhr?: boolean;
1212

13-
/** The name of the logger used by Sentry. Default: javascript */
14-
logger?: string;
13+
/* Whether to collect console logs, defaults to true */
14+
console?: boolean;
15+
16+
/* Whether to collect dom events, defaults to true */
17+
dom?: boolean;
1518

19+
/* Whether to record window location and navigation, defaults to true */
20+
location?: boolean;
21+
}
22+
23+
interface CommonRavenOptions {
1624
/** The environment of the application you are monitoring with Sentry */
1725
environment?: string;
1826

1927
/** The release version of the application you are monitoring with Sentry */
2028
release?: string;
2129

30+
/** Additional data to be tagged onto the error. */
31+
tags?: {
32+
[id: string]: string;
33+
};
34+
35+
/** Exra metadata to collect */
36+
extra?: any;
37+
38+
/** The name of the logger used by Sentry. Default: javascript */
39+
logger?: string;
40+
}
41+
42+
interface RavenOptions extends CommonRavenOptions {
43+
44+
/** The name of the server or device that the client is running on */
45+
server_name?: string;
46+
47+
/** The log level associated with this event. Default: error */
48+
level?: string;
49+
50+
/** set to true to get the strack trace of your message */
51+
stacktrace?: boolean;
52+
53+
/** In some cases you may see issues where Sentry groups multiple events together when they should be separate entities. In other cases, Sentry simply doesn’t group events together because they’re so sporadic that they never look the same. */
54+
fingerprint?: string[];
55+
56+
/** Number of frames to trim off the stacktrace, defaults to 1 */
57+
trimHeadFrames?: number;
58+
59+
/** The name of the device platform. Default: "javascript" */
60+
platform?: string;
61+
}
62+
63+
interface RavenGlobalOptions extends CommonRavenOptions {
64+
2265
/** The name of the server or device that the client is running on */
2366
serverName?: string;
2467

68+
/** set to true to get the strack trace of your message */
69+
stacktrace?: boolean;
70+
2571
/** List of messages to be fitlered out before being sent to Sentry. */
2672
ignoreErrors?: (RegExp | string)[];
2773

74+
/** Configures which breadcrumbs are collected automatically */
75+
autoBreadcrumbs?: boolean | BreadcrumbSettings;
76+
77+
/** Whether to collect errors on the window via TraceKit.collectWindowErrors. Defaults to true. */
78+
collectWindowErrors?: boolean;
79+
80+
/** Max number of breadcrumbs to collect, defaults to 100 */
81+
maxBreadcrumbs?: number;
82+
2883
/** Similar to ignoreErrors, but will ignore errors from whole urls patching a regex pattern. */
2984
ignoreUrls?: (RegExp | string)[];
3085

@@ -34,30 +89,36 @@ interface RavenOptions {
3489
/** An array of regex patterns to indicate which urls are a part of your app. */
3590
includePaths?: (RegExp | string)[];
3691

37-
/** Additional data to be tagged onto the error. */
38-
tags?: {
39-
[id: string]: string;
40-
};
92+
/** Maximum amount of stack frames to collect, defaults to infinity */
93+
stackTraceLimit?: number;
4194

42-
/** set to true to get the strack trace of your message */
43-
stacktrace?: boolean;
95+
/** Override the default HTTP data transport handler. */
96+
transport?: (options: RavenTransportOptions) => void;
4497

45-
extra?: any;
98+
/** By default, Raven does not truncate messages. If you need to truncate characters for whatever reason, you may set this to limit the length. */
99+
maxMessageLength?: number;
46100

47-
/** In some cases you may see issues where Sentry groups multiple events together when they should be separate entities. In other cases, Sentry simply doesn’t group events together because they’re so sporadic that they never look the same. */
48-
fingerprint?: string[];
101+
/** A callback function that allows you to apply your own filters to determine if the message should be sent to Sentry. */
102+
shouldSendCallback?: (data: any) => boolean;
49103

50104
/** A function which allows mutation of the data payload right before being sent to Sentry */
51105
dataCallback?: (data: any) => any;
106+
}
52107

53-
/** A callback function that allows you to apply your own filters to determine if the message should be sent to Sentry. */
54-
shouldSendCallback?: (data: any) => boolean;
55-
56-
/** By default, Raven does not truncate messages. If you need to truncate characters for whatever reason, you may set this to limit the length. */
57-
maxMessageLength?: number;
108+
interface RavenWrapOptions extends RavenOptions {
109+
/**
110+
* Whether to run the wrap recursively, defaults to false.
111+
*/
112+
deep?: boolean;
113+
}
58114

59-
/** Override the default HTTP data transport handler. */
60-
transport?: (options: RavenTransportOptions) => void;
115+
/**
116+
* General details about the user to be logged to Sentry.
117+
*/
118+
interface RavenUserContext {
119+
id?: string;
120+
username?: string;
121+
email?: string;
61122
}
62123

63124
interface RavenStatic {
@@ -90,7 +151,7 @@ interface RavenStatic {
90151
* @param {object} options Optional set of of global options [optional]
91152
* @return {Raven}
92153
*/
93-
config(dsn: string, options?: RavenOptions): RavenStatic;
154+
config(dsn: string, options?: RavenGlobalOptions): RavenStatic;
94155

95156
/*
96157
* Installs a global window.onerror error handler
@@ -118,7 +179,7 @@ interface RavenStatic {
118179
* @param {array} args An array of arguments to be called with the callback [optional]
119180
*/
120181
context(func: Function, ...args: any[]): void;
121-
context(options: RavenOptions, func: Function, ...args: any[]): void;
182+
context(options: RavenWrapOptions, func: Function, ...args: any[]): void;
122183

123184
/*
124185
* Wrap code within a context and returns back a new function to be executed
@@ -128,9 +189,9 @@ interface RavenStatic {
128189
* @return {function} The newly wrapped functions with a context
129190
*/
130191
wrap(func: Function): Function;
131-
wrap(options: RavenOptions, func: Function): Function;
192+
wrap(options: RavenWrapOptions, func: Function): Function;
132193
wrap<T extends Function>(func: T): T;
133-
wrap<T extends Function>(options: RavenOptions, func: T): T;
194+
wrap<T extends Function>(options: RavenWrapOptions, func: T): T;
134195

135196
/*
136197
* Uninstalls the global error handler.
@@ -171,11 +232,7 @@ interface RavenStatic {
171232
* @param {object} user An object representing user data [optional]
172233
* @return {Raven}
173234
*/
174-
setUserContext(user: {
175-
id?: string;
176-
username?: string;
177-
email?: string;
178-
}): RavenStatic;
235+
setUserContext(user: RavenUserContext): RavenStatic;
179236

180237
/** Merge extra attributes to be sent along with the payload. */
181238
setExtraContext(context: Object): RavenStatic;
@@ -217,7 +274,11 @@ interface RavenStatic {
217274
setShouldSendCallback(data: any, orig?: any): RavenStatic;
218275

219276
/** Show Sentry user feedback dialog */
220-
showReportDialog(options: Object): void;
277+
showReportDialog(options?: {
278+
eventId?: number,
279+
dsn?: string,
280+
user?: RavenUserContext,
281+
}): void;
221282
}
222283

223284
interface RavenTransportOptions {

0 commit comments

Comments
 (0)