Skip to content

Commit

Permalink
fix: update android calls after SDK update (#2211)
Browse files Browse the repository at this point in the history
* fix: update android calls after SDK update

* ktlint
  • Loading branch information
vaind authored Aug 2, 2024
1 parent 0eb16e1 commit 648f8bc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 25 deletions.
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 @@ class ReplayEventProcessor implements EventProcessor {
event.exceptions?.isNotEmpty == true) {

Check warning on line 15 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#L14-L15

Added lines #L14 - L15 were not covered by tests
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#L17-L18

Added lines #L17 - L18 were 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 @@ class SentryNativeChannel
channel.invokeMethod('resumeAppHangTracking');

@override

Check warning on line 200 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#L200

Added line #L200 was not covered by tests
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));

Check warning on line 204 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#L204

Added line #L204 was not covered by tests
}
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

0 comments on commit 648f8bc

Please sign in to comment.