From 0990d37496f4b802497c9c528745cc83f3cbfc23 Mon Sep 17 00:00:00 2001 From: GODrums Date: Wed, 4 Dec 2024 16:37:19 +0100 Subject: [PATCH 01/15] Basic Sentry config --- webapp/Dockerfile | 5 + webapp/package-lock.json | 96 ++++++++++++++++++++ webapp/package.json | 1 + webapp/src/app/app.component.ts | 8 +- webapp/src/app/app.config.ts | 15 ++- webapp/src/app/core/sentry/sentry.service.ts | 31 +++++++ webapp/src/environments/environment.prod.ts | 5 + webapp/src/environments/environment.ts | 5 + 8 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 webapp/src/app/core/sentry/sentry.service.ts diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 2b45d02b..7cab5188 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -24,6 +24,11 @@ RUN set -a && \ export const environment = { clientUrl: '${APPLICATION_CLIENT_URL}', serverUrl: '${APPLICATION_SERVER_URL}', + version: '${APPLICATION_VERSION}', + sentry: { + dsn: '${SENTRY_DSN}', + environment: 'prod', + }, keycloak: { url: '${KEYCLOAK_URL}', realm: '${KEYCLOAK_REALM}', diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 19f24322..8a8a7591 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -21,6 +21,7 @@ "@ng-icons/lucide": "^26.3.0", "@ng-icons/octicons": "29.5.0", "@primer/primitives": "9.1.1", + "@sentry/angular": "^8.42.0", "@spartan-ng/ui-accordion-brain": "0.0.1-alpha.356", "@spartan-ng/ui-alertdialog-brain": "0.0.1-alpha.356", "@spartan-ng/ui-avatar-brain": "0.0.1-alpha.356", @@ -6401,6 +6402,101 @@ } } }, + "node_modules/@sentry-internal/browser-utils": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/browser-utils/-/browser-utils-8.42.0.tgz", + "integrity": "sha512-xzgRI0wglKYsPrna574w1t38aftuvo44gjOKFvPNGPnYfiW9y4m+64kUz3JFbtanvOrKPcaITpdYiB4DeJXEbA==", + "license": "MIT", + "dependencies": { + "@sentry/core": "8.42.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry-internal/feedback": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-8.42.0.tgz", + "integrity": "sha512-dkIw5Wdukwzngg5gNJ0QcK48LyJaMAnBspqTqZ3ItR01STi6Z+6+/Bt5XgmrvDgRD+FNBinflc5zMmfdFXXhvw==", + "license": "MIT", + "dependencies": { + "@sentry/core": "8.42.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry-internal/replay": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay/-/replay-8.42.0.tgz", + "integrity": "sha512-oNcJEBlDfXnRFYC5Mxj5fairyZHNqlnU4g8kPuztB9G5zlsyLgWfPxzcn1ixVQunth2/WZRklDi4o1ZfyHww7w==", + "license": "MIT", + "dependencies": { + "@sentry-internal/browser-utils": "8.42.0", + "@sentry/core": "8.42.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry-internal/replay-canvas": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-8.42.0.tgz", + "integrity": "sha512-XrPErqVhPsPh/oFLVKvz7Wb+Fi2J1zCPLeZCxWqFuPWI2agRyLVu0KvqJyzSpSrRAEJC/XFzuSVILlYlXXSfgA==", + "license": "MIT", + "dependencies": { + "@sentry-internal/replay": "8.42.0", + "@sentry/core": "8.42.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry/angular": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@sentry/angular/-/angular-8.42.0.tgz", + "integrity": "sha512-gQ3gHNw7FadlLEtE57l9AZ2bkW1bVAk8FnbOkpc3NXkBJTKtxWODbhqCGDxGOWplJGzVOJ4EmXU2GHm7APOdwA==", + "license": "MIT", + "dependencies": { + "@sentry/browser": "8.42.0", + "@sentry/core": "8.42.0", + "tslib": "^2.4.1" + }, + "engines": { + "node": ">=14.18" + }, + "peerDependencies": { + "@angular/common": ">= 14.x <= 19.x", + "@angular/core": ">= 14.x <= 19.x", + "@angular/router": ">= 14.x <= 19.x", + "rxjs": "^6.5.5 || ^7.x" + } + }, + "node_modules/@sentry/browser": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-8.42.0.tgz", + "integrity": "sha512-lStrEk609KJHwXfDrOgoYVVoFFExixHywxSExk7ZDtwj2YPv6r6Y1gogvgr7dAZj7jWzadHkxZ33l9EOSJBfug==", + "license": "MIT", + "dependencies": { + "@sentry-internal/browser-utils": "8.42.0", + "@sentry-internal/feedback": "8.42.0", + "@sentry-internal/replay": "8.42.0", + "@sentry-internal/replay-canvas": "8.42.0", + "@sentry/core": "8.42.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry/core": { + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.42.0.tgz", + "integrity": "sha512-ac6O3pgoIbU6rpwz6LlwW0wp3/GAHuSI0C5IsTgIY6baN8rOBnlAtG6KrHDDkGmUQ2srxkDJu9n1O6Td3cBCqw==", + "license": "MIT", + "engines": { + "node": ">=14.18" + } + }, "node_modules/@sigstore/bundle": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/@sigstore/bundle/-/bundle-2.3.2.tgz", diff --git a/webapp/package.json b/webapp/package.json index 1aa1854f..463c2d1a 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -33,6 +33,7 @@ "@ng-icons/lucide": "^26.3.0", "@ng-icons/octicons": "29.5.0", "@primer/primitives": "9.1.1", + "@sentry/angular": "^8.42.0", "@spartan-ng/ui-accordion-brain": "0.0.1-alpha.356", "@spartan-ng/ui-alertdialog-brain": "0.0.1-alpha.356", "@spartan-ng/ui-avatar-brain": "0.0.1-alpha.356", diff --git a/webapp/src/app/app.component.ts b/webapp/src/app/app.component.ts index 28fb1a29..6cc6b260 100644 --- a/webapp/src/app/app.component.ts +++ b/webapp/src/app/app.component.ts @@ -1,17 +1,19 @@ -import { Component, isDevMode } from '@angular/core'; +import { Component, inject, isDevMode } from '@angular/core'; import { AngularQueryDevtools } from '@tanstack/angular-query-devtools-experimental'; -import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router'; +import { RouterOutlet } from '@angular/router'; import { HeaderComponent } from '@app/core/header/header.component'; import { FooterComponent } from './core/footer/footer.component'; +import { SentryService } from './core/sentry/sentry.service'; @Component({ selector: 'app-root', standalone: true, - imports: [RouterOutlet, RouterLink, RouterLinkActive, AngularQueryDevtools, HeaderComponent, FooterComponent], + imports: [RouterOutlet, AngularQueryDevtools, HeaderComponent, FooterComponent], templateUrl: './app.component.html' }) export class AppComponent { title = 'Hephaestus'; + sentry = inject(SentryService); isDevMode() { return isDevMode(); diff --git a/webapp/src/app/app.config.ts b/webapp/src/app/app.config.ts index 4e64ab39..8fe6368f 100644 --- a/webapp/src/app/app.config.ts +++ b/webapp/src/app/app.config.ts @@ -1,5 +1,5 @@ -import { APP_INITIALIZER, ApplicationConfig, provideExperimentalZonelessChangeDetection } from '@angular/core'; -import { provideRouter } from '@angular/router'; +import { APP_INITIALIZER, ApplicationConfig, ErrorHandler, provideExperimentalZonelessChangeDetection } from '@angular/core'; +import { provideRouter, Router } from '@angular/router'; import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; import { provideHttpClient, withInterceptors } from '@angular/common/http'; import { provideAngularQuery, QueryClient } from '@tanstack/angular-query-experimental'; @@ -8,6 +8,7 @@ import { BASE_PATH } from 'app/core/modules/openapi'; import { routes } from 'app/app.routes'; import { AnalyticsService } from './analytics.service'; import { securityInterceptor } from './core/security/security-interceptor'; +import { createErrorHandler, TraceService } from '@sentry/angular'; function initializeAnalytics(analyticsService: AnalyticsService): () => void { return () => { @@ -23,6 +24,14 @@ export const appConfig: ApplicationConfig = { provideHttpClient(withInterceptors([securityInterceptor])), provideAnimationsAsync(), { provide: BASE_PATH, useValue: environment.serverUrl }, - { provide: APP_INITIALIZER, useFactory: initializeAnalytics, multi: true, deps: [AnalyticsService] } + { provide: APP_INITIALIZER, useFactory: initializeAnalytics, multi: true, deps: [AnalyticsService] }, + { provide: ErrorHandler, useValue: createErrorHandler() }, + { provide: TraceService, deps: [Router] }, + { + provide: APP_INITIALIZER, + useFactory: () => () => {}, + deps: [TraceService], + multi: true, + }, ] }; diff --git a/webapp/src/app/core/sentry/sentry.service.ts b/webapp/src/app/core/sentry/sentry.service.ts new file mode 100644 index 00000000..20f6eb33 --- /dev/null +++ b/webapp/src/app/core/sentry/sentry.service.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; +import * as Sentry from "@sentry/angular"; + +@Injectable({ providedIn: 'root' }) +export class SentryService { + private environment = environment; + + constructor() { + this.init(); + } + + /** + * Initialize Sentry with environment. + */ + async init() { + console.log('Initializing Sentry'); + const env = this.environment; + if (!env || !env.version || !env.sentry?.dsn) { + return; + } + + Sentry.init({ + dsn: env.sentry.dsn, + release: env.version, + environment: env.sentry.environment, + integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()], + tracesSampleRate: env.sentry.environment !== 'prod' ? 1.0 : 0.2 + }); + } +} diff --git a/webapp/src/environments/environment.prod.ts b/webapp/src/environments/environment.prod.ts index c7e2ad97..8cbf62e9 100644 --- a/webapp/src/environments/environment.prod.ts +++ b/webapp/src/environments/environment.prod.ts @@ -1,6 +1,11 @@ export const environment = { clientUrl: 'http://localhost:4200', serverUrl: 'http://localhost:8080', + version: '0.0.1', + sentry: { + dsn: '', + environment: 'prod' + }, keycloak: { url: 'http://localhost:8081', realm: 'hephaestus', diff --git a/webapp/src/environments/environment.ts b/webapp/src/environments/environment.ts index c7e2ad97..cb1af5b8 100644 --- a/webapp/src/environments/environment.ts +++ b/webapp/src/environments/environment.ts @@ -1,6 +1,11 @@ export const environment = { clientUrl: 'http://localhost:4200', serverUrl: 'http://localhost:8080', + version: '0.0.1', + sentry: { + dsn: '', + environment: 'local' + }, keycloak: { url: 'http://localhost:8081', realm: 'hephaestus', From 5b205fe8ee28b61f5ce0a6052e30ac2f98204be8 Mon Sep 17 00:00:00 2001 From: GODrums Date: Wed, 4 Dec 2024 17:32:35 +0100 Subject: [PATCH 02/15] Set User on Sentry --- webapp/src/app/app.component.ts | 8 +++- webapp/src/app/app.config.ts | 5 +- .../core/security/security-store.service.ts | 4 ++ .../app/core/sentry/sentry.error-handler.ts | 47 +++++++++++++++++++ webapp/src/app/core/sentry/sentry.service.ts | 31 ------------ 5 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 webapp/src/app/core/sentry/sentry.error-handler.ts delete mode 100644 webapp/src/app/core/sentry/sentry.service.ts diff --git a/webapp/src/app/app.component.ts b/webapp/src/app/app.component.ts index 6cc6b260..48d18c45 100644 --- a/webapp/src/app/app.component.ts +++ b/webapp/src/app/app.component.ts @@ -3,7 +3,7 @@ import { AngularQueryDevtools } from '@tanstack/angular-query-devtools-experimen import { RouterOutlet } from '@angular/router'; import { HeaderComponent } from '@app/core/header/header.component'; import { FooterComponent } from './core/footer/footer.component'; -import { SentryService } from './core/sentry/sentry.service'; +import { SentryErrorHandler } from './core/sentry/sentry.error-handler'; @Component({ selector: 'app-root', @@ -13,9 +13,13 @@ import { SentryService } from './core/sentry/sentry.service'; }) export class AppComponent { title = 'Hephaestus'; - sentry = inject(SentryService); + sentry = inject(SentryErrorHandler); isDevMode() { return isDevMode(); } + + constructor() { + this.sentry.init(); + } } diff --git a/webapp/src/app/app.config.ts b/webapp/src/app/app.config.ts index 8fe6368f..57405d10 100644 --- a/webapp/src/app/app.config.ts +++ b/webapp/src/app/app.config.ts @@ -8,7 +8,8 @@ import { BASE_PATH } from 'app/core/modules/openapi'; import { routes } from 'app/app.routes'; import { AnalyticsService } from './analytics.service'; import { securityInterceptor } from './core/security/security-interceptor'; -import { createErrorHandler, TraceService } from '@sentry/angular'; +import { TraceService } from '@sentry/angular'; +import { SentryErrorHandler } from './core/sentry/sentry.error-handler'; function initializeAnalytics(analyticsService: AnalyticsService): () => void { return () => { @@ -25,7 +26,7 @@ export const appConfig: ApplicationConfig = { provideAnimationsAsync(), { provide: BASE_PATH, useValue: environment.serverUrl }, { provide: APP_INITIALIZER, useFactory: initializeAnalytics, multi: true, deps: [AnalyticsService] }, - { provide: ErrorHandler, useValue: createErrorHandler() }, + { provide: ErrorHandler, useClass: SentryErrorHandler }, { provide: TraceService, deps: [Router] }, { provide: APP_INITIALIZER, diff --git a/webapp/src/app/core/security/security-store.service.ts b/webapp/src/app/core/security/security-store.service.ts index 20add32c..94413202 100644 --- a/webapp/src/app/core/security/security-store.service.ts +++ b/webapp/src/app/core/security/security-store.service.ts @@ -2,6 +2,7 @@ import { computed, inject, Injectable, PLATFORM_ID, signal } from '@angular/core import { isPlatformServer } from '@angular/common'; import { KeycloakService } from './keycloak.service'; import { ANONYMOUS_USER, User } from './models'; +import { setUser } from '@sentry/angular'; @Injectable({ providedIn: 'root' }) export class SecurityStore { @@ -23,6 +24,7 @@ export class SecurityStore { if (isServer) { this.user.set(ANONYMOUS_USER); this.loaded.set(true); + setUser(ANONYMOUS_USER); return; } @@ -40,9 +42,11 @@ export class SecurityStore { }; this.user.set(user); this.loaded.set(true); + setUser(user); } else { this.user.set(ANONYMOUS_USER); this.loaded.set(true); + setUser(ANONYMOUS_USER); } } diff --git a/webapp/src/app/core/sentry/sentry.error-handler.ts b/webapp/src/app/core/sentry/sentry.error-handler.ts new file mode 100644 index 00000000..34ca9625 --- /dev/null +++ b/webapp/src/app/core/sentry/sentry.error-handler.ts @@ -0,0 +1,47 @@ +import { ErrorHandler, Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; +import * as Sentry from "@sentry/angular"; + +@Injectable({ providedIn: 'root' }) +export class SentryErrorHandler extends ErrorHandler { + private environment = environment; + + constructor() { + super(); + } + + /** + * Initialize Sentry with environment. + */ + async init() { + console.log('Initializing Sentry'); + const env = this.environment; + if (!env || !env.version || !env.sentry?.dsn) { + return; + } + + Sentry.init({ + dsn: env.sentry.dsn, + release: env.version, + environment: env.sentry.environment, + integrations: [Sentry.browserTracingIntegration()], + tracesSampleRate: env.sentry.environment !== 'prod' ? 1.0 : 0.2 + }); + } + + /** + * Send an HttpError to Sentry. Only if it's not in the range 400-499. + * @param error + */ + override handleError(error: any): void { + if (error && error.name === 'HttpErrorResponse' && error.status < 500 && error.status >= 400) { + super.handleError(error); + return; + } + if (this.environment.sentry.environment !== 'prod') { + const exception = error.error || error.message || error.originalError || error; + Sentry.captureException(exception); + } + super.handleError(error); + } +} diff --git a/webapp/src/app/core/sentry/sentry.service.ts b/webapp/src/app/core/sentry/sentry.service.ts deleted file mode 100644 index 20f6eb33..00000000 --- a/webapp/src/app/core/sentry/sentry.service.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Injectable } from '@angular/core'; -import { environment } from 'environments/environment'; -import * as Sentry from "@sentry/angular"; - -@Injectable({ providedIn: 'root' }) -export class SentryService { - private environment = environment; - - constructor() { - this.init(); - } - - /** - * Initialize Sentry with environment. - */ - async init() { - console.log('Initializing Sentry'); - const env = this.environment; - if (!env || !env.version || !env.sentry?.dsn) { - return; - } - - Sentry.init({ - dsn: env.sentry.dsn, - release: env.version, - environment: env.sentry.environment, - integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()], - tracesSampleRate: env.sentry.environment !== 'prod' ? 1.0 : 0.2 - }); - } -} From db79c0566d60af1562bf8f568029220ac40eff5c Mon Sep 17 00:00:00 2001 From: GODrums Date: Wed, 4 Dec 2024 21:51:14 +0100 Subject: [PATCH 03/15] Remove logging --- webapp/src/app/core/sentry/sentry.error-handler.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp/src/app/core/sentry/sentry.error-handler.ts b/webapp/src/app/core/sentry/sentry.error-handler.ts index 34ca9625..90bb9a3c 100644 --- a/webapp/src/app/core/sentry/sentry.error-handler.ts +++ b/webapp/src/app/core/sentry/sentry.error-handler.ts @@ -14,7 +14,6 @@ export class SentryErrorHandler extends ErrorHandler { * Initialize Sentry with environment. */ async init() { - console.log('Initializing Sentry'); const env = this.environment; if (!env || !env.version || !env.sentry?.dsn) { return; From d940503844681e81e29e2ba0358dc3e10143fcd6 Mon Sep 17 00:00:00 2001 From: GODrums Date: Thu, 5 Dec 2024 00:09:20 +0100 Subject: [PATCH 04/15] Add test error button --- webapp/angular.json | 8 +++++++- webapp/src/app/core/sentry/sentry.error-handler.ts | 8 +++++--- .../src/app/home/leaderboard/filter/filter.component.html | 1 + .../src/app/home/leaderboard/filter/filter.component.ts | 4 ++++ webapp/src/environments/environment.prod.ts | 2 +- webapp/src/environments/environment.ts | 4 ++-- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/webapp/angular.json b/webapp/angular.json index fef40ff5..a2a9e259 100644 --- a/webapp/angular.json +++ b/webapp/angular.json @@ -78,7 +78,13 @@ "maximumError": "10kb" } ], - "outputHashing": "all" + "outputHashing": "all", + "sourceMap": { + "scripts": true, + "styles": false, + "hidden": false, + "vendor": false + } }, "development": { "optimization": false, diff --git a/webapp/src/app/core/sentry/sentry.error-handler.ts b/webapp/src/app/core/sentry/sentry.error-handler.ts index 90bb9a3c..4d0a1b11 100644 --- a/webapp/src/app/core/sentry/sentry.error-handler.ts +++ b/webapp/src/app/core/sentry/sentry.error-handler.ts @@ -26,6 +26,8 @@ export class SentryErrorHandler extends ErrorHandler { integrations: [Sentry.browserTracingIntegration()], tracesSampleRate: env.sentry.environment !== 'prod' ? 1.0 : 0.2 }); + + console.log('Sentry initialized'); } /** @@ -37,9 +39,9 @@ export class SentryErrorHandler extends ErrorHandler { super.handleError(error); return; } - if (this.environment.sentry.environment !== 'prod') { - const exception = error.error || error.message || error.originalError || error; - Sentry.captureException(exception); + if (this.environment.sentry.environment !== 'local') { + const exception = error.error || error.message || error.originalError || error; + Sentry.captureException(exception); } super.handleError(error); } diff --git a/webapp/src/app/home/leaderboard/filter/filter.component.html b/webapp/src/app/home/leaderboard/filter/filter.component.html index 8f956684..916a1a6d 100644 --- a/webapp/src/app/home/leaderboard/filter/filter.component.html +++ b/webapp/src/app/home/leaderboard/filter/filter.component.html @@ -9,4 +9,5 @@

Filter

} + diff --git a/webapp/src/app/home/leaderboard/filter/filter.component.ts b/webapp/src/app/home/leaderboard/filter/filter.component.ts index 19f3cf54..fd2dde3c 100644 --- a/webapp/src/app/home/leaderboard/filter/filter.component.ts +++ b/webapp/src/app/home/leaderboard/filter/filter.component.ts @@ -14,4 +14,8 @@ export class LeaderboardFilterComponent { protected ListFilter = ListFilter; teams = input(); + + throwTestError() { + throw new Error("Sentry Test Error2"); + } } diff --git a/webapp/src/environments/environment.prod.ts b/webapp/src/environments/environment.prod.ts index 8cbf62e9..a409952e 100644 --- a/webapp/src/environments/environment.prod.ts +++ b/webapp/src/environments/environment.prod.ts @@ -3,7 +3,7 @@ export const environment = { serverUrl: 'http://localhost:8080', version: '0.0.1', sentry: { - dsn: '', + dsn: 'https://289f1f62feeb4f70a8878dc0101825cd@sentry.ase.in.tum.de/3', environment: 'prod' }, keycloak: { diff --git a/webapp/src/environments/environment.ts b/webapp/src/environments/environment.ts index cb1af5b8..a409952e 100644 --- a/webapp/src/environments/environment.ts +++ b/webapp/src/environments/environment.ts @@ -3,8 +3,8 @@ export const environment = { serverUrl: 'http://localhost:8080', version: '0.0.1', sentry: { - dsn: '', - environment: 'local' + dsn: 'https://289f1f62feeb4f70a8878dc0101825cd@sentry.ase.in.tum.de/3', + environment: 'prod' }, keycloak: { url: 'http://localhost:8081', From bc873d38b8ac34a0795fdc487fab5d69be7e160f Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 00:41:15 +0100 Subject: [PATCH 05/15] chore: formatting --- webapp/src/app/app.config.ts | 10 +++++----- .../app/core/sentry/sentry.error-handler.ts | 18 +++++++++--------- .../leaderboard/filter/filter.component.ts | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/webapp/src/app/app.config.ts b/webapp/src/app/app.config.ts index 57405d10..3da5f04e 100644 --- a/webapp/src/app/app.config.ts +++ b/webapp/src/app/app.config.ts @@ -29,10 +29,10 @@ export const appConfig: ApplicationConfig = { { provide: ErrorHandler, useClass: SentryErrorHandler }, { provide: TraceService, deps: [Router] }, { - provide: APP_INITIALIZER, - useFactory: () => () => {}, - deps: [TraceService], - multi: true, - }, + provide: APP_INITIALIZER, + useFactory: () => () => {}, + deps: [TraceService], + multi: true + } ] }; diff --git a/webapp/src/app/core/sentry/sentry.error-handler.ts b/webapp/src/app/core/sentry/sentry.error-handler.ts index 4d0a1b11..06cb11fd 100644 --- a/webapp/src/app/core/sentry/sentry.error-handler.ts +++ b/webapp/src/app/core/sentry/sentry.error-handler.ts @@ -1,6 +1,6 @@ import { ErrorHandler, Injectable } from '@angular/core'; import { environment } from 'environments/environment'; -import * as Sentry from "@sentry/angular"; +import * as Sentry from '@sentry/angular'; @Injectable({ providedIn: 'root' }) export class SentryErrorHandler extends ErrorHandler { @@ -35,14 +35,14 @@ export class SentryErrorHandler extends ErrorHandler { * @param error */ override handleError(error: any): void { - if (error && error.name === 'HttpErrorResponse' && error.status < 500 && error.status >= 400) { - super.handleError(error); - return; - } - if (this.environment.sentry.environment !== 'local') { - const exception = error.error || error.message || error.originalError || error; - Sentry.captureException(exception); - } + if (error && error.name === 'HttpErrorResponse' && error.status < 500 && error.status >= 400) { super.handleError(error); + return; + } + if (this.environment.sentry.environment !== 'local') { + const exception = error.error || error.message || error.originalError || error; + Sentry.captureException(exception); + } + super.handleError(error); } } diff --git a/webapp/src/app/home/leaderboard/filter/filter.component.ts b/webapp/src/app/home/leaderboard/filter/filter.component.ts index fd2dde3c..9592c6bb 100644 --- a/webapp/src/app/home/leaderboard/filter/filter.component.ts +++ b/webapp/src/app/home/leaderboard/filter/filter.component.ts @@ -16,6 +16,6 @@ export class LeaderboardFilterComponent { teams = input(); throwTestError() { - throw new Error("Sentry Test Error2"); + throw new Error('Sentry Test Error2'); } } From 268a2ecb27afcab6c6d2ee3907d08ce63d668bf6 Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 01:18:08 +0100 Subject: [PATCH 06/15] Add Sentry-CLI for sourcemaps --- webapp/Dockerfile | 1 + webapp/package-lock.json | 232 +++++++++++++++++- webapp/package.json | 4 +- .../app/core/sentry/sentry.error-handler.ts | 2 + webapp/src/environments/environment.prod.ts | 2 +- 5 files changed, 231 insertions(+), 10 deletions(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 7cab5188..bc94507a 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -50,6 +50,7 @@ EOF RUN npm install RUN npm run build +RUN npx sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENRY_RELEASE} ./dist/webapp FROM nginx:latest diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 8a8a7591..caa1b35f 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -22,6 +22,7 @@ "@ng-icons/octicons": "29.5.0", "@primer/primitives": "9.1.1", "@sentry/angular": "^8.42.0", + "@sentry/cli": "^2.39.1", "@spartan-ng/ui-accordion-brain": "0.0.1-alpha.356", "@spartan-ng/ui-alertdialog-brain": "0.0.1-alpha.356", "@spartan-ng/ui-avatar-brain": "0.0.1-alpha.356", @@ -6488,6 +6489,175 @@ "node": ">=14.18" } }, + "node_modules/@sentry/cli": { + "version": "2.39.1", + "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-2.39.1.tgz", + "integrity": "sha512-JIb3e9vh0+OmQ0KxmexMXg9oZsR/G7HMwxt5BUIKAXZ9m17Xll4ETXTRnRUBT3sf7EpNGAmlQk1xEmVN9pYZYQ==", + "hasInstallScript": true, + "license": "BSD-3-Clause", + "dependencies": { + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.7", + "progress": "^2.0.3", + "proxy-from-env": "^1.1.0", + "which": "^2.0.2" + }, + "bin": { + "sentry-cli": "bin/sentry-cli" + }, + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@sentry/cli-darwin": "2.39.1", + "@sentry/cli-linux-arm": "2.39.1", + "@sentry/cli-linux-arm64": "2.39.1", + "@sentry/cli-linux-i686": "2.39.1", + "@sentry/cli-linux-x64": "2.39.1", + "@sentry/cli-win32-i686": "2.39.1", + "@sentry/cli-win32-x64": "2.39.1" + } + }, + "node_modules/@sentry/cli-darwin": { + "version": "2.39.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-darwin/-/cli-darwin-2.39.1.tgz", + "integrity": "sha512-kiNGNSAkg46LNGatfNH5tfsmI/kCAaPA62KQuFZloZiemTNzhy9/6NJP8HZ/GxGs8GDMxic6wNrV9CkVEgFLJQ==", + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-arm": { + "version": "2.39.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm/-/cli-linux-arm-2.39.1.tgz", + "integrity": "sha512-DkENbxyRxUrfLnJLXTA4s5UL/GoctU5Cm4ER1eB7XN7p9WsamFJd/yf2KpltkjEyiTuplv0yAbdjl1KX3vKmEQ==", + "cpu": [ + "arm" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-arm64": { + "version": "2.39.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.39.1.tgz", + "integrity": "sha512-5VbVJDatolDrWOgaffsEM7znjs0cR8bHt9Bq0mStM3tBolgAeSDHE89NgHggfZR+DJ2VWOy4vgCwkObrUD6NQw==", + "cpu": [ + "arm64" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-i686": { + "version": "2.39.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-i686/-/cli-linux-i686-2.39.1.tgz", + "integrity": "sha512-pXWVoKXCRrY7N8vc9H7mETiV9ZCz+zSnX65JQCzZxgYrayQPJTc+NPRnZTdYdk5RlAupXaFicBI2GwOCRqVRkg==", + "cpu": [ + "x86", + "ia32" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-x64": { + "version": "2.39.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-x64/-/cli-linux-x64-2.39.1.tgz", + "integrity": "sha512-IwayNZy+it7FWG4M9LayyUmG1a/8kT9+/IEm67sT5+7dkMIMcpmHDqL8rWcPojOXuTKaOBBjkVdNMBTXy0mXlA==", + "cpu": [ + "x64" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-win32-i686": { + "version": "2.39.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-win32-i686/-/cli-win32-i686-2.39.1.tgz", + "integrity": "sha512-NglnNoqHSmE+Dz/wHeIVRnV2bLMx7tIn3IQ8vXGO5HWA2f8zYJGktbkLq1Lg23PaQmeZLPGlja3gBQfZYSG10Q==", + "cpu": [ + "x86", + "ia32" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-win32-x64": { + "version": "2.39.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-win32-x64/-/cli-win32-x64-2.39.1.tgz", + "integrity": "sha512-xv0R2CMf/X1Fte3cMWie1NXuHmUyQPDBfCyIt6k6RPFPxAYUgcqgMPznYwVMwWEA1W43PaOkSn3d8ZylsDaETw==", + "cpu": [ + "x64" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli/node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/@sentry/cli/node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/@sentry/core": { "version": "8.42.0", "resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.42.0.tgz", @@ -11705,7 +11875,6 @@ "version": "4.3.7", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", - "dev": true, "dependencies": { "ms": "^2.1.3" }, @@ -12176,7 +12345,6 @@ "version": "0.1.13", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", - "dev": true, "optional": true, "dependencies": { "iconv-lite": "^0.6.2" @@ -12186,7 +12354,6 @@ "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, "optional": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" @@ -16984,8 +17151,7 @@ "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/msgpackr": { "version": "1.11.0", @@ -17182,6 +17348,26 @@ "dev": true, "optional": true }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/node-forge": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", @@ -19317,6 +19503,15 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, + "node_modules/progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", @@ -19352,8 +19547,7 @@ "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "dev": true + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, "node_modules/prr": { "version": "1.0.1", @@ -20101,7 +20295,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "devOptional": true }, "node_modules/sass": { "version": "1.77.6", @@ -21723,6 +21917,12 @@ "node": ">=0.6" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, "node_modules/tree-dump": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/tree-dump/-/tree-dump-1.0.2.tgz", @@ -22974,6 +23174,12 @@ "integrity": "sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw==", "dev": true }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, "node_modules/webpack": { "version": "5.94.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.94.0.tgz", @@ -23419,6 +23625,16 @@ "node": ">=0.10.0" } }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/webapp/package.json b/webapp/package.json index 463c2d1a..450aad00 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -13,7 +13,8 @@ "prettier:check": "prettier --check src/", "prettier:write": "prettier --write src/", "lint": "eslint", - "lint:fix": "eslint --fix" + "lint:fix": "eslint --fix", + "sentry:sourcemaps": "sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && sentry-cli sourcemaps upload --org aet --project hephaestus --release=0.0.1 ./dist/webapp" }, "private": true, "engines": { @@ -34,6 +35,7 @@ "@ng-icons/octicons": "29.5.0", "@primer/primitives": "9.1.1", "@sentry/angular": "^8.42.0", + "@sentry/cli": "^2.39.1", "@spartan-ng/ui-accordion-brain": "0.0.1-alpha.356", "@spartan-ng/ui-alertdialog-brain": "0.0.1-alpha.356", "@spartan-ng/ui-avatar-brain": "0.0.1-alpha.356", diff --git a/webapp/src/app/core/sentry/sentry.error-handler.ts b/webapp/src/app/core/sentry/sentry.error-handler.ts index 06cb11fd..f393d3e7 100644 --- a/webapp/src/app/core/sentry/sentry.error-handler.ts +++ b/webapp/src/app/core/sentry/sentry.error-handler.ts @@ -19,6 +19,8 @@ export class SentryErrorHandler extends ErrorHandler { return; } + console.log('Initializing Sentry: ', env.version); + Sentry.init({ dsn: env.sentry.dsn, release: env.version, diff --git a/webapp/src/environments/environment.prod.ts b/webapp/src/environments/environment.prod.ts index a409952e..30d868d1 100644 --- a/webapp/src/environments/environment.prod.ts +++ b/webapp/src/environments/environment.prod.ts @@ -1,7 +1,7 @@ export const environment = { clientUrl: 'http://localhost:4200', serverUrl: 'http://localhost:8080', - version: '0.0.1', + version: '0.0.2', sentry: { dsn: 'https://289f1f62feeb4f70a8878dc0101825cd@sentry.ase.in.tum.de/3', environment: 'prod' From 98ea666706eca9d77a7cb9033ad881f389a2394b Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 01:30:21 +0100 Subject: [PATCH 07/15] Update sentry-cli path --- webapp/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index bc94507a..8cd6055e 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -50,7 +50,7 @@ EOF RUN npm install RUN npm run build -RUN npx sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENRY_RELEASE} ./dist/webapp +RUN ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENRY_RELEASE} ./dist/webapp FROM nginx:latest From fa8e9580db31c3f432967a5c2df27a3e1742f44b Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 01:39:21 +0100 Subject: [PATCH 08/15] fix: dockerfile sentry-cli --- webapp/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 8cd6055e..c6613454 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -50,7 +50,7 @@ EOF RUN npm install RUN npm run build -RUN ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENRY_RELEASE} ./dist/webapp +RUN ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && ./node_modules/.bin/sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENRY_RELEASE} ./dist/webapp FROM nginx:latest From fbf0e833a81497cd34c140315b0f1426c393d093 Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 01:44:16 +0100 Subject: [PATCH 09/15] fix: snetry-cli command --- webapp/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index c6613454..5e18f518 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -50,7 +50,7 @@ EOF RUN npm install RUN npm run build -RUN ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && ./node_modules/.bin/sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENRY_RELEASE} ./dist/webapp +RUN ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && ./node_modules/.bin/sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENTRY_PROJECT} ./dist/webapp FROM nginx:latest From 35394341ac5c3b00926860fb46a5fc7d44acf380 Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 01:49:01 +0100 Subject: [PATCH 10/15] fix: switch to sentry release --- webapp/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 5e18f518..7e4269e5 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -50,7 +50,8 @@ EOF RUN npm install RUN npm run build -RUN ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && ./node_modules/.bin/sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENTRY_PROJECT} ./dist/webapp +# Fix buggy replacement of COOLIFY_URL in .env +RUN ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && ./node_modules/.bin/sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENTRY_RELEASE} ./dist/webapp FROM nginx:latest From a3d6bff4427e8bceb581a5f65698d21b34c279ca Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 01:52:08 +0100 Subject: [PATCH 11/15] fix: env value replacement --- webapp/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 7e4269e5..08ee7f88 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -50,8 +50,11 @@ EOF RUN npm install RUN npm run build -# Fix buggy replacement of COOLIFY_URL in .env -RUN ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && ./node_modules/.bin/sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENTRY_RELEASE} ./dist/webapp +RUN set -a && \ + . /app/.env && \ + set +a && \ + ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && \ + ./node_modules/.bin/sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENTRY_RELEASE} ./dist/webapp FROM nginx:latest From 6c27511cad6edd34d0e2f23fcce087b72dc0d3b6 Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 02:42:26 +0100 Subject: [PATCH 12/15] Remove sentry-cli --- webapp/Dockerfile | 5 - webapp/package-lock.json | 232 +----------------- webapp/package.json | 4 +- .../app/core/sentry/sentry.error-handler.ts | 4 - 4 files changed, 9 insertions(+), 236 deletions(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 08ee7f88..7cab5188 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -50,11 +50,6 @@ EOF RUN npm install RUN npm run build -RUN set -a && \ - . /app/.env && \ - set +a && \ - ./node_modules/.bin/sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && \ - ./node_modules/.bin/sentry-cli sourcemaps upload --org aet --project hephaestus --release=${SENTRY_RELEASE} ./dist/webapp FROM nginx:latest diff --git a/webapp/package-lock.json b/webapp/package-lock.json index caa1b35f..8a8a7591 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -22,7 +22,6 @@ "@ng-icons/octicons": "29.5.0", "@primer/primitives": "9.1.1", "@sentry/angular": "^8.42.0", - "@sentry/cli": "^2.39.1", "@spartan-ng/ui-accordion-brain": "0.0.1-alpha.356", "@spartan-ng/ui-alertdialog-brain": "0.0.1-alpha.356", "@spartan-ng/ui-avatar-brain": "0.0.1-alpha.356", @@ -6489,175 +6488,6 @@ "node": ">=14.18" } }, - "node_modules/@sentry/cli": { - "version": "2.39.1", - "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-2.39.1.tgz", - "integrity": "sha512-JIb3e9vh0+OmQ0KxmexMXg9oZsR/G7HMwxt5BUIKAXZ9m17Xll4ETXTRnRUBT3sf7EpNGAmlQk1xEmVN9pYZYQ==", - "hasInstallScript": true, - "license": "BSD-3-Clause", - "dependencies": { - "https-proxy-agent": "^5.0.0", - "node-fetch": "^2.6.7", - "progress": "^2.0.3", - "proxy-from-env": "^1.1.0", - "which": "^2.0.2" - }, - "bin": { - "sentry-cli": "bin/sentry-cli" - }, - "engines": { - "node": ">= 10" - }, - "optionalDependencies": { - "@sentry/cli-darwin": "2.39.1", - "@sentry/cli-linux-arm": "2.39.1", - "@sentry/cli-linux-arm64": "2.39.1", - "@sentry/cli-linux-i686": "2.39.1", - "@sentry/cli-linux-x64": "2.39.1", - "@sentry/cli-win32-i686": "2.39.1", - "@sentry/cli-win32-x64": "2.39.1" - } - }, - "node_modules/@sentry/cli-darwin": { - "version": "2.39.1", - "resolved": "https://registry.npmjs.org/@sentry/cli-darwin/-/cli-darwin-2.39.1.tgz", - "integrity": "sha512-kiNGNSAkg46LNGatfNH5tfsmI/kCAaPA62KQuFZloZiemTNzhy9/6NJP8HZ/GxGs8GDMxic6wNrV9CkVEgFLJQ==", - "license": "BSD-3-Clause", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@sentry/cli-linux-arm": { - "version": "2.39.1", - "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm/-/cli-linux-arm-2.39.1.tgz", - "integrity": "sha512-DkENbxyRxUrfLnJLXTA4s5UL/GoctU5Cm4ER1eB7XN7p9WsamFJd/yf2KpltkjEyiTuplv0yAbdjl1KX3vKmEQ==", - "cpu": [ - "arm" - ], - "license": "BSD-3-Clause", - "optional": true, - "os": [ - "linux", - "freebsd" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@sentry/cli-linux-arm64": { - "version": "2.39.1", - "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.39.1.tgz", - "integrity": "sha512-5VbVJDatolDrWOgaffsEM7znjs0cR8bHt9Bq0mStM3tBolgAeSDHE89NgHggfZR+DJ2VWOy4vgCwkObrUD6NQw==", - "cpu": [ - "arm64" - ], - "license": "BSD-3-Clause", - "optional": true, - "os": [ - "linux", - "freebsd" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@sentry/cli-linux-i686": { - "version": "2.39.1", - "resolved": "https://registry.npmjs.org/@sentry/cli-linux-i686/-/cli-linux-i686-2.39.1.tgz", - "integrity": "sha512-pXWVoKXCRrY7N8vc9H7mETiV9ZCz+zSnX65JQCzZxgYrayQPJTc+NPRnZTdYdk5RlAupXaFicBI2GwOCRqVRkg==", - "cpu": [ - "x86", - "ia32" - ], - "license": "BSD-3-Clause", - "optional": true, - "os": [ - "linux", - "freebsd" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@sentry/cli-linux-x64": { - "version": "2.39.1", - "resolved": "https://registry.npmjs.org/@sentry/cli-linux-x64/-/cli-linux-x64-2.39.1.tgz", - "integrity": "sha512-IwayNZy+it7FWG4M9LayyUmG1a/8kT9+/IEm67sT5+7dkMIMcpmHDqL8rWcPojOXuTKaOBBjkVdNMBTXy0mXlA==", - "cpu": [ - "x64" - ], - "license": "BSD-3-Clause", - "optional": true, - "os": [ - "linux", - "freebsd" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@sentry/cli-win32-i686": { - "version": "2.39.1", - "resolved": "https://registry.npmjs.org/@sentry/cli-win32-i686/-/cli-win32-i686-2.39.1.tgz", - "integrity": "sha512-NglnNoqHSmE+Dz/wHeIVRnV2bLMx7tIn3IQ8vXGO5HWA2f8zYJGktbkLq1Lg23PaQmeZLPGlja3gBQfZYSG10Q==", - "cpu": [ - "x86", - "ia32" - ], - "license": "BSD-3-Clause", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@sentry/cli-win32-x64": { - "version": "2.39.1", - "resolved": "https://registry.npmjs.org/@sentry/cli-win32-x64/-/cli-win32-x64-2.39.1.tgz", - "integrity": "sha512-xv0R2CMf/X1Fte3cMWie1NXuHmUyQPDBfCyIt6k6RPFPxAYUgcqgMPznYwVMwWEA1W43PaOkSn3d8ZylsDaETw==", - "cpu": [ - "x64" - ], - "license": "BSD-3-Clause", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@sentry/cli/node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "license": "MIT", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/@sentry/cli/node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "license": "MIT", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/@sentry/core": { "version": "8.42.0", "resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.42.0.tgz", @@ -11875,6 +11705,7 @@ "version": "4.3.7", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, "dependencies": { "ms": "^2.1.3" }, @@ -12345,6 +12176,7 @@ "version": "0.1.13", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "dev": true, "optional": true, "dependencies": { "iconv-lite": "^0.6.2" @@ -12354,6 +12186,7 @@ "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, "optional": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" @@ -17151,7 +16984,8 @@ "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true }, "node_modules/msgpackr": { "version": "1.11.0", @@ -17348,26 +17182,6 @@ "dev": true, "optional": true }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-forge": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", @@ -19503,15 +19317,6 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", @@ -19547,7 +19352,8 @@ "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true }, "node_modules/prr": { "version": "1.0.1", @@ -20295,7 +20101,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "devOptional": true + "dev": true }, "node_modules/sass": { "version": "1.77.6", @@ -21917,12 +21723,6 @@ "node": ">=0.6" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" - }, "node_modules/tree-dump": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/tree-dump/-/tree-dump-1.0.2.tgz", @@ -23174,12 +22974,6 @@ "integrity": "sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw==", "dev": true }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "license": "BSD-2-Clause" - }, "node_modules/webpack": { "version": "5.94.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.94.0.tgz", @@ -23625,16 +23419,6 @@ "node": ">=0.10.0" } }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "license": "MIT", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/webapp/package.json b/webapp/package.json index 450aad00..463c2d1a 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -13,8 +13,7 @@ "prettier:check": "prettier --check src/", "prettier:write": "prettier --write src/", "lint": "eslint", - "lint:fix": "eslint --fix", - "sentry:sourcemaps": "sentry-cli sourcemaps inject --org aet --project hephaestus ./dist/webapp && sentry-cli sourcemaps upload --org aet --project hephaestus --release=0.0.1 ./dist/webapp" + "lint:fix": "eslint --fix" }, "private": true, "engines": { @@ -35,7 +34,6 @@ "@ng-icons/octicons": "29.5.0", "@primer/primitives": "9.1.1", "@sentry/angular": "^8.42.0", - "@sentry/cli": "^2.39.1", "@spartan-ng/ui-accordion-brain": "0.0.1-alpha.356", "@spartan-ng/ui-alertdialog-brain": "0.0.1-alpha.356", "@spartan-ng/ui-avatar-brain": "0.0.1-alpha.356", diff --git a/webapp/src/app/core/sentry/sentry.error-handler.ts b/webapp/src/app/core/sentry/sentry.error-handler.ts index f393d3e7..fabfc776 100644 --- a/webapp/src/app/core/sentry/sentry.error-handler.ts +++ b/webapp/src/app/core/sentry/sentry.error-handler.ts @@ -19,8 +19,6 @@ export class SentryErrorHandler extends ErrorHandler { return; } - console.log('Initializing Sentry: ', env.version); - Sentry.init({ dsn: env.sentry.dsn, release: env.version, @@ -28,8 +26,6 @@ export class SentryErrorHandler extends ErrorHandler { integrations: [Sentry.browserTracingIntegration()], tracesSampleRate: env.sentry.environment !== 'prod' ? 1.0 : 0.2 }); - - console.log('Sentry initialized'); } /** From 11549e1c29389ed8c09f2945b1b223b111bc1c83 Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 03:07:00 +0100 Subject: [PATCH 13/15] chore: ignore any check --- webapp/src/app/core/sentry/sentry.error-handler.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/src/app/core/sentry/sentry.error-handler.ts b/webapp/src/app/core/sentry/sentry.error-handler.ts index fabfc776..2bde1073 100644 --- a/webapp/src/app/core/sentry/sentry.error-handler.ts +++ b/webapp/src/app/core/sentry/sentry.error-handler.ts @@ -32,6 +32,7 @@ export class SentryErrorHandler extends ErrorHandler { * Send an HttpError to Sentry. Only if it's not in the range 400-499. * @param error */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any override handleError(error: any): void { if (error && error.name === 'HttpErrorResponse' && error.status < 500 && error.status >= 400) { super.handleError(error); From 2a825a9467922d7cf718ff54fb2db49c4d83bdbc Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 03:15:12 +0100 Subject: [PATCH 14/15] Remove test error button --- webapp/src/app/home/leaderboard/filter/filter.component.html | 1 - webapp/src/app/home/leaderboard/filter/filter.component.ts | 4 ---- 2 files changed, 5 deletions(-) diff --git a/webapp/src/app/home/leaderboard/filter/filter.component.html b/webapp/src/app/home/leaderboard/filter/filter.component.html index 916a1a6d..8f956684 100644 --- a/webapp/src/app/home/leaderboard/filter/filter.component.html +++ b/webapp/src/app/home/leaderboard/filter/filter.component.html @@ -9,5 +9,4 @@

Filter

} - diff --git a/webapp/src/app/home/leaderboard/filter/filter.component.ts b/webapp/src/app/home/leaderboard/filter/filter.component.ts index 9592c6bb..19f3cf54 100644 --- a/webapp/src/app/home/leaderboard/filter/filter.component.ts +++ b/webapp/src/app/home/leaderboard/filter/filter.component.ts @@ -14,8 +14,4 @@ export class LeaderboardFilterComponent { protected ListFilter = ListFilter; teams = input(); - - throwTestError() { - throw new Error('Sentry Test Error2'); - } } From bf2b7c37cfba713472c3a9e819e33371e56eaa46 Mon Sep 17 00:00:00 2001 From: GODrums Date: Sat, 7 Dec 2024 03:15:40 +0100 Subject: [PATCH 15/15] Reset environment version --- webapp/src/environments/environment.prod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/environments/environment.prod.ts b/webapp/src/environments/environment.prod.ts index 30d868d1..a409952e 100644 --- a/webapp/src/environments/environment.prod.ts +++ b/webapp/src/environments/environment.prod.ts @@ -1,7 +1,7 @@ export const environment = { clientUrl: 'http://localhost:4200', serverUrl: 'http://localhost:8080', - version: '0.0.2', + version: '0.0.1', sentry: { dsn: 'https://289f1f62feeb4f70a8878dc0101825cd@sentry.ase.in.tum.de/3', environment: 'prod'