forked from Uniswap/interface
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement Sentry for state tracking (Uniswap#6015)
* feat: add sentry middleware * chore: remove file * chore: reorg * chore: update txt * chore: fix types * chore * chore: normalize * add todo * Update src/state/logging.ts Co-authored-by: Zach Pomerantz <[email protected]> * Update src/state/logging.ts Co-authored-by: Zach Pomerantz <[email protected]> * chore: update type * nits --------- Co-authored-by: Zach Pomerantz <[email protected]>
- Loading branch information
Showing
15 changed files
with
125 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' | ||
import { AppDispatch, AppState } from 'state' | ||
|
||
export const useAppDispatch = () => useDispatch<AppDispatch>() | ||
export const useAppSelector: TypedUseSelectorHook<AppState> = useSelector | ||
import store from './index' | ||
|
||
export const useAppDispatch = () => useDispatch<typeof store.dispatch>() | ||
export const useAppSelector: TypedUseSelectorHook<ReturnType<typeof store.getState>> = useSelector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as Sentry from '@sentry/react' | ||
|
||
import { AppState } from './types' | ||
|
||
/* Utility type to mark all properties of a type as optional */ | ||
type DeepPartial<T> = T extends object | ||
? { | ||
[P in keyof T]?: DeepPartial<T[P]> | ||
} | ||
: T | ||
|
||
/** | ||
* This enhancer will automatically store the latest state in Sentry's scope, so that it will be available | ||
* in the Sentry dashboard when an exception happens. | ||
*/ | ||
export const sentryEnhancer = Sentry.createReduxEnhancer({ | ||
/** | ||
* We don't want to store actions as breadcrumbs in Sentry, so we return null to disable the default behavior. | ||
*/ | ||
actionTransformer: () => null, | ||
/** | ||
* We only want to store a subset of the state in Sentry, containing only the relevant parts for debugging. | ||
* Note: This function runs on every state update, so we're keeping it as fast as possible by avoiding any function | ||
* calls and deep object traversals. | ||
*/ | ||
stateTransformer: (state: AppState): DeepPartial<AppState> => { | ||
const { application, user, connection, transactions } = state | ||
return { | ||
application: { | ||
fiatOnramp: application.fiatOnramp, | ||
chainId: application.chainId, | ||
openModal: application.openModal, | ||
popupList: application.popupList, | ||
}, | ||
user: { | ||
fiatOnrampAcknowledgments: user.fiatOnrampAcknowledgments, | ||
selectedWallet: user.selectedWallet, | ||
lastUpdateVersionTimestamp: user.lastUpdateVersionTimestamp, | ||
matchesDarkMode: user.matchesDarkMode, | ||
userDarkMode: user.userDarkMode, | ||
userLocale: user.userLocale, | ||
userExpertMode: user.userExpertMode, | ||
userClientSideRouter: user.userClientSideRouter, | ||
userHideClosedPositions: user.userHideClosedPositions, | ||
userSlippageTolerance: user.userSlippageTolerance, | ||
userSlippageToleranceHasBeenMigratedToAuto: user.userSlippageToleranceHasBeenMigratedToAuto, | ||
userDeadline: user.userDeadline, | ||
timestamp: user.timestamp, | ||
URLWarningVisible: user.URLWarningVisible, | ||
showSurveyPopup: user.showSurveyPopup, | ||
}, | ||
connection: { | ||
errorByConnectionType: connection.errorByConnectionType, | ||
}, | ||
transactions, | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import multicall from 'lib/state/multicall' | ||
|
||
import application from './application/reducer' | ||
import burn from './burn/reducer' | ||
import burnV3 from './burn/v3/reducer' | ||
import connection from './connection/reducer' | ||
import lists from './lists/reducer' | ||
import logs from './logs/slice' | ||
import mint from './mint/reducer' | ||
import mintV3 from './mint/v3/reducer' | ||
import { routingApi } from './routing/slice' | ||
import swap from './swap/reducer' | ||
import transactions from './transactions/reducer' | ||
import user from './user/reducer' | ||
import wallets from './wallets/reducer' | ||
|
||
export default { | ||
application, | ||
user, | ||
connection, | ||
transactions, | ||
wallets, | ||
swap, | ||
mint, | ||
mintV3, | ||
burn, | ||
burnV3, | ||
multicall: multicall.reducer, | ||
lists, | ||
logs, | ||
[routingApi.reducerPath]: routingApi.reducer, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Reducer } from '@reduxjs/toolkit' | ||
|
||
import reducer from './reducer' | ||
|
||
/* Utility type to extract state type out of a @reduxjs/toolkit Reducer type */ | ||
type GetState<T> = T extends Reducer<infer State> ? State : never | ||
|
||
export type AppState = { | ||
[K in keyof typeof reducer]: GetState<typeof reducer[K]> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters