Kubesense Session Replay
Warning
This package is currently in preview! Portions of the public API for this package may break without a major version update.
A package for integrating Kubesense Session Replay into Flutter applications.
Getting started
Session Replay for Flutter requires using the Kubesense Flutter Plugin in conjunction with Kubesense RUM. For more information, see the official Kubesense documentation.
Important
Flutter Session Replay relies on FFI, and iOS requires a build change that the package cannot change automatically.
To ensure the required FFI symbols are not stripped during Archiving or IPA creation, you must set Strip Style in your Xcode project to Non-Global Symbols.
For more information, see this issue in the Flutter repo.
To use Kubesense Session Replay for Flutter, first add the package to your pubspec.yaml:
packages:
# other packages
kubesense_flutter_plugin: ^1.0.0
kubesense_session_replay: ^x.x.x
Next, add Session Replay to your KubesenseConfiguration:
import 'package:kubesense_session_replay/kubesense_session_replay.dart';
// ....
final configuration = KubesenseConfiguration(
// Normal Kubesense configuration
clientToken: 'client-token',
// RUM is required to use Kubesense Session Replay
rumConfiguration: RumConfiguration(
applicationId: '<application-id'>
),
)..enableSessionReplay(
KubesenseSessionReplayConfiguration(
// Setup default text, image, and touch privacy
textAndInputPrivacyLevel: TextAndInputPrivacyLevel.maskSensitiveInputs,
touchPrivacyLevel: TouchPrivacyLevel.show,
// Setup session replay sample rate.
replaySampleRate: 1.0,
),
);
Manual start and stop
By default, Session Replay starts recording when it initializes. To start recording manually, set startRecordingImmediately: false on KubesenseSessionReplayConfiguration. Then, call KubesenseSessionReplay.instance!.startRecording() to begin recording and KubesenseSessionReplay.instance!.stopRecording() to pause it. The background processor isolate stays running while recording is stopped, so resuming is fast.
Calling stopRecording() also stops pointer capture (touch and gesture events). Both resume on the next startRecording() call.
// Begin capturing when the user reaches a screen you want recorded
KubesenseSessionReplay.instance!.startRecording();
// Pause capture (for example, before showing a sensitive screen)
KubesenseSessionReplay.instance!.stopRecording();
Last, add a SessionReplayCapture widget to the root of your Widget tree, above your MaterialApp or similar application widget:
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// Note a key is required for SessionReplayCapture
final captureKey = GlobalKey();
// Other App Configuration
@override
Widget build(BuildContext context) {
return SessionReplayCapture(
key: captureKey,
rum: KubesenseSdk.instance.rum!,
sessionReplay: KubesenseSessionReplay.instance!,
child: MaterialApp.router(color: color, routerConfig: router),
);
}
}
Note
SessionReplayCapture includes a RumUserActionDetector. If you are already using a RumUserActionDetector, you should remove it in favor of the one used by SessionReplayCapture.