getsentry / raven-node

A standalone (Node.js) client for Sentry
https://sentry.io/
BSD 2-Clause "Simplified" License
454 stars 134 forks source link

Add TypeScript type definitions #189

Open rabbitfang opened 8 years ago

rabbitfang commented 8 years ago

The raven-js library for browsers got TypeScript definitions in https://github.com/getsentry/raven-js/pull/610, but those definitions cannot be used for the nodejs library.

The definitions should be implemented for this version as well.

thesmart commented 8 years ago

Not sure if this helps, but here's a partial definition file that probably has bugs in it, but will at least compile:

///  raven v0.12.x
///******************
/// <reference path="../node/node.d.ts" />

declare namespace raven {
  export class Client {
    // Passing any falsey value as the DSN will disable sending events upstream:
    constructor(dsn: string, options?: ConstructorOptions);
    captureException(error: Error, options?: CaptureOptions, cb?: CaptureCallback): void; // Send an error to sentry
    captureMessage(message: string, options?: CaptureOptions, cb?: CaptureCallback): void; // Send a log message to sentry
    setUserContext(data: UserData): void; // While a user is logged in, you can tell Sentry to associate errors with user data.
  }

  interface UserData {
    id: string;
    handle?: string;
  }

  interface CaptureCallback {
    (result: { string: any }): void
  }

  interface DataCallback {
    (data: { string: any }): void
  }

  interface TransportCallback {
    (options: { string: any }): void
  }

  export interface ConstructorOptions {
    logger?: string; // The name of the logger used by Sentry. Default: ''
    release?: string; // Track the version of your application in Sentry.
    environment?: string; // Track the environment name inside Sentry.
    tags?: { string: string }; // Additional tags to assign to each event. E.g. {git_commit: 'c0deb10c4'}
    extra?: { string: string }; // Arbitrary data to associate with the event.
    dataCallback?: DataCallback; // A function that allows mutation of the data payload right before being sent to Sentry.
    transport?: TransportCallback;  // Override the default HTTP data transport handler.
  }

  export interface CaptureOptions {
    tags?: { string: string }; // Additional tags to assign to each event. E.g. {git_commit: 'c0deb10c4'}
    extra?: { string: string }; // Arbitrary data to associate with the event.
    fingerprint?: string; // The fingerprint for grouping this event.
    level?: string; // The level of the event. Defaults to error.
  }
}

declare module "raven" {
  export = raven;
}
benvinegar commented 8 years ago

A big reason we added TypeScript support for Raven.js is because Angular 2 uses TypeScript by default, which is an officially supported framework.

Since there are externally available d.ts files out there, I'm going to keep this on hold until we get more support / votes.

jabooth commented 8 years ago

@benvinegar unless I'm mistaken, you linked to a 3rd party d.ts file for raven-js (which is obsoleted by getsentry/raven-js#610)

AFAIK there is no community d.ts files for raven-node on DefinitelyTyped, and no submissions under review which makes the issue raised here more acute.

At the very least, as a community we should try and get a solid definition file submitted to DT? @thesmart seems like you have made a good start there!

rosslavery commented 8 years ago

Just adding my +1 for this, we'd appreciate typings available via @types/raven-node .

dcharbonnier commented 7 years ago

more and more people use typescript

Aryk commented 7 years ago

+1

asimonf commented 7 years ago

I'm going to leave my +1 here since there's no voting mechanism around here.

ethanrubio commented 7 years ago

+1

myspivey commented 7 years ago

+1

CBXZero commented 7 years ago

+1

jpinkster commented 7 years ago

Please!!

martinambrus commented 7 years ago

this can't be so difficult as to take it a year to implement... or can it? :-O

dcharbonnier commented 7 years ago

Its not, but its an open source software so we can provide a PR if we think it take too much time to implement :-)

jpinkster commented 7 years ago

Ouch @martinambrus! Now there is the https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/raven but it would be cool to be shipped here and maintained ... I am happy to migrate and start the process. Just need help maintaining once it is here. Best done by the release team but I am happy to do the initial leg work

benvinegar commented 7 years ago

this can't be so difficult as to take it a year to implement... or can it? :-O

We had a lot of grief maintaining TypeScript bindings for raven-js. It has been a serious maintenance burden, because people don't often contribute towards them (for example, nobody in this thread has contributed a PR). It's hard to commit to doing them when we don't write TypeScript ourselves.

benvinegar commented 7 years ago

(Not saying this is a hard no, I can be convinced, but we're low on maintenance resources right now so it's not going to happen any time in the next few months without community help.)

jpinkster commented 7 years ago

@benvinegar Would you prefer me leave them in DT? I am cool either way and can at least update to the 2.1 release ... right now it is at 1.2 so shouldnt be too time consuming to update the signatures and add what is missing. Let me know how you want me to proceed!

alfaproject commented 7 years ago

@jpinkster let me know if you decide to do it, or else I'll make a PR myself in the next weeks

martinambrus commented 7 years ago

@benvinegar, @jpinkster thanks for the update guys... if my comment seemed negative, I apologize but not seeing any response from the developers led me to think they just ignore us... very glad it's not the case :)

kamilogorek commented 7 years ago

@jpinkster @alfaproject still interested in writing those definitions?

bilby91 commented 6 years ago

What is the status of this issue ?

kamilogorek commented 6 years ago

It's still open for contributions. Unfortunately I'm not any good with TS and don't have enough time to tackle this issue.