Skip to content

Update type definitions for breadcrumbs #963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions typescript/raven-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ var options = {
whitelistUrls: [
/https?:\/\/google\.com/,
'https://www.google.com'
]
],
autoBreadcrumbs: {
xhr: false,
console: false,
dom: true,
location: false
}
};

Raven.config('https://public@sentry.io/1', options).install();
Expand Down Expand Up @@ -55,7 +61,9 @@ var err:Error = Raven.lastException();
Raven.captureMessage('Broken!');
Raven.captureMessage('Broken!', {tags: { key: "value" }});
+Raven.captureMessage('Broken!', { stacktrace: true });
Raven.captureBreadcrumb({});
Raven.captureBreadcrumb({
message: "This is a breadcrumb message."
});

Raven.setRelease('abc123');
Raven.setEnvironment('production');
Expand Down
26 changes: 24 additions & 2 deletions typescript/raven.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export = Raven;

interface RavenOptions {
/** The log level associated with this event. Default: error */
level?: string;
level?: LogLevel;

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

/** Enables/disables instrumentation of globals. */
instrument?: boolean | RavenInstrumentationOptions;

/** Enables/disables automatic collection of breadcrumbs. */
autoBreadcrumbs?: boolean | AutoBreadcrumbOptions
}

interface RavenInstrumentationOptions {
Expand Down Expand Up @@ -168,7 +171,7 @@ interface RavenStatic {
captureMessage(msg: string, options?: RavenOptions): RavenStatic;

/** Log a breadcrumb */
captureBreadcrumb(crumb: Object): RavenStatic;
captureBreadcrumb(crumb: Breadcrumb): RavenStatic;

/**
* Clear the user context, removing the user data that would be sent to Sentry.
Expand Down Expand Up @@ -245,3 +248,22 @@ interface RavenTransportOptions {
interface RavenPlugin {
(raven: RavenStatic, ...args: any[]): RavenStatic;
}

interface Breadcrumb {
message?: string;
category?: string;
level?: LogLevel;
data?: any;
type?: BreadcrumbType
}

type BreadcrumbType = "navigation" | "http";

interface AutoBreadcrumbOptions {
xhr?: boolean;
console?: boolean;
dom?: boolean;
location?: boolean;
}

type LogLevel = "critical" | "error" | "warn" | "info" | "debug";