The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/setup sentry for www (#37894)
Joshen Lim20f24718190f
diff --git a/apps/www/app/api-v2/luma-events/route.tsx b/apps/www/app/api-v2/luma-events/route.tsxindex 9d7fc28ddc6..ffd30e14daa 100644--- a/apps/www/app/api-v2/luma-events/route.tsx+++ b/apps/www/app/api-v2/luma-events/route.tsx@@ -1,3 +1,4 @@+import * as Sentry from '@sentry/nextjs'import { NextRequest, NextResponse } from 'next/server'export interface LumaGeoAddressJson {@@ -115,6 +116,7 @@ export async function GET(request: NextRequest) {},})} catch (error) {+ Sentry.captureException(error)console.error('Error fetching meetups from Luma:', error)return NextResponse.json({diff --git a/apps/www/app/api-v2/opt-out/[ref]/route.ts b/apps/www/app/api-v2/opt-out/[ref]/route.tsindex 9028a6934b2..8cc41ee481d 100644--- a/apps/www/app/api-v2/opt-out/[ref]/route.ts+++ b/apps/www/app/api-v2/opt-out/[ref]/route.ts@@ -1,5 +1,6 @@-import { NextRequest, NextResponse } from 'next/server'+import * as Sentry from '@sentry/nextjs'import { createClient } from '@supabase/supabase-js'+import { NextRequest, NextResponse } from 'next/server'const supabaseUrl = process.env.NEXT_PUBLIC_EMAIL_ABUSE_URL as stringconst supabaseServiceKey = process.env.EMAIL_ABUSE_SERVICE_KEY as string@@ -78,7 +79,9 @@ export async function POST(req: NextRequest, props: { params: Promise<{ ref: str.from('manual_reports').insert([{ project_ref: ref, reason, email }])- if (supabaseError) throw new Error(`Supabase error: ${supabaseError.message}`)+ if (supabaseError) {+ throw new Error(`Supabase error: ${supabaseError.message}`)+ }const response = await fetch(process.env.EMAIL_REPORT_SLACK_WEBHOOK as string, {method: 'POST',@@ -93,6 +96,7 @@ export async function POST(req: NextRequest, props: { params: Promise<{ ref: str{ status: 200 })} catch (error) {+ Sentry.captureException(error)const errorMessage = (error as Error).messagereturn NextResponse.json({ error: `Failure: Could not send post to Slack. Error: ${errorMessage}` },diff --git a/apps/www/app/api-v2/submit-form-contact-sales/route.tsx b/apps/www/app/api-v2/submit-form-contact-sales/route.tsxindex 4f2e1aed08e..a8e2ef53720 100644--- a/apps/www/app/api-v2/submit-form-contact-sales/route.tsx+++ b/apps/www/app/api-v2/submit-form-contact-sales/route.tsx@@ -1,3 +1,5 @@+import * as Sentry from '@sentry/nextjs'+const corsHeaders = {'Access-Control-Allow-Origin': '*','Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',@@ -92,6 +94,7 @@ export async function POST(req: Request) {if (!response.ok) {const errorData = await response.json()+ Sentry.captureException(errorData)return new Response(JSON.stringify({ message: errorData.message }), {headers: { ...corsHeaders, 'Content-Type': 'application/json' },status: response.status,@@ -103,6 +106,7 @@ export async function POST(req: Request) {status: 200,})} catch (error: any) {+ Sentry.captureException(error)return new Response(JSON.stringify({ error: error.message }), {headers: { ...corsHeaders, 'Content-Type': 'application/json' },status: 500,diff --git a/apps/www/app/api-v2/submit-form-sos2025-newsletter/route.tsx b/apps/www/app/api-v2/submit-form-sos2025-newsletter/route.tsxindex 856845ad620..ed9c6a668eb 100644--- a/apps/www/app/api-v2/submit-form-sos2025-newsletter/route.tsx+++ b/apps/www/app/api-v2/submit-form-sos2025-newsletter/route.tsx@@ -1,3 +1,5 @@+import * as Sentry from '@sentry/nextjs'+const corsHeaders = {'Access-Control-Allow-Origin': '*','Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',@@ -56,6 +58,7 @@ export async function POST(req: Request) {if (!response.ok) {const errorData = await response.json()+ Sentry.captureException(errorData)return new Response(JSON.stringify({ message: errorData.message }), {headers: { ...corsHeaders, 'Content-Type': 'application/json' },status: response.status,@@ -67,6 +70,7 @@ export async function POST(req: Request) {status: 200,})} catch (error: any) {+ Sentry.captureException(error)return new Response(JSON.stringify({ error: error.message }), {headers: { ...corsHeaders, 'Content-Type': 'application/json' },status: 500,diff --git a/apps/www/app/api-v2/submit-form-talk-to-partnership/route.tsx b/apps/www/app/api-v2/submit-form-talk-to-partnership/route.tsxindex b41b9064300..a4d65619280 100644--- a/apps/www/app/api-v2/submit-form-talk-to-partnership/route.tsx+++ b/apps/www/app/api-v2/submit-form-talk-to-partnership/route.tsx@@ -1,3 +1,5 @@+import * as Sentry from '@sentry/nextjs'+const corsHeaders = {'Access-Control-Allow-Origin': '*','Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',@@ -91,6 +93,7 @@ export async function POST(req: Request) {if (!response.ok) {const errorData = await response.json()+ Sentry.captureException(errorData)return new Response(JSON.stringify({ message: errorData.message }), {headers: { ...corsHeaders, 'Content-Type': 'application/json' },status: response.status,@@ -102,6 +105,7 @@ export async function POST(req: Request) {status: 200,})} catch (error: any) {+ Sentry.captureException(error)return new Response(JSON.stringify({ error: error.message }), {headers: { ...corsHeaders, 'Content-Type': 'application/json' },status: 500,diff --git a/apps/www/app/api-v2/ticket-og/route.tsx b/apps/www/app/api-v2/ticket-og/route.tsxindex 61f4cc0fdeb..6c9ba7807a3 100644--- a/apps/www/app/api-v2/ticket-og/route.tsx+++ b/apps/www/app/api-v2/ticket-og/route.tsx@@ -1,6 +1,6 @@-import React from 'react'-import { ImageResponse } from '@vercel/og'+import * as Sentry from '@sentry/nextjs'import { createClient } from '@supabase/supabase-js'+import { ImageResponse } from '@vercel/og'import useTicketBg from 'components/LaunchWeek/15/hooks/use-ticket-bg'export const runtime = 'edge' // 'nodejs' is the default@@ -501,6 +501,9 @@ export async function GET(req: Request, res: Response) {return await fetch(`${STORAGE_URL}/og/${ticketType}/${username}.png?t=${NEW_TIMESTAMP}`)} catch (error: any) {+ Sentry.captureException(error)+ await Sentry.flush(2000)+return new Response(JSON.stringify({ error: error.message }), {headers: { ...corsHeaders, 'Content-Type': 'application/json' },status: 400,diff --git a/apps/www/instrumentation.ts b/apps/www/instrumentation.tsnew file mode 100644index 00000000000..3063091e693--- /dev/null+++ b/apps/www/instrumentation.ts@@ -0,0 +1,13 @@+import * as Sentry from '@sentry/nextjs'++export async function register() {+ if (process.env.NEXT_RUNTIME === 'nodejs') {+ await import('./sentry.server.config')+ }++ if (process.env.NEXT_RUNTIME === 'edge') {+ await import('./sentry.edge.config')+ }+}++export const onRequestError = Sentry.captureRequestErrordiff --git a/apps/www/next.config.mjs b/apps/www/next.config.mjsindex a04689a8a98..88390c9889d 100644--- a/apps/www/next.config.mjs+++ b/apps/www/next.config.mjs@@ -1,5 +1,6 @@import bundleAnalyzer from '@next/bundle-analyzer'import nextMdx from '@next/mdx'+import { withSentryConfig } from '@sentry/nextjs'import rehypeSlug from 'rehype-slug'import remarkGfm from 'remark-gfm'@@ -124,11 +125,37 @@ const nextConfig = {}// next.config.js.-export default () => {+const configExport = () => {const plugins = [withContentlayer, withMDX, withBundleAnalyzer]return plugins.reduce((acc, next) => next(acc), nextConfig)}+export default withSentryConfig(configExport, {+ // For all available options, see:+ // https://www.npmjs.com/package/@sentry/webpack-plugin#options++ org: 'supabase',+ project: 'www',++ // Only print logs for uploading source maps in CI+ silent: !process.env.CI,++ // For all available options, see:+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/++ // Upload a larger set of source maps for prettier stack traces (increases build time)+ widenClientFileUpload: true,++ // Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.+ // This can increase your server load as well as your hosting bill.+ // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-+ // side errors will fail.+ // tunnelRoute: "/monitoring",++ // Automatically tree-shake Sentry logger statements to reduce bundle size+ disableLogger: true,+})+function getAssetPrefix() {// If not force enabled, but not production env, disable CDNif (process.env.FORCE_ASSET_CDN !== '1' && process.env.VERCEL_ENV !== 'production') {diff --git a/apps/www/package.json b/apps/www/package.jsonindex a35b815912b..6f63357f1c5 100644--- a/apps/www/package.json+++ b/apps/www/package.json@@ -30,6 +30,7 @@"@octokit/plugin-paginate-graphql": "^4.0.0","@octokit/rest": "^21.0.0","@radix-ui/react-dialog": "^1.0.5",+ "@sentry/nextjs": "^10","@supabase/supabase-js": "catalog:","@vercel/og": "^0.6.2","ai-commands": "workspace:*",diff --git a/apps/www/sentry.edge.config.ts b/apps/www/sentry.edge.config.tsnew file mode 100644index 00000000000..9bc4d3e1e64--- /dev/null+++ b/apps/www/sentry.edge.config.ts@@ -0,0 +1,16 @@+// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).+// The config you add here will be used whenever one of the edge features is loaded.+// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.+// https://docs.sentry.io/platforms/javascript/guides/nextjs/++import * as Sentry from '@sentry/nextjs'++Sentry.init({+ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,++ // Enable logs to be sent to Sentry+ enableLogs: true,++ // Setting this option to true will print useful information to the console while you're setting up Sentry.+ debug: false,+})diff --git a/apps/www/sentry.server.config.ts b/apps/www/sentry.server.config.tsnew file mode 100644index 00000000000..89dc5a230bf--- /dev/null+++ b/apps/www/sentry.server.config.ts@@ -0,0 +1,15 @@+// This file configures the initialization of Sentry on the server.+// The config you add here will be used whenever the server handles a request.+// https://docs.sentry.io/platforms/javascript/guides/nextjs/++import * as Sentry from '@sentry/nextjs'++Sentry.init({+ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,++ // Enable logs to be sent to Sentry+ enableLogs: true,++ // Setting this option to true will print useful information to the console while you're setting up Sentry.+ debug: false,+})diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 383f72de40b..4214a59b26f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1553,6 +1553,9 @@ importers:'@radix-ui/react-dialog':specifier: ^1.0.5version: 1.0.5(@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])+ '@sentry/nextjs':+ specifier: ^10+ version: 10.3.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected]([email protected]))'@supabase/supabase-js':specifier: 'catalog:'version: 2.49.3@@ -24785,6 +24788,32 @@ snapshots:'@sentry/[email protected]': {}+ '@sentry/[email protected](@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected]([email protected]))':+ dependencies:+ '@opentelemetry/api': 1.9.0+ '@opentelemetry/semantic-conventions': 1.36.0+ '@rollup/plugin-commonjs': 28.0.1([email protected])+ '@sentry-internal/browser-utils': 10.3.0+ '@sentry/core': 10.3.0+ '@sentry/node': 10.3.0([email protected])+ '@sentry/opentelemetry': 10.3.0(@opentelemetry/[email protected])(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected])+ '@sentry/react': 10.3.0([email protected])+ '@sentry/vercel-edge': 10.3.0+ '@sentry/webpack-plugin': 4.0.2([email protected])([email protected])([email protected]([email protected]))+ chalk: 3.0.0+ next: 15.3.3(@babel/[email protected]([email protected]))(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])+ resolve: 1.22.8+ rollup: 4.38.0+ stacktrace-parser: 0.1.10+ transitivePeerDependencies:+ - '@opentelemetry/context-async-hooks'+ - '@opentelemetry/core'+ - '@opentelemetry/sdk-trace-base'+ - encoding+ - react+ - supports-color+ - webpack+'@sentry/[email protected](@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@babel/[email protected]([email protected]))(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])':dependencies:'@opentelemetry/api': 1.9.0@@ -24864,6 +24893,15 @@ snapshots:transitivePeerDependencies:- supports-color+ '@sentry/[email protected](@opentelemetry/[email protected])(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected])':+ dependencies:+ '@opentelemetry/api': 1.9.0+ '@opentelemetry/context-async-hooks': 2.0.1(@opentelemetry/[email protected])+ '@opentelemetry/core': 1.30.1(@opentelemetry/[email protected])+ '@opentelemetry/sdk-trace-base': 1.30.1(@opentelemetry/[email protected])+ '@opentelemetry/semantic-conventions': 1.36.0+ '@sentry/core': 10.3.0+'@sentry/[email protected](@opentelemetry/[email protected])(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected])':dependencies:'@opentelemetry/api': 1.9.0@@ -24886,6 +24924,16 @@ snapshots:'@opentelemetry/resources': 2.0.1(@opentelemetry/[email protected])'@sentry/core': 10.3.0+ '@sentry/[email protected]([email protected])([email protected])([email protected]([email protected]))':+ dependencies:+ '@sentry/bundler-plugin-core': 4.0.2([email protected])([email protected])+ unplugin: 1.0.1+ uuid: 9.0.1+ webpack: 5.94.0([email protected])+ transitivePeerDependencies:+ - encoding+ - supports-color+dependencies:'@sentry/bundler-plugin-core': 4.0.2([email protected])([email protected])@@ -26786,7 +26834,7 @@ snapshots:'@types/[email protected]':dependencies:'@types/node': 22.13.14- pg-protocol: 1.7.1+ pg-protocol: 1.10.3pg-types: 2.2.0'@types/[email protected]': {}@@ -37040,7 +37088,6 @@ snapshots:webpack: 5.94.0([email protected])optionalDependencies:esbuild: 0.25.2- optional: truedependencies:@@ -38409,7 +38456,6 @@ snapshots:- '@swc/core'- esbuild- uglify-js- optional: truedependencies:diff --git a/turbo.json b/turbo.jsonindex 6d010af23b4..0409cabc4c9 100644--- a/turbo.json+++ b/turbo.json@@ -124,6 +124,7 @@"NEXT_PUBLIC_HCAPTCHA_SITE_KEY","HCAPTCHA_SECRET_KEY","NODE_ENV",+ "NEXT_PUBLIC_SENTRY_DSN",// These envs are used in the packages"NEXT_PUBLIC_STORAGE_KEY","NEXT_PUBLIC_AUTH_DEBUG_KEY",