Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(about): copy your environment #649

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/renderer/src/lib/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { detectBrowser, getOS } from "./utils"

export const getCurrentEnvironment = () => {
const ua = navigator.userAgent
const appVersion = APP_VERSION
const env = window.electron ? "electron" : "web"
const os = getOS()
const browser = detectBrowser()

return [
"### Environment",
"",
`**App Version**: ${appVersion}`,
`**OS**: ${os}`,
`**User Agent**: ${ua}`,
`**Env**: ${env}`,
`**Browser**: ${browser}`,
]
}
20 changes: 2 additions & 18 deletions apps/renderer/src/lib/issues.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { repository } from "@pkg"

import { detectBrowser, getOS } from "./utils"
import { getCurrentEnvironment } from "./environment"

interface IssueOptions {
title: string
Expand All @@ -12,23 +12,7 @@ export const getNewIssueUrl = ({ body, label, title }: Partial<IssueOptions> = {

const searchParams = new URLSearchParams()

const ua = navigator.userAgent
const appVersion = APP_VERSION
const env = window.electron ? "electron" : "web"
const os = getOS()
const browser = detectBrowser()

const nextBody = [
body || "",
"",
"### Environment",
"",
`**App Version**: ${appVersion}`,
`**OS**: ${os}`,
`**User Agent**: ${ua}`,
`**Env**: ${env}`,
`**Browser**: ${browser}`,
].join("\n")
const nextBody = [body || "", "", ...getCurrentEnvironment()].join("\n")
searchParams.set("body", nextBody)
if (label) searchParams.set("label", label)
if (title) searchParams.set("title", title)
Expand Down
6 changes: 5 additions & 1 deletion apps/renderer/src/modules/settings/tabs/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import { Trans, useTranslation } from "react-i18next"
import { Logo } from "~/components/icons/logo"
import { Button } from "~/components/ui/button"
import { styledButtonVariant } from "~/components/ui/button/variants"
import { CopyButton } from "~/components/ui/code-highlighter"
import { Divider } from "~/components/ui/divider"
import { SocialMediaLinks } from "~/constants/social"
import { getCurrentEnvironment } from "~/lib/environment"
import { getNewIssueUrl } from "~/lib/issues"

import { SettingsTitle } from "../title"

export const SettingAbout = () => {
const { t } = useTranslation("settings")
const currentEnvironment = getCurrentEnvironment().join("\n")

return (
<div>
Expand All @@ -24,8 +27,9 @@ export const SettingAbout = () => {
<div className="text-lg font-bold">
{APP_NAME} {!import.meta.env.PROD ? `(${import.meta.env.MODE})` : ""}
</div>
<div>
<div className="flex items-center gap-2">
<span className="rounded bg-muted px-2 py-1 text-xs">{APP_VERSION}</span>
<CopyButton value={currentEnvironment} className="p-1 [&_i]:size-2.5" />
</div>
</div>

Expand Down
Loading