-
-
Notifications
You must be signed in to change notification settings - Fork 270
Sentry Supabase Integration #2913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
denrase
wants to merge
67
commits into
main
Choose a base branch
from
feat/supabase
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 58 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
a8cee18
add sentry_supabase package
denrase 30c089b
add to flutter/example app
denrase 8bd9497
Merge branch 'main' into feat/supabase
denrase 34b0923
instument with breadcrumbs for basic operations
denrase b104265
fix typo
denrase 4459e95
only add breadcrumb when enabled
denrase cac23c4
add query to breadcrumb
denrase 7bc29d3
format
denrase d4b1036
add body to breadcrumb
denrase 56f7aa8
implement body redaction
denrase f1df16d
format
denrase a7b8b28
refactor
denrase 0a08454
Merge branch 'main' into feat/supabase
denrase 6ee6dfb
basic tracing support
denrase f6e68ae
cleanup
denrase 6fc8c85
instument insert
denrase 0f77a5f
add renamining span tests
denrase 6df4a38
split responsibility for breadcrumbs, errors and tracing into multipl…
denrase f114e44
Merge branch 'main' into feat/supabase
denrase 4c8accc
add SentrySupabaseClient
denrase 63a5c67
update
denrase 24bed61
only export client
denrase cb7f1f5
update example
denrase 6b5ddc7
update github actions and scripts
denrase 2d5495b
run fix & format
denrase 5e3ca91
remove from sample app
denrase dedb01b
move mocks to folder
denrase c3cbf8a
attribute https://github.com/supabase-community/sentry-integration-js
denrase 8693820
don’t send request body per default
denrase 94320da
add docs
denrase b6a14af
treat query as pii
denrase c808725
add cl entry
denrase a39e9b4
remove supabase from flutter sample app
denrase e4d1bf6
format main
denrase d28daa6
add example to readme
denrase 6a8651f
Merge branch 'main' into feat/supabase
buenaflor 0efceb9
Merge branch 'main' into feat/supabase
denrase d97f89c
start child from hub span
denrase 08ef583
cleanup and change db.operation
denrase 8d1e9ec
rename ctor params
denrase 891a8fb
set db-system
denrase 0ab2edd
add unknwon operation
denrase a15d533
Merge branch 'main' into feat/supabase
denrase d2f4fd9
fix cl
denrase 522db05
add support for SQL queries
denrase 77c7ea9
Merge branch 'main' into feat/supabase
buenaflor 7f02156
wrap clients on init, not on every send
denrase 27911aa
fix cl
denrase 5adeefc
Merge branch 'main' into feat/supabase
denrase f8ec07b
format example
denrase 0be2561
Merge branch 'main' into feat/supabase
denrase e9315ab
fix merge
denrase a2e2132
move supabase into packages folder
denrase 2fc4386
set melos_managed_dependency_overrides
denrase 7ddd4e0
fix path in supabase workflow file
denrase 5753f12
format
denrase 73fb9a0
handle exception in jsonDecode
denrase c14cbfe
fix non-json body
denrase 05c877f
respects defaul pii and max request body size
denrase 4f1237b
add more checks for table names
denrase 92025fc
Merge branch 'main' into feat/supabase
denrase ecfbb1d
fix cl
denrase ae38761
Merge branch 'main' into feat/supabase
denrase b0debb1
fix working dir
denrase 4651cbd
Merge branch 'main' into feat/supabase
denrase e0b51dc
analyzer fix
denrase 1476f86
Merge branch 'main' into feat/supabase
denrase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: sentry-supabase | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/** | ||
pull_request: | ||
paths: | ||
- '!**/*.md' | ||
- '!**/class-diagram.svg' | ||
- '.github/workflows/supabase.yml' | ||
- '.github/workflows/analyze.yml' | ||
- '.github/actions/dart-test/**' | ||
- '.github/actions/coverage/**' | ||
- 'packages/dart/**' | ||
- 'packages/flutter/**' | ||
- 'packages/supabase/**' | ||
|
||
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: '${{ matrix.os }} | ${{ matrix.sdk }}' | ||
runs-on: ${{ matrix.os }}-latest | ||
timeout-minutes: 30 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos, ubuntu, windows] | ||
sdk: [stable, beta] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/flutter-test | ||
with: | ||
directory: packages/supabase | ||
web: false | ||
|
||
# TODO: don't set coverage for now to finish publishing it | ||
# - uses: ./.github/actions/coverage | ||
# if: runner.os == 'Linux' && matrix.sdk == 'stable' | ||
# with: | ||
# token: ${{ secrets.CODECOV_TOKEN }} | ||
# directory: packages/supabase | ||
# coverage: sentry_supabase | ||
# min-coverage: 55 | ||
|
||
analyze: | ||
uses: ./.github/workflows/analyze.yml | ||
with: | ||
package: packages/supabase | ||
sdk: flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Omit committing pubspec.lock for library packages; see | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
pubspec.lock | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../CHANGELOG.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Sentry | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<p align="center"> | ||
<a href="https://sentry.io" target="_blank" align="center"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> | ||
</a> | ||
<br /> | ||
</p> | ||
|
||
|
||
=========== | ||
|
||
<p align="center"> | ||
<a href="https://sentry.io" target="_blank" align="center"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> | ||
</a> | ||
<br /> | ||
</p> | ||
|
||
Sentry integration for `supabase` package | ||
=========== | ||
|
||
| package | build | pub | likes | popularity | pub points | | ||
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------| ------- | | ||
| sentry_supabase | [](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Asentry-supabase) | [](https://pub.dev/packages/sentry_supabase) | [](https://pub.dev/packages/sentry_supabase/score) | [](https://pub.dev/packages/sentry_supabase/score) | [](https://pub.dev/packages/sentry_supabase/score) | ||
|
||
Integration for [`supabase`](https://pub.dev/packages/supabase) package. | ||
|
||
#### Usage | ||
|
||
- Sign up for a Sentry.io account and get a DSN at https://sentry.io. | ||
|
||
- Follow the installing instructions on [pub.dev](https://pub.dev/packages/sentry/install). | ||
|
||
- Initialize the Sentry SDK using the DSN issued by Sentry.io. | ||
|
||
- Call... | ||
|
||
```dart | ||
import 'package:supabase_flutter/supabase_flutter.dart'; | ||
import 'package:sentry_supabase/sentry_supabase.dart'; | ||
|
||
// Create a [SentrySupabaseClient] and pass it to Supabase during initialization. | ||
|
||
final sentrySupabaseClient = SentrySupabaseClient(); | ||
await Supabase.initialize( | ||
url: '<YOUR_SUPABASE_URL>', | ||
anonKey: '<YOUR_SUPABASE_ANON_KEY>', | ||
httpClient: sentrySupabaseClient, | ||
); | ||
|
||
// Now all [Supabase] operations and queries will | ||
// be instrumented with Sentry breadcrumbs, traces and errors. | ||
|
||
final issues = await Supabase.instance.client | ||
.from('issues') | ||
.select(); | ||
``` | ||
|
||
#### Resources | ||
|
||
* [](https://docs.sentry.io/platforms/flutter/) | ||
* [](https://docs.sentry.io/platforms/dart/) | ||
* [](https://github.com/getsentry/sentry-dart/discussions) | ||
* [](https://discord.gg/PXa5Apfe7K) | ||
* [](https://stackoverflow.com/questions/tagged/sentry) | ||
* [](https://twitter.com/intent/follow?screen_name=getsentry) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
include: package:lints/recommended.yaml | ||
|
||
analyzer: | ||
language: | ||
strict-casts: true | ||
strict-inference: true | ||
strict-raw-types: true | ||
errors: | ||
# treat missing required parameters as a warning (not a hint) | ||
missing_required_param: error | ||
# treat missing returns as a warning (not a hint) | ||
missing_return: error | ||
# allow having TODOs in the code | ||
todo: ignore | ||
# allow self-reference to deprecated members (we do this because otherwise we have | ||
# to annotate every member in every test, assert, etc, when we deprecate something) | ||
deprecated_member_use_from_same_package: warning | ||
# ignore sentry/path on pubspec as we change it on deployment | ||
invalid_dependency: ignore | ||
exclude: | ||
- example/** | ||
- test/mocks/mocks.mocks.dart | ||
|
||
linter: | ||
rules: | ||
- prefer_final_locals | ||
- prefer_single_quotes | ||
- prefer_relative_imports | ||
- unnecessary_brace_in_string_interps | ||
- implementation_imports | ||
- require_trailing_commas | ||
- unawaited_futures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../dart/dartdoc_options.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:supabase_flutter/supabase_flutter.dart'; | ||
import 'package:sentry_supabase/sentry_supabase.dart'; | ||
|
||
Future<void> main() async { | ||
// Create a [SentrySupabaseClient] and pass it to Supabase during initialization. | ||
|
||
final sentrySupabaseClient = SentrySupabaseClient(); | ||
await Supabase.initialize( | ||
url: '<YOUR_SUPABASE_URL>', | ||
anonKey: '<YOUR_SUPABASE_ANON_KEY>', | ||
httpClient: sentrySupabaseClient, | ||
); | ||
|
||
// Now all [Supabase] operations and queries will | ||
// be instrumented with Sentry breadcrumbs, traces and errors. | ||
|
||
final issues = await Supabase.instance.client.from('issues').select(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
library; | ||
|
||
export 'src/sentry_supabase_client.dart'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
enum Operation { | ||
select('select'), | ||
insert('insert'), | ||
upsert('upsert'), | ||
update('update'), | ||
delete('delete'), | ||
unknown('unknown'); | ||
|
||
final String value; | ||
const Operation(this.value); | ||
} |
50 changes: 50 additions & 0 deletions
50
packages/supabase/lib/src/sentry_supabase_breadcrumb_client.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:http/http.dart'; | ||
import 'package:sentry/sentry.dart'; | ||
|
||
import 'sentry_supabase_request.dart'; | ||
|
||
class SentrySupabaseBreadcrumbClient extends BaseClient { | ||
final Client _innerClient; | ||
final Hub _hub; | ||
|
||
SentrySupabaseBreadcrumbClient(this._innerClient, this._hub); | ||
|
||
@override | ||
Future<StreamedResponse> send(BaseRequest request) async { | ||
final supabaseRequest = SentrySupabaseRequest.fromRequest(request); | ||
|
||
if (supabaseRequest == null) { | ||
return _innerClient.send(request); | ||
} | ||
|
||
final breadcrumb = Breadcrumb( | ||
message: 'from(${supabaseRequest.table})', | ||
category: 'db.${supabaseRequest.operation.value}', | ||
type: 'supabase', | ||
); | ||
|
||
breadcrumb.data ??= {}; | ||
|
||
breadcrumb.data?['table'] = supabaseRequest.table; | ||
breadcrumb.data?['operation'] = supabaseRequest.operation.value; | ||
|
||
// ignore: invalid_use_of_internal_member | ||
if (supabaseRequest.query.isNotEmpty && _hub.options.sendDefaultPii) { | ||
breadcrumb.data?['query'] = supabaseRequest.query; | ||
} | ||
|
||
// ignore: invalid_use_of_internal_member | ||
if (supabaseRequest.body != null && _hub.options.sendDefaultPii) { | ||
breadcrumb.data?['body'] = supabaseRequest.body; | ||
} | ||
|
||
await _hub.addBreadcrumb(breadcrumb); | ||
|
||
return _innerClient.send(request); | ||
} | ||
|
||
@override | ||
void close() { | ||
_innerClient.close(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.