Supabase

Adds instrumentation for Supabase client operations.

Import name: Sentry.supabaseIntegration

The supabaseIntegration adds instrumentation for the Supabase client to capture spans for both authentication and database operations.

You need to have both the Sentry SDK and the Supabase library installed. For Supabase installation instructions, refer to the Supabase JavaScript documentation.

This is the preferred method for most use cases. and follows Sentry's standard integration pattern.

Copied
import * as Sentry from "@sentry/browser";
import { createClient } from "@supabase/supabase-js";

const supabaseClient = createClient(
  "YOUR_SUPABASE_URL",
  "YOUR_SUPABASE_KEY",
);

Sentry.init({
  dsn: "YOUR_DSN",
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.supabaseIntegration({ supabaseClient }),
  ],
  tracesSampleRate: 1.0,
});

The integration provides comprehensive monitoring for both authentication and database operations:

The integration automatically instruments the following auth operations:

  • signInWithPassword
  • signOut
  • signInAnonymously
  • signInWithOAuth
  • signInWithIdToken
  • signInWithOtp
  • signInWithSSO
  • signUp
  • verifyOtp
  • reauthenticate

Admin operations are also instrumented:

  • createUser
  • deleteUser
  • listUsers
  • getUserById
  • updateUserById
  • inviteUserByEmail

These spans are used to populate Sentry's Query Insights feature, which provides performance metrics and analysis for your database operations. With Query Insights, you can identify slow queries, track query frequency, and optimize your database interactions.

  • db.table: The table being queried
  • db.schema: The database schema
  • db.url: The Supabase instance URL
  • db.sdk: Client information
  • db.system: Set to 'postgresql'
  • db.query: The query parameters
  • db.body: The request body (for mutations)

Coming soon, the Sentry SDK will also support generating spans for interactions with Supabase queues. For more information, please follow this GitHub issue.

The integration automatically:

  • Captures errors from failed operations
  • Adds breadcrumbs for database operations
  • Includes detailed context about the operation that failed

  • @supabase/supabase-js: >=2.0.0
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").