Skip to content

Commit b183d4e

Browse files
committed
Send info to open issue
1 parent 0f5af05 commit b183d4e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

site/src/components/Margins/Margins.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const useStyles = makeStyles(() => ({
2525
},
2626
}))
2727

28-
export const Margins: FC<JSX.IntrinsicElements["div"] & { size: Size }> = ({
28+
export const Margins: FC<JSX.IntrinsicElements["div"] & { size?: Size }> = ({
2929
size = "regular",
3030
...divProps
3131
}) => {

site/src/components/RuntimeErrorState/RuntimeErrorState.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Button from "@material-ui/core/Button"
22
import Link from "@material-ui/core/Link"
33
import { makeStyles } from "@material-ui/core/styles"
44
import RefreshOutlined from "@material-ui/icons/RefreshOutlined"
5+
import { BuildInfoResponse } from "api/typesGenerated"
56
import { CoderIcon } from "components/Icons/CoderIcon"
67
import { FullScreenLoader } from "components/Loader/FullScreenLoader"
78
import { Stack } from "components/Stack/Stack"
@@ -51,7 +52,16 @@ export const RuntimeErrorState: FC<{ error: Error }> = ({ error }) => {
5152
Coder Discord community
5253
</Link>{" "}
5354
or{" "}
54-
<Link href="https://github.com/coder/coder/issues/new">
55+
<Link
56+
href={`https://github.com/coder/coder/issues/new?body=${encodeURIComponent(
57+
[
58+
["**Version**", getStaticBuildInfo()].join("\n"),
59+
["**Path**", "`" + location.pathname + "`"].join("\n"),
60+
["**Error**", "```\n" + error.stack + "\n```"].join("\n"),
61+
].join("\n\n"),
62+
)}`}
63+
target="_blank"
64+
>
5565
open an issue
5666
</Link>
5767
.
@@ -78,6 +88,21 @@ export const RuntimeErrorState: FC<{ error: Error }> = ({ error }) => {
7888
)
7989
}
8090

91+
// During the build process, we inject the build info into the HTML
92+
const getStaticBuildInfo = () => {
93+
const buildInfoJson = document
94+
.querySelector("meta[property=build-info]")
95+
?.getAttribute("content")
96+
97+
if (buildInfoJson) {
98+
try {
99+
return JSON.parse(buildInfoJson) as BuildInfoResponse
100+
} catch {
101+
return "-- Set the version --"
102+
}
103+
}
104+
}
105+
81106
const useStyles = makeStyles((theme) => ({
82107
root: {
83108
paddingTop: theme.spacing(4),

0 commit comments

Comments
 (0)