Skip to content
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

fix: update android calls after SDK update #2211

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
"loadContexts" -> loadContexts(result)
"displayRefreshRate" -> displayRefreshRate(result)
"addReplayScreenshot" -> addReplayScreenshot(call.argument("path"), call.argument("timestamp"), result)
"sendReplayForEvent" -> sendReplayForEvent(call.argument("eventId"), call.argument("isCrash"), result)
"captureReplay" -> captureReplay(call.argument("isCrash"), result)
else -> result.notImplemented()
}
}
Expand Down Expand Up @@ -555,16 +555,15 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
result.success("")
}

private fun sendReplayForEvent(
eventId: String?,
private fun captureReplay(
isCrash: Boolean?,
result: Result,
) {
if (eventId == null || isCrash == null) {
if (isCrash == null) {
result.error("5", "Arguments are null", null)
return
}
replay.sendReplay(isCrash, eventId, null)
replay.captureReplay(isCrash)
result.success(replay.getReplayId().toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
event.exceptions?.isNotEmpty == true) {
final isCrash =
event.exceptions!.any((e) => e.mechanism?.handled == false);
await _binding.sendReplayForEvent(event.eventId, isCrash);
await _binding.captureReplay(isCrash);

Check warning on line 18 in flutter/lib/src/event_processor/replay_event_processor.dart

View check run for this annotation

Codecov / codecov/patch

flutter/lib/src/event_processor/replay_event_processor.dart#L18

Added line #L18 was not covered by tests
}
return event;
}
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/src/native/sentry_native_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ abstract class SentryNativeBinding {

Future<void> resumeAppHangTracking();

Future<SentryId> sendReplayForEvent(SentryId eventId, bool isCrash);
Future<SentryId> captureReplay(bool isCrash);
}
5 changes: 2 additions & 3 deletions flutter/lib/src/native/sentry_native_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@
channel.invokeMethod('resumeAppHangTracking');

@override
Future<SentryId> sendReplayForEvent(SentryId eventId, bool isCrash) =>
channel.invokeMethod('sendReplayForEvent', {
'eventId': eventId.toString(),
Future<SentryId> captureReplay(bool isCrash) =>
channel.invokeMethod('captureReplay', {

Check warning on line 202 in flutter/lib/src/native/sentry_native_channel.dart

View check run for this annotation

Codecov / codecov/patch

flutter/lib/src/native/sentry_native_channel.dart#L202

Added line #L202 was not covered by tests
'isCrash': isCrash,
}).then((value) => SentryId.fromId(value as String));
}
20 changes: 5 additions & 15 deletions flutter/test/mocks.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1364,26 +1364,16 @@ class MockSentryNativeBinding extends _i1.Mock
) as _i7.Future<void>);

@override
_i7.Future<_i2.SentryId> sendReplayForEvent(
_i2.SentryId? eventId,
bool? isCrash,
) =>
(super.noSuchMethod(
_i7.Future<_i2.SentryId> captureReplay(bool? isCrash) => (super.noSuchMethod(
Invocation.method(
#sendReplayForEvent,
[
eventId,
isCrash,
],
#captureReplay,
[isCrash],
),
returnValue: _i7.Future<_i2.SentryId>.value(_FakeSentryId_5(
this,
Invocation.method(
#sendReplayForEvent,
[
eventId,
isCrash,
],
#captureReplay,
[isCrash],
),
)),
) as _i7.Future<_i2.SentryId>);
Expand Down
Loading