Skip to content

Commit 9c7d887

Browse files
committed
fix(logging): use sentry-angular with special providers and tracing
1 parent 94b73e9 commit 9c7d887

File tree

6 files changed

+50
-33
lines changed

6 files changed

+50
-33
lines changed

package-lock.json

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@fortawesome/free-regular-svg-icons": "^6.6.0",
4343
"@fortawesome/free-solid-svg-icons": "^6.6.0",
4444
"@ngneat/until-destroy": "^10.0.0",
45-
"@sentry/browser": "^8.20.0",
45+
"@sentry/angular": "^8.20.0",
4646
"angulartics2": "^14.0.0",
4747
"assert": "^2.1.0",
4848
"crypto-es": "^2.1.0",

src/app/app.module.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@
1717

1818
import { BrowserModule } from "@angular/platform-browser";
1919
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
20-
import { ErrorHandler, Inject, LOCALE_ID, NgModule } from "@angular/core";
20+
import {
21+
APP_INITIALIZER,
22+
ErrorHandler,
23+
Inject,
24+
LOCALE_ID,
25+
NgModule,
26+
} from "@angular/core";
2127
import { HttpClientModule } from "@angular/common/http";
28+
import * as Sentry from "@sentry/angular";
2229

2330
import { AppComponent } from "./app.component";
2431
import { allRoutes } from "./app.routing";
@@ -31,7 +38,6 @@ import {
3138
SwRegistrationOptions,
3239
} from "@angular/service-worker";
3340
import { environment } from "../environments/environment";
34-
import { LoggingErrorHandler } from "./core/logging/logging-error-handler";
3541
import { AnalyticsService } from "./core/analytics/analytics.service";
3642
import { ConfigurableEnumModule } from "./core/basic-datatypes/configurable-enum/configurable-enum.module";
3743
import { MatPaginatorIntl } from "@angular/material/paginator";
@@ -75,7 +81,7 @@ import { HistoricalDataModule } from "./features/historical-data/historical-data
7581
import { MatchingEntitiesModule } from "./features/matching-entities/matching-entities.module";
7682
import { ProgressDashboardWidgetModule } from "./features/dashboard-widgets/progress-dashboard-widget/progress-dashboard-widget.module";
7783
import { ReportingModule } from "./features/reporting/reporting.module";
78-
import { RouterModule } from "@angular/router";
84+
import { Router, RouterModule } from "@angular/router";
7985
import { TodosModule } from "./features/todos/todos.module";
8086
import moment from "moment";
8187
import { getLocaleFirstDayOfWeek } from "@angular/common";
@@ -141,7 +147,22 @@ import { AdminModule } from "./core/admin/admin.module";
141147
MatDialogModule,
142148
],
143149
providers: [
144-
{ provide: ErrorHandler, useClass: LoggingErrorHandler },
150+
/* Sentry setup */
151+
{
152+
provide: ErrorHandler,
153+
useValue: Sentry.createErrorHandler(),
154+
},
155+
{
156+
provide: Sentry.TraceService,
157+
deps: [Router],
158+
},
159+
{
160+
provide: APP_INITIALIZER,
161+
useFactory: () => () => {},
162+
deps: [Sentry.TraceService],
163+
multi: true,
164+
},
165+
145166
{ provide: MatPaginatorIntl, useValue: TranslatableMatPaginator() },
146167
{ provide: ComponentRegistry, useValue: componentRegistry },
147168
{ provide: EntityRegistry, useValue: entityRegistry },

src/app/core/logging/logging-error-handler.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/app/core/logging/logging.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LogLevel } from "./log-level";
2-
import * as Sentry from "@sentry/browser";
2+
import * as Sentry from "@sentry/angular";
33
import { environment } from "../../../environments/environment";
44

55
/* eslint-disable no-console */

src/app/core/support/support/support.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, Inject, OnInit } from "@angular/core";
22
import { LOCATION_TOKEN, WINDOW_TOKEN } from "../../../utils/di-tokens";
33
import { SyncState } from "../../session/session-states/sync-state.enum";
44
import { SwUpdate } from "@angular/service-worker";
5-
import * as Sentry from "@sentry/browser";
5+
import * as Sentry from "@sentry/angular";
66
import { ConfirmationDialogService } from "../../common-components/confirmation-dialog/confirmation-dialog.service";
77
import { HttpClient } from "@angular/common/http";
88
import { environment } from "../../../../environments/environment";

0 commit comments

Comments
 (0)