Simpl-Resultat/src/services/feedbackService.ts
maximus 4f4ab87bea feat: feedback hub widget in Settings Logs card (#67)
Closes #67

Add opt-in Feedback Hub widget integrated into the Settings Logs card. Routes through a Rust command to bypass CORS and centralize privacy audit. First submission triggers a one-time consent dialog; three opt-in checkboxes (context, logs, identify with Maximus account) all unchecked by default. Wording and payload follow the cross-app conventions in la-compagnie-maximus/docs/feedback-hub-ops.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 14:36:26 +00:00

50 lines
1.1 KiB
TypeScript

import { invoke } from "@tauri-apps/api/core";
export type FeedbackErrorCode =
| "invalid"
| "rate_limit"
| "server_error"
| "network_error";
export interface FeedbackContext {
page?: string;
locale?: string;
theme?: string;
viewport?: string;
userAgent?: string;
timestamp?: string;
}
export interface FeedbackSuccess {
id: string;
created_at: string;
}
export interface SendFeedbackInput {
content: string;
userId?: string | null;
context?: FeedbackContext;
}
export async function sendFeedback(
input: SendFeedbackInput,
): Promise<FeedbackSuccess> {
return invoke<FeedbackSuccess>("send_feedback", {
content: input.content,
userId: input.userId ?? null,
context: input.context ?? null,
});
}
export async function getFeedbackUserAgent(): Promise<string> {
return invoke<string>("get_feedback_user_agent");
}
export function isFeedbackErrorCode(value: unknown): value is FeedbackErrorCode {
return (
value === "invalid" ||
value === "rate_limit" ||
value === "server_error" ||
value === "network_error"
);
}