Skip to content

Commit 2e4513d

Browse files
committed
co pilot pr comments
1 parent 7207817 commit 2e4513d

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

.github/workflows/web-app-deployer.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ jobs:
227227
echo "REACT_APP_REMOTE_CONFIG_MINIMUM_FETCH_INTERVAL_MILLI=300000" >> $GITHUB_ENV
228228
echo "REACT_APP_FEED_API_BASE_URL=https://api-qa.mobilitydatabase.org" >> $GITHUB_ENV
229229
echo "REACT_APP_GBFS_VALIDATOR_API_BASE_URL=https://dev.gbfs.api.mobilitydatabase.org" >> $GITHUB_ENV
230+
echo "REACT_APP_SENTRY_DSN=" >> $GITHUB_ENV
231+
echo "REACT_APP_SENTRY_REPLAY_SESSION_SAMPLE_RATE=" >> $GITHUB_ENV
232+
echo "REACT_APP_SENTRY_REPLAY_ERROR_SAMPLE_RATE=" >> $GITHUB_ENV
233+
echo "REACT_APP_SENTRY_TRACES_SAMPLE_RATE=" >> $GITHUB_ENV
230234
elif [[ ${{ inputs.FIREBASE_PROJECT }} == 'prod' ]]; then
231235
echo "Setting FIREBASE_PROJECT to 'prod'"
232236
echo "FIREBASE_PROJECT=prod" >> $GITHUB_ENV
@@ -257,6 +261,10 @@ jobs:
257261
echo "REACT_APP_REMOTE_CONFIG_MINIMUM_FETCH_INTERVAL_MILLI=300000" >> $GITHUB_ENV
258262
echo "REACT_APP_FEED_API_BASE_URL=https://api-dev.mobilitydatabase.org" >> $GITHUB_ENV
259263
echo "REACT_APP_GBFS_VALIDATOR_API_BASE_URL=https://dev.gbfs.api.mobilitydatabase.org" >> $GITHUB_ENV
264+
echo "REACT_APP_SENTRY_DSN=" >> $GITHUB_ENV
265+
echo "REACT_APP_SENTRY_REPLAY_SESSION_SAMPLE_RATE=" >> $GITHUB_ENV
266+
echo "REACT_APP_SENTRY_REPLAY_ERROR_SAMPLE_RATE=" >> $GITHUB_ENV
267+
echo "REACT_APP_SENTRY_TRACES_SAMPLE_RATE=" >> $GITHUB_ENV
260268
fi
261269
262270
- name: Populate Variables

web-app/src/app/store/store.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ const makeStore = () =>
6868
}),
6969
sagaMiddleware,
7070
],
71-
enhancers: (existing) =>
72-
sentryReduxEnhancer ? [...existing, sentryReduxEnhancer] : existing,
71+
enhancers: (existing) => [...existing, sentryReduxEnhancer],
7372
});
7473
/* eslint-enable */
7574

@@ -84,7 +83,7 @@ if (window.Cypress) {
8483

8584
sagaMiddleware.run(rootSaga);
8685

87-
export type RootState = ReturnType<typeof persistedReducer>;
86+
export type RootState = ReturnType<typeof store.getState>;
8887
export type AppDispatch = typeof store.dispatch;
8988
export type AppThunk<ReturnType = void> = ThunkAction<
9089
ReturnType,

web-app/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ root.render(
3939
</SentryErrorBoundary>
4040
</ContextProviders>
4141
</ThemeProvider>
42-
</React.StrictMode>,
42+
</React.StrictMode>
4343
);

web-app/src/sentry.ts

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import * as Sentry from '@sentry/react';
22
import packageJson from '../package.json';
33
import * as React from 'react';
4-
import { createRoutesFromChildren, matchRoutes } from 'react-router-dom';
4+
import {
5+
createRoutesFromChildren,
6+
matchRoutes,
7+
useLocation,
8+
useNavigationType,
9+
} from 'react-router-dom';
510

611
// Helper to safely parse Sentry sample rates from environment variables
7-
const parseSampleRate = (value: string | undefined, defaultValue: number): number => {
12+
const parseSampleRate = (
13+
value: string | undefined,
14+
defaultValue: number,
15+
): number => {
816
const parsed = parseFloat(value ?? String(defaultValue));
917
if (isNaN(parsed) || parsed < 0 || parsed > 1) {
1018
return defaultValue;
@@ -14,7 +22,9 @@ const parseSampleRate = (value: string | undefined, defaultValue: number): numbe
1422

1523
const dsn = process.env.REACT_APP_SENTRY_DSN || '';
1624
const environment =
17-
process.env.REACT_APP_FIREBASE_PROJECT_ID || process.env.NODE_ENV || "mobility-feeds-dev";
25+
process.env.REACT_APP_FIREBASE_PROJECT_ID ||
26+
process.env.NODE_ENV ||
27+
'mobility-feeds-dev';
1828
const release = packageJson.version;
1929
const tracesSampleRate = parseSampleRate(
2030
process.env.REACT_APP_SENTRY_TRACES_SAMPLE_RATE,
@@ -30,29 +40,29 @@ const replaysOnErrorSampleRate = parseSampleRate(
3040
);
3141

3242
if (dsn) {
33-
// Prefer dedicated react-router v6 integration if available, else fall back to generic browser tracing with manual routing instrumentation.
3443
const routerTracingIntegration =
35-
(Sentry as any).reactRouterV6BrowserTracingIntegration?.({
44+
Sentry.reactRouterV6BrowserTracingIntegration({
3645
useEffect: React.useEffect,
37-
reactRouterV6: { createRoutesFromChildren, matchRoutes },
38-
}) ||
39-
(Sentry as any).browserTracingIntegration?.({
40-
routingInstrumentation: (Sentry as any).reactRouterV6Instrumentation?.(
41-
React.useEffect,
42-
true,
43-
createRoutesFromChildren,
44-
matchRoutes,
45-
),
46+
useLocation,
47+
useNavigationType,
48+
createRoutesFromChildren,
49+
matchRoutes,
4650
});
4751

52+
const integrations = [];
53+
if (routerTracingIntegration) {
54+
integrations.push(routerTracingIntegration);
55+
}
56+
const replayIntegration = Sentry.replayIntegration?.();
57+
if (replayIntegration) {
58+
integrations.push(replayIntegration);
59+
}
60+
4861
Sentry.init({
4962
dsn,
5063
environment,
5164
release,
52-
integrations: [
53-
routerTracingIntegration,
54-
(Sentry as any).replayIntegration?.(),
55-
].filter(Boolean),
65+
integrations: integrations,
5666
tracesSampleRate,
5767
replaysSessionSampleRate,
5868
replaysOnErrorSampleRate,

0 commit comments

Comments
 (0)