Skip to content

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
wants to merge 50 commits into
base: main
Choose a base branch
from
Open

Sentry Supabase Integration #2913

wants to merge 50 commits into from

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented May 6, 2025

📜 Description

Supabase instrumentation for database operations (no auth instrumentation)

  • Breadcrumbs
  • Body Redaction
  • Tracing
  • Errors
  • PII (Body, Query)

💡 Motivation and Context

Closes #2727

💚 How did you test it?

Unit tests.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

Copy link
Contributor

github-actions bot commented May 6, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f8ec07b

Copy link

codecov bot commented May 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.78%. Comparing base (7cfbbd6) to head (f8ec07b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2913   +/-   ##
=======================================
  Coverage   87.78%   87.78%           
=======================================
  Files         290      290           
  Lines        9834     9834           
=======================================
  Hits         8633     8633           
  Misses       1201     1201           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

github-actions bot commented May 6, 2025

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 452.65 ms 537.85 ms 85.21 ms
Size 6.54 MiB 7.70 MiB 1.17 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
eca355d 485.50 ms 569.85 ms 84.35 ms
6f47800 451.04 ms 509.64 ms 58.60 ms
2cf9161 454.12 ms 512.67 ms 58.55 ms
cc4e375 426.15 ms 482.34 ms 56.19 ms
793f4dc 462.68 ms 544.21 ms 81.53 ms
b6c8720 457.41 ms 519.04 ms 61.63 ms
3615e19 468.38 ms 504.71 ms 36.33 ms
575ebaa 478.00 ms 585.76 ms 107.76 ms
2d34233 470.54 ms 558.90 ms 88.36 ms
9b99523 456.91 ms 490.55 ms 33.64 ms

App size

Revision Plain With Sentry Diff
eca355d 6.54 MiB 7.70 MiB 1.16 MiB
6f47800 6.54 MiB 7.69 MiB 1.15 MiB
2cf9161 6.54 MiB 7.70 MiB 1.16 MiB
cc4e375 6.54 MiB 7.69 MiB 1.15 MiB
793f4dc 6.54 MiB 7.69 MiB 1.15 MiB
b6c8720 6.54 MiB 7.69 MiB 1.15 MiB
3615e19 6.54 MiB 7.70 MiB 1.16 MiB
575ebaa 6.54 MiB 7.69 MiB 1.15 MiB
2d34233 6.54 MiB 7.55 MiB 1.01 MiB
9b99523 6.54 MiB 7.69 MiB 1.15 MiB

Previous results on branch: feat/supabase

Startup times

Revision Plain With Sentry Diff
d2f4fd9 453.31 ms 507.02 ms 53.71 ms
0a08454 515.10 ms 634.67 ms 119.57 ms
8bd9497 470.21 ms 524.26 ms 54.05 ms
77c7ea9 447.20 ms 497.53 ms 50.33 ms
0ab2edd 459.85 ms 506.63 ms 46.77 ms
e4d1bf6 499.64 ms 528.47 ms 28.82 ms
34b0923 509.55 ms 590.18 ms 80.62 ms
30c089b 471.71 ms 522.65 ms 50.94 ms
5e3ca91 451.24 ms 496.74 ms 45.50 ms
6a8651f 476.65 ms 532.62 ms 55.96 ms

App size

Revision Plain With Sentry Diff
d2f4fd9 6.54 MiB 7.53 MiB 1017.45 KiB
0a08454 6.44 MiB 7.43 MiB 1013.22 KiB
8bd9497 6.44 MiB 7.43 MiB 1013.21 KiB
77c7ea9 6.54 MiB 7.70 MiB 1.17 MiB
0ab2edd 6.54 MiB 7.53 MiB 1016.33 KiB
e4d1bf6 6.44 MiB 7.44 MiB 1017.53 KiB
34b0923 6.44 MiB 7.43 MiB 1013.10 KiB
30c089b 6.44 MiB 7.43 MiB 1010.46 KiB
5e3ca91 6.44 MiB 7.44 MiB 1017.53 KiB
6a8651f 6.54 MiB 7.53 MiB 1015.94 KiB

Copy link
Contributor

github-actions bot commented May 6, 2025

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1259.06 ms 1273.22 ms 14.16 ms
Size 7.86 MiB 9.44 MiB 1.58 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
dbd526b 1244.78 ms 1259.02 ms 14.24 ms
640ad0c 1241.04 ms 1253.96 ms 12.92 ms
7cfbbd6 1270.63 ms 1285.36 ms 14.72 ms
0fb45d0 1273.24 ms 1286.44 ms 13.19 ms
6ba4675 1223.12 ms 1238.17 ms 15.04 ms
575ebaa 1262.20 ms 1274.24 ms 12.04 ms
f761369 1261.69 ms 1277.82 ms 16.12 ms
2cf9161 1248.33 ms 1266.55 ms 18.22 ms
73dca78 1246.65 ms 1265.42 ms 18.76 ms
4481076 1256.48 ms 1266.64 ms 10.17 ms

App size

Revision Plain With Sentry Diff
dbd526b 7.86 MiB 9.44 MiB 1.58 MiB
640ad0c 7.86 MiB 9.44 MiB 1.58 MiB
7cfbbd6 7.86 MiB 9.44 MiB 1.58 MiB
0fb45d0 7.86 MiB 9.44 MiB 1.58 MiB
6ba4675 7.86 MiB 9.44 MiB 1.58 MiB
575ebaa 7.86 MiB 9.44 MiB 1.58 MiB
f761369 7.86 MiB 9.44 MiB 1.58 MiB
2cf9161 7.86 MiB 9.44 MiB 1.58 MiB
73dca78 7.86 MiB 9.44 MiB 1.58 MiB
4481076 7.86 MiB 9.44 MiB 1.58 MiB

Previous results on branch: feat/supabase

Startup times

Revision Plain With Sentry Diff
0ab2edd 1254.71 ms 1264.28 ms 9.56 ms
6a8651f 1254.15 ms 1266.88 ms 12.73 ms
d2f4fd9 1252.60 ms 1271.13 ms 18.52 ms
77c7ea9 1264.57 ms 1279.47 ms 14.89 ms
8bd9497 1265.35 ms 1273.98 ms 8.63 ms
5e3ca91 1263.90 ms 1277.43 ms 13.53 ms
34b0923 1269.29 ms 1275.88 ms 6.59 ms
0a08454 1265.15 ms 1283.18 ms 18.04 ms
e4d1bf6 1249.16 ms 1267.12 ms 17.96 ms
30c089b 1257.23 ms 1269.16 ms 11.93 ms

App size

Revision Plain With Sentry Diff
0ab2edd 7.85 MiB 9.45 MiB 1.59 MiB
6a8651f 7.85 MiB 9.42 MiB 1.57 MiB
d2f4fd9 7.86 MiB 9.45 MiB 1.59 MiB
77c7ea9 7.86 MiB 9.44 MiB 1.58 MiB
8bd9497 8.43 MiB 10.01 MiB 1.58 MiB
5e3ca91 8.43 MiB 10.00 MiB 1.56 MiB
34b0923 8.43 MiB 10.01 MiB 1.58 MiB
0a08454 8.43 MiB 10.01 MiB 1.58 MiB
e4d1bf6 8.43 MiB 10.00 MiB 1.56 MiB
30c089b 8.43 MiB 10.01 MiB 1.58 MiB

Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick pass, I'll have a closer look later

static Map<String, dynamic>? _readBody(String table, BaseRequest request) {
final bodyString =
request is Request && request.body.isNotEmpty ? request.body : null;
final body = bodyString != null ? jsonDecode(bodyString) : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we introduce some limit? or does the supabase SDK already handle big request bodies?

@denrase denrase requested a review from buenaflor June 30, 2025 12:55
@buenaflor
Copy link
Contributor

Will make another review pass soon

cursor[bot]

This comment was marked as outdated.

@buenaflor
Copy link
Contributor

buenaflor commented Jul 22, 2025

@denrase pls take a look at cursor's comment I think the concern is valid since we'd be doing this for every request

@denrase
Copy link
Collaborator Author

denrase commented Jul 23, 2025

@buenaflor 🤦‍♂️

cursor[bot]

This comment was marked as outdated.

} else {
return null;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unhandled JSON Errors Break HTTP Requests

Malformed JSON in request bodies causes SentrySupabaseRequest._readBody to throw a FormatException. This exception is unhandled by SentrySupabaseRequest.fromRequest callers in SentrySupabaseBreadcrumbClient, SentrySupabaseTracingClient, and SentrySupabaseErrorClient (even within its error handling finally block). This leads to HTTP requests crashing instead of gracefully skipping Sentry instrumentation, thus breaking the original request functionality.

Additional Locations (3)
Fix in Cursor Fix in Web

if (!url.path.startsWith('/rest/v1')) {
return null;
}
final table = url.pathSegments.last;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Table Name Extraction in URL Handling

The SentrySupabaseRequest.fromRequest method incorrectly extracts the table name from URLs. For paths like /rest/v1, url.pathSegments.last returns 'v1', and for /rest/v1/, it returns an empty string. This leads to incorrect table names in generated SQL queries and Sentry data (spans, breadcrumbs, error contexts). The method should validate that the URL has at least three path segments and that the last segment is not empty before extraction.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supabase Support
2 participants