Files
wizwar6e/packages/web/src/main.ts
T
Eric WagonerandClaude Fable 5.1 5c956c24bb Sentry ignores the in-app browser's own scripts
Facebook's Android browser injects a performance logger under iabjs://
and its bridge dies on unload; the error wore our name (WIZWAR-6).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
2026-09-07 15:31:33 -05:00

38 lines
1.5 KiB
TypeScript

import { mount } from "svelte";
import * as Sentry from "@sentry/browser";
// Errors only — no tracing, no replay. Without a DSN baked at build time
// (VITE_SENTRY_DSN in .env.production) this is entirely inert.
if (import.meta.env.VITE_SENTRY_DSN) {
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
environment: "production",
// Facebook's in-app browser injects its own scripts (iabjs://) and
// reports their failures as ours when the page unloads.
denyUrls: [/^iabjs:\/\//],
ignoreErrors: ["Java object is gone"],
});
}
// A page loaded before a deploy may ask for a chunk the deploy retired.
// Vite reports the failed import here; one reload fetches the live bundle.
// The flag keeps a broken build from reloading forever.
window.addEventListener("vite:preloadError", (e) => {
e.preventDefault();
try {
if (sessionStorage.getItem("wizwar-reloaded")) return;
sessionStorage.setItem("wizwar-reloaded", "1");
} catch { /* storage may be unavailable; reload anyway */ }
location.reload();
});
try { sessionStorage.removeItem("wizwar-reloaded"); } catch { /* ignore */ }
// /watch/<id> is the public share page — one turn, anyone may look. It
// loads its own component so the full app (and its live socket appetite)
// stays out of a shared link's way.
const target = document.getElementById("app")!;
const page = location.pathname.startsWith("/watch/")
? import("./SharePage.svelte")
: import("./App.svelte");
page.then(({ default: Root }) => mount(Root, { target }));