Commit 95db44e0 authored by Moody Salem's avatar Moody Salem

add a little state to the automatic issue body

parent 7d45ff5c
import React, { ErrorInfo } from 'react' import React, { ErrorInfo } from 'react'
import store, { AppState } from '../../state'
import { ExternalLink, ThemedBackground, TYPE } from '../../theme' import { ExternalLink, ThemedBackground, TYPE } from '../../theme'
import { AutoColumn } from '../Column' import { AutoColumn } from '../Column'
import styled from 'styled-components' import styled from 'styled-components'
...@@ -114,26 +115,45 @@ export default class ErrorBoundary extends React.Component<unknown, ErrorBoundar ...@@ -114,26 +115,45 @@ export default class ErrorBoundary extends React.Component<unknown, ErrorBoundar
} }
} }
function getRelevantState(): null | keyof AppState {
const path = window.location.hash
if (!path.startsWith('#/')) {
return null
}
const pieces = path.substring(2).split(/[\/\\?]/)
switch (pieces[0]) {
case 'swap':
return 'swap'
case 'add':
if (pieces[1] === 'v2') return 'mint'
else return 'mintV3'
case 'remove':
if (pieces[1] === 'v2') return 'burn'
else return 'burnV3'
}
return null
}
function issueBody(error: Error): string { function issueBody(error: Error): string {
if (!error) throw new Error('no error to report') const relevantState = getRelevantState()
const deviceData = getUserAgent() const deviceData = getUserAgent()
return `**Bug Description** return `## URL
App crashed
**Steps to Reproduce**
1. Go to ...
2. Click on ...
...
**URL**
${window.location.href} ${window.location.href}
${
relevantState
? `## \`${relevantState}\` state
\`\`\`json
${JSON.stringify(store.getState()[relevantState], null, 2)}
\`\`\`
`
: ''
}
${ ${
error.name && error.name &&
`**Error** `## Error
\`\`\` \`\`\`
${error.name}${error.message && `: ${error.message}`} ${error.name}${error.message && `: ${error.message}`}
...@@ -142,7 +162,7 @@ ${error.name}${error.message && `: ${error.message}`} ...@@ -142,7 +162,7 @@ ${error.name}${error.message && `: ${error.message}`}
} }
${ ${
error.stack && error.stack &&
`**Stacktrace** `## Stacktrace
\`\`\` \`\`\`
${error.stack} ${error.stack}
...@@ -151,9 +171,9 @@ ${error.stack} ...@@ -151,9 +171,9 @@ ${error.stack}
} }
${ ${
deviceData && deviceData &&
`**Device data** `## Device data
\`\`\`json5 \`\`\`json
${JSON.stringify(deviceData, null, 2)} ${JSON.stringify(deviceData, null, 2)}
\`\`\` \`\`\`
` `
......
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