forked from Uniswap/interface
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogging.ts
55 lines (52 loc) · 2 KB
/
logging.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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: {
selectedWallet: user.selectedWallet,
lastUpdateVersionTimestamp: user.lastUpdateVersionTimestamp,
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,
}
},
})