Skip to content

Commit

Permalink
updated README with Sentry v8 usage (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevdavid authored Jun 7, 2024
1 parent bab9673 commit fa1b519
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,31 @@ See https://github.com/supabase-community/sentry-integration-js/blob/master/inde

### Removing duplicated http/fetch spans

If you are using built-in `Http`, `Fetch` or `Undici` integrations in your current Sentry setup, you might want to skip some of the spans that will be already covered by `SupabaseIntegration`. Here's a quick snippet how to do that:
If you are using built-in `Http`, `Fetch` or `nativeNodeFetchIntegration` integrations in your current Sentry setup, you might want to skip some of the spans that will be already covered by `supabaseIntegration`. Here's a quick snippet how to do that:

```js
import * 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`);
Expand All @@ -155,14 +155,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`);
Expand All @@ -184,7 +184,7 @@ See this example for a setup with Next.js to cover browser, server, and edge env
```js sentry.client.config.ts
import * 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,
Expand All @@ -207,12 +207,12 @@ Sentry.init({
maskAllText: true,
blockAllMedia: true,
}),
new SupabaseIntegration(SupabaseClient, {
supabaseIntegration(SupabaseClient, Sentry, {
tracing: true,
breadcrumbs: true,
errors: true,
}),
new Sentry.BrowserTracing({
Sentry.browserTracingIntegration({
shouldCreateSpanForRequest: (url) => {
return !url.startsWith(`${process.env.NEXT_PUBLIC_SUPABASE_URL}/rest`);
},
Expand All @@ -226,17 +226,17 @@ Sentry.init({
```js sentry.server.config.ts
import * 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.nativeNodeFetchIntegration({
shouldCreateSpanForRequest: (url) => {
console.log(
"server",
Expand All @@ -261,17 +261,17 @@ Sentry.init({
```js sentry.edge.config.ts
import * 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.WinterCGFetch({
Sentry.winterCGFetchIntegration({
breadcrumbs: true,
shouldCreateSpanForRequest: (url) => {
return !url.startsWith(`${process.env.NEXT_PUBLIC_SUPABASE_URL}/rest`);
Expand All @@ -286,6 +286,18 @@ Sentry.init({
});
```

```js instrumentation.ts
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');
}
}
```

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.

</details>
Expand Down

0 comments on commit fa1b519

Please sign in to comment.