2018-10-31 11:43:13 +00:00
|
|
|
import * as plugins from './sentry.plugins';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the constructor options for Sentry
|
|
|
|
*/
|
|
|
|
export interface ISentryConstructorOptions {
|
|
|
|
appName: string;
|
|
|
|
dsn: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main class that is used creating instances of sentry
|
|
|
|
*/
|
|
|
|
export class Sentry {
|
|
|
|
constructor(optionsArg: ISentryConstructorOptions) {
|
|
|
|
plugins.sentry.init({
|
2021-08-14 15:47:55 +00:00
|
|
|
dsn: optionsArg.dsn,
|
2018-10-31 11:43:13 +00:00
|
|
|
});
|
2018-11-01 22:44:49 +00:00
|
|
|
process
|
|
|
|
.on('unhandledRejection', (reason, p) => {
|
|
|
|
console.error(reason, 'Unhandled Rejection at Promise', p);
|
|
|
|
})
|
2021-08-14 15:47:55 +00:00
|
|
|
.on('uncaughtException', (err) => {
|
2018-11-01 22:44:49 +00:00
|
|
|
console.log(err);
|
|
|
|
this.captureException(err);
|
|
|
|
process.exit(1);
|
|
|
|
});
|
2018-10-31 11:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
captureException(exceptionArg: any) {
|
|
|
|
plugins.sentry.captureException(exceptionArg);
|
|
|
|
}
|
|
|
|
}
|