Skip to content

Commit

Permalink
add sentry support from API settings
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Oct 25, 2023
1 parent 204914e commit e5b1939
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 0 deletions.
157 changes: 157 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@blueprintjs/icons": "^3.33.0",
"@mapbox/mapbox-gl-draw": "^1.4.1",
"@material-ui/lab": "^4.0.0-alpha.61",
"@sentry/react": "^7.75.1",
"@terralego/core": "^1.31.4",
"@terralego/ra-data-drf": "^2.0.1-mkc.0",
"@turf/bbox": "^6.5.0",
Expand Down
25 changes: 25 additions & 0 deletions src/components/AppProvider/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import connect from 'react-ctx-connect';
import * as Sentry from '@sentry/react';

import { useLocation } from 'react-router-dom';
import { getSettings } from '../../services/settings';
import Loading from '../Loading';

Expand All @@ -24,6 +26,29 @@ export class AppProvider extends React.Component {
if (settings.token && !localStorage.getItem('tf:auth:token')) {
localStorage.setItem('tf:auth:token', settings.token);
}

if (settings.sentry.dsn !== '') {
Sentry.init({
sendDefaultPii: settings.sentry.sendDefaultPii,
dsn: settings.sentry.dsn,
release: settings.sentry.release,
environment: settings.sentry.environment,
integrations: [
new Sentry.BrowserTracing({
// See docs for support of different versions of variation of react router
// https://docs.sentry.io/platforms/javascript/guides/react/configuration/integrations/react-router/
routingInstrumentation: Sentry.reactRouterV5Instrumentation(
React.useEffect,
useLocation,
),
}),
new Sentry.Replay(),
],
tracesSampleRate: settings.sentry.tracesSampleRate,
replaysSessionSampleRate: settings.sentry.replaysSessionSampleRate,
replaysOnErrorSampleRate: settings.sentry.replaysOnErrorSampleRate,
});
}
} catch (e) {
result.error = e;
}
Expand Down

0 comments on commit e5b1939

Please sign in to comment.