GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Adds sentry error tracking

parent e9a295d6
......@@ -84,7 +84,8 @@
"ts-loader": "^6.2.1",
"tslib": "^1.10.0",
"web-animations-js": "^2.3.2",
"zone.js": "~0.9.1"
"zone.js": "~0.9.1",
"@sentry/browser": "latest"
},
"devDependencies": {
"@angular/cli": "^8.3.18",
......
import { HttpClient } from '@angular/common/http';
import { NgModule, PLATFORM_ID } from '@angular/core';
import { ErrorHandler, NgModule, PLATFORM_ID } from '@angular/core';
import { BrowserModule, BrowserTransferStateModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule, Routes } from '@angular/router';
......@@ -28,6 +28,7 @@ import { RootComponent } from './root/root/root.component';
import { ThemeSwitcherComponent } from './root/theme-switcher/theme-switcher.component';
import rxStompConfig from './rx-stomp.config';
import { StaticLoginService } from './service/login/static-login.service';
import { SentryErrorHandler } from './shared/sentry-error-handler';
import { SharedModule } from './shared/shared.module';
const appRoutes: Routes = [
......@@ -142,17 +143,16 @@ export function markedOptionsFactory(): MarkedOptions {
],
providers: [
{
provide: ErrorHandler,
useClass: SentryErrorHandler,
}, {
provide: InjectableRxStompConfig,
useValue: rxStompConfig,
},
{
}, {
provide: RxStompService,
useFactory: rxStompServiceFactory,
deps: [InjectableRxStompConfig],
},
SimpleMQ,
RoutePreloader,
NgbActiveModal,
}, SimpleMQ, RoutePreloader, NgbActiveModal,
],
bootstrap: [RootComponent],
})
......@@ -163,7 +163,7 @@ export class RootModule {
log: function (): void {},
info: function (): void {},
trace: function (): void {},
warn: function (): void {},
warn: window.console.warn,
error: window.console.error,
};
}
......
import { isPlatformBrowser, LocationStrategy, PathLocationStrategy } from '@angular/common';
import { ErrorHandler, Inject, Injectable, Injector, PLATFORM_ID } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class GlobalErrorHandler implements ErrorHandler {
private _errorMap = [];
constructor(@Inject(PLATFORM_ID) private platformId: Object, private injector: Injector) {
if (isPlatformBrowser(this.platformId)) {
// window.addEventListener('error', this.handleError, { passive: true });
// window.onerror = this.handleError;
}
}
public handleError(evt: any): void {
const location = this.injector.get(LocationStrategy);
this._errorMap.push({
msg: evt.message,
line: evt.lineno,
file: evt.filename,
type: evt.type,
elem: (
evt.srcElement || evt.target
),
url: location instanceof PathLocationStrategy ? location.path() : '',
});
}
public onZoneError(error): void {
this.handleError(error);
}
}
import { ErrorHandler, Injectable } from '@angular/core';
import { captureException, init as SentryInit, showReportDialog } from '@sentry/browser';
import { environment } from '../../environments/environment';
if (!environment.production) {
SentryInit({
dsn: 'https://f16c02fdefe64c018f5d580d1cf05b56@sentry.io/1819496',
});
}
@Injectable({ providedIn: 'root' })
export class SentryErrorHandler implements ErrorHandler {
constructor() {}
public handleError(error): void {
if (!environment.production) {
return;
}
const eventId = captureException(error.originalError || error);
showReportDialog({ eventId });
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment