Commit 92c21c28 authored by Mike Grabowski's avatar Mike Grabowski Committed by GitHub

feat: better UX when Sentry disabled (#5695)

* feat: disable sentry

* chore: update error page

* chore: use continue on error instead

* chore: wrap in trans

* flip check
parent e70723aa
...@@ -4,6 +4,7 @@ REACT_APP_AWS_API_REGION="us-east-2" ...@@ -4,6 +4,7 @@ REACT_APP_AWS_API_REGION="us-east-2"
REACT_APP_AWS_API_ENDPOINT="https://beta.api.uniswap.org/v1/graphql" REACT_APP_AWS_API_ENDPOINT="https://beta.api.uniswap.org/v1/graphql"
REACT_APP_TEMP_API_URL="https://temp.api.uniswap.org/v1" REACT_APP_TEMP_API_URL="https://temp.api.uniswap.org/v1"
REACT_APP_SENTRY_DSN="https://a3c62e400b8748b5a8d007150e2f38b7@o1037921.ingest.sentry.io/4504255148851200" REACT_APP_SENTRY_DSN="https://a3c62e400b8748b5a8d007150e2f38b7@o1037921.ingest.sentry.io/4504255148851200"
REACT_APP_SENTRY_ENABLED=false
ESLINT_NO_DEV_ERRORS=true ESLINT_NO_DEV_ERRORS=true
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847" REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
REACT_APP_MOONPAY_API="https://api.moonpay.com" REACT_APP_MOONPAY_API="https://api.moonpay.com"
......
...@@ -112,7 +112,8 @@ jobs: ...@@ -112,7 +112,8 @@ jobs:
githubToken: ${{ secrets.GITHUB_TOKEN }} githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Upload source maps to Sentry - name: Upload source maps to Sentry
uses: getsentry/action-release@bd5f874fcda966ba48139b0140fb3ec0cb3aabdd uses: getsentry/action-release@bd5f874fcda966ba48139b0140fb3ec0cb3aabdd
continue-on-error: true
env: env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
...@@ -120,4 +121,4 @@ jobs: ...@@ -120,4 +121,4 @@ jobs:
with: with:
environment: production environment: production
sourcemaps: './build/static/js' sourcemaps: './build/static/js'
url_prefix: '/static/js' url_prefix: '/static/js'
\ No newline at end of file
...@@ -6,6 +6,7 @@ import { useIsMobile } from 'nft/hooks' ...@@ -6,6 +6,7 @@ import { useIsMobile } from 'nft/hooks'
import React, { PropsWithChildren, useState } from 'react' import React, { PropsWithChildren, useState } from 'react'
import { Copy } from 'react-feather' import { Copy } from 'react-feather'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { isSentryEnabled } from 'utils/env'
import { CopyToClipboard, ExternalLink, ThemedText } from '../../theme' import { CopyToClipboard, ExternalLink, ThemedText } from '../../theme'
import { Column } from '../Column' import { Column } from '../Column'
...@@ -85,6 +86,7 @@ const CodeTitle = styled.div` ...@@ -85,6 +86,7 @@ const CodeTitle = styled.div`
display: flex; display: flex;
gap: 14px; gap: 14px;
align-items: center; align-items: center;
justify-content: space-between;
word-break: break-word; word-break: break-word;
` `
...@@ -92,49 +94,87 @@ const Fallback = ({ error, eventId }: { error: Error; eventId: string | null }) ...@@ -92,49 +94,87 @@ const Fallback = ({ error, eventId }: { error: Error; eventId: string | null })
const [isExpanded, setExpanded] = useState(false) const [isExpanded, setExpanded] = useState(false)
const isMobile = useIsMobile() const isMobile = useIsMobile()
const errorId = eventId || 'unknown-error'
// @todo: ThemedText components should be responsive by default // @todo: ThemedText components should be responsive by default
const [Title, Description] = isMobile const [Title, Description] = isMobile
? [ThemedText.HeadlineSmall, ThemedText.BodySmall] ? [ThemedText.HeadlineSmall, ThemedText.BodySmall]
: [ThemedText.HeadlineLarge, ThemedText.BodySecondary] : [ThemedText.HeadlineLarge, ThemedText.BodySecondary]
const showErrorId = isSentryEnabled() && eventId
const showMoreButton = (
<ShowMoreButton onClick={() => setExpanded((s) => !s)}>
<ThemedText.Link color="textSecondary">
<Trans>{isExpanded ? 'Show less' : 'Show more'}</Trans>
</ThemedText.Link>
<ShowMoreIcon $isExpanded={isExpanded} secondaryWidth="20" secondaryHeight="20" />
</ShowMoreButton>
)
const errorDetails = error.stack || error.message
return ( return (
<FallbackWrapper> <FallbackWrapper>
<BodyWrapper> <BodyWrapper>
<Column gap="xl"> <Column gap="xl">
<Column gap="sm"> {showErrorId ? (
<Title textAlign="center"> <>
<Trans>Something went wrong</Trans> <Column gap="sm">
</Title> <Title textAlign="center">
<Description textAlign="center" color="textSecondary"> <Trans>Something went wrong</Trans>
<Trans> </Title>
Sorry, an error occured while processing your request. If you request support, be sure to provide your <Description textAlign="center" color="textSecondary">
error ID. <Trans>
</Trans> Sorry, an error occured while processing your request. If you request support, be sure to provide
</Description> your error ID.
</Column> </Trans>
<CodeBlockWrapper> </Description>
<CodeTitle> </Column>
<ThemedText.SubHeader fontWeight={500}>Error ID: {errorId}</ThemedText.SubHeader> <CodeBlockWrapper>
<CopyToClipboard toCopy={errorId}> <CodeTitle>
<CopyIcon /> <ThemedText.SubHeader fontWeight={500}>
</CopyToClipboard> <Trans>Error ID: {eventId}</Trans>
</CodeTitle> </ThemedText.SubHeader>
<Separator /> <CopyToClipboard toCopy={eventId}>
{isExpanded && ( <CopyIcon />
<> </CopyToClipboard>
<Code>{error.stack}</Code> </CodeTitle>
<Separator />
{isExpanded && (
<>
<Code>{errorDetails}</Code>
<Separator />
</>
)}
{showMoreButton}
</CodeBlockWrapper>
</>
) : (
<>
<Column gap="sm">
<Title textAlign="center">
<Trans>Something went wrong</Trans>
</Title>
<Description textAlign="center" color="textSecondary">
<Trans>
Sorry, an error occured while processing your request. If you request support, be sure to copy the
details of this error.
</Trans>
</Description>
</Column>
<CodeBlockWrapper>
<CodeTitle>
<ThemedText.SubHeader fontWeight={500}>Error details</ThemedText.SubHeader>
<CopyToClipboard toCopy={errorDetails}>
<CopyIcon />
</CopyToClipboard>
</CodeTitle>
<Separator />
<Code>{errorDetails.split('\n').slice(0, isExpanded ? undefined : 4)}</Code>
<Separator /> <Separator />
</> {showMoreButton}
)} </CodeBlockWrapper>
<ShowMoreButton onClick={() => setExpanded((s) => !s)}> </>
<ThemedText.Link color="textSecondary"> )}
<Trans>{isExpanded ? 'Show less' : 'Show more'}</Trans>
</ThemedText.Link>
<ShowMoreIcon $isExpanded={isExpanded} secondaryWidth="20" secondaryHeight="20" />
</ShowMoreButton>
</CodeBlockWrapper>
<StretchedRow> <StretchedRow>
<SmallButtonPrimary onClick={() => window.location.reload()}> <SmallButtonPrimary onClick={() => window.location.reload()}>
<Trans>Reload the app</Trans> <Trans>Reload the app</Trans>
......
...@@ -14,7 +14,7 @@ import { createRoot } from 'react-dom/client' ...@@ -14,7 +14,7 @@ import { createRoot } from 'react-dom/client'
import { QueryClient, QueryClientProvider } from 'react-query' import { QueryClient, QueryClientProvider } from 'react-query'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { HashRouter } from 'react-router-dom' import { HashRouter } from 'react-router-dom'
import { isProductionEnv } from 'utils/env' import { isSentryEnabled } from 'utils/env'
import Web3Provider from './components/Web3Provider' import Web3Provider from './components/Web3Provider'
import { LanguageProvider } from './i18n' import { LanguageProvider } from './i18n'
...@@ -33,7 +33,7 @@ if (window.ethereum) { ...@@ -33,7 +33,7 @@ if (window.ethereum) {
window.ethereum.autoRefreshOnNetworkChange = false window.ethereum.autoRefreshOnNetworkChange = false
} }
if (isProductionEnv()) { if (isSentryEnabled()) {
Sentry.init({ Sentry.init({
dsn: process.env.REACT_APP_SENTRY_DSN, dsn: process.env.REACT_APP_SENTRY_DSN,
release: process.env.REACT_APP_GIT_COMMIT_HASH, release: process.env.REACT_APP_GIT_COMMIT_HASH,
......
...@@ -14,3 +14,7 @@ export function isStagingEnv(): boolean { ...@@ -14,3 +14,7 @@ export function isStagingEnv(): boolean {
export function isProductionEnv(): boolean { export function isProductionEnv(): boolean {
return process.env.NODE_ENV === 'production' && !isStagingEnv() return process.env.NODE_ENV === 'production' && !isStagingEnv()
} }
export function isSentryEnabled(): boolean {
return process.env.REACT_APP_SENTRY_ENABLED === 'true'
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment