Back to Blog Home

Sentry & Supabase

Steven Eubank image
Kamil Ogórek image

Steven Eubank, Kamil Ogórek -

Sentry & Supabase

Sentry helping keep Supabase Super

One of the great things about working for a company like Sentry, is you get to try and find ways to make the latest and greatest developer tools work with the ones you’ve already been enjoying for years. Supabase came onto the scene in recent years and has been growing in popularity with developers around the world as an OpenSource one stop shop for their Postgres database needs. And as always at Sentry, where the developers go we shall follow. We are creepy stalkers like that.

When big brand cloud services first started popping up and evolving many years ago, it was amazing for developers to be able to spin up and scale all kind of infrastructure to deploy their web applications around the world. However, big box cloud providers were often very complex to use and scaling anything was often very expensive. Plus, we are spoiled in DX world, and want things to be easy. So the clunky UX to deploy websites has been replaced by platforms like Netlify and Vercel. Now Supabase does the same but for your database needs. And we at Sentry, who have always aimed to make monitoring your code locally and in the wild easier, have worked together with Supabase to make it easier for you to super power Supabase services with Sentry.

Instrument Database Integrations

Supabase provides a JavaScript client @supabase/supabase-js to set your application up to interact with a Postgres database running on their platform. There is now with support from Kamil Ogórek over at Supabase (but always a Sentaur in our <3), there is now a Sentry JavaScript SDK Integration that can be used to instrument Supabase’s JavaScript SDK and collect traces, breadcrumbs and errors.

Setup

You know the schpiel copy pasta and let’s go.

First install.

npm install @supabase/sentry-js-integration

Then setup the SDK.

import { SupabaseIntegration } from "@supabase/sentry-js-integration";
import { SupabaseClient } from "@supabase/supabase-js";

Sentry.init({
  dsn: "<https://dsn@sentry.io/1337>",
  integrations: [

new SupabaseIntegration(SupabaseClient, { tracing: true, breadcrumbs: true, errors: true, }), ], });

See the @supabase/sentry-js-integration documentation and repo for more information about setting up your application to ensure your errors and traces are captured in Sentry. The Supabase clients also allow you build login and user management functionality, manage large files, and invoke Deno Edge Functions, Sentry can help ensure those are monitored as well, even when your code is running on the Edge … out there … somewhere. Edge Function Support In our Launch Week November 2023, I talked about how we work to ensure we provide support to as many developers on as many platforms as possible. Of note this includes Deno. Deno has been growing in popularity, not just amongst hipster developers around the world, but has also been adopted on many growing platforms like Supabase. Supabase uses Deno as the runtime for their edge functions. Which we of course can support through our Deno SDK. While deno gives you the ability to run your code on their Edge runtimes, Sentry can ensure your code is monitored and you are alerted when there are any errors or performance issues, import * as Sentry from ’https://deno.land/x/sentry/index.mjs

Sentry.init({ dsn: ‘SENTRY_DSN’, integrations: [], debug: true, // Performance Monitoring tracesSampleRate: 1.0, })

// Set region and execution_id as custom tags Sentry.setTag(‘region’, Deno.env.get(‘SB_REGION’)) Sentry.setTag(‘execution_id’, Deno.env.get(‘SB_EXECUTION_ID’))

console.log(“Hello from Functions!“)

Deno.serve(async (req) => { try { const { name } = await req.json() const data = { message: Hello ${name}!, }

return new Response(JSON.stringify(data), { headers: { ‘Content-Type’: ‘application/json’ } }) } catch (e) { Sentry.captureException(e) return new Response(JSON.stringify({ msg: ‘error’ }), { status: 500, headers: { ‘Content-Type’: ‘application/json’ }, }) } })

Connecting the Pieces Supabase promises to allow you to build in a weekend and scale to the world with their databases and other services. Sentry wants to ensure you do that with the security of knowing you’ll capture any errors and ensure your users don’t run into any slow DB queries with our Performance offerings. If you don’t have a Sentry account already, you can sign up here, starting with our free Developer tier, and the same goes for Supabase with their signup here.

Share

Share on Twitter
Share on Facebook
Share on HackerNews
Share on LinkedIn

Published

Sentry Sign Up CTA

Code breaks, fix it faster

Sign up for Sentry and monitor your application in minutes.

Try Sentry Free

Topics

SDK Updates

The best way to debug slow web pages

Listen to the Syntax Podcast

Of course we sponsor a developer podcast. Check it out on your favorite listening platform.

Listen To Syntax
    TwitterGitHubDribbbleLinkedinDiscord
© 2024 • Sentry is a registered Trademark
of Functional Software, Inc.