-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replay orientation change (#2462)
* refactor: move replay integration to a separate class * Add onBuild callback to ScreenshotWidget * configure replay from dart to native (java) * send replay config from dart to native * fix: missing return in android plugin leading to duplicate response * fix android replay start before the setting is present * tmp log * logging * change screenshot dimensions to double * refactor android replay integration and fix timing issues during orientation changes * fix tests * cleanup * ktlint * update test coverage * linter issues * chore: changelog * enh: use ensureVisualUpdate instead of scheduleFrame * avoid errors during initial "unconfigured" replay startup * linter
- Loading branch information
Showing
31 changed files
with
826 additions
and
347 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,48 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
import '../../../sentry_flutter.dart'; | ||
import '../../replay/scheduled_recorder.dart'; | ||
import '../sentry_safe_method_channel.dart'; | ||
|
||
@internal | ||
class AndroidReplayRecorder extends ScheduledScreenshotRecorder { | ||
final SentrySafeMethodChannel _channel; | ||
final String _cacheDir; | ||
|
||
AndroidReplayRecorder( | ||
super.config, super.options, this._channel, this._cacheDir) { | ||
super.callback = _addReplayScreenshot; | ||
} | ||
|
||
Future<void> _addReplayScreenshot( | ||
ScreenshotPng screenshot, bool isNewlyCaptured) async { | ||
final timestamp = DateTime.now().millisecondsSinceEpoch; | ||
final filePath = "$_cacheDir/$timestamp.png"; | ||
|
||
options.logger( | ||
SentryLevel.debug, | ||
'$logName: saving ${isNewlyCaptured ? 'new' : 'repeated'} screenshot to' | ||
' $filePath (${screenshot.width}x${screenshot.height} pixels, ' | ||
'${screenshot.data.lengthInBytes} bytes)'); | ||
try { | ||
await options.fileSystem | ||
.file(filePath) | ||
.writeAsBytes(screenshot.data.buffer.asUint8List(), flush: true); | ||
|
||
await _channel.invokeMethod( | ||
'addReplayScreenshot', | ||
{'path': filePath, 'timestamp': timestamp}, | ||
); | ||
} catch (error, stackTrace) { | ||
options.logger( | ||
SentryLevel.error, | ||
'$logName: native call `addReplayScreenshot` failed', | ||
exception: error, | ||
stackTrace: stackTrace, | ||
); | ||
if (options.automatedTestMode) { | ||
rethrow; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.