Skip to content

Commit

Permalink
chore: report replay integration (#2349)
Browse files Browse the repository at this point in the history
* chore: add replay integration to events

* test

* chore: add changelog

* update tests
  • Loading branch information
vaind authored Oct 14, 2024
1 parent f3a18f2 commit 8da6ae0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 10 deletions.
20 changes: 11 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@
- Deprecated `SentryClient.captureUserFeedback`, use `captureFeedback` instead.
- Deprecated `SentryUserFeedback`, use `SentryFeedback` instead.
- Add `SentryFeedbackWidget` ([#2240](https://github.com/getsentry/sentry-dart/pull/2240))
```dart
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SentryFeedbackWidget(associatedEventId: id),
fullscreenDialog: true,
),
);
```

```dart
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SentryFeedbackWidget(associatedEventId: id),
fullscreenDialog: true,
),
);
```

### Enhancements

Expand All @@ -55,6 +56,7 @@ Navigator.push(
- Fixes ([#2103](https://github.com/getsentry/sentry-dart/issues/2103))
- Fixes ([#2233](https://github.com/getsentry/sentry-dart/issues/2233))
- Only store slow and frozen frames for frame delay calculation ([#2337](https://github.com/getsentry/sentry-dart/pull/2337))
- Add ReplayIntegration to the integrations list on events when replay is enabled. ([#2349](https://github.com/getsentry/sentry-dart/pull/2349))

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion flutter/ios/Classes/SentryFlutterPluginApple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
}

if let integrations = PrivateSentrySDKOnly.options.integrations {
infos["integrations"] = integrations
infos["integrations"] = integrations.filter { $0 != "SentrySessionReplayIntegration" }
}

let deviceStr = "device"
Expand Down
3 changes: 3 additions & 0 deletions flutter/lib/src/native/cocoa/sentry_native_cocoa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:meta/meta.dart';

import '../../../sentry_flutter.dart';
import '../../event_processor/replay_event_processor.dart';
import '../../replay/integration.dart';
import '../../replay/recorder.dart';
import '../../replay/recorder_config.dart';
import '../sentry_native_channel.dart';
Expand All @@ -25,6 +26,8 @@ class SentryNativeCocoa extends SentryNativeChannel {
// so let's set it up conditionally. This allows Dart to trim the code.
if (options.experimental.replay.isEnabled &&
options.platformChecker.platform.isIOS) {
options.sdk.addIntegration(replayIntegrationName);

// We only need the integration when error-replay capture is enabled.
if ((options.experimental.replay.onErrorSampleRate ?? 0) > 0) {
options.addEventProcessor(ReplayEventProcessor(hub, this));
Expand Down
3 changes: 3 additions & 0 deletions flutter/lib/src/native/java/sentry_native_java.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:meta/meta.dart';

import '../../../sentry_flutter.dart';
import '../../event_processor/replay_event_processor.dart';
import '../../replay/integration.dart';
import '../../replay/scheduled_recorder.dart';
import '../../replay/recorder_config.dart';
import '../sentry_native_channel.dart';
Expand All @@ -23,6 +24,8 @@ class SentryNativeJava extends SentryNativeChannel {
// We only need these when replay is enabled (session or error capture)
// so let's set it up conditionally. This allows Dart to trim the code.
if (options.experimental.replay.isEnabled) {
options.sdk.addIntegration(replayIntegrationName);

// We only need the integration when error-replay capture is enabled.
if ((options.experimental.replay.onErrorSampleRate ?? 0) > 0) {
options.addEventProcessor(ReplayEventProcessor(hub, this));
Expand Down
6 changes: 6 additions & 0 deletions flutter/lib/src/replay/integration.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:meta/meta.dart';

/// We don't actually have an integration, just want to have a name reported
/// on events so we can filter them out.
@internal
const replayIntegrationName = 'ReplayIntegration';
16 changes: 16 additions & 0 deletions flutter/test/replay/replay_native_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_flutter/src/event_processor/replay_event_processor.dart';
import 'package:sentry_flutter/src/native/factory.dart';
import 'package:sentry_flutter/src/native/sentry_native_binding.dart';
import 'package:sentry_flutter/src/replay/integration.dart';

import '../mocks.dart';
import '../mocks.mocks.dart';
Expand Down Expand Up @@ -70,6 +71,21 @@ void main() {
await sut.close();
});

test('init adds $replayIntegrationName when replay is enabled', () async {
options.experimental.replay.sessionSampleRate = 0.1;
await sut.init(hub);

expect(options.sdk.integrations, contains(replayIntegrationName));
});

test('init does not add $replayIntegrationName when replay is disabled',
() async {
await sut.init(hub);

expect(
options.sdk.integrations, isNot(contains(replayIntegrationName)));
});

test('init sets $ReplayEventProcessor when error replay is enabled',
() async {
options.experimental.replay.onErrorSampleRate = 0.1;
Expand Down

0 comments on commit 8da6ae0

Please sign in to comment.