diff --git a/package-lock.json b/package-lock.json index 3f1345e9..4e8042f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,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", @@ -5865,6 +5866,96 @@ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==" }, + "node_modules/@sentry-internal/tracing": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.75.1.tgz", + "integrity": "sha512-nynV+7iVcF8k3CqhvI2K7iA8h4ovJhgYHKnXR8RDDevQOqNG2AEX9+hjCj9fZM4MhKHYFqf1od2oO9lTr38kwg==", + "dependencies": { + "@sentry/core": "7.75.1", + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/browser": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.75.1.tgz", + "integrity": "sha512-0+jPfPA5P9HVYYRQraDokGCY2NiMknSfz11dggClK4VmjvG+hOXiEyf73SFVwLFnv/hwrkWySjoIrVCX65xXQA==", + "dependencies": { + "@sentry-internal/tracing": "7.75.1", + "@sentry/core": "7.75.1", + "@sentry/replay": "7.75.1", + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/core": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.75.1.tgz", + "integrity": "sha512-Kw4KyKBxbxbh8OKO0S11Tm0gWP+6AaXXYrsq3hp8H338l/wOmIzyckmCbUrc/XJeoRqaFLJbdcCrcUEDZUvsVQ==", + "dependencies": { + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/react": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/react/-/react-7.75.1.tgz", + "integrity": "sha512-5zFcIor8vwQa13VRwk7yDE8U7uspj0eKpsjOcYcfSvDkiL7LW0sA6rXxvO3jwd1AKaB3EAfr1F4oIdEz8aRIkA==", + "dependencies": { + "@sentry/browser": "7.75.1", + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1", + "hoist-non-react-statics": "^3.3.2" + }, + "engines": { + "node": ">=8" + }, + "peerDependencies": { + "react": "15.x || 16.x || 17.x || 18.x" + } + }, + "node_modules/@sentry/replay": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.75.1.tgz", + "integrity": "sha512-MKQTDWNYs9QXCJ+irGX5gu8Kxdk/Ds5puhILy8+DnCoXgXuPFRMGob1Sxt8qXmbQmcGeogsx221MNTselsRS6g==", + "dependencies": { + "@sentry-internal/tracing": "7.75.1", + "@sentry/core": "7.75.1", + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry/types": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.75.1.tgz", + "integrity": "sha512-km+ygqgMDaFfTrbQwdhrptFqx0Oq15jZABqIoIpbaOCkCAMm+tyCqrFS8dTfaq5wpCktqWOy2qU/DOpppO99Cg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/utils": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.75.1.tgz", + "integrity": "sha512-QzW2eRjY20epD//9/tQ0FTNwdAL6XZi+LyJNUQIeK3NMnc5NgHrgpxId87gmFq8cNx47utH1Blub8RuMbKqiwQ==", + "dependencies": { + "@sentry/types": "7.75.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sinonjs/commons": { "version": "1.8.6", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", @@ -37425,6 +37516,72 @@ } } }, + "@sentry-internal/tracing": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.75.1.tgz", + "integrity": "sha512-nynV+7iVcF8k3CqhvI2K7iA8h4ovJhgYHKnXR8RDDevQOqNG2AEX9+hjCj9fZM4MhKHYFqf1od2oO9lTr38kwg==", + "requires": { + "@sentry/core": "7.75.1", + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1" + } + }, + "@sentry/browser": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.75.1.tgz", + "integrity": "sha512-0+jPfPA5P9HVYYRQraDokGCY2NiMknSfz11dggClK4VmjvG+hOXiEyf73SFVwLFnv/hwrkWySjoIrVCX65xXQA==", + "requires": { + "@sentry-internal/tracing": "7.75.1", + "@sentry/core": "7.75.1", + "@sentry/replay": "7.75.1", + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1" + } + }, + "@sentry/core": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.75.1.tgz", + "integrity": "sha512-Kw4KyKBxbxbh8OKO0S11Tm0gWP+6AaXXYrsq3hp8H338l/wOmIzyckmCbUrc/XJeoRqaFLJbdcCrcUEDZUvsVQ==", + "requires": { + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1" + } + }, + "@sentry/react": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/react/-/react-7.75.1.tgz", + "integrity": "sha512-5zFcIor8vwQa13VRwk7yDE8U7uspj0eKpsjOcYcfSvDkiL7LW0sA6rXxvO3jwd1AKaB3EAfr1F4oIdEz8aRIkA==", + "requires": { + "@sentry/browser": "7.75.1", + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1", + "hoist-non-react-statics": "^3.3.2" + } + }, + "@sentry/replay": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.75.1.tgz", + "integrity": "sha512-MKQTDWNYs9QXCJ+irGX5gu8Kxdk/Ds5puhILy8+DnCoXgXuPFRMGob1Sxt8qXmbQmcGeogsx221MNTselsRS6g==", + "requires": { + "@sentry-internal/tracing": "7.75.1", + "@sentry/core": "7.75.1", + "@sentry/types": "7.75.1", + "@sentry/utils": "7.75.1" + } + }, + "@sentry/types": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.75.1.tgz", + "integrity": "sha512-km+ygqgMDaFfTrbQwdhrptFqx0Oq15jZABqIoIpbaOCkCAMm+tyCqrFS8dTfaq5wpCktqWOy2qU/DOpppO99Cg==" + }, + "@sentry/utils": { + "version": "7.75.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.75.1.tgz", + "integrity": "sha512-QzW2eRjY20epD//9/tQ0FTNwdAL6XZi+LyJNUQIeK3NMnc5NgHrgpxId87gmFq8cNx47utH1Blub8RuMbKqiwQ==", + "requires": { + "@sentry/types": "7.75.1" + } + }, "@sinonjs/commons": { "version": "1.8.6", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", diff --git a/package.json b/package.json index 88349cd3..76333a2b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/AppProvider/index.js b/src/components/AppProvider/index.js index e4424080..9365d953 100644 --- a/src/components/AppProvider/index.js +++ b/src/components/AppProvider/index.js @@ -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'; @@ -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; }