-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
base: main
Are you sure you want to change the base?
Changes from all commits
a8cee18
30c089b
8bd9497
34b0923
b104265
4459e95
cac23c4
7bc29d3
d4b1036
56f7aa8
f1df16d
a7b8b28
0a08454
6ee6dfb
f6e68ae
6fc8c85
0f77a5f
6df4a38
f114e44
4c8accc
63a5c67
24bed61
cb7f1f5
6b5ddc7
2d5495b
5e3ca91
dedb01b
c3cbf8a
8693820
94320da
b6a14af
c808725
a39e9b4
e4d1bf6
d28daa6
6a8651f
0efceb9
d97f89c
08ef583
8d1e9ec
891a8fb
0ab2edd
a15d533
d2f4fd9
522db05
77c7ea9
7f02156
27911aa
5adeefc
f8ec07b
0be2561
e9315ab
a2e2132
2fc4386
7ddd4e0
5753f12
73fb9a0
c14cbfe
05c877f
4f1237b
92025fc
ecfbb1d
ae38761
b0debb1
4651cbd
e0b51dc
1476f86
2db18e6
4135f7f
5454931
7e9d32c
b0f288d
925fe9b
1b1f0c3
6dc9b2c
0f11a4e
22c24e6
de422e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,13 @@ | |
|
|
||
| ### Features | ||
|
|
||
| - Sentry Supabase Integration ([#2913](https://github.com/getsentry/sentry-dart/pull/2913)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - Adds the `sentry_supabase` package to instrument supabase with Sentry breadcrumbs, traces and errors. | ||
|
|
||
| ## 9.7.0 | ||
|
|
||
| ### Features | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BugThe Supabase integration feature entry is incorrectly placed under version 9.8.0 when it should be under version 9.7.0 based on the PR description. The CHANGELOG.md changes show that:
This creates a duplicate version heading and misplaces the feature announcement. Based on the PR description stating this is about adding Supabase integration, and looking at the rest of the context showing this is a new v9.x release, the Supabase feature should likely be under version 9.7.0 or the version structure needs to be fixed to remove the duplicate 9.7.0 heading. |
||
|
|
||
| - Mark file sync spans run in the main isolate with `blocked_main_thread` ([#3270](https://github.com/getsentry/sentry-dart/pull/3270)) | ||
| - This allows Sentry to create issues automatically out of file spans running a certain time on the main thread: https://docs.sentry.io/product/issues/issue-details/performance-issues/file-main-thread-io/ | ||
|
|
||
|
|
||
| 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/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../CHANGELOG.md |
| 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. |
| 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) |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../dart/dartdoc_options.yaml |
| 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(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| library; | ||
|
|
||
| export 'src/sentry_supabase_client.dart'; |
| 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); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| 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, | ||
| // ignore: invalid_use_of_internal_member | ||
| options: _hub.options, | ||
| ); | ||
|
|
||
| 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(); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.