Skip to content

Commit

Permalink
Browser compat debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
N2D4 committed Dec 11, 2024
1 parent 6bf2c2b commit 032bc7c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/backend/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";
import { getBrowserCompatibilityProblems } from "@stackframe/stack-shared/dist/utils/browser-compat";
import { nicify } from "@stackframe/stack-shared/dist/utils/strings";

Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,

Expand Down Expand Up @@ -54,6 +54,7 @@ Sentry.init({
...error,
},
nicifiedError: nicified,
clientBrowserCompatibility: getBrowserCompatibilityProblems(),
};
}
return event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
import { UserTable } from "@/components/data-table/user-table";
import { StyledLink } from "@/components/link";
import { UserDialog } from "@/components/user-dialog";
import { getBrowserCompatibilityProblems } from "@stackframe/stack-shared/dist/utils/browser-compat";
import { Alert, Button } from "@stackframe/stack-ui";
import { PageLayout } from "../page-layout";
import { useAdminApp } from "../use-admin-app";


export default function PageClient() {
const stackAdminApp = useAdminApp();
const project = stackAdminApp.useProject();
const firstUser = stackAdminApp.useUsers({ limit: 1 });

console.log(getBrowserCompatibilityProblems());


return (
<PageLayout
title="Users"
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/app/page-client.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

import { useRouter } from 'next/navigation';
import { useStackApp, useUser } from '@stackframe/stack';
import { Button, Link, Typography } from '@stackframe/stack-ui';
import { useRouter } from 'next/navigation';

export default function PageClient() {
const user = useUser();
Expand Down
17 changes: 17 additions & 0 deletions packages/stack-shared/src/utils/browser-compat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export function getBrowserCompatibilityProblems() {
const test = (snippet: string) => {
try {
(0, eval)(snippet);
return null;
} catch (e) {
return `FAILED: ${e}`;
}
};

return {
optionalChaining: test("({})?.b?.c"),
nullishCoalescing: test("0 ?? 1"),
weakRef: test("new WeakRef({})"),
cryptoUuid: test("crypto.randomUUID()"),
};
}

0 comments on commit 032bc7c

Please sign in to comment.