Skip to content

Update raven option typings #811

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 2 commits into from
Jan 10, 2017
Merged
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
123 changes: 92 additions & 31 deletions typescript/raven.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,80 @@ declare var Raven: RavenStatic;

export = Raven;

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

/** The name of the logger used by Sentry. Default: javascript */
logger?: string;
/* Whether to collect console logs, defaults to true */
console?: boolean;

/* Whether to collect dom events, defaults to true */
dom?: boolean;

/* Whether to record window location and navigation, defaults to true */
location?: boolean;
}

interface CommonRavenOptions {
/** The environment of the application you are monitoring with Sentry */
environment?: string;

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

/** Additional data to be tagged onto the error. */
tags?: {
[id: string]: string;
};

/** Exra metadata to collect */
extra?: any;

/** The name of the logger used by Sentry. Default: javascript */
logger?: string;
}

interface RavenOptions extends CommonRavenOptions {

/** The name of the server or device that the client is running on */
server_name?: string;

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

/** set to true to get the strack trace of your message */
stacktrace?: boolean;

/** 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. */
fingerprint?: string[];

/** Number of frames to trim off the stacktrace, defaults to 1 */
trimHeadFrames?: number;

/** The name of the device platform. Default: "javascript" */
platform?: string;
}

interface RavenGlobalOptions extends CommonRavenOptions {

/** The name of the server or device that the client is running on */
serverName?: string;

/** set to true to get the strack trace of your message */
stacktrace?: boolean;

/** List of messages to be fitlered out before being sent to Sentry. */
ignoreErrors?: (RegExp | string)[];

/** Configures which breadcrumbs are collected automatically */
autoBreadcrumbs?: boolean | BreadcrumbSettings;

/** Whether to collect errors on the window via TraceKit.collectWindowErrors. Defaults to true. */
collectWindowErrors?: boolean;

/** Max number of breadcrumbs to collect, defaults to 100 */
maxBreadcrumbs?: number;

/** Similar to ignoreErrors, but will ignore errors from whole urls patching a regex pattern. */
ignoreUrls?: (RegExp | string)[];

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

/** Additional data to be tagged onto the error. */
tags?: {
[id: string]: string;
};
/** Maximum amount of stack frames to collect, defaults to infinity */
stackTraceLimit?: number;

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

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

/** 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. */
fingerprint?: string[];
/** A callback function that allows you to apply your own filters to determine if the message should be sent to Sentry. */
shouldSendCallback?: (data: any) => boolean;

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

/** A callback function that allows you to apply your own filters to determine if the message should be sent to Sentry. */
shouldSendCallback?: (data: any) => boolean;

/** By default, Raven does not truncate messages. If you need to truncate characters for whatever reason, you may set this to limit the length. */
maxMessageLength?: number;
interface RavenWrapOptions extends RavenOptions {
/**
* Whether to run the wrap recursively, defaults to false.
*/
deep?: boolean;
}

/** Override the default HTTP data transport handler. */
transport?: (options: RavenTransportOptions) => void;
/**
* General details about the user to be logged to Sentry.
*/
interface RavenUserContext {
id?: string;
username?: string;
email?: string;
}

interface RavenStatic {
Expand Down Expand Up @@ -90,7 +151,7 @@ interface RavenStatic {
* @param {object} options Optional set of of global options [optional]
* @return {Raven}
*/
config(dsn: string, options?: RavenOptions): RavenStatic;
config(dsn: string, options?: RavenGlobalOptions): RavenStatic;

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

/*
* Wrap code within a context and returns back a new function to be executed
Expand All @@ -128,9 +189,9 @@ interface RavenStatic {
* @return {function} The newly wrapped functions with a context
*/
wrap(func: Function): Function;
wrap(options: RavenOptions, func: Function): Function;
wrap(options: RavenWrapOptions, func: Function): Function;
wrap<T extends Function>(func: T): T;
wrap<T extends Function>(options: RavenOptions, func: T): T;
wrap<T extends Function>(options: RavenWrapOptions, func: T): T;

/*
* Uninstalls the global error handler.
Expand Down Expand Up @@ -171,11 +232,7 @@ interface RavenStatic {
* @param {object} user An object representing user data [optional]
* @return {Raven}
*/
setUserContext(user: {
id?: string;
username?: string;
email?: string;
}): RavenStatic;
setUserContext(user: RavenUserContext): RavenStatic;

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

/** Show Sentry user feedback dialog */
showReportDialog(options: Object): void;
showReportDialog(options?: {
eventId?: number,
dsn?: string,
user?: RavenUserContext,
}): void;
}

interface RavenTransportOptions {
Expand Down