-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathmain.tsx
More file actions
69 lines (61 loc) · 2.21 KB
/
main.tsx
File metadata and controls
69 lines (61 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React from "react";
import ReactDOM from "react-dom/client";
import { installBrowserLogCapture } from "@/browser/utils/browserLog";
import { installWindowOpenLocalhostProxyNormalization } from "@/browser/utils/windowOpenLocalhostProxy";
import { AppLoader } from "@/browser/components/AppLoader/AppLoader";
import { initTelemetry, trackAppStarted } from "@/common/telemetry";
import { initTitlebarInsets } from "@/browser/hooks/useDesktopTitlebar";
import { resolveBrowserAssetUrl } from "@/browser/utils/frontendBasePath";
// Initialize telemetry on app startup
try {
installBrowserLogCapture();
} catch {
// Silent failure — never crash the app for logging capture
}
installWindowOpenLocalhostProxyNormalization();
initTelemetry();
trackAppStarted();
// Initialize titlebar CSS custom properties (platform-specific insets)
initTitlebarInsets();
// Global error handlers for renderer process
// These catch errors that escape the ErrorBoundary
window.addEventListener("error", (event) => {
console.error("Uncaught error in renderer:", event.error);
console.error("Error details:", {
message: event.message,
filename: event.filename,
lineno: event.lineno,
colno: event.colno,
error: event.error,
stack: event.error?.stack,
});
});
window.addEventListener("unhandledrejection", (event) => {
console.error("Unhandled promise rejection in renderer:", event.reason);
console.error("Promise:", event.promise);
if (event.reason instanceof Error) {
console.error("Stack:", event.reason.stack);
}
});
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<AppLoader />
</React.StrictMode>
);
// Register service worker for PWA support
if ("serviceWorker" in navigator) {
const isHttpProtocol =
window.location.protocol === "http:" || window.location.protocol === "https:";
if (isHttpProtocol) {
window.addEventListener("load", () => {
navigator.serviceWorker
.register(resolveBrowserAssetUrl("service-worker.js"))
.then((registration) => {
console.log("Service Worker registered:", registration);
})
.catch((error) => {
console.log("Service Worker registration failed:", error);
});
});
}
}