Improve ops monitoring and chart loading

This commit is contained in:
2569718930@qq.com
2026-05-31 03:21:58 +08:00
parent ca72072da0
commit 2a6d8748f4
38 changed files with 3110 additions and 637 deletions
+15
View File
@@ -11,6 +11,7 @@ type TrackableAnalyticsEvent =
| "trial_created"
| "payment_start"
| "payment_success"
| "degraded_auth_profile"
| "signup_completed"
| "dashboard_active"
| "paywall_feature_clicked"
@@ -41,6 +42,15 @@ function getStoredId(storage: Storage, key: string) {
return value;
}
function getDeviceType() {
if (!isClient()) return "unknown";
const width = window.innerWidth || 0;
const ua = navigator.userAgent || "";
if (/ipad|tablet/i.test(ua) || (width >= 768 && width < 1100)) return "tablet";
if (/mobi|android|iphone/i.test(ua) || width < 768) return "mobile";
return "desktop";
}
export function getAnalyticsClientId() {
if (!isClient()) return "";
try {
@@ -88,6 +98,11 @@ export function trackAppEvent(
...payload,
path: window.location.pathname,
href: window.location.href,
referrer: document.referrer || "",
language: navigator.language || "",
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || "",
device_type: getDeviceType(),
viewport: `${window.innerWidth || 0}x${window.innerHeight || 0}`,
captured_at: new Date().toISOString(),
},
};