Skip to content

Commit

Permalink
feat(ui): add sentry support (#3649)
Browse files Browse the repository at this point in the history
* feat(ui): add sentry

Signed-off-by: Benjamin Coenen <[email protected]>

* feat(ui): add sentry

Signed-off-by: Benjamin Coenen <[email protected]>

* feat(ui): add sentry

Signed-off-by: Benjamin Coenen <[email protected]>
  • Loading branch information
bnjjj authored and richardlt committed Nov 28, 2018
1 parent 13534e7 commit 60e3e58
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 37 deletions.
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"ngx-infinite-scroll": "^6.0.1",
"ngx-markdown": "6.1.0",
"prismjs": "^1.15.0",
"raven-js": "^3.27.0",
"rxjs": "6.3.3",
"rxjs-compat": "6.3.3",
"sanitize-html": "^1.19.1",
Expand Down
36 changes: 18 additions & 18 deletions ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {registerLocaleData} from '@angular/common';
import { registerLocaleData } from '@angular/common';
import localeEN from '@angular/common/locales/en';
import localeFR from '@angular/common/locales/fr';
import {Component, NgZone, OnInit} from '@angular/core';
import { Component, NgZone, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import {ActivatedRoute, NavigationEnd, ResolveEnd, ResolveStart, Router} from '@angular/router';
import {TranslateService} from '@ngx-translate/core';
import {Observable} from 'rxjs';
import {filter, map, mergeMap} from 'rxjs/operators';
import {Subscription} from 'rxjs/Subscription';
import { ActivatedRoute, NavigationEnd, ResolveEnd, ResolveStart, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { filter, map, mergeMap } from 'rxjs/operators';
import { Subscription } from 'rxjs/Subscription';
import * as format from 'string-format-obj';
import {environment} from '../environments/environment';
import {AppService} from './app.service';
import {Event} from './model/event.model';
import {AuthentificationStore} from './service/auth/authentification.store';
import {LanguageStore} from './service/language/language.store';
import {NotificationService} from './service/notification/notification.service';
import {AutoUnsubscribe} from './shared/decorator/autoUnsubscribe';
import {ToastService} from './shared/toast/ToastService';
import {CDSSharedWorker} from './shared/worker/shared.worker';
import {CDSWebWorker} from './shared/worker/web.worker';
import {CDSWorker} from './shared/worker/worker';
import { environment } from '../environments/environment';
import { AppService } from './app.service';
import { Event } from './model/event.model';
import { AuthentificationStore } from './service/auth/authentification.store';
import { LanguageStore } from './service/language/language.store';
import { NotificationService } from './service/notification/notification.service';
import { AutoUnsubscribe } from './shared/decorator/autoUnsubscribe';
import { ToastService } from './shared/toast/ToastService';
import { CDSSharedWorker } from './shared/worker/shared.worker';
import { CDSWebWorker } from './shared/worker/web.worker';
import { CDSWorker } from './shared/worker/worker';

@Component({
selector: 'app-root',
Expand Down
64 changes: 48 additions & 16 deletions ui/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import {HttpClient, HttpClientModule} from '@angular/common/http';
import {LOCALE_ID, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {ToasterModule} from 'angular2-toaster/angular2-toaster';
import {AppComponent} from './app.component';
import {routing} from './app.routing';
import {AppService} from './app.service';
import {ServicesModule} from './service/services.module';
import {SharedModule} from './shared/shared.module';
import {NavbarModule} from './views/navbar/navbar.module';

@NgModule({
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { ErrorHandler, LOCALE_ID, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { ToasterModule } from 'angular2-toaster/angular2-toaster';
import * as Raven from 'raven-js';
import { environment } from '../environments/environment';
import { AppComponent } from './app.component';
import { routing } from './app.routing';
import { AppService } from './app.service';
import { ServicesModule } from './service/services.module';
import { SharedModule } from './shared/shared.module';
import { NavbarModule } from './views/navbar/navbar.module';

let ngModule: NgModule = {
declarations: [
AppComponent
],
Expand Down Expand Up @@ -41,7 +43,37 @@ import {NavbarModule} from './views/navbar/navbar.module';
{ provide: LOCALE_ID, useValue: navigator.language.match(/fr/) ? 'fr' : 'en' }
],
bootstrap: [AppComponent]
})
};

if (environment.sentryUrl) {
class RavenErrorHandler implements ErrorHandler {
handleError(err: any): void {
console.error(err);
let tags = {};
let userStr = localStorage.getItem('CDS-USER');
if (userStr) {
try {
tags['CDS_USER'] = JSON.parse(userStr).username;
} catch (e) {

}
}

Raven.captureException(err, {tags});
}
}

Raven
.config(environment.sentryUrl)
.install();

ngModule.providers.unshift({ provide: ErrorHandler, useClass: RavenErrorHandler });
}




@NgModule(ngModule)
export class AppModule {
}

Expand Down
3 changes: 2 additions & 1 deletion ui/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const environment = {
production: true,
apiURL: './cdsapi',
name: 'prod'
name: 'prod',
sentryUrl: ''
};
3 changes: 2 additions & 1 deletion ui/src/environments/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
export const environment = {
production: false,
apiURL: 'foo.bar',
name: 'test'
name: 'test',
sentryUrl: ''
};
3 changes: 2 additions & 1 deletion ui/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const environment = {
production: false,
apiURL: 'http://localhost:8081',
name: 'local'
name: 'local',
sentryUrl: ''
};

0 comments on commit 60e3e58

Please sign in to comment.