Merge pull request #1630 from Benebo7/feat/environment-section-on-issues

feat: add new autofill environment section on automatic issues
This commit is contained in:
Rohan Verma 2026-07-25 16:23:17 -07:00 committed by GitHub
commit 13ebb562a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import "./globals.css";
import posthog from "posthog-js";
import { useEffect, useMemo } from "react";
import { Button } from "@/components/ui/button";
import { detectEnvironment } from "@/lib/env-config";
const ISSUES_URL = "https://github.com/MODSetter/SurfSense/issues/new";
@ -19,6 +20,7 @@ function buildBasicIssueUrl(error: Error & { digest?: string }) {
"",
`- **Error:** ${error.message}`,
...(error.digest ? [`- **Digest:** \`${error.digest}\``] : []),
`- **Environment:** ${detectEnvironment()}`,
`- **Timestamp:** ${new Date().toISOString()}`,
`- **Page:** \`${typeof window !== "undefined" ? window.location.pathname : "unknown"}\``,
`- **User Agent:** \`${typeof navigator !== "undefined" ? navigator.userAgent : "unknown"}\``,

View file

@ -67,6 +67,21 @@ export const BUILD_TIME_ETL_SERVICE = process.env.NEXT_PUBLIC_ETL_SERVICE || "DO
// DEPLOYMENT_MODE through the runtime config provider first, then falls back to this baked value.
export const BUILD_TIME_DEPLOYMENT_MODE = process.env.NEXT_PUBLIC_DEPLOYMENT_MODE || "self-hosted";
/**
* Detect the environment for diagnostics (e.g. GitHub issue auto-fill).
* Inferred from the hostname so it needs no configuration from the operator.
*
* - "SurfSense Cloud": served from the official SurfSense domain (root + subdomains)
* - "self-hosted": everything else (covers self-hosted and community cloud deploys)
*/
export function detectEnvironment(): "SurfSense Cloud" | "self-hosted" {
const hostname = typeof window !== "undefined" ? window.location.hostname : "";
if (hostname === "surfsense.com" || hostname.endsWith(".surfsense.com")) {
return "SurfSense Cloud";
}
return "self-hosted";
}
// App version - defaults to package.json version
// Can be overridden at build time with NEXT_PUBLIC_APP_VERSION for full git tag version
export const APP_VERSION = process.env.NEXT_PUBLIC_APP_VERSION || packageJson.version;

View file

@ -1,5 +1,6 @@
import { toast } from "sonner";
import { AbortedError, AppError, AuthenticationError, SURFSENSE_ISSUES_URL } from "./error";
import { detectEnvironment } from "./env-config";
/**
* Build a GitHub issue URL pre-filled with diagnostic context.
@ -8,6 +9,8 @@ import { AbortedError, AppError, AuthenticationError, SURFSENSE_ISSUES_URL } fro
export function buildIssueUrl(error: unknown): string {
const params = new URLSearchParams();
const environment = detectEnvironment();
const lines: string[] = ["## Bug Report", "", "**Describe what happened:**", "", ""];
if (error instanceof AppError) {
@ -16,9 +19,11 @@ export function buildIssueUrl(error: unknown): string {
if (error.requestId) lines.push(`- **Request ID:** \`${error.requestId}\``);
if (error.status) lines.push(`- **HTTP status:** ${error.status}`);
lines.push(`- **Message:** ${error.message}`);
lines.push(`- **Environment:** ${environment}`);
} else if (error instanceof Error) {
lines.push("## Diagnostics (auto-filled)", "");
lines.push(`- **Error:** ${error.message}`);
lines.push(`- **Environment:** ${environment}`);
}
lines.push(`- **Timestamp:** ${new Date().toISOString()}`);