Skip to content

Commit c383319

Browse files
authored
Upgrade Sentry to v10 with React integration (#3313)
* Create sourcemaps * Replace Sentry browser with React integration * Update import sources * Simplify test import * Set up React Router-Sentry integration * Add TODO * Fix lint * Fix tests
1 parent e5f1472 commit c383319

File tree

17 files changed

+105
-63
lines changed

17 files changed

+105
-63
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@mantine/hooks": "^7.11.2",
4040
"@octokit/rest": "^22.0.0",
4141
"@reduxjs/toolkit": "^1.9.7",
42-
"@sentry/browser": "^8.33.0",
42+
"@sentry/react": "^10.5.0",
4343
"@sourceacademy/c-slang": "^1.0.21",
4444
"@sourceacademy/sharedb-ace": "2.1.1",
4545
"@sourceacademy/sling-client": "^0.1.0",

rsbuild.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export default defineConfig({
151151
output: {
152152
distPath: {
153153
root: './build'
154-
}
154+
},
155+
sourceMap: true
155156
}
156157
});

src/commons/application/ApplicationWrapper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Classes, NonIdealState } from '@blueprintjs/core';
22
import { IconNames } from '@blueprintjs/icons';
3+
import * as Sentry from '@sentry/react';
34
import classNames from 'classnames';
45
import { useEffect, useMemo, useState } from 'react';
56
import { useDispatch } from 'react-redux';
@@ -37,7 +38,7 @@ const ApplicationWrapper: React.FC = () => {
3738
? playgroundOnlyRouterConfig
3839
: getFullAcademyRouterConfig({ name, isLoggedIn, courseId, academyRoutes });
3940

40-
const r = createBrowserRouter(routerConfig);
41+
const r = Sentry.wrapCreateBrowserRouterV7(createBrowserRouter)(routerConfig);
4142
dispatch(updateReactRouter(r));
4243

4344
return r;

src/commons/application/__tests__/Application.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { Mock, vi } from 'vitest';
44

55
import Application from '../Application';
66

7-
vi.mock('react-redux', () => ({
7+
vi.mock('react-redux', async importOriginal => ({
8+
...(await importOriginal()),
89
useDispatch: vi.fn(),
910
useSelector: vi.fn()
1011
}));

src/commons/editor/UseShareAce.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
AceMultiSelectionManager,
66
AceRadarView
77
} from '@convergencelabs/ace-collab-ext';
8-
import * as Sentry from '@sentry/browser';
8+
import * as Sentry from '@sentry/react';
99
import sharedbAce from '@sourceacademy/sharedb-ace';
1010
import type SharedbAceBinding from '@sourceacademy/sharedb-ace/binding';
1111
import { CollabEditingAccess } from '@sourceacademy/sharedb-ace/types';

src/commons/navigationBar/NavigationBar.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import { IconName, IconNames } from '@blueprintjs/icons';
1616
import classNames from 'classnames';
1717
import React, { useMemo, useState } from 'react';
1818
import { Translation } from 'react-i18next';
19-
import { Location, NavLink, Route, Routes, useLocation } from 'react-router';
19+
import { type Location, NavLink, Route, useLocation } from 'react-router';
2020
import { i18nDefaultLangKeys } from 'src/i18n/i18next';
21+
import { SentryRoutes } from 'src/routes/routerConfig';
2122
import classes from 'src/styles/NavigationBar.module.scss';
2223

2324
import Dropdown from '../dropdown/Dropdown';
@@ -312,7 +313,7 @@ const NavigationBar: React.FC = () => {
312313
{commonNavbarRight}
313314
</Navbar>
314315

315-
<Routes>
316+
<SentryRoutes>
316317
<Route path="/playground/*" element={null} />
317318
<Route path="/contributors" element={null} />
318319
<Route path="/courses/:courseId/sourcecast" element={null} />
@@ -327,7 +328,7 @@ const NavigationBar: React.FC = () => {
327328
) : null
328329
}
329330
/>
330-
</Routes>
331+
</SentryRoutes>
331332
</>
332333
);
333334
};

src/commons/navigationBar/subcomponents/__tests__/AcademyNavigationBar.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { Mock, vi } from 'vitest';
55
import { Role } from '../../../application/ApplicationTypes';
66
import AcademyNavigationBar from '../AcademyNavigationBar';
77

8-
vi.mock('react-redux', () => ({
8+
vi.mock('react-redux', async importOriginal => ({
9+
...(await importOriginal()),
910
useSelector: vi.fn()
1011
}));
1112
const useSelectorMock = useTypedSelector as Mock;

src/commons/sagas/LoginSaga.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { setUser } from '@sentry/browser';
1+
import { setUser } from '@sentry/react';
22
import { call, select } from 'redux-saga/effects';
33
import Messages, { sendToWebview } from 'src/features/vscode/messages';
44

src/commons/sagas/SafeEffects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ActionMatchingPattern } from '@redux-saga/types';
2-
import * as Sentry from '@sentry/browser';
2+
import * as Sentry from '@sentry/react';
33
import {
44
type ActionPattern,
55
type ForkEffect,

src/commons/sagas/__tests__/SafeEffects.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as Sentry from '@sentry/browser';
1+
import * as Sentry from '@sentry/react';
22
import { call } from 'redux-saga/effects';
33
import { expectSaga } from 'redux-saga-test-plan';
44
import { vi } from 'vitest';
55

66
import { wrapSaga } from '../SafeEffects';
77

8-
vi.mock('@sentry/browser', async () => ({
9-
...(await vi.importActual('../../../../node_modules/@sentry/browser')),
8+
vi.mock('@sentry/react', async importOriginal => ({
9+
...(await importOriginal()),
1010
captureException: vi.fn()
1111
}));
1212

0 commit comments

Comments
 (0)