2022-05-14 10:22:06 +00:00
|
|
|
import { hydrate } from "react-dom";
|
|
|
|
import { RemixBrowser } from "@remix-run/react";
|
2022-06-26 15:01:55 +00:00
|
|
|
import * as Sentry from "@sentry/browser";
|
|
|
|
import { Integrations } from "@sentry/tracing";
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
shellphoneConfig: {
|
|
|
|
sentry: { dsn: string };
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Sentry.init({
|
|
|
|
dsn: window.shellphoneConfig.sentry.dsn,
|
|
|
|
tracesSampleRate: 1.0,
|
|
|
|
integrations: [new Integrations.BrowserTracing()],
|
|
|
|
});
|
2022-05-14 10:22:06 +00:00
|
|
|
|
|
|
|
hydrate(<RemixBrowser />, document);
|
2022-05-30 00:21:42 +00:00
|
|
|
|
|
|
|
if ("serviceWorker" in navigator) {
|
|
|
|
window.addEventListener("load", async () => {
|
|
|
|
try {
|
|
|
|
await navigator.serviceWorker.register("/entry.worker.js");
|
|
|
|
await navigator.serviceWorker.ready;
|
2022-06-05 22:01:33 +00:00
|
|
|
|
|
|
|
if (navigator.serviceWorker.controller) {
|
|
|
|
return navigator.serviceWorker.controller.postMessage({
|
|
|
|
type: "SYNC_REMIX_MANIFEST",
|
|
|
|
manifest: window.__remixManifest,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
|
|
navigator.serviceWorker.controller?.postMessage({
|
|
|
|
type: "SYNC_REMIX_MANIFEST",
|
|
|
|
manifest: window.__remixManifest,
|
|
|
|
});
|
|
|
|
});
|
2022-05-30 00:21:42 +00:00
|
|
|
} catch (error) {
|
|
|
|
console.error("Service worker registration failed", error, (error as Error).name);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|