feat: add user id to sentry (#6896)
* feat: add user id to sentry * downgrade * key * Update src/tracing/index.ts Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update src/tracing/index.ts Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * fixes --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
This commit is contained in:
parent
dfe50b4bee
commit
bcb45cded6
@ -6,12 +6,16 @@ import { initializeAnalytics, OriginApplication } from '@uniswap/analytics'
|
|||||||
import { SharedEventName } from '@uniswap/analytics-events'
|
import { SharedEventName } from '@uniswap/analytics-events'
|
||||||
import { isSentryEnabled } from 'utils/env'
|
import { isSentryEnabled } from 'utils/env'
|
||||||
import { getEnvName, isProductionEnv } from 'utils/env'
|
import { getEnvName, isProductionEnv } from 'utils/env'
|
||||||
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
import { beforeSend } from './errors'
|
import { beforeSend } from './errors'
|
||||||
|
|
||||||
// Dump some metadata into the window to allow client verification.
|
// Dump some metadata into the window to allow client verification.
|
||||||
window.GIT_COMMIT_HASH = process.env.REACT_APP_GIT_COMMIT_HASH
|
window.GIT_COMMIT_HASH = process.env.REACT_APP_GIT_COMMIT_HASH
|
||||||
|
|
||||||
|
// This is used to identify the user in Sentry.
|
||||||
|
const SENTRY_USER_ID_KEY = 'sentry-user-id'
|
||||||
|
|
||||||
// Actual KEYs are set by proxy servers.
|
// Actual KEYs are set by proxy servers.
|
||||||
const AMPLITUDE_DUMMY_KEY = '00000000000000000000000000000000'
|
const AMPLITUDE_DUMMY_KEY = '00000000000000000000000000000000'
|
||||||
export const STATSIG_DUMMY_KEY = 'client-0000000000000000000000000000000000000000000'
|
export const STATSIG_DUMMY_KEY = 'client-0000000000000000000000000000000000000000000'
|
||||||
@ -31,6 +35,12 @@ Sentry.init({
|
|||||||
beforeSend,
|
beforeSend,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let sentryUserId = localStorage.getItem(SENTRY_USER_ID_KEY)
|
||||||
|
if (!sentryUserId) {
|
||||||
|
localStorage.setItem(SENTRY_USER_ID_KEY, (sentryUserId = uuidv4()))
|
||||||
|
}
|
||||||
|
Sentry.setUser({ id: sentryUserId })
|
||||||
|
|
||||||
initializeAnalytics(AMPLITUDE_DUMMY_KEY, OriginApplication.INTERFACE, {
|
initializeAnalytics(AMPLITUDE_DUMMY_KEY, OriginApplication.INTERFACE, {
|
||||||
proxyUrl: process.env.REACT_APP_AMPLITUDE_PROXY_URL,
|
proxyUrl: process.env.REACT_APP_AMPLITUDE_PROXY_URL,
|
||||||
defaultEventName: SharedEventName.PAGE_VIEWED,
|
defaultEventName: SharedEventName.PAGE_VIEWED,
|
||||||
|
Loading…
Reference in New Issue
Block a user