-
-
Notifications
You must be signed in to change notification settings - Fork 257
feat: ttid #1910
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
Merged
feat: ttid #1910
Changes from 50 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
0b21267
Change app start integration in a way that works with ttid as well
buenaflor 6f6e71c
Formatting
buenaflor 6ed7700
Update
buenaflor 2f8a47d
add visibleForTesting
buenaflor 50f298b
Update
buenaflor 3477e6f
update
buenaflor dc80015
Merge branch 'main' into feat/ttid-appstart
buenaflor ed3d4ae
Add app start info test
buenaflor 81346de
Remove set app start info null
buenaflor 9d09211
Merge branch 'main' into feat/ttid-appstart
buenaflor cf5af40
Review improvements
buenaflor c653eb1
Merge branch 'main' into feat/ttid-appstart
buenaflor 487e55f
Add TTID
buenaflor 845e6a8
Improvements
buenaflor 96c8766
Improvements
buenaflor 1d9e71f
Fix integration test
buenaflor e3c227f
Merge branch 'main' into feat/ttid
buenaflor cea12c5
Update
buenaflor 9af3455
Clear after tracking
buenaflor 71fd7ec
Update CHANGELOG
buenaflor 7a977fb
Format
buenaflor d7a6a83
Update
buenaflor cde560f
Update
buenaflor f66206d
remove import
buenaflor 87d2755
Merge branch 'main' into feat/ttid
buenaflor 4dedf37
Update sentry tracer
buenaflor 5dd824e
Add (not all) improvements for pr review
buenaflor bf2ad2f
combine transaction handler
buenaflor 4d33aab
Refactor trackAppStart and trackRegularRoute to use private method
buenaflor 248cb8f
Fix dart analyzer
buenaflor 35ec31c
Remove clear
buenaflor e1fde58
Clear in tearDown
buenaflor 4efd9f9
Apply suggestions from code review
buenaflor 579a3c5
Apply PR suggestions
buenaflor f2ba992
fix analyze
buenaflor 7c64a3f
update
buenaflor d90a7ed
update
buenaflor b2767aa
Fix tests
buenaflor 4c6301a
Fix analyze
buenaflor eaa6d8d
revert sample
buenaflor 6ca06dd
Update
buenaflor c73de7b
Update
buenaflor 238995e
Fix test
buenaflor 133e166
Move clear to the beginning of function
buenaflor cc4398d
Fix start time
buenaflor c0f41d8
Fix analyze
buenaflor 2dafed4
Merge branch 'main' into feat/ttid
buenaflor 7434ca1
remove comment
buenaflor e0298fe
Formatting
buenaflor 7e8478c
fix test
buenaflor 67c6e8f
add ttid duration assertion and determineEndTime timeout
buenaflor d32bdea
Merge branch 'main' into feat/ttid
buenaflor 320f92b
Rename finish transaction and do an early exit with enableAutoTransac…
buenaflor a823366
Rename function
buenaflor 1cd1025
Merge branch 'main' into feat/ttid
buenaflor dbc4320
Remove static and getter for in navigator observer
buenaflor 9c6e2b1
Expose SentryDisplayWidget as public api and add it to example app
buenaflor 1aa2343
Fix dart analyze
buenaflor b15eccf
Fix dart doc
buenaflor aeaebfa
Improve tests
buenaflor 5552732
Reduce fake frame finishing time and improve tests
buenaflor 524935c
Improve test names
buenaflor 6e86523
Fix tests
buenaflor 5fa126e
Apply formatting
buenaflor d209276
Add extra assertion in tests
buenaflor 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
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,7 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
@internal | ||
class SentrySpanOperations { | ||
static const String uiLoad = 'ui.load'; | ||
static const String uiTimeToInitialDisplay = 'ui.load.initial_display'; | ||
} |
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
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,60 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'time_to_initial_display_tracker.dart'; | ||
|
||
import '../frame_callback_handler.dart'; | ||
|
||
/// A widget that reports the Time To Initially Displayed (TTID) of its child widget. | ||
/// | ||
/// This widget wraps around another widget to measure and report the time it takes | ||
/// for the child widget to be initially displayed on the screen. This method | ||
/// allows a more accurate measurement than what the default TTID implementation | ||
/// provides. The TTID measurement begins when the route to the widget is pushed and ends | ||
/// when [WidgetsBinding.instance.addPostFrameCallback] is triggered. | ||
/// | ||
/// Wrap the widget you want to measure with [SentryDisplayWidget], and ensure that you | ||
/// have set up Sentry's routing instrumentation according to the Sentry documentation. | ||
/// | ||
/// ```dart | ||
/// SentryDisplayWidget( | ||
/// child: MyWidget(), | ||
/// ) | ||
/// ``` | ||
/// | ||
/// Make sure to configure Sentry's routing instrumentation in your app by following | ||
/// the guidelines provided in Sentry's documentation for Flutter integrations: | ||
/// https://docs.sentry.io/platforms/flutter/integrations/routing-instrumentation/ | ||
/// | ||
/// See also: | ||
/// - [Sentry's documentation on Flutter integrations](https://docs.sentry.io/platforms/flutter/) | ||
/// for more information on how to integrate Sentry into your Flutter application. | ||
class SentryDisplayWidget extends StatefulWidget { | ||
final Widget child; | ||
final FrameCallbackHandler _frameCallbackHandler; | ||
|
||
SentryDisplayWidget({ | ||
super.key, | ||
required this.child, | ||
@visibleForTesting FrameCallbackHandler? frameCallbackHandler, | ||
}) : _frameCallbackHandler = | ||
frameCallbackHandler ?? DefaultFrameCallbackHandler(); | ||
|
||
@override | ||
_SentryDisplayWidgetState createState() => _SentryDisplayWidgetState(); | ||
} | ||
|
||
class _SentryDisplayWidgetState extends State<SentryDisplayWidget> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
TimeToInitialDisplayTracker().markAsManual(); | ||
buenaflor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
widget._frameCallbackHandler.addPostFrameCallback((_) { | ||
TimeToInitialDisplayTracker().completeTracking(); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return widget.child; | ||
} | ||
} |
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,34 @@ | ||
// ignore_for_file: invalid_use_of_internal_member | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:meta/meta.dart'; | ||
|
||
import '../../sentry_flutter.dart'; | ||
import 'time_to_initial_display_tracker.dart'; | ||
|
||
@internal | ||
class TimeToDisplayTracker { | ||
philipphofmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
final TimeToInitialDisplayTracker _ttidTracker; | ||
|
||
TimeToDisplayTracker({ | ||
TimeToInitialDisplayTracker? ttidTracker, | ||
}) : _ttidTracker = ttidTracker ?? TimeToInitialDisplayTracker(); | ||
|
||
Future<void> trackAppStartTTD(ISentrySpan transaction, | ||
{required DateTime startTimestamp, | ||
required DateTime endTimestamp}) async { | ||
// We start and immediately finish the spans since we cannot mutate the history of spans. | ||
await _ttidTracker.trackAppStart(transaction, | ||
startTimestamp: startTimestamp, endTimestamp: endTimestamp); | ||
} | ||
|
||
Future<void> trackRegularRouteTTD(ISentrySpan transaction, | ||
{required DateTime startTimestamp}) async { | ||
await _ttidTracker.trackRegularRoute(transaction, startTimestamp); | ||
} | ||
|
||
void clear() { | ||
_ttidTracker.clear(); | ||
} | ||
} |
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.