diff --git a/raven-js/index.d.ts b/raven-js/index.d.ts index fda465c30d..ddb5e8503d 100644 --- a/raven-js/index.d.ts +++ b/raven-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Raven.js +// Type definitions for Raven.js // Project: https://github.com/getsentry/raven-js // Original Definitions by: Santi Albo , Benjamin Pannell // ; DefinitelyTyped @@ -8,8 +8,8 @@ // , Luca Vazzano -declare var Raven: RavenStatic; -export = Raven; +declare let Raven: RavenStatic; +export default Raven; interface RavenStatic { /** Raven.js version. */ @@ -43,7 +43,7 @@ interface RavenStatic { * * @param dsn The public Sentry DSN */ - setDSN(dsn: string); + setDSN(dsn: string): RavenStatic; /** * Installs a global window.onerror error handler to capture and report uncaught exceptions. @@ -200,7 +200,7 @@ interface RavenStatic { // --- Helper Interfaces for Options -------------- -interface RavenBreadcrumOptions { +export interface RavenBreadcrumOptions { /** Whether to collect XHR calls, defaults to true */ xhr?: boolean; @@ -214,7 +214,7 @@ interface RavenBreadcrumOptions { location?: boolean; } -interface CommonRavenOptions { +export interface CommonRavenOptions { /** The environment of the application you are monitoring with Sentry */ environment?: string; @@ -234,7 +234,7 @@ interface CommonRavenOptions { stacktrace?: boolean; } -interface RavenOptions extends CommonRavenOptions { +export interface RavenOptions extends CommonRavenOptions { /** The name of the server or device that the client is running on */ server_name?: string; @@ -253,7 +253,7 @@ interface RavenOptions extends CommonRavenOptions { platform?: string; } -interface RavenGlobalOptions extends CommonRavenOptions { +export interface RavenGlobalOptions extends CommonRavenOptions { /** The name of the server or device that the client is running on */ serverName?: string; @@ -294,12 +294,12 @@ interface RavenGlobalOptions extends CommonRavenOptions { dataCallback?: (data: any) => any; } -interface RavenWrapOptions extends RavenOptions { +export interface RavenWrapOptions extends RavenOptions { /** Whether to run the wrap recursively. Default: false. */ deep?: boolean; } -interface RavenTransportOptions { +export interface RavenTransportOptions { url: string; data: any; auth: { @@ -311,7 +311,7 @@ interface RavenTransportOptions { onFailure: () => void; } -interface RavenReportDialogOptions { +export interface RavenReportDialogOptions { eventId?: number, dsn?: string, user?: { @@ -322,11 +322,11 @@ interface RavenReportDialogOptions { // --- Helper Interfaces for complex Data Structures -------------- -interface RavenPlugin { +export interface RavenPlugin { (raven: RavenStatic, ...args: any[]): RavenStatic; } -interface RavenUserContext { +export interface RavenUserContext { id?: string; username?: string; email?: string; @@ -334,7 +334,7 @@ interface RavenUserContext { extra?: { [prop: string]: any }; } -interface RavenBreadcrumb { +export interface RavenBreadcrumb { message: string; data: { [id: string]: string }; category: string; diff --git a/raven-js/raven-js-tests.ts b/raven-js/raven-js-tests.ts index 9608e41322..bbd3285e1e 100644 --- a/raven-js/raven-js-tests.ts +++ b/raven-js/raven-js-tests.ts @@ -1,24 +1,24 @@ - - import RavenJS from 'raven-js'; RavenJS.config('https://public@getsentry.com/1').install(); -var options: RavenOptions = { - logger: 'my-logger', - ignoreUrls: [ - /graph\.facebook\.com/i - ], - ignoreErrors: [ - 'fb_xd_fragment' - ], - includePaths: [ - /https?:\/\/(www\.)?getsentry\.com/, - /https?:\/\/d3nslu0hdya83q\.cloudfront\.net/ - ] -}; -Raven.config('https://public@getsentry.com/1', options).install(); +RavenJS.config( + 'https://public@getsentry.com/1', + { + logger: 'my-logger', + ignoreUrls: [ + /graph\.facebook\.com/i + ], + ignoreErrors: [ + 'fb_xd_fragment' + ], + includePaths: [ + /https?:\/\/(www\.)?getsentry\.com/, + /https?:\/\/d3nslu0hdya83q\.cloudfront\.net/ + ] + } +).install(); var throwsError = () => { throw new Error('broken'); @@ -27,28 +27,35 @@ var throwsError = () => { try { throwsError(); } catch(e) { - Raven.captureException(e); - Raven.captureException(e, {tags: { key: "value" }}); + RavenJS.captureException(e); + RavenJS.captureException(e, {tags: { key: "value" }}); } -Raven.context(throwsError); -Raven.context({tags: { key: "value" }}, throwsError); -Raven.context({extra: {planet: {name: 'Earth'}}}, throwsError); +RavenJS.context(throwsError); +RavenJS.context({tags: { key: "value" }}, throwsError); +RavenJS.context({extra: {planet: {name: 'Earth'}}}, throwsError); -setTimeout(Raven.wrap(throwsError), 1000); -Raven.wrap({logger: "my.module"}, throwsError)(); -Raven.wrap({tags: {git_commit: 'c0deb10c4'}}, throwsError)(); +setTimeout(RavenJS.wrap(throwsError), 1000); +RavenJS.wrap({logger: "my.module"}, throwsError)(); +RavenJS.wrap({tags: {git_commit: 'c0deb10c4'}}, throwsError)(); -Raven.setUserContext({ +RavenJS.setUserContext({ email: 'matt@example.com', id: '123' }); -Raven.captureMessage('Broken!'); -Raven.captureMessage('Broken!', {tags: { key: "value" }}); +RavenJS.captureMessage('Broken!'); +RavenJS.captureMessage('Broken!', {tags: { key: "value" }}); -Raven.showReportDialog(options); +RavenJS.showReportDialog({ + eventId: 0815, + dsn:'1337asdf', + user: { + name: 'DefenitelyTyped', + email: 'df@ts.ms' + } +}); -Raven.setTagsContext({ key: "value" }); +RavenJS.setTagsContext({ key: "value" }); -Raven.setExtraContext({ foo: "bar" }); +RavenJS.setExtraContext({ foo: "bar" });