Skip to content

feat: add GlitchTip integration and error handling - #3

Merged
ladaniprem merged 1 commit into
masterfrom
04-Organization-and-05-error-tracking-with-bug
Jun 11, 2026
Merged

ladaniprem merged 1 commit into
masterfrom
04-Organization-and-05-error-tracking-with-bug

Conversation

@ladaniprem

@ladaniprem ladaniprem commented Jun 11, 2026

Copy link
Copy Markdown
Owner
  • Implemented GlitchTip tunnel route for Sentry SDK envelope requests.
  • Created example API route to test server-side error monitoring with GlitchTip.
  • Added global error handling component to capture exceptions with Sentry.
  • Developed a test page for sending errors to GlitchTip.
  • Introduced authentication guards and organization selection views for user management.
  • Implemented infinite scroll hook for loading more data efficiently.
  • Added mobile detection hook for responsive design.
  • Configured Sentry for client, server, and edge environments.
  • Established layouts for dashboard and conversations with resizable panels.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added error monitoring and reporting system for improved app stability tracking
    • Introduced organization selection flow for multi-organization support
    • Added resizable dashboard panels for customizable conversation layout
    • Enhanced mobile responsiveness detection
  • Bug Fixes

    • Improved global error handling and display
  • Style

    • Updated typography and design tokens for refined visual appearance

- Implemented GlitchTip tunnel route for Sentry SDK envelope requests.
- Created example API route to test server-side error monitoring with GlitchTip.
- Added global error handling component to capture exceptions with Sentry.
- Developed a test page for sending errors to GlitchTip.
- Introduced authentication guards and organization selection views for user management.
- Implemented infinite scroll hook for loading more data efficiently.
- Added mobile detection hook for responsive design.
- Configured Sentry for client, server, and edge environments.
- Established layouts for dashboard and conversations with resizable panels.
Copilot AI review requested due to automatic review settings June 11, 2026 17:08
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 5520ac7a-fe34-4607-bf74-1306db53dd23

📥 Commits

Reviewing files that changed from the base of the PR and between 43bd44d and 2a83635.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (29)
  • apps/web/.mcp.json
  • apps/web/app/(auth)/layout.tsx
  • apps/web/app/(auth)/org-selection/[[...org-selection]]/page.tsx
  • apps/web/app/(dashboard)/layout.tsx
  • apps/web/app/(dashboard)/page.tsx
  • apps/web/app/api/glitchtip-tunnel/route.ts
  • apps/web/app/api/sentry-example-api/route.ts
  • apps/web/app/global-error.tsx
  • apps/web/app/layout.tsx
  • apps/web/app/sentry-example-page/page.tsx
  • apps/web/hooks/use-infinite-scroll.ts
  • apps/web/hooks/use-moblie.ts
  • apps/web/instrumentation-client.ts
  • apps/web/instrumentation.ts
  • apps/web/modules/auth/ui/components/auth-guard.tsx
  • apps/web/modules/auth/ui/components/organization-guard.tsx
  • apps/web/modules/auth/ui/layouts/auth-layout.tsx
  • apps/web/modules/auth/ui/views/org-selection-view.tsx
  • apps/web/modules/auth/ui/views/sign-in-view.tsx
  • apps/web/modules/auth/ui/views/sign-up-view.tsx
  • apps/web/modules/dashboard/layouts/conversations-layout.tsx
  • apps/web/next.config.ts
  • apps/web/package.json
  • apps/web/proxy.ts
  • apps/web/sentry.edge.config.ts
  • apps/web/sentry.server.config.ts
  • apps/widget/app/layout.tsx
  • packages/backend/convex/users.ts
  • packages/ui/src/styles/globals.css

📝 Walkthrough

Walkthrough

This PR implements Clerk-based authentication with organization gating, integrates Sentry/GlitchTip error monitoring across server and client, adds utility hooks for infinite scroll and mobile detection, updates design tokens to Tailwind v4, and includes backend org context validation with a test tracking error.

Changes

Authentication & Organization Architecture

Layer / File(s) Summary
Auth guard components and view components
apps/web/modules/auth/ui/components/auth-guard.tsx, apps/web/modules/auth/ui/components/organization-guard.tsx, apps/web/modules/auth/ui/layouts/auth-layout.tsx, apps/web/modules/auth/ui/views/org-selection-view.tsx, apps/web/modules/auth/ui/views/sign-in-view.tsx, apps/web/modules/auth/ui/views/sign-up-view.tsx
AuthGuard and OrganizationGuard components conditionally render UI based on Convex and Clerk auth state; view components wrap Clerk's SignIn, SignUp, and OrganizationList with hash routing and org-selection URLs.
Route layouts and page structure
apps/web/app/(auth)/layout.tsx, apps/web/app/(auth)/org-selection/[[...org-selection]]/page.tsx, apps/web/app/(dashboard)/layout.tsx, apps/web/app/(dashboard)/page.tsx
Auth and dashboard layouts use AuthGuard and OrganizationGuard to gate content; org-selection route provides catch-all page; dashboard page removes Convex auth wrappers and renders Clerk header unconditionally.
Clerk middleware and org-selection routing
apps/web/proxy.ts
Middleware extends public routes to include /api/glitchtip-tunnel, defines org-free routes, and redirects authenticated users without orgId to /org-selection with the original URL as redirectUrl parameter.

Error Monitoring & Sentry Integration

Layer / File(s) Summary
Sentry initialization and configuration modules
apps/web/instrumentation.ts, apps/web/instrumentation-client.ts, apps/web/sentry.server.config.ts, apps/web/sentry.edge.config.ts, apps/web/next.config.ts, apps/web/package.json
Adds runtime-aware Sentry initialization (server, edge, client), GlitchTip DSN configuration, tracesSampleRate: 0.01 for production sampling, next.config integration with withSentryConfig for source-map uploads, and @sentry/nextjs dependency.
Error monitoring endpoints and test page
apps/web/app/api/glitchtip-tunnel/route.ts, apps/web/app/api/sentry-example-api/route.ts, apps/web/app/global-error.tsx, apps/web/app/sentry-example-page/page.tsx
POST endpoint proxies Sentry envelopes via /api/glitchtip-tunnel to avoid ad-blockers; GET endpoint /api/sentry-example-api throws test error for server monitoring; global-error.tsx captures unhandled errors via Sentry; test page provides UI to manually trigger client and server error reporting flows.

UI Infrastructure, Hooks, and Design Tokens

Layer / File(s) Summary
Utility hooks for scroll and viewport
apps/web/hooks/use-infinite-scroll.ts, apps/web/hooks/use-moblie.ts
useInfiniteScroll hook with IntersectionObserver-based pagination (loadMore callback on intersection, configurable threshold/size); useIsMobile hook detects viewport width against 768px breakpoint via matchMedia.
Dashboard and layout components
apps/web/modules/dashboard/layouts/conversations-layout.tsx
ConversationsLayout renders horizontally resizable two-panel layout with fixed left sidebar (ConversationsPanel, 30% default) and right content panel via ResizablePanelGroup and ResizableHandle.
Font configuration updates
apps/web/app/layout.tsx, apps/widget/app/layout.tsx
Updates Geist and Geist Mono fonts to use CSS variables --font-geist-sans and --font-geist-mono; sets preload: false on Mono font.
Global design tokens and Tailwind v4 setup
packages/ui/src/styles/globals.css
Imports Tailwind v4 core, removes shadcn/tailwind.css, adds @source globs and dark variant; refreshes :root and .dark color palettes with Oklch values; reduces radius tokens to --radius-sm/md/lg/xl and adds shadow mappings; extends base-layer styling with button cursor and body typography.
Development configuration
apps/web/.mcp.json
Adds MCP server configuration for next-devtools via npx.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop into Auth, where Clerk and guards align,
Errors caught by Sentry, through tunnels they shine,
Hooks scroll infinite, mobile views now fleet,
Tokens in Tailwind make the design complete!


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@ladaniprem
ladaniprem merged commit c533a7f into master Jun 11, 2026
2 of 3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR integrates GlitchTip (via the Sentry Next.js SDK) into the apps/web Next.js app for client/server/edge error reporting (including a tunnel route), and adds initial auth/org-guard UI plus a couple of reusable UI/layout hooks/components.

Changes:

  • Add Sentry/GlitchTip SDK setup (client + server + edge), a tunnel API route, and a global error boundary to capture unhandled exceptions.
  • Add auth/org selection views and guards, plus Clerk middleware logic (route protection + org selection redirect) and dashboard layout scaffolding.
  • Add utility hooks (infinite scroll + mobile detection) and a resizable conversations layout.

Reviewed changes

Copilot reviewed 29 out of 30 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
pnpm-lock.yaml Locks new Sentry/GlitchTip-related dependencies (and transitive deps).
packages/ui/src/styles/globals.css Updates global theme tokens, fonts, and base styles for UI consistency.
packages/backend/convex/users.ts Adds org presence check (but currently includes a breaking test throw).
apps/widget/app/layout.tsx Aligns font CSS variable names with updated global styles.
apps/web/sentry.server.config.ts Initializes Sentry/GlitchTip on the server runtime.
apps/web/sentry.edge.config.ts Initializes Sentry/GlitchTip for edge runtime features.
apps/web/proxy.ts Adds Clerk middleware logic for public routes + org redirect (but file naming may prevent execution).
apps/web/package.json Adds @sentry/nextjs dependency.
apps/web/next.config.ts Wraps Next config with withSentryConfig for source map upload support.
apps/web/modules/dashboard/layouts/conversations-layout.tsx Introduces a resizable split-panel layout for conversations.
apps/web/modules/auth/ui/views/sign-up-view.tsx Adds a Clerk sign-up view wrapper.
apps/web/modules/auth/ui/views/sign-in-view.tsx Adds a Clerk sign-in view wrapper.
apps/web/modules/auth/ui/views/org-selection-view.tsx Adds a Clerk org selection view wrapper.
apps/web/modules/auth/ui/layouts/auth-layout.tsx Adds a centered auth layout wrapper used by guards/views.
apps/web/modules/auth/ui/components/organization-guard.tsx Adds client-side org selection gating.
apps/web/modules/auth/ui/components/auth-guard.tsx Adds client-side auth gating using Convex auth components.
apps/web/instrumentation.ts Registers runtime-specific Sentry config imports (node/edge).
apps/web/instrumentation-client.ts Initializes Sentry/GlitchTip on the client and configures tunneling.
apps/web/hooks/use-moblie.ts Adds a mobile detection hook (filename typo).
apps/web/hooks/use-infinite-scroll.ts Adds an IntersectionObserver-based infinite scroll hook.
apps/web/app/sentry-example-page/page.tsx Adds a UI page to generate test events for GlitchTip.
apps/web/app/layout.tsx Updates font variable names and layout formatting.
apps/web/app/global-error.tsx Adds global error component capturing exceptions with Sentry.
apps/web/app/api/sentry-example-api/route.ts Adds an API route that intentionally throws to test server-side reporting.
apps/web/app/api/glitchtip-tunnel/route.ts Adds an envelope tunnel route to proxy SDK traffic through the app.
apps/web/app/(dashboard)/page.tsx Updates dashboard page to use Clerk org switcher and simplified UI.
apps/web/app/(dashboard)/layout.tsx Adds auth/org guards wrapper (currently broken due to return newline).
apps/web/app/(auth)/org-selection/[[...org-selection]]/page.tsx Adds org selection route page.
apps/web/app/(auth)/layout.tsx Cleans up auth layout formatting.
apps/web/.mcp.json Adds MCP tooling configuration for local dev tooling.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +16
const Layout = ({children}:{children: React.ReactNode}) => {
return
(
<AuthGuard>
<OrganizationGuard>
{children}
</OrganizationGuard>
</AuthGuard>
)
}

export default Layout No newline at end of file
Comment on lines +25 to 26
throw new Error("Tracking Test");
const userId = await ctx.db.insert("users", {
Comment on lines +3 to +12
const DSN = "https://02cb8f8361b24d65a90ce7749a7665a3@app.glitchtip.com/24553";

/**
* GlitchTip tunnel route — proxies Sentry SDK envelope requests through
* this server to avoid ad-blockers blocking direct calls to app.glitchtip.com.
*
* Referenced in instrumentation-client.ts via `tunnel: "/api/glitchtip-tunnel"`.
*/
export async function POST(req: NextRequest) {
const dsn = new URL(DSN);
Comment on lines +7 to +16
Sentry.init({
dsn: "https://02cb8f8361b24d65a90ce7749a7665a3@app.glitchtip.com/24553",


// Set a low sample rate in production to save disk space (1%)
tracesSampleRate: 0.01,

// Route events through our own API to avoid ad-blockers
tunnel: "/api/glitchtip-tunnel",
});
Comment on lines +7 to +13
Sentry.init({
dsn: "https://02cb8f8361b24d65a90ce7749a7665a3@app.glitchtip.com/24553",

// Set a low sample rate in production to save disk space (1%)
tracesSampleRate: 0.01,

});
Comment on lines +7 to +13
Sentry.init({
dsn: "https://02cb8f8361b24d65a90ce7749a7665a3@app.glitchtip.com/24553",

// Set a low sample rate in production to save disk space (1%)
tracesSampleRate: 0.01,

});
Comment on lines +10 to +15
// A faulty API route to test GlitchTip's server-side error monitoring
export function GET() {
throw new SentryExampleAPIError(
"This error is raised on the backend called by the GlitchTip example page.",
);
}
Comment on lines +13 to +14
export default function Page() {
const [status, setStatus] = useState<"idle" | "sent" | "error">("idle");
@@ -0,0 +1,70 @@
import * as React from "react"
Comment thread apps/web/proxy.ts
Comment on lines +1 to 3
import { NextResponse } from 'next/server';
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants