From 2183bf2d5905ea3e86919082d184071c20443763 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Mon, 4 Oct 2021 17:18:42 -0700 Subject: [PATCH] Misc Bugfixes (#637) * Use null coalescing for comicinfo * Removed Sentry. The integrations were not providing any userful information. * Updated to the latest versions of dependencies --- API.Tests/API.Tests.csproj | 4 +- API/API.csproj | 29 ++-- API/Program.cs | 59 -------- API/Services/MetadataService.cs | 2 +- Kavita.Common/Kavita.Common.csproj | 3 +- UI/Web/package-lock.json | 129 ------------------ UI/Web/package.json | 2 - UI/Web/src/app/_services/account.service.ts | 7 - .../src/app/_services/message-hub.service.ts | 2 +- UI/Web/src/app/app.module.ts | 55 +------- 10 files changed, 20 insertions(+), 272 deletions(-) diff --git a/API.Tests/API.Tests.csproj b/API.Tests/API.Tests.csproj index e01bab216..59ecff406 100644 --- a/API.Tests/API.Tests.csproj +++ b/API.Tests/API.Tests.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/API/API.csproj b/API/API.csproj index d4cfe4316..01bfaa2a9 100644 --- a/API/API.csproj +++ b/API/API.csproj @@ -38,38 +38,37 @@ - + - - + + - + - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + - - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/API/Program.cs b/API/Program.cs index 0587cec98..06c860366 100644 --- a/API/Program.cs +++ b/API/Program.cs @@ -1,13 +1,11 @@ using System; using System.IO; using System.Security.Cryptography; -using System.Threading; using System.Threading.Tasks; using API.Data; using API.Entities; using API.Services; using Kavita.Common; -using Kavita.Common.EnvironmentInfo; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Server.Kestrel.Core; @@ -15,7 +13,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Sentry; namespace API { @@ -95,62 +92,6 @@ namespace API opts.ListenAnyIP(HttpPort, options => { options.Protocols = HttpProtocols.Http1AndHttp2; }); }); - var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); - if (environment != Environments.Development) - { - webBuilder.UseSentry(options => - { - options.Dsn = "https://40f4e7b49c094172a6f99d61efb2740f@o641015.ingest.sentry.io/5757423"; - options.MaxBreadcrumbs = 200; - options.AttachStacktrace = true; - options.Debug = false; - options.SendDefaultPii = false; - options.DiagnosticLevel = SentryLevel.Debug; - options.ShutdownTimeout = TimeSpan.FromSeconds(5); - options.Release = BuildInfo.Version.ToString(); - options.AddExceptionFilterForType(); - options.AddExceptionFilterForType(); - options.AddExceptionFilterForType(); - options.AddExceptionFilterForType(); - - options.BeforeSend = sentryEvent => - { - if (sentryEvent.Exception != null - && sentryEvent.Exception.Message.StartsWith("[GetCoverImage]") - && sentryEvent.Exception.Message.StartsWith("[BookService]") - && sentryEvent.Exception.Message.StartsWith("[ExtractArchive]") - && sentryEvent.Exception.Message.StartsWith("[GetSummaryInfo]") - && sentryEvent.Exception.Message.StartsWith("[GetSummaryInfo]") - && sentryEvent.Exception.Message.StartsWith("[GetNumberOfPagesFromArchive]") - && sentryEvent.Exception.Message.Contains("EPUB parsing error") - && sentryEvent.Exception.Message.Contains("Unsupported EPUB version") - && sentryEvent.Exception.Message.Contains("Incorrect EPUB") - && sentryEvent.Exception.Message.Contains("Access is Denied")) - { - return null; // Don't send this event to Sentry - } - - sentryEvent.ServerName = null; // Never send Server Name to Sentry - return sentryEvent; - }; - - options.ConfigureScope(scope => - { - scope.User = new User() - { - Id = HashUtil.AnonymousToken() - }; - scope.Contexts.App.Name = BuildInfo.AppName; - scope.Contexts.App.Version = BuildInfo.Version.ToString(); - scope.Contexts.App.StartTime = DateTime.UtcNow; - scope.Contexts.App.Hash = HashUtil.AnonymousToken(); - scope.Contexts.App.Build = BuildInfo.Release; - scope.SetTag("culture", Thread.CurrentThread.CurrentCulture.Name); - scope.SetTag("branch", BuildInfo.Branch); - }); - }); - } - webBuilder.UseStartup(); }); } diff --git a/API/Services/MetadataService.cs b/API/Services/MetadataService.cs index 40e44f02a..820b9246c 100644 --- a/API/Services/MetadataService.cs +++ b/API/Services/MetadataService.cs @@ -185,7 +185,7 @@ namespace API.Services if (Parser.Parser.IsPdf(firstFile.FilePath)) return false; var comicInfo = GetComicInfo(series.Format, firstFile); - if (string.IsNullOrEmpty(comicInfo.Summary)) return false; + if (string.IsNullOrEmpty(comicInfo?.Summary)) return false; series.Summary = comicInfo.Summary; return true; diff --git a/Kavita.Common/Kavita.Common.csproj b/Kavita.Common/Kavita.Common.csproj index 9b195f3ee..a8960e4bb 100644 --- a/Kavita.Common/Kavita.Common.csproj +++ b/Kavita.Common/Kavita.Common.csproj @@ -11,8 +11,7 @@ - - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UI/Web/package-lock.json b/UI/Web/package-lock.json index 2ae36e55d..e47a8be17 100644 --- a/UI/Web/package-lock.json +++ b/UI/Web/package-lock.json @@ -2679,135 +2679,6 @@ } } }, - "@sentry/angular": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@sentry/angular/-/angular-6.10.0.tgz", - "integrity": "sha512-SSnsz4sVu9LJh7RM+z9FopWytl2yYNZQ2nK/zv/6iQKIBOqvnCqUIPjVjq1rFYXOe0jOJKsn0QlQLKp4MajYMg==", - "requires": { - "@sentry/browser": "6.10.0", - "@sentry/types": "6.10.0", - "@sentry/utils": "6.10.0", - "rxjs": "^6.6.0", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/browser": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.10.0.tgz", - "integrity": "sha512-H0Blgp8f8bomebkkGWIgxHVjabtQAlsKJDiFXBg7gIc75YcarRxwH0R3hMog1/h8mmv4CGGUsy5ljYW6jsNnvA==", - "requires": { - "@sentry/core": "6.10.0", - "@sentry/types": "6.10.0", - "@sentry/utils": "6.10.0", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/core": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.10.0.tgz", - "integrity": "sha512-5KlxHJlbD7AMo+b9pMGkjxUOfMILtsqCtGgI7DMvZNfEkdohO8QgUY+hPqr540kmwArFS91ipQYWhqzGaOhM3Q==", - "requires": { - "@sentry/hub": "6.10.0", - "@sentry/minimal": "6.10.0", - "@sentry/types": "6.10.0", - "@sentry/utils": "6.10.0", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/hub": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.10.0.tgz", - "integrity": "sha512-MV8wjhWiFAXZAhmj7Ef5QdBr2IF93u8xXiIo2J+dRZ7eVa4/ZszoUiDbhUcl/TPxczaw4oW2a6tINBNFLzXiig==", - "requires": { - "@sentry/types": "6.10.0", - "@sentry/utils": "6.10.0", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/integrations": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-6.10.0.tgz", - "integrity": "sha512-NMtB0jjFYFZRxyjYu2dWLThk9YPIwqhi4hYywmWkbv4/ILzi5Rwnh+aqNW6yrj8qG4b9itNMh3YvEzmf0aqauw==", - "requires": { - "@sentry/types": "6.10.0", - "@sentry/utils": "6.10.0", - "localforage": "^1.8.1", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/minimal": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.10.0.tgz", - "integrity": "sha512-yarm046UgUFIBoxqnBan2+BEgaO9KZCrLzsIsmALiQvpfW92K1lHurSawl5W6SR7wCYBnNn7CPvPE/BHFdy4YA==", - "requires": { - "@sentry/hub": "6.10.0", - "@sentry/types": "6.10.0", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/types": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.10.0.tgz", - "integrity": "sha512-M7s0JFgG7/6/yNVYoPUbxzaXDhnzyIQYRRJJKRaTD77YO4MHvi4Ke8alBWqD5fer0cPIfcSkBqa9BLdqRqcMWw==" - }, - "@sentry/utils": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.10.0.tgz", - "integrity": "sha512-F9OczOcZMFtazYVZ6LfRIe65/eOfQbiAedIKS0li4npuMz0jKYRbxrjd/U7oLiNQkPAp4/BujU4m1ZIwq6a+tg==", - "requires": { - "@sentry/types": "6.10.0", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, "@sinonjs/commons": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.2.tgz", diff --git a/UI/Web/package.json b/UI/Web/package.json index 515c35df8..c54eee713 100644 --- a/UI/Web/package.json +++ b/UI/Web/package.json @@ -31,8 +31,6 @@ "@ng-bootstrap/ng-bootstrap": "^9.1.0", "@ngx-lite/nav-drawer": "^0.4.6", "@ngx-lite/util": "0.0.0", - "@sentry/angular": "^6.10.0", - "@sentry/integrations": "^6.10.0", "@types/file-saver": "^2.0.1", "angular-ng-autocomplete": "^2.0.5", "bootstrap": "^4.5.0", diff --git a/UI/Web/src/app/_services/account.service.ts b/UI/Web/src/app/_services/account.service.ts index 1581dafe7..d3006815a 100644 --- a/UI/Web/src/app/_services/account.service.ts +++ b/UI/Web/src/app/_services/account.service.ts @@ -5,7 +5,6 @@ import { map, takeUntil } from 'rxjs/operators'; import { environment } from 'src/environments/environment'; import { Preferences } from '../_models/preferences/preferences'; import { User } from '../_models/user'; -import * as Sentry from "@sentry/angular"; import { Router } from '@angular/router'; import { MessageHubService } from './message-hub.service'; @@ -63,12 +62,6 @@ export class AccountService implements OnDestroy { user.roles = []; const roles = this.getDecodedToken(user.token).role; Array.isArray(roles) ? user.roles = roles : user.roles.push(roles); - Sentry.setContext('admin', {'admin': this.hasAdminRole(user)}); - Sentry.configureScope(scope => { - scope.setUser({ - username: user.username - }); - }); localStorage.setItem(this.userKey, JSON.stringify(user)); localStorage.setItem(this.lastLoginKey, user.username); diff --git a/UI/Web/src/app/_services/message-hub.service.ts b/UI/Web/src/app/_services/message-hub.service.ts index a2e682e62..dc7490d74 100644 --- a/UI/Web/src/app/_services/message-hub.service.ts +++ b/UI/Web/src/app/_services/message-hub.service.ts @@ -1,7 +1,6 @@ import { EventEmitter, Injectable } from '@angular/core'; import { HubConnection, HubConnectionBuilder } from '@microsoft/signalr'; import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; -import { User } from '@sentry/angular'; import { ToastrService } from 'ngx-toastr'; import { BehaviorSubject, ReplaySubject } from 'rxjs'; import { environment } from 'src/environments/environment'; @@ -10,6 +9,7 @@ import { RefreshMetadataEvent } from '../_models/events/refresh-metadata-event'; import { ScanLibraryProgressEvent } from '../_models/events/scan-library-progress-event'; import { ScanSeriesEvent } from '../_models/events/scan-series-event'; import { SeriesAddedEvent } from '../_models/events/series-added-event'; +import { User } from '../_models/user'; export enum EVENTS { UpdateAvailable = 'UpdateAvailable', diff --git a/UI/Web/src/app/app.module.ts b/UI/Web/src/app/app.module.ts index f68ef4341..21a4c6ae4 100644 --- a/UI/Web/src/app/app.module.ts +++ b/UI/Web/src/app/app.module.ts @@ -21,13 +21,6 @@ import { AutocompleteLibModule } from 'angular-ng-autocomplete'; import { ReviewSeriesModalComponent } from './_modals/review-series-modal/review-series-modal.component'; import { CarouselModule } from './carousel/carousel.module'; - -import * as Sentry from '@sentry/angular'; -import { environment } from 'src/environments/environment'; -import { version } from 'package.json'; -import { Router } from '@angular/router'; -import { RewriteFrames as RewriteFramesIntegration } from '@sentry/integrations'; -import { Dedupe as DedupeIntegration } from '@sentry/integrations'; import { PersonBadgeComponent } from './person-badge/person-badge.component'; import { TypeaheadModule } from './typeahead/typeahead.module'; import { RecentlyAddedComponent } from './recently-added/recently-added.component'; @@ -38,51 +31,6 @@ import { SAVER, getSaver } from './shared/_providers/saver.provider'; import { ReadingListModule } from './reading-list/reading-list.module'; import { DashboardComponent } from './dashboard/dashboard.component'; -let sentryProviders: any[] = []; - -if (environment.production) { - Sentry.init({ - dsn: 'https://db1a1f6445994b13a6f479512aecdd48@o641015.ingest.sentry.io/5757426', - environment: environment.production ? 'prod' : 'dev', - release: version, - integrations: [ - new Sentry.Integrations.GlobalHandlers({ - onunhandledrejection: true, - onerror: true - }), - new DedupeIntegration(), - new RewriteFramesIntegration(), - ], - ignoreErrors: [new RegExp(/\/api\/admin/)], - tracesSampleRate: 0, - }); - - Sentry.configureScope(scope => { - scope.setUser({ - username: 'Not authorized' - }); - scope.setTag('production', environment.production); - scope.setTag('version', version); - }); - - sentryProviders = [{ - provide: ErrorHandler, - useValue: Sentry.createErrorHandler({ - showDialog: false, - }), - }, - { - provide: Sentry.TraceService, - deps: [Router], - }, - { - provide: APP_INITIALIZER, - useFactory: () => () => {}, - deps: [Sentry.TraceService], - multi: true, - }]; -} - @NgModule({ declarations: [ AppComponent, @@ -133,8 +81,7 @@ if (environment.production) { {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true}, {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, Title, - {provide: SAVER, useFactory: getSaver}, - ...sentryProviders, + {provide: SAVER, useFactory: getSaver} ], entryComponents: [], bootstrap: [AppComponent]