From 071c1d33d9c80921b88a908d16c17f5ebd2166f6 Mon Sep 17 00:00:00 2001 From: Hel Nershing Thapa Date: Fri, 18 Aug 2023 11:09:09 +0545 Subject: [PATCH] Configure Sentry setup --- frontend/package.json | 7 ++++--- frontend/src/index.js | 24 +++++++++++++++++++++--- frontend/yarn.lock | 20 ++++++++++++-------- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index ec6e27cdbd..06d929771d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,8 +14,8 @@ "@mapbox/mapbox-gl-geocoder": "^5.0.1", "@mapbox/mapbox-gl-language": "^0.10.1", "@placemarkio/geo-viewport": "^1.0.1", + "@sentry/cli": "^2.20.5", "@sentry/react": "^7.56.0", - "@sentry/tracing": "^7.56.0", "@tmcw/togeojson": "^4.7.0", "@turf/area": "^6.5.0", "@turf/bbox": "^6.5.0", @@ -85,12 +85,13 @@ "patch-rapid": "bash -c \"cp patch/rapid-imagery.min.json public/static/rapid/data/imagery.min.json\"", "preparation": "bash -c \"if (test -a ../tasking-manager.env); then grep -hs ^ ../tasking-manager.env .env.expand > .env; else cp .env.expand .env; fi\"", "start": "npm run preparation && npm run copy-static && npm run patch-id && npm run patch-rapid && react-scripts start", - "build": "npm run preparation && npm run update-static && npm run patch-id && npm run patch-rapid && react-scripts build", + "build": "npm run preparation && npm run update-static && npm run patch-id && npm run patch-rapid && react-scripts build && yarn run sentry:sourcemaps", "prettier": "prettier --write 'src/**/*.js'", "lint": "eslint src", "test": "npm run lint && react-scripts test --env=jsdom", "coverage": "npm run test -- --coverage --watchAll=false", - "analyze": "source-map-explorer 'build/static/js/*.js'" + "analyze": "source-map-explorer 'build/static/js/*.js'", + "sentry:sourcemaps": "sentry-cli sourcemaps inject --org humanitarian-openstreetmap-tea --project taskingmanager-frontend ./build && sentry-cli sourcemaps upload --org humanitarian-openstreetmap-tea --project taskingmanager-frontend ./build" }, "eslintConfig": { "extends": "react-app" diff --git a/frontend/src/index.js b/frontend/src/index.js index 668106f448..65cd2defd3 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -4,7 +4,12 @@ import { PersistGate } from 'redux-persist/integration/react'; import { Provider } from 'react-redux'; import WebFont from 'webfontloader'; import * as Sentry from '@sentry/react'; -import { BrowserTracing } from '@sentry/tracing'; +import { + createRoutesFromChildren, + matchRoutes, + useLocation, + useNavigationType, +} from 'react-router-dom'; import App from './App'; import { store, persistor } from './store'; @@ -16,8 +21,21 @@ if (SENTRY_FRONTEND_DSN) { Sentry.init({ dsn: SENTRY_FRONTEND_DSN, environment: ENVIRONMENT, - integrations: [new BrowserTracing()], - tracesSampleRate: 0.1, + integrations: [ + new Sentry.BrowserTracing({ + routingInstrumentation: Sentry.reactRouterV6Instrumentation( + React.useEffect, + useLocation, + useNavigationType, + createRoutesFromChildren, + matchRoutes, + ), + }), + new Sentry.Replay(), + ], + tracesSampleRate: 1.0, // TODO: Find the right number + replaysSessionSampleRate: 1.0, // TODO: Find the right number + replaysOnErrorSampleRate: 1.0, }); } diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 2e74e529c8..f62ad34da1 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -2420,6 +2420,17 @@ "@sentry/utils" "7.56.0" tslib "^1.9.3" +"@sentry/cli@^2.20.5": + version "2.20.5" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.20.5.tgz#255a5388ca24c211a0eae01dcc4ad813a7ff335a" + integrity sha512-ZvWb86eF0QXH9C5Mbi87aUmr8SH848yEpXJmlM2AoBowpE9kKDnewCAKvyXUihojUFwCSEEjoJhrRMMgmCZqXA== + dependencies: + https-proxy-agent "^5.0.0" + node-fetch "^2.6.7" + progress "^2.0.3" + proxy-from-env "^1.1.0" + which "^2.0.2" + "@sentry/core@7.56.0": version "7.56.0" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.56.0.tgz#f4253e0d61f55444180a63e5278b62e57303f7cf" @@ -2449,13 +2460,6 @@ "@sentry/types" "7.56.0" "@sentry/utils" "7.56.0" -"@sentry/tracing@^7.56.0": - version "7.56.0" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.56.0.tgz#f119c2b04c06718fa3a0d00b2781c56005e9dd80" - integrity sha512-Qy7lJdC2YBk9T8JFt4da7xHB3pTZH6yUiIwo5edmSBv2cY6MQ0QZgLzsjJurjf47+/WecVYYKdye9q4twsBlDA== - dependencies: - "@sentry-internal/tracing" "7.56.0" - "@sentry/types@7.56.0": version "7.56.0" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.56.0.tgz#9042a099cf9e8816d081886d24b88082a5d9f87a" @@ -12241,7 +12245,7 @@ process@^0.11.10: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== -progress@^2.0.0: +progress@^2.0.0, progress@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==