Skip to content

Commit ebda873

Browse files
committed
Move supabaseIntegration to @sentry/core
1 parent e5213f8 commit ebda873

File tree

24 files changed

+116
-21
lines changed

24 files changed

+116
-21
lines changed

.craft.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ targets:
3232
- name: npm
3333
id: '@sentry-internal/replay-canvas'
3434
includeNames: /^sentry-internal-replay-canvas-\d.*\.tgz$/
35+
3536
## 2. Browser & Node SDKs
3637
- name: npm
3738
id: '@sentry/browser'
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as Sentry from '@sentry/browser';
2+
import { createClient } from '@supabase/supabase-js';
3+
4+
5+
window.Sentry = Sentry;
6+
7+
const supabase = createClient(
8+
'https://test.supabase.co',
9+
'test-key'
10+
);
11+
12+
Sentry.init({
13+
dsn: 'https://[email protected]/1337',
14+
integrations: [
15+
new Sentry.BrowserTracing({
16+
tracingOrigins: ['localhost', 'my.supabase.co'],
17+
}),
18+
Sentry.supabaseIntegration(supabase)
19+
],
20+
tracesSampleRate: 1.0,
21+
});
22+
23+
// Simulate database operations
24+
async function performDatabaseOperations() {
25+
try {
26+
await supabase
27+
.from('todos')
28+
.insert([{ title: 'Test Todo' }]);
29+
30+
await supabase
31+
.from('todos')
32+
.select('*');
33+
34+
// Trigger an error to capture the breadcrumbs
35+
throw new Error('Test Error');
36+
} catch (error) {
37+
Sentry.captureException(error);
38+
}
39+
}
40+
41+
performDatabaseOperations();
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { expect } from '@playwright/test';
2+
import type { Event } from '@sentry/core';
3+
4+
import { sentryTest } from '../../../../utils/fixtures';
5+
import { getFirstSentryEnvelopeRequest, getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';
6+
7+
describe('Supabase Integration', () => {
8+
sentryTest('should capture Supabase database operation breadcrumbs', async ({ getLocalTestUrl, page }) => {
9+
const url = await getLocalTestUrl({ testDir: __dirname });
10+
11+
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
12+
13+
expect(eventData.breadcrumbs).toBeDefined();
14+
expect(eventData.breadcrumbs).toContainEqual({
15+
timestamp: expect.any(Number),
16+
type: 'supabase',
17+
category: 'db.insert',
18+
message: 'from(todos)',
19+
data: expect.any(Object),
20+
});
21+
});
22+
23+
sentryTest('should capture multiple Supabase operations in sequence', async ({ getLocalTestUrl, page }) => {
24+
const url = await getLocalTestUrl({ testDir: __dirname });
25+
26+
const events = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });
27+
28+
expect(events).toHaveLength(2);
29+
30+
events.forEach(event => {
31+
expect(
32+
event.breadcrumbs?.some(
33+
breadcrumb => breadcrumb.type === 'supabase' && breadcrumb?.category?.startsWith('db.'),
34+
),
35+
).toBe(true);
36+
});
37+
});
38+
39+
sentryTest('should include correct data payload in Supabase breadcrumbs', async ({ getLocalTestUrl, page }) => {
40+
const url = await getLocalTestUrl({ testDir: __dirname });
41+
42+
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
43+
44+
const supaBreadcrumb = eventData.breadcrumbs?.find(b => b.type === 'supabase');
45+
46+
expect(supaBreadcrumb).toBeDefined();
47+
expect(supaBreadcrumb?.data).toMatchObject({
48+
table: expect.any(String),
49+
operation: expect.any(String),
50+
timestamp: expect.any(Number),
51+
});
52+
});
53+
});

dev-packages/e2e-tests/test-applications/supabase-nextjs/.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

dev-packages/e2e-tests/test-applications/supabase-nextjs/lib/initSupabaseAdmin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createClient } from '@supabase/supabase-js';
22
import * as Sentry from '@sentry/nextjs';
3-
import { supabaseIntegration } from '@sentry/supabase';
43

54
// These are the default development keys for a local Supabase instance
65
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
@@ -16,7 +15,7 @@ export const supabase = createClient(NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_
1615
});
1716

1817
Sentry.addIntegration(
19-
supabaseIntegration({
18+
Sentry.supabaseIntegration({
2019
supabaseClient: supabase,
2120
}),
2221
);
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createClient } from '@supabase/supabase-js';
22
import * as Sentry from '@sentry/nextjs';
3-
import { supabaseIntegration } from '@sentry/supabase';
43

54
// These are the default development keys for a local Supabase instance
65
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
@@ -10,7 +9,7 @@ const NEXT_PUBLIC_SUPABASE_ANON_KEY =
109
export const supabase = createClient(NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY);
1110

1211
Sentry.addIntegration(
13-
supabaseIntegration({
12+
Sentry.supabaseIntegration({
1413
supabaseClient: supabase,
1514
}),
1615
);

dev-packages/e2e-tests/test-applications/supabase-nextjs/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
"start": "next start",
99
"clean": "npx rimraf node_modules pnpm-lock.yaml .next",
1010
"start-local-supabase": "supabase init --force --workdir . && supabase start -o env",
11-
"test:prod": "TEST_ENV=production playwright test",
11+
"test:prod": "TEST_ENV=production playwright test --ui",
1212
"test:build": "pnpm install && pnpm start-local-supabase && pnpm build",
1313
"test:assert": "pnpm test:prod"
1414
},
1515
"dependencies": {
16-
"@next/font": "14.2.15",
16+
"@next/font": "14.2.25",
1717
"@sentry/nextjs": "latest || *",
18-
"@sentry/supabase": "latest || *",
1918
"@supabase/auth-helpers-react": "0.5.0",
2019
"@supabase/auth-ui-react": "0.4.7",
2120
"@supabase/supabase-js": "2.49.1",
2221
"@types/node": "18.14.0",
2322
"@types/react": "18.0.28",
2423
"@types/react-dom": "18.0.11",
2524
"concurrently": "7.6.0",
26-
"next": "14.2.15",
25+
"next": "14.2.25",
2726
"react": "18.2.0",
2827
"react-dom": "18.2.0",
2928
"supabase": "2.19.7",
@@ -33,7 +32,7 @@
3332
"@playwright/test": "~1.50.0",
3433
"@sentry-internal/test-utils": "link:../../../test-utils",
3534
"eslint": "8.34.0",
36-
"eslint-config-next": "14.2.15"
35+
"eslint-config-next": "14.2.25"
3736
},
3837
"volta": {
3938
"extends": "../../package.json"

dev-packages/e2e-tests/test-applications/supabase-nextjs/playwright.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
22

33
const config = getPlaywrightConfig({
4-
startCommand: `pnpm start`,
4+
startCommand: `pnpm dev`,
55
port: 3030,
66
});
77

dev-packages/e2e-tests/verdaccio-config/config.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ packages:
158158
unpublish: $all
159159
# proxy: npmjs # Don't proxy for E2E tests!
160160

161-
'@sentry/supabase':
162-
access: $all
163-
publish: $all
164-
unpublish: $all
165-
# proxy: npmjs # Don't proxy for E2E tests!
166-
167161
'@sentry/svelte':
168162
access: $all
169163
publish: $all

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
"packages/replay-worker",
8080
"packages/solid",
8181
"packages/solidstart",
82-
"packages/supabase",
8382
"packages/svelte",
8483
"packages/sveltekit",
8584
"packages/tanstackstart",

0 commit comments

Comments
 (0)