Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Sentry init and captureException on epics #335

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export const handleHttpJsonResponseError = (

if (error instanceof HttpError) {
res.status(error.httpCode);
if (error.httpCode === 409) {
return unhandledError(error, req, res);
}

return res.json({ errors: toValidJSONObjectOrString(error) });
}

Expand Down
1 change: 0 additions & 1 deletion front/.nvmrc

This file was deleted.

1 change: 1 addition & 0 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@mui/icons-material": "^5.8.0",
"@mui/material": "^5.11.8",
"@reduxjs/toolkit": "^1.8.1",
"@sentry/browser": "^7.56.0",
"@types/jest": "^29.5.2",
"@types/node": "^18.13.0",
"@types/papaparse": "^5.3.7",
Expand Down
11 changes: 11 additions & 0 deletions front/src/app/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ import React from "react";
import { createRoot } from "react-dom/client";
import { Provider } from "react-redux";
import { startReactDsfr } from "@codegouvfr/react-dsfr/spa";
import * as Sentry from "@sentry/browser";
import { App } from "src/app/App";
import { store } from "src/config/dependencies";
import { ENV } from "src/config/environmentVariables";
import { MetaContent } from "./components/layout/MetaContent";
import { RouteProvider } from "./routes/routes";

Sentry.init({
dsn: "https://c2909f1d7f384d17bde3e75e250f2828@sentry.gip-inclusion.cloud-ed.fr/2",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: je propose de variabiliser cette information grâce à une variable d'environnement (si possible, à moindre frais).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: utiliser xxx@sentry.gip-inclusion.org plutôt que l'URL technique sous-jacente.

integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],
environment: ENV.envType,
tracesSampleRate: 0.01,
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0,
});

startReactDsfr({ defaultColorScheme: "light" });

const rootContainer = document.getElementById("root");
Expand Down
8 changes: 7 additions & 1 deletion front/src/core-logic/storeConfig/catchEpicError.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Sentry from "@sentry/browser";
import { catchError, merge, Observable, of } from "rxjs";

export const catchEpicError =
Expand All @@ -8,4 +9,9 @@ export const catchEpicError =
cb: (error: Error) => OutputAction,
) =>
(inputObs: Observable<InputAction>): Observable<OutputAction | InputAction> =>
inputObs.pipe(catchError((error, caught) => merge(of(cb(error)), caught)));
inputObs.pipe(
catchError((error, caught) => {
Sentry.captureException(error);
return merge(of(cb(error)), caught);
}),
);
2 changes: 2 additions & 0 deletions front/src/core-logic/storeConfig/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { combineReducers, configureStore } from "@reduxjs/toolkit";
import * as Sentry from "@sentry/browser";
import { combineEpics, createEpicMiddleware, Epic } from "redux-observable";
import { catchError } from "rxjs";
import type { Dependencies } from "src/config/dependencies";
Expand Down Expand Up @@ -88,6 +89,7 @@ const rootEpic: Epic = (action$, store$, dependencies) =>
catchError((error, source) => {
//eslint-disable-next-line no-console
console.error("combineEpic", error);
Sentry.captureException(error);
return source;
}),
);
Expand Down
56 changes: 56 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.