|
| 1 | +--- |
| 2 | +title: Supabase |
| 3 | +description: "Adds instrumentation for Supabase client operations." |
| 4 | +supported: |
| 5 | + - javascript.browser |
| 6 | + - javascript.node |
| 7 | + - javascript.aws-lambda |
| 8 | + - javascript.azure-functions |
| 9 | + - javascript.connect |
| 10 | + - javascript.express |
| 11 | + - javascript.fastify |
| 12 | + - javascript.gcp-functions |
| 13 | + - javascript.hapi |
| 14 | + - javascript.hono |
| 15 | + - javascript.koa |
| 16 | + - javascript.nestjs |
| 17 | + - javascript.electron |
| 18 | + - javascript.nextjs |
| 19 | + - javascript.nuxt |
| 20 | + - javascript.solidstart |
| 21 | + - javascript.sveltekit |
| 22 | + - javascript.remix |
| 23 | + - javascript.react-router |
| 24 | + - javascript.astro |
| 25 | + - javascript.bun |
| 26 | + - javascript.tanstackstart-react |
| 27 | +--- |
| 28 | + |
| 29 | +_Import name: `Sentry.supabaseIntegration`_ |
| 30 | + |
| 31 | +The `supabaseIntegration` adds instrumentation for the Supabase client to capture spans for both authentication and database operations. |
| 32 | + |
| 33 | +## Installation |
| 34 | + |
| 35 | +You need to have both the Sentry SDK and the Supabase library installed. For Supabase installation instructions, refer to the [Supabase JavaScript documentation](https://supabase.com/docs/reference/javascript/introduction). |
| 36 | + |
| 37 | + |
| 38 | +## Configuration |
| 39 | + |
| 40 | +This is the preferred method for most use cases. and follows Sentry's standard integration pattern. |
| 41 | + |
| 42 | +```javascript |
| 43 | +import * as Sentry from '@sentry/browser'; |
| 44 | +import { createClient } from '@supabase/supabase-js'; |
| 45 | + |
| 46 | +const supabaseClient = createClient('YOUR_SUPABASE_URL', 'YOUR_SUPABASE_KEY'); |
| 47 | + |
| 48 | +Sentry.init({ |
| 49 | + dsn: 'YOUR_DSN', |
| 50 | + integrations: [ |
| 51 | + Sentry.browserTracingIntegration(), |
| 52 | + Sentry.supabaseIntegration({ supabaseClient }) |
| 53 | + ], |
| 54 | + tracesSampleRate: 1.0, |
| 55 | +}); |
| 56 | +``` |
| 57 | + |
| 58 | +## Generated Spans |
| 59 | + |
| 60 | +The integration provides comprehensive monitoring for both authentication and database operations: |
| 61 | + |
| 62 | +### Authentication Spans |
| 63 | + |
| 64 | +The integration automatically instruments the following auth operations: |
| 65 | +- `signInWithPassword` |
| 66 | +- `signOut` |
| 67 | +- `signInAnonymously` |
| 68 | +- `signInWithOAuth` |
| 69 | +- `signInWithIdToken` |
| 70 | +- `signInWithOtp` |
| 71 | +- `signInWithSSO` |
| 72 | +- `signUp` |
| 73 | +- `verifyOtp` |
| 74 | +- `reauthenticate` |
| 75 | + |
| 76 | +Admin operations are also instrumented: |
| 77 | +- `createUser` |
| 78 | +- `deleteUser` |
| 79 | +- `listUsers` |
| 80 | +- `getUserById` |
| 81 | +- `updateUserById` |
| 82 | +- `inviteUserByEmail` |
| 83 | + |
| 84 | +### Database Operation Spans |
| 85 | + |
| 86 | +These spans are used to populate Sentry's [Query Insights](/product/insights/backend/queries/) 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. |
| 87 | + |
| 88 | +- `db.table`: The table being queried |
| 89 | +- `db.schema`: The database schema |
| 90 | +- `db.url`: The Supabase instance URL |
| 91 | +- `db.sdk`: Client information |
| 92 | +- `db.system`: Set to 'postgresql' |
| 93 | +- `db.query`: The query parameters |
| 94 | +- `db.body`: The request body (for mutations) |
| 95 | + |
| 96 | +### Queue Operation Spans (in progress) |
| 97 | + |
| 98 | +Coming soon, the Sentry SDK will also support generating spans for interactions with Supabase queues. For more information, please follow [this GitHub issue](https://github.com/getsentry/sentry-javascript/issues/14611). |
| 99 | + |
| 100 | + |
| 101 | +## Error Tracking |
| 102 | + |
| 103 | +The integration automatically: |
| 104 | +- Captures errors from failed operations |
| 105 | +- Adds breadcrumbs for database operations |
| 106 | +- Includes detailed context about the operation that failed |
| 107 | + |
| 108 | + |
| 109 | +## Supported Versions |
| 110 | + |
| 111 | +- `@supabase/supabase-js`: `>=2.0.0` |
0 commit comments