Skip to content

Commit 4167e15

Browse files
authored
Supabase integration (#5296)
* Basic Supabase integration * Tests for Supabase integration * Lint fixes; changelog entry * Changelog entry update
1 parent 2104bb9 commit 4167e15

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Features
1212

1313
- Adds GraphQL integration ([#5299](https://github.com/getsentry/sentry-react-native/pull/5299))
14+
- Adds Supabase integration ([#5296](https://github.com/getsentry/sentry-react-native/pull/5296))
1415

1516
### Dependencies
1617

packages/core/src/js/integrations/exports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export { breadcrumbsIntegration } from './breadcrumbs';
2626
export { primitiveTagIntegration } from './primitiveTagIntegration';
2727
export { logEnricherIntegration } from './logEnricherIntegration';
2828
export { graphqlIntegration } from './graphql';
29+
export { supabaseIntegration } from './supabase';
2930

3031
export {
3132
browserApiErrorsIntegration,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { supabaseIntegration as browserSupabaseIntegration } from '@sentry/browser';
2+
import type { Integration } from '@sentry/core';
3+
4+
type SupabaseReactNativeIntegrationOptions = {
5+
supabaseClient: unknown;
6+
};
7+
8+
/**
9+
* Use this integration to instrument your Supabase client.
10+
*
11+
* Learn more about Supabase at https://supabase.com
12+
*/
13+
export function supabaseIntegration(options: SupabaseReactNativeIntegrationOptions): Integration {
14+
return browserSupabaseIntegration({ supabaseClient: options.supabaseClient });
15+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { supabaseIntegration as browserSupabaseIntegration } from '@sentry/browser';
2+
import { supabaseIntegration } from '../../src/js';
3+
4+
jest.mock('@sentry/browser', () => ({
5+
supabaseIntegration: jest.fn(),
6+
}));
7+
8+
function createMockClient() {
9+
return {
10+
init: jest.fn(),
11+
};
12+
}
13+
14+
describe('supabase', () => {
15+
afterEach(() => {
16+
jest.resetAllMocks();
17+
});
18+
19+
// this test is sufficient to test the integration because everything else
20+
// is covered by the integration tests in the @sentry/browser package
21+
it('passes React Native options to browserSupabaseIntegration', () => {
22+
const mockClient = createMockClient();
23+
supabaseIntegration({ supabaseClient: mockClient });
24+
25+
expect(browserSupabaseIntegration).toHaveBeenCalledWith({
26+
supabaseClient: mockClient,
27+
});
28+
});
29+
});

0 commit comments

Comments
 (0)