feat(feedback): add problem reporting flow
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import packageInfo from "../../../package.json";
|
||||
|
||||
import type { FeedbackContext } from "@/data/dto/feedback";
|
||||
import { BrowserDetector } from "@/utils/browser-detect";
|
||||
import { PlatformDetector } from "@/utils/platform-detect";
|
||||
|
||||
export function createFeedbackContext(): FeedbackContext {
|
||||
const platform = PlatformDetector.getPlatformInfo();
|
||||
const browser = BrowserDetector.getBrowserInfo();
|
||||
const browserName = browser.inAppBrowserName
|
||||
? `${browser.inAppBrowserName} IAB / ${browser.name}`
|
||||
: browser.name;
|
||||
|
||||
return {
|
||||
appVersion: packageInfo.version,
|
||||
platform: joinContextParts([
|
||||
platform.platform,
|
||||
platform.osName,
|
||||
platform.osVersion,
|
||||
]),
|
||||
browser: joinContextParts([browserName, browser.version]),
|
||||
viewport:
|
||||
typeof window === "undefined"
|
||||
? "unknown"
|
||||
: `${window.innerWidth}x${window.innerHeight}@${window.devicePixelRatio}`,
|
||||
};
|
||||
}
|
||||
|
||||
function joinContextParts(parts: readonly string[]): string {
|
||||
return parts.filter((part) => part.trim().length > 0).join(" ") || "unknown";
|
||||
}
|
||||
Reference in New Issue
Block a user