Skip to content

Commit

Permalink
feat: add SentryErrorInfo component
Browse files Browse the repository at this point in the history
  • Loading branch information
gleiser-oliveira committed Nov 23, 2023
1 parent 099e500 commit 1ce62e3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/App/SentryErrorInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { setTag, setUser } from '@sentry/react';
import React, { useEffect } from 'react';

import { useAuth } from 'context/AuthContext';

export const SentryErrorInfo: React.FC = () => {
const { accountAddress, chainId } = useAuth();

// Enriches Sentry events with info about the user and chain
useEffect(() => {
if (accountAddress) {
setUser({
id: accountAddress,
});
} else {
setUser(null);
}

setTag('chainId', chainId);
}, [accountAddress, chainId]);

return null;
};
3 changes: 3 additions & 0 deletions src/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AuthProvider } from 'context/AuthContext';
import { MuiThemeProvider } from 'theme/MuiThemeProvider';

import Router from './Router';
import { SentryErrorInfo } from './SentryErrorInfo';

const NotificationCenter = lazy(() => import('packages/notifications/NotificationCenter'));

Expand All @@ -21,6 +22,8 @@ const App = () => (
<QueryClientProvider client={queryClient}>
<Web3Wrapper>
<AuthProvider>
<SentryErrorInfo />

<AnalyticProvider>
<HashRouter>
<Layout>
Expand Down

0 comments on commit 1ce62e3

Please sign in to comment.