Record Flutter sessions
Use the sessionReplay module in Flutter hybrid applications.
Prerequisites
-
You must have an enterprise subscription.
-
You must use Splunk RUM agent version
1.0.0or higher.
Module configuration
The session replay module is included in the Splunk RUM Flutter agent and is enabled by default. This module captures user interactions and visual changes, allowing you to replay sessions step by step.
Session replay being enabled allows recording, but does not start it automatically. To begin recording, call start().
import 'package:splunk_otel_flutter/splunk_otel_flutter.dart';
await SplunkRum.instance.install(
agentConfiguration: AgentConfiguration(
endpointConfiguration: EndpointConfiguration.forRum(
realm: 'YOUR_ENV',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
),
appName: 'YOUR_APP',
deploymentEnvironment: 'YOUR_ENV',
),
moduleConfigurations: [
SessionReplayModuleConfiguration(
isEnabled: true,
samplingRate: 0.2,
),
],
);
isEnabled: Enables or disables session replay. When disabled, recording cannot be started.
samplingRate: Defines the sampling rate for session replay recordings (0 to 1). The default value is 0.2 (20%).
Session replay instance
import 'package:splunk_otel_flutter_session_replay/splunk_otel_flutter_session_replay.dart';
final sessionReplay = SplunkSessionReplay.instance;
Start or stop recording
start() and stop(). Subsequent calls to start() or stop() have no effect if the recording state is unchanged.
import 'package:splunk_otel_flutter_session_replay/splunk_otel_flutter_session_replay.dart';
// Start recording
await SplunkSessionReplay.instance.start();
// Stop recording
await SplunkSessionReplay.instance.stop();
Check recording status
To determine whether session replay is currently recording, use the following API:
import 'package:splunk_otel_flutter_session_replay/splunk_otel_flutter_session_replay.dart';
final status = await SplunkSessionReplay.instance.getStatus();
if (status == SessionReplayStatus.isRecording) {
// Session replay is currently recording
}
Set the recording mask
To protect user privacy, configure session replay to mask sensitive areas of the application UI.
RecordingMask to define regions that should not be recorded.
import 'dart:ui';
import 'package:splunk_otel_flutter_session_replay/splunk_otel_flutter_session_replay.dart';
await SplunkSessionReplay.instance.setRecordingMask(
mask: RecordingMask(
elements: [
MaskElement(
rect: Rect.fromLTWH(0, 0, 200, 300),
type: MaskType.covering,
),
MaskElement(
rect: Rect.fromLTWH(50, 50, 100, 100),
type: MaskType.erasing,
),
],
),
);
RecordingMask can be active at a time. A mask can include multiple MaskElement instances to cover multiple areas.
MaskElement can be one of two types:
| Mask type | How it works |
|---|---|
MaskType.covering |
The area defined by the element Rect is not recorded. |
MaskType.erasing |
The area defined by the element Rect is recorded even if a previous MaskElement inside a list was covering the area. |
Recording mask example
The following example describes a RecordingMask use case.
The blue box in this first example represents a video_item element. The red box represents a video_item_image element.
The video_item element in this second example has a .covering value. The .covering value masks the element in the session recording.