Skip to content

Commit 00fd792

Browse files
tomasklingenbenvinegar
authored andcommitted
Update type definitions for breadcrumbs (#963)
* Add breadcrumb and loglevel typings. * add auto breadcrumb options definitions. * Add comment for autobreadcrumb options * Add test for auto breadcrumbs * Change from BreadCrumb to Breadcrumb spelling for consistency
1 parent 6224a42 commit 00fd792

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

typescript/raven-tests.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ var options = {
1919
whitelistUrls: [
2020
/https?:\/\/google\.com/,
2121
'https://www.google.com'
22-
]
22+
],
23+
autoBreadcrumbs: {
24+
xhr: false,
25+
console: false,
26+
dom: true,
27+
location: false
28+
}
2329
};
2430

2531
Raven.config('https://[email protected]/1', options).install();
@@ -55,7 +61,9 @@ var err:Error = Raven.lastException();
5561
Raven.captureMessage('Broken!');
5662
Raven.captureMessage('Broken!', {tags: { key: "value" }});
5763
+Raven.captureMessage('Broken!', { stacktrace: true });
58-
Raven.captureBreadcrumb({});
64+
Raven.captureBreadcrumb({
65+
message: "This is a breadcrumb message."
66+
});
5967

6068
Raven.setRelease('abc123');
6169
Raven.setEnvironment('production');

typescript/raven.d.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export = Raven;
88

99
interface RavenOptions {
1010
/** The log level associated with this event. Default: error */
11-
level?: string;
11+
level?: LogLevel;
1212

1313
/** The name of the logger used by Sentry. Default: javascript */
1414
logger?: string;
@@ -64,6 +64,9 @@ interface RavenOptions {
6464

6565
/** Enables/disables instrumentation of globals. */
6666
instrument?: boolean | RavenInstrumentationOptions;
67+
68+
/** Enables/disables automatic collection of breadcrumbs. */
69+
autoBreadcrumbs?: boolean | AutoBreadcrumbOptions
6770
}
6871

6972
interface RavenInstrumentationOptions {
@@ -168,7 +171,7 @@ interface RavenStatic {
168171
captureMessage(msg: string, options?: RavenOptions): RavenStatic;
169172

170173
/** Log a breadcrumb */
171-
captureBreadcrumb(crumb: Object): RavenStatic;
174+
captureBreadcrumb(crumb: Breadcrumb): RavenStatic;
172175

173176
/**
174177
* Clear the user context, removing the user data that would be sent to Sentry.
@@ -245,3 +248,22 @@ interface RavenTransportOptions {
245248
interface RavenPlugin {
246249
(raven: RavenStatic, ...args: any[]): RavenStatic;
247250
}
251+
252+
interface Breadcrumb {
253+
message?: string;
254+
category?: string;
255+
level?: LogLevel;
256+
data?: any;
257+
type?: BreadcrumbType
258+
}
259+
260+
type BreadcrumbType = "navigation" | "http";
261+
262+
interface AutoBreadcrumbOptions {
263+
xhr?: boolean;
264+
console?: boolean;
265+
dom?: boolean;
266+
location?: boolean;
267+
}
268+
269+
type LogLevel = "critical" | "error" | "warn" | "info" | "debug";

0 commit comments

Comments
 (0)