The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Sentry docs updates (#27092)
Kamil Ogórek7940e50d93ce
diff --git a/apps/docs/content/guides/functions/examples/sentry-monitoring.mdx b/apps/docs/content/guides/functions/examples/sentry-monitoring.mdxindex 3571c5108dd..ec522e0a892 100644--- a/apps/docs/content/guides/functions/examples/sentry-monitoring.mdx+++ b/apps/docs/content/guides/functions/examples/sentry-monitoring.mdx@@ -78,3 +78,12 @@ supabase functions deploy sentryfied --no-verify-jwt### 4. Try it yourselfFind the complete example on [GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/sentryfied/index.ts).++## Working With Scopes++Sentry Deno SDK currently do not support `Deno.serve` instrumentation, which means that there is no scope separation between requests.+Because of that, when the Edge Functions runtime is reused between multiple requests, all globally captured breadcrumbs and contextual data+will be shared, which is not the desired behavior. To work around this, all default integrations in the example code above are disabled,+and you should be relying on [`withScope`](https://docs.sentry.io/platforms/javascript/enriching-events/scopes/#using-withscope) to encapsulate+all Sentry SDK API calls, or [pass context directly](https://docs.sentry.io/platforms/javascript/enriching-events/context/#passing-context-directly)+to the `captureException` or `captureMessage` calls.diff --git a/apps/docs/content/guides/platform/sentry-monitoring.mdx b/apps/docs/content/guides/platform/sentry-monitoring.mdxindex ba7adb00df8..b64cb0d9512 100644--- a/apps/docs/content/guides/platform/sentry-monitoring.mdx+++ b/apps/docs/content/guides/platform/sentry-monitoring.mdx@@ -41,6 +41,12 @@ pnpm add @supabase/sentry-js-integration## Use+<Admonition type='note'>++If you are using Sentry JavaScript SDK v7, reference [`supabase-community/sentry-integration-js` repository](https://github.com/supabase-community/sentry-integration-js/blob/master/README-7v.md) instead.++</Admonition>+To use the Supabase Sentry integration, add it to your `integrations` list when initializing your Sentry client.You can supply either the Supabase Client constructor or an already-initiated instance of a Supabase Client.@@ -52,12 +58,12 @@ You can supply either the Supabase Client constructor or an already-initiated in```tsimport * as Sentry from '@sentry/browser'import { SupabaseClient } from '@supabase/supabase-js'-import { SupabaseIntegration } from '@supabase/sentry-js-integration'+import { supabaseIntegration } from '@supabase/sentry-js-integration'Sentry.init({dsn: SENTRY_DSN,integrations: [- new SupabaseIntegration(SupabaseClient, {+ supabaseIntegration(SupabaseClient, Sentry, {tracing: true,breadcrumbs: true,errors: true,@@ -73,14 +79,14 @@ Sentry.init({```tsimport * as Sentry from '@sentry/browser'import { createClient } from '@supabase/supabase-js'-import { SupabaseIntegration } from '@supabase/sentry-js-integration'+import { supabaseIntegration } from '@supabase/sentry-js-integration'const supabaseClient = createClient(SUPABASE_URL, SUPABASE_KEY)Sentry.init({dsn: SENTRY_DSN,integrations: [- new SupabaseIntegration(supabaseClient, {+ supabaseIntegration(supabaseClient, Sentry, {tracing: true,breadcrumbs: true,errors: true,@@ -93,6 +99,8 @@ Sentry.init({</Tabs>+All available configuration options are available in our [`supabase-community/sentry-integration-js` repository](https://github.com/supabase-community/sentry-integration-js/blob/master/README.md#options).+## Deduplicating spansIf you're already monitoring HTTP errors in Sentry, for example with the Http, Fetch, or Undici integrations, you will get duplicate spans for Supabase calls. You can deduplicate the spans by skipping them in your other integration:@@ -100,26 +108,26 @@ If you're already monitoring HTTP errors in Sentry, for example with the Http, F```tsimport * as Sentry from '@sentry/browser'import { SupabaseClient } from '@supabase/supabase-js'-import { SupabaseIntegration } from '@supabase/sentry-js-integration'+import { supabaseIntegration } from '@supabase/sentry-js-integration'Sentry.init({dsn: SENTRY_DSN,integrations: [- new SupabaseIntegration(SupabaseClient, {+ supabaseIntegration(SupabaseClient, Sentry, {tracing: true,breadcrumbs: true,errors: true,}),// @sentry/browser- new Sentry.BrowserTracing({+ Sentry.browserTracingIntegration({shouldCreateSpanForRequest: (url) => {return !url.startsWith(`${SUPABASE_URL}/rest`)},}),// or @sentry/node- new Sentry.Integrations.Http({+ Sentry.httpIntegration({tracing: {shouldCreateSpanForRequest: (url) => {return !url.startsWith(`${SUPABASE_URL}/rest`)@@ -128,14 +136,14 @@ Sentry.init({}),// or @sentry/node with Fetch support- new Sentry.Integrations.Undici({+ Sentry.nativeNodeFetchIntegration({shouldCreateSpanForRequest: (url) => {return !url.startsWith(`${SUPABASE_URL}/rest`)},}),// or @sentry/WinterCGFetch for Next.js Middleware & Edge Functions- new Sentry.Integrations.WinterCGFetch({+ Sentry.winterCGFetchIntegration({breadcrumbs: true,shouldCreateSpanForRequest: (url) => {return !url.startsWith(`${SUPABASE_URL}/rest`)@@ -156,40 +164,29 @@ See this example for a setup with Next.js to cover browser, server, and edge env```ts sentry.client.config.tsimport * as Sentry from '@sentry/nextjs'import { SupabaseClient } from '@supabase/supabase-js'-import { SupabaseIntegration } from '@supabase/sentry-js-integration'+import { supabaseIntegration } from '@supabase/sentry-js-integration'Sentry.init({dsn: SENTRY_DSN,- // Adjust this value in production, or use tracesSampler for greater control- tracesSampleRate: 1,-- // Setting this option to true will print useful information to the console while you're setting up Sentry.- debug: true,-- replaysOnErrorSampleRate: 1.0,-- // This sets the sample rate to be 10%. You may want this to be 100% while- // in development and sample at a lower rate in production- replaysSessionSampleRate: 0.1,-- // You can remove this option if you're not planning to use the Sentry Session Replay feature:integrations: [- Sentry.replayIntegration({- // Additional Replay configuration goes in here, for example:- maskAllText: true,- blockAllMedia: true,- }),- new SupabaseIntegration(SupabaseClient, {+ supabaseIntegration(SupabaseClient, Sentry, {tracing: true,breadcrumbs: true,errors: true,}),- Sentry.browserTracingIntegration({+ Sentry.nativeNodeFetchIntegration({shouldCreateSpanForRequest: (url) => {+ console.log('server', `${process.env.NEXT_PUBLIC_SUPABASE_URL}/rest`, url)return !url.startsWith(`${process.env.NEXT_PUBLIC_SUPABASE_URL}/rest`)},}),],++ // Adjust this value in production, or use tracesSampler for greater control+ tracesSampleRate: 1,++ // Setting this option to true will print useful information to the console while you're setting up Sentry.+ debug: true,})```@@ -200,23 +197,23 @@ Sentry.init({```ts sentry.server.config.tsimport * as Sentry from '@sentry/nextjs'import { SupabaseClient } from '@supabase/supabase-js'-import { SupabaseIntegration } from '@supabase/sentry-js-integration'+import { supabaseIntegration } from '@supabase/sentry-js-integration'Sentry.init({dsn: SENTRY_DSN,integrations: [- new SupabaseIntegration(SupabaseClient, {+ supabaseIntegration(SupabaseClient, Sentry, {tracing: true,breadcrumbs: true,errors: true,}),- new Sentry.Integrations.Undici({+ Sentry.winterCGFetchIntegration({+ breadcrumbs: true,shouldCreateSpanForRequest: (url) => {return !url.startsWith(`${process.env.NEXT_PUBLIC_SUPABASE_URL}/rest`)},}),],-// Adjust this value in production, or use tracesSampler for greater controltracesSampleRate: 1,@@ -259,6 +256,23 @@ Sentry.init({</TabPanel>+<TabPanel id="instrumentation" label="Instrumentation">++```js instrumentation.ts+// https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation+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')+ }+}+```++</TabPanel>+</Tabs>Afterward build your application (`npm run build`) and start it locally (`npm run start`). You will now see the transactions being logged in the terminal when making supabase-js requests.