-
-
Notifications
You must be signed in to change notification settings - Fork 275
Add sentry.replay_id
to flutter logs
#3257
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
21
commits into
main
Choose a base branch
from
enha/logs-replay-id
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.
+477
−16
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
234bb86
Add `sentry.replay_id` to flutter logs
denrase c365316
add cl entry
denrase 006a60d
Merge branch 'main' into enha/logs-replay-id
denrase f0030f0
Add `sentry._internal.replay_is_buffering` attribute
denrase 91562e2
remove in client
denrase 1fafd0c
remove old test
denrase 0c6d307
update logic
denrase 02f86c3
format
denrase 8488d63
Merge branch 'main' into enha/logs-replay-id
denrase 9e888b6
update replay id handling from ios/android native
denrase 1e63021
Merge branch 'main' into enha/logs-replay-id
denrase ccd6a45
Merge branch 'main' into enha/logs-replay-id
denrase b892b55
remove newline
denrase 8b1e81e
fix cl
denrase 506f5cb
additionally check options
denrase f98c32f
Merge branch 'enha/logs-replay-id' of github.com:getsentry/sentry-dar…
denrase 744d429
check args
denrase 56579e7
Merge branch 'main' into enha/logs-replay-id
denrase a279e8d
Change how native side reports the replay id
denrase 34436c7
curreclty check if in buffering mode
denrase 2b5369f
add override annotation
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
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
63 changes: 63 additions & 0 deletions
63
packages/flutter/lib/src/integrations/replay_log_integration.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,63 @@ | ||
// ignore_for_file: invalid_use_of_internal_member | ||
|
||
import 'package:sentry/sentry.dart'; | ||
import '../sentry_flutter_options.dart'; | ||
import '../native/sentry_native_binding.dart'; | ||
|
||
/// Integration that adds replay-related information to logs using lifecycle callbacks | ||
class ReplayLogIntegration implements Integration<SentryFlutterOptions> { | ||
static const String integrationName = 'ReplayLog'; | ||
|
||
final SentryNativeBinding? _native; | ||
ReplayLogIntegration(this._native); | ||
|
||
SentryFlutterOptions? _options; | ||
SdkLifecycleCallback<OnBeforeCaptureLog>? _addReplayInformation; | ||
|
||
@override | ||
Future<void> call(Hub hub, SentryFlutterOptions options) async { | ||
if (!options.replay.isEnabled) { | ||
return; | ||
} | ||
final sessionSampleRate = options.replay.sessionSampleRate ?? 0; | ||
final onErrorSampleRate = options.replay.onErrorSampleRate ?? 0; | ||
|
||
_options = options; | ||
_addReplayInformation = (OnBeforeCaptureLog event) { | ||
final scopeReplayId = hub.scope.replayId; | ||
final replayId = scopeReplayId ?? _native?.replayId; | ||
final replayIsBuffering = replayId != null && scopeReplayId == null; | ||
|
||
if (sessionSampleRate > 0 && replayId != null && !replayIsBuffering) { | ||
event.log.attributes['sentry.replay_id'] = SentryLogAttribute.string( | ||
scopeReplayId.toString(), | ||
); | ||
} else if (onErrorSampleRate > 0 && | ||
replayId != null && | ||
replayIsBuffering) { | ||
event.log.attributes['sentry.replay_id'] = SentryLogAttribute.string( | ||
replayId.toString(), | ||
); | ||
event.log.attributes['sentry._internal.replay_is_buffering'] = | ||
SentryLogAttribute.bool(true); | ||
} | ||
denrase marked this conversation as resolved.
Show resolved
Hide resolved
denrase marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
options.lifecycleRegistry | ||
.registerCallback<OnBeforeCaptureLog>(_addReplayInformation!); | ||
options.sdk.addIntegration(integrationName); | ||
} | ||
|
||
@override | ||
Future<void> close() async { | ||
final options = _options; | ||
final addReplayInformation = _addReplayInformation; | ||
|
||
if (options != null && addReplayInformation != null) { | ||
options.lifecycleRegistry | ||
.removeCallback<OnBeforeCaptureLog>(addReplayInformation); | ||
} | ||
|
||
_options = null; | ||
_addReplayInformation = null; | ||
} | ||
} |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## 9.7.0
.Consider moving the entry to the
## Unreleased
section, please.