Skip to content

enh(navigator-observer): make new trace id on navigation opt-in instead of opt-out#3657

Merged
buenaflor merged 2 commits into
mainfrom
enh/disable-new-trace-on-navigation-default
Apr 22, 2026
Merged

enh(navigator-observer): make new trace id on navigation opt-in instead of opt-out#3657
buenaflor merged 2 commits into
mainfrom
enh/disable-new-trace-on-navigation-default

Conversation

@buenaflor

@buenaflor buenaflor commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

📜 Description

Creating a fresh trace id on each route push/pop/replace by default can break trace continuity for users who don't expect it. And through experience the default (trace by session) is much more useful and understandable.

Flip the default of enableNewTraceOnNavigation to false; users who want the old behavior can opt in.

💡 Motivation and Context

Closes #3589

💚 How did you test it?

Change existing test

📝 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

Creating a fresh trace on each route push/pop/replace by default can
break trace continuity for users who don't expect it. Flip the default
of enableNewTraceOnNavigation to false; users who want the old behavior
can opt in.

Refs #3589

Co-Authored-By: Claude <[email protected]>
@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Enhancements

  • (navigator-observer) Disable new trace on navigation by default by buenaflor in #3657

Internal Changes

Deps

  • Bump actions/create-github-app-token from 3.0.0 to 3.1.1 by dependabot in #3652
  • Bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.25.2 to 2.25.4 by dependabot in #3655
  • Bump actions/cache from 5.0.4 to 5.0.5 by dependabot in #3656

🤖 This preview updates automatically when you update the PR.

@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.80%. Comparing base (107a26b) to head (59695da).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3657      +/-   ##
==========================================
+ Coverage   86.96%   91.80%   +4.84%     
==========================================
  Files         321      102     -219     
  Lines       10802     3479    -7323     
==========================================
- Hits         9394     3194    -6200     
+ Misses       1408      285    -1123     
Flag Coverage Δ
sentry ?
sentry_dio ?
sentry_drift ?
sentry_file ?
sentry_firebase_remote_config 100.00% <ø> (ø)
sentry_flutter 91.38% <ø> (ø)
sentry_hive ?
sentry_isar ?
sentry_link ?
sentry_logging ?
sentry_sqflite ?
sentry_supabase 97.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@sentry

sentry Bot commented Apr 21, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
sentry_flutter_example io.sentry.flutter.sample 9.18.0 (1) Release

⚙️ sentry-flutter Build Distribution Settings

@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1259.57 ms 1262.06 ms 2.49 ms
Size 5.73 MiB 6.17 MiB 453.72 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
f761369 1261.69 ms 1277.82 ms 16.12 ms
9b99523 1256.06 ms 1270.33 ms 14.27 ms
e45c0e1 1269.08 ms 1278.83 ms 9.75 ms
e2d675d 1238.48 ms 1242.76 ms 4.28 ms
101a9c7 1225.80 ms 1236.04 ms 10.25 ms
dc53d48 1252.06 ms 1255.61 ms 3.55 ms
027fcfd 1239.04 ms 1243.65 ms 4.61 ms
7cfee3b 1260.90 ms 1273.14 ms 12.24 ms
1ce780b 1252.49 ms 1256.17 ms 3.68 ms
765aa8b 1259.09 ms 1269.90 ms 10.82 ms

App size

Revision Plain With Sentry Diff
f761369 7.86 MiB 9.44 MiB 1.58 MiB
9b99523 7.86 MiB 9.44 MiB 1.58 MiB
e45c0e1 7.86 MiB 9.44 MiB 1.58 MiB
e2d675d 7.86 MiB 9.44 MiB 1.58 MiB
101a9c7 5.73 MiB 6.17 MiB 455.47 KiB
dc53d48 5.65 MiB 6.09 MiB 446.96 KiB
027fcfd 5.73 MiB 6.17 MiB 455.48 KiB
7cfee3b 20.70 MiB 22.46 MiB 1.75 MiB
1ce780b 5.66 MiB 6.10 MiB 451.58 KiB
765aa8b 7.86 MiB 9.44 MiB 1.58 MiB

Previous results on branch: enh/disable-new-trace-on-navigation-default

Startup times

Revision Plain With Sentry Diff
58f5a7f 1267.83 ms 1269.95 ms 2.12 ms

App size

Revision Plain With Sentry Diff
58f5a7f 5.73 MiB 6.17 MiB 453.61 KiB

@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 418.28 ms 431.31 ms 13.03 ms
Size 14.31 MiB 15.49 MiB 1.19 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7b21e8b 467.74 ms 466.24 ms -1.50 ms
827bf09 475.40 ms 547.14 ms 71.74 ms
f872f8e 402.38 ms 416.20 ms 13.82 ms
a69a51f 437.18 ms 450.60 ms 13.42 ms
8bfae64 370.78 ms 369.15 ms -1.63 ms
cc4e375 426.15 ms 482.34 ms 56.19 ms
e1ab497 429.30 ms 439.00 ms 9.70 ms
9b99523 456.91 ms 490.55 ms 33.64 ms
1777727 438.67 ms 447.11 ms 8.44 ms
1f639ee 429.98 ms 476.60 ms 46.62 ms

App size

Revision Plain With Sentry Diff
7b21e8b 13.93 MiB 15.00 MiB 1.06 MiB
827bf09 6.54 MiB 7.53 MiB 1015.27 KiB
f872f8e 13.93 MiB 15.18 MiB 1.25 MiB
a69a51f 13.93 MiB 15.06 MiB 1.13 MiB
8bfae64 14.09 MiB 15.28 MiB 1.19 MiB
cc4e375 6.54 MiB 7.69 MiB 1.15 MiB
e1ab497 13.93 MiB 15.06 MiB 1.13 MiB
9b99523 6.54 MiB 7.69 MiB 1.15 MiB
1777727 14.30 MiB 15.49 MiB 1.19 MiB
1f639ee 13.93 MiB 15.00 MiB 1.06 MiB

Previous results on branch: enh/disable-new-trace-on-navigation-default

Startup times

Revision Plain With Sentry Diff
58f5a7f 371.51 ms 358.81 ms -12.70 ms

App size

Revision Plain With Sentry Diff
58f5a7f 14.31 MiB 15.49 MiB 1.19 MiB

@buenaflor
buenaflor marked this pull request as ready for review April 21, 2026 11:10
Copilot AI review requested due to automatic review settings April 21, 2026 11:10
@buenaflor
buenaflor requested a review from denrase as a code owner April 21, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates SentryNavigatorObserver to avoid starting a fresh trace on every navigation event by default, preserving trace continuity unless explicitly opted in.

Changes:

  • Flip enableNewTraceOnNavigation default from true to false in SentryNavigatorObserver.
  • Update and expand navigator observer trace tests to reflect the new default and verify opt-in behavior still works.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/flutter/lib/src/navigation/sentry_navigator_observer.dart Changes the default for enableNewTraceOnNavigation and updates the API docs accordingly.
packages/flutter/test/navigation/sentry_navigator_observer_traces_test.dart Adjusts existing tests and adds coverage to validate both default-disabled and explicitly-enabled behaviors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/flutter/lib/src/navigation/sentry_navigator_observer.dart

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 58f5a7f. Configure here.

Comment thread packages/flutter/lib/src/navigation/sentry_navigator_observer.dart
@buenaflor buenaflor changed the title enh(navigator-observer): disable new trace on navigation by default enh(navigator-observer): make new trace on navigation opt-in instead of opt-out Apr 22, 2026
@buenaflor buenaflor changed the title enh(navigator-observer): make new trace on navigation opt-in instead of opt-out enh(navigator-observer): make new trace id on navigation opt-in instead of opt-out Apr 22, 2026
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.

When using SentryNavigatorObserver dont create trace ids on route push by default

3 participants