feat(feedback): always-on nav button with GitHub/email handoff when analytics is off (#428)

Keep the top-nav feedback button always visible (icon plus label on desktop, icon-only on mobile) instead of hiding it when an instance opts out of analytics. When analytics is off, the dialog keeps the typed message and hands off to a prefilled GitHub issue plus a contact@snapotter.com email, with no fake Thanks. Adds a feedback.yml issue template, URL builders, and feedback strings across all 21 locales.

Claude-Session: https://claude.ai/code/session_01XVrHKXwzZDWBWgkGQdPZ3A
This commit is contained in:
SnapOtter
2026-07-04 17:37:12 +08:00
committed by GitHub
parent 7b04317ed2
commit 5dcc06a99e
28 changed files with 302 additions and 10 deletions
+30
View File
@@ -155,3 +155,33 @@ export function shouldShowUsageSurvey({
export async function submitFeedback(payload: FeedbackPayload): Promise<FeedbackResponse> {
return apiPost<FeedbackResponse>("/v1/feedback", payload);
}
const FEEDBACK_ISSUE_NEW_URL = "https://github.com/snapotter-hq/snapotter/issues/new";
const MAX_FEEDBACK_LEN = 2000;
export const SNAPOTTER_FEEDBACK_EMAIL = "contact@snapotter.com";
/** Normalize newlines, trim, and clamp so the message is safe to put in a URL. */
function sanitizeFeedbackMessage(message: string): string {
return message.replace(/\r\n/g, "\n").trim().slice(0, MAX_FEEDBACK_LEN);
}
/**
* Prefilled GitHub issue URL for general feedback. Blank issues are disabled on
* the repo, so we must target a template by file name; `details` matches the
* `id` of the textarea in `.github/ISSUE_TEMPLATE/feedback.yml`.
*/
export function buildFeedbackGithubUrl(message: string): string {
const params = new URLSearchParams({
template: "feedback.yml",
details: sanitizeFeedbackMessage(message),
});
return `${FEEDBACK_ISSUE_NEW_URL}?${params.toString()}`;
}
/** Prefilled mailto to the project address, for users who prefer a private channel. */
export function buildFeedbackMailtoUrl(message: string): string {
const subject = encodeURIComponent("SnapOtter feedback");
const body = encodeURIComponent(sanitizeFeedbackMessage(message));
return `mailto:${SNAPOTTER_FEEDBACK_EMAIL}?subject=${subject}&body=${body}`;
}