Skip to content

Commit

Permalink
added Sentry init and captureException on epics
Browse files Browse the repository at this point in the history
  • Loading branch information
enguerranws authored and bbohec committed Jun 20, 2023
1 parent a4950e3 commit 1e1751b
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 6 deletions.
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",
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.

0 comments on commit 1e1751b

Please sign in to comment.