Skip to content

Commit dc03a30

Browse files
committed
Add TypeScript type definitions (from DefinitelyTyped)
1 parent 755da21 commit dc03a30

File tree

1 file changed

+195
-0
lines changed

1 file changed

+195
-0
lines changed

index.d.ts

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
// Type definitions for Raven.js
2+
// Project: https://github.com/getsentry/raven-js
3+
// Definitions by: Santi Albo <https://github.com/santialbo/>, Benjamin Pannell <http://github.com/spartan563>
4+
5+
interface RavenOptions {
6+
/** The log level associated with this event. Default: error */
7+
level?: string;
8+
9+
/** The name of the logger used by Sentry. Default: javascript */
10+
logger?: string;
11+
12+
/** The release version of the application you are monitoring with Sentry */
13+
release?: string;
14+
15+
/** The name of the server or device that the client is running on */
16+
serverName?: string;
17+
18+
/** List of messages to be fitlered out before being sent to Sentry. */
19+
ignoreErrors?: string[];
20+
21+
/** Similar to ignoreErrors, but will ignore errors from whole urls patching a regex pattern. */
22+
ignoreUrls?: RegExp[];
23+
24+
/** The inverse of ignoreUrls. Only report errors from whole urls matching a regex pattern. */
25+
whitelistUrls?: RegExp[];
26+
27+
/** An array of regex patterns to indicate which urls are a part of your app. */
28+
includePaths?: RegExp[];
29+
30+
/** Additional data to be tagged onto the error. */
31+
tags?: {
32+
[id: string]: string;
33+
};
34+
35+
extra?: any;
36+
37+
/** 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. */
38+
fingerprint?: string[];
39+
40+
/** A function which allows mutation of the data payload right before being sent to Sentry */
41+
dataCallback?: (data: any) => any;
42+
43+
/** A callback function that allows you to apply your own filters to determine if the message should be sent to Sentry. */
44+
shouldSendCallback?: (data: any) => boolean;
45+
46+
/** By default, Raven does not truncate messages. If you need to truncate characters for whatever reason, you may set this to limit the length. */
47+
maxMessageLength?: number;
48+
49+
/** Override the default HTTP data transport handler. */
50+
transport?: (options: RavenTransportOptions) => void;
51+
}
52+
53+
interface RavenStatic {
54+
55+
/** Raven.js version. */
56+
VERSION: string;
57+
58+
Plugins: { [id: string]: RavenPlugin };
59+
60+
/*
61+
* Allow Raven to be configured as soon as it is loaded
62+
* It uses a global RavenConfig = {dsn: '...', config: {}}
63+
*
64+
* @return undefined
65+
*/
66+
afterLoad(): void;
67+
68+
/*
69+
* Allow multiple versions of Raven to be installed.
70+
* Strip Raven from the global context and returns the instance.
71+
*
72+
* @return {Raven}
73+
*/
74+
noConflict(): RavenStatic;
75+
76+
/*
77+
* Configure Raven with a DSN and extra options
78+
*
79+
* @param {string} dsn The public Sentry DSN
80+
* @param {object} options Optional set of of global options [optional]
81+
* @return {Raven}
82+
*/
83+
config(dsn: string, options?: RavenOptions): RavenStatic;
84+
85+
/*
86+
* Installs a global window.onerror error handler
87+
* to capture and report uncaught exceptions.
88+
* At this point, install() is required to be called due
89+
* to the way TraceKit is set up.
90+
*
91+
* @return {Raven}
92+
*/
93+
install(): RavenStatic;
94+
95+
/*
96+
* Adds a plugin to Raven
97+
*
98+
* @return {Raven}
99+
*/
100+
addPlugin(plugin: RavenPlugin, ...pluginArgs: any[]): RavenStatic;
101+
102+
/*
103+
* Wrap code within a context so Raven can capture errors
104+
* reliably across domains that is executed immediately.
105+
*
106+
* @param {object} options A specific set of options for this context [optional]
107+
* @param {function} func The callback to be immediately executed within the context
108+
* @param {array} args An array of arguments to be called with the callback [optional]
109+
*/
110+
context(func: Function, ...args: any[]): void;
111+
context(options: RavenOptions, func: Function, ...args: any[]): void;
112+
113+
/*
114+
* Wrap code within a context and returns back a new function to be executed
115+
*
116+
* @param {object} options A specific set of options for this context [optional]
117+
* @param {function} func The function to be wrapped in a new context
118+
* @return {function} The newly wrapped functions with a context
119+
*/
120+
wrap(func: Function): Function;
121+
wrap(options: RavenOptions, func: Function): Function;
122+
wrap<T extends Function>(func: T): T;
123+
wrap<T extends Function>(options: RavenOptions, func: T): T;
124+
125+
/*
126+
* Uninstalls the global error handler.
127+
*
128+
* @return {Raven}
129+
*/
130+
uninstall(): RavenStatic;
131+
132+
/*
133+
* Manually capture an exception and send it over to Sentry
134+
*
135+
* @param {error} ex An exception to be logged
136+
* @param {object} options A specific set of options for this error [optional]
137+
* @return {Raven}
138+
*/
139+
captureException(ex: Error, options?: RavenOptions): RavenStatic;
140+
141+
/*
142+
* Manually send a message to Sentry
143+
*
144+
* @param {string} msg A plain message to be captured in Sentry
145+
* @param {object} options A specific set of options for this message [optional]
146+
* @return {Raven}
147+
*/
148+
captureMessage(msg: string, options?: RavenOptions): RavenStatic;
149+
150+
/**
151+
* Clear the user context, removing the user data that would be sent to Sentry.
152+
*/
153+
setUserContext(): RavenStatic;
154+
155+
/*
156+
* Set a user to be sent along with the payload.
157+
*
158+
* @param {object} user An object representing user data [optional]
159+
* @return {Raven}
160+
*/
161+
setUserContext(user: {
162+
id?: string;
163+
username?: string;
164+
email?: string;
165+
}): RavenStatic;
166+
167+
/** Override the default HTTP data transport handler. */
168+
setTransport(transportFunction: (options: RavenTransportOptions) => void): RavenStatic;
169+
170+
/** An event id is a globally unique id for the event that was just sent. This event id can be used to find the exact event from within Sentry. */
171+
lastEventId(): string;
172+
173+
/** If you need to conditionally check if raven needs to be initialized or not, you can use the isSetup function. It will return true if Raven is already initialized. */
174+
isSetup(): boolean;
175+
}
176+
177+
interface RavenTransportOptions {
178+
url: string;
179+
data: any;
180+
auth: {
181+
sentry_version: string;
182+
sentry_client: string;
183+
sentry_key: string;
184+
};
185+
onSuccess: () => void;
186+
onFailure: () => void;
187+
}
188+
189+
interface RavenPlugin {
190+
(raven: RavenStatic, ...args: any[]): RavenStatic;
191+
}
192+
193+
declare var Raven: RavenStatic;
194+
195+
export default Raven;

0 commit comments

Comments
 (0)