Skip to content

Commit 20faa47

Browse files
authored
Sentry Supabase Integration (#2913)
1 parent bbdbcb9 commit 20faa47

32 files changed

+3137
-1
lines changed

.craft.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ targets:
1919
packages/isar:
2020
packages/link:
2121
packages/firebase_remote_config:
22+
packages/supabase:
2223
- name: github
2324
- name: registry
2425
sdks:
@@ -33,3 +34,5 @@ targets:
3334
pub:sentry_isar:
3435
pub:sentry_link:
3536
pub:sentry_firebase_remote_config:
37+
# TODO: after we published supabase we need to add it to the registry repo and then uncomment here
38+
# pub:sentry_supabase:

.github/workflows/diagrams.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ jobs:
5959
working-directory: ./packages/firebase_remote_config
6060
run: lakos . -i "{test/**,example/**}" | dot -Tsvg -o class-diagram.svg
6161

62+
- name: supabase
63+
working-directory: ./packages/supabase
64+
run: lakos . -i "{test/**,example/**}" | dot -Tsvg -o class-diagram.svg
65+
6266
# Source: https://stackoverflow.com/a/58035262
6367
- name: Extract branch name
6468
shell: bash

.github/workflows/supabase.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: sentry-supabase
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- release/**
7+
pull_request:
8+
paths:
9+
- '!**/*.md'
10+
- '!**/class-diagram.svg'
11+
- '.github/workflows/supabase.yml'
12+
- '.github/workflows/analyze.yml'
13+
- '.github/actions/dart-test/**'
14+
- '.github/actions/coverage/**'
15+
- 'packages/dart/**'
16+
- 'packages/flutter/**'
17+
- 'packages/supabase/**'
18+
19+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
build:
26+
name: '${{ matrix.os }} | ${{ matrix.sdk }}'
27+
runs-on: ${{ matrix.os }}-latest
28+
timeout-minutes: 30
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
os: [macos, ubuntu, windows]
33+
sdk: [stable, beta]
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- uses: ./.github/actions/flutter-test
39+
with:
40+
directory: packages/supabase
41+
web: false
42+
43+
# TODO: don't set coverage for now to finish publishing it
44+
# - uses: ./.github/actions/coverage
45+
# if: runner.os == 'Linux' && matrix.sdk == 'stable'
46+
# with:
47+
# token: ${{ secrets.CODECOV_TOKEN }}
48+
# directory: packages/supabase
49+
# coverage: sentry_supabase
50+
# min-coverage: 55
51+
52+
analyze:
53+
uses: ./.github/workflows/analyze.yml
54+
with:
55+
package: packages/supabase
56+
sdk: flutter

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- Add `Sentry.setAttributes` and `Sentry.removeAttribute` ([#3352](https://github.com/getsentry/sentry-dart/pull/3352))
88
- These attributes are set at the scope level and apply to all logs (and later to metrics and spans).
99
- When a scope attribute conflicts with a log-level attribute, the log-level attribute always takes precedence.
10+
- Sentry Supabase Integration ([#2913](https://github.com/getsentry/sentry-dart/pull/2913))
11+
- Adds the `sentry_supabase` package to instrument supabase with Sentry breadcrumbs, traces and errors.
1012

1113
### Fixes
1214

packages/dart/lib/src/constants.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ class SentrySpanOperations {
1616
class SentrySpanData {
1717
static const String dbSystemKey = 'db.system';
1818
static const String dbNameKey = 'db.name';
19+
static const String dbSchemaKey = 'db.schema';
20+
static const String dbTableKey = 'db.table';
21+
static const String dbUrlKey = 'db.url';
22+
static const String dbSdkKey = 'db.sdk';
23+
static const String dbQueryKey = 'db.query';
24+
static const String dbBodyKey = 'db.body';
25+
static const String dbOperationKey = 'db.operation';
26+
static const String httpResponseStatusCodeKey = 'http.response.status_code';
27+
static const String httpResponseContentLengthKey =
28+
'http.response_content_length';
1929

2030
static const String dbSystemSqlite = 'db.sqlite';
31+
static const String dbSystemPostgresql = 'postgresql';
2132
}
2233

2334
@internal

packages/dart/lib/src/sentry_trace_origins.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ class SentryTraceOrigins {
2727
static const autoDbDriftQueryInterceptor = 'auto.db.drift.query.interceptor';
2828
static const autoUiTimeToDisplay = 'auto.ui.time_to_display';
2929
static const manualUiTimeToDisplay = 'manual.ui.time_to_display';
30+
static const autoDbSupabase = 'auto.db.supabase';
3031
}

packages/supabase/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Omit committing pubspec.lock for library packages; see
2+
# https://dart.dev/guides/libraries/private-files#pubspeclock.
3+
pubspec.lock
4+
5+
# Flutter/Dart/Pub related
6+
**/doc/api/
7+
**/ios/Flutter/.last_build_id
8+
.dart_tool/
9+
.flutter-plugins
10+
.flutter-plugins-dependencies
11+
.packages
12+
.pub-cache/
13+
.pub/
14+
/build/

packages/supabase/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CHANGELOG.md

packages/supabase/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Sentry
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/supabase/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<p align="center">
2+
<a href="https://sentry.io" target="_blank" align="center">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
4+
</a>
5+
<br />
6+
</p>
7+
8+
9+
===========
10+
11+
<p align="center">
12+
<a href="https://sentry.io" target="_blank" align="center">
13+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
14+
</a>
15+
<br />
16+
</p>
17+
18+
Sentry integration for `supabase` package
19+
===========
20+
21+
| package | build | pub | likes | popularity | pub points |
22+
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------| ------- |
23+
| sentry_supabase | [![build](https://github.com/getsentry/sentry-dart/actions/workflows/supabase.yml/badge.svg?branch=main)](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Asentry-supabase) | [![pub package](https://img.shields.io/pub/v/sentry_supabase.svg)](https://pub.dev/packages/sentry_supabase) | [![likes](https://img.shields.io/pub/likes/sentry_supabase)](https://pub.dev/packages/sentry_supabase/score) | [![popularity](https://img.shields.io/pub/popularity/sentry_supabase)](https://pub.dev/packages/sentry_supabase/score) | [![pub points](https://img.shields.io/pub/points/sentry_supabase)](https://pub.dev/packages/sentry_supabase/score)
24+
25+
Integration for [`supabase`](https://pub.dev/packages/supabase) package.
26+
27+
#### Usage
28+
29+
- Sign up for a Sentry.io account and get a DSN at https://sentry.io.
30+
31+
- Follow the installing instructions on [pub.dev](https://pub.dev/packages/sentry/install).
32+
33+
- Initialize the Sentry SDK using the DSN issued by Sentry.io.
34+
35+
- Call...
36+
37+
```dart
38+
import 'package:supabase_flutter/supabase_flutter.dart';
39+
import 'package:sentry_supabase/sentry_supabase.dart';
40+
41+
// Create a [SentrySupabaseClient] and pass it to Supabase during initialization.
42+
43+
final sentrySupabaseClient = SentrySupabaseClient();
44+
await Supabase.initialize(
45+
url: '<YOUR_SUPABASE_URL>',
46+
anonKey: '<YOUR_SUPABASE_ANON_KEY>',
47+
httpClient: sentrySupabaseClient,
48+
);
49+
50+
// Now all [Supabase] operations and queries will
51+
// be instrumented with Sentry breadcrumbs, traces and errors.
52+
53+
final issues = await Supabase.instance.client
54+
.from('issues')
55+
.select();
56+
```
57+
58+
#### Resources
59+
60+
* [![Flutter docs](https://img.shields.io/badge/documentation-sentry.io-green.svg?label=flutter%20docs)](https://docs.sentry.io/platforms/flutter/)
61+
* [![Dart docs](https://img.shields.io/badge/documentation-sentry.io-green.svg?label=dart%20docs)](https://docs.sentry.io/platforms/dart/)
62+
* [![Discussions](https://img.shields.io/github/discussions/getsentry/sentry-dart.svg)](https://github.com/getsentry/sentry-dart/discussions)
63+
* [![Discord Chat](https://img.shields.io/discord/621778831602221064?logo=discord&logoColor=ffffff&color=7389D8)](https://discord.gg/PXa5Apfe7K)
64+
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](https://stackoverflow.com/questions/tagged/sentry)
65+
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)

0 commit comments

Comments
 (0)