sentry/ts/sentry.classes.sentry.ts

34 lines
762 B
TypeScript
Raw Permalink Normal View History

2022-08-02 15:05:30 +00:00
import * as plugins from './sentry.plugins.js';
2018-10-31 11:43:13 +00:00
/**
* 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
});
process
.on('unhandledRejection', (reason, p) => {
console.error(reason, 'Unhandled Rejection at Promise', p);
})
2021-08-14 15:47:55 +00:00
.on('uncaughtException', (err) => {
console.log(err);
this.captureException(err);
process.exit(1);
});
2018-10-31 11:43:13 +00:00
}
captureException(exceptionArg: any) {
plugins.sentry.captureException(exceptionArg);
}
}