mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-08 02:54:16 +00:00
Send version to Sentry
This commit is contained in:
parent
957b93ec41
commit
0435fcec89
@ -79,13 +79,16 @@ import { RavenErrorHandler } from "./raven-error-handler";
|
||||
import { LocalServerComponent } from './components/local-server/local-server.component';
|
||||
import { ProgressComponent } from './common/progress/progress.component';
|
||||
import { ProgressService } from "./common/progress/progress.service";
|
||||
import { version } from "./version";
|
||||
|
||||
|
||||
Raven
|
||||
.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726')
|
||||
.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||
release: version
|
||||
})
|
||||
.install();
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
|
@ -64,6 +64,8 @@ export class ProjectsComponent implements OnInit {
|
||||
.subscribe((projects: Project[]) => {
|
||||
this.projectDatabase.addProjects(projects);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
delete(project: Project) {
|
||||
|
@ -1,8 +1,6 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { PersistenceService } from "angular-persistence";
|
||||
|
||||
import * as Raven from 'raven-js';
|
||||
|
||||
import { SettingsService } from "./services/settings.service";
|
||||
import { RavenErrorHandler } from "./raven-error-handler";
|
||||
import { environment } from "../environments/environment";
|
||||
@ -32,17 +30,12 @@ describe('RavenErrorHandler', () => {
|
||||
|
||||
it('should handle error', () => {
|
||||
settingsService.set('crash_reports', true);
|
||||
const error = new Error("My error");
|
||||
const captureException = spyOn(Raven, 'captureException');
|
||||
environment.production = true;
|
||||
handler.handleError(error);
|
||||
expect(captureException).toHaveBeenCalledWith(error);
|
||||
expect(handler.shouldSend()).toBeTruthy()
|
||||
});
|
||||
|
||||
it('should not handle when not in production', () => {
|
||||
const captureException = spyOn(Raven, 'captureException');
|
||||
environment.production = false;
|
||||
handler.handleError(new Error("My error"));
|
||||
expect(captureException).not.toHaveBeenCalled();
|
||||
it('should not handle when crash reports are disabled', () => {
|
||||
settingsService.set('crash_reports', false);
|
||||
expect(handler.shouldSend()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
@ -10,11 +10,13 @@ export class RavenErrorHandler implements ErrorHandler {
|
||||
constructor(@Inject(Injector) private injector: Injector) {}
|
||||
|
||||
handleError(err: any): void {
|
||||
const settingsService: SettingsService = this.injector.get(SettingsService);
|
||||
console.error(err.originalError || err);
|
||||
Raven.setShouldSendCallback(this.shouldSend);
|
||||
|
||||
if (environment.production && settingsService.get('crash_reports')) {
|
||||
Raven.captureException(err.originalError || err);
|
||||
}
|
||||
console.error(err.originalError || err);
|
||||
}
|
||||
|
||||
shouldSend() {
|
||||
const settingsService: SettingsService = this.injector.get(SettingsService);
|
||||
return environment.production && settingsService.get('crash_reports');
|
||||
}
|
||||
}
|
||||
|
1
src/app/version.ts
Normal file
1
src/app/version.ts
Normal file
@ -0,0 +1 @@
|
||||
export const version = require('../../package.json').version;
|
Loading…
x
Reference in New Issue
Block a user