stack/apps/dashboard/src/app/client-polyfill.tsx
Stan Wohlwend 1e051c1bbf
Some checks are pending
Runs E2E API Tests / build (20.x) (push) Waiting to run
Lint & build / lint_and_build (18.x) (push) Waiting to run
Lint & build / lint_and_build (20.x) (push) Waiting to run
Fix suspense error on dashboard
2024-07-26 17:08:20 -07:00

30 lines
648 B
TypeScript

"use client";
import * as Sentry from "@sentry/nextjs";
import { useUser } from "@stackframe/stack";
import { Suspense, useEffect } from "react";
// ensure that the polyfills are loaded even on the client
import "../polyfills";
export function ClientPolyfill() {
return <Suspense fallback={null}><InnerClientPolyfill /></Suspense>;
}
function InnerClientPolyfill() {
const user = useUser();
useEffect(() => {
Sentry.setUser(user ? {
id: user.id,
username: user.displayName ?? user.primaryEmail ?? user.id,
email: user.primaryEmail ?? undefined,
} : null);
return () => {};
}, [user]);
return null;
}