amplitude_session_replay 0.1.0-beta.5 copy "amplitude_session_replay: ^0.1.0-beta.5" to clipboard
amplitude_session_replay: ^0.1.0-beta.5 copied to clipboard

Session Replay SDK for Flutter.


Amplitude Session Replay Flutter SDK #

Warning This SDK is currently in alpha. APIs may change and there will be breaking changes before the stable release.

This is Amplitude's Session Replay SDK for Flutter.

Installation #

Add the package to your pubspec.yaml:

dependencies:
  amplitude_session_replay: ^0.1.0-beta.5

Then run:

flutter pub get

Quick Start #

Call SessionReplay.instance.init with a SessionReplayConfig, then start recording when your app is ready:

import 'package:amplitude_session_replay/amplitude_session_replay.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final config = SessionReplayConfig(
    apiKey: 'YOUR_AMPLITUDE_API_KEY',
    deviceId: 'your-device-id',
    sessionId: DateTime.now().millisecondsSinceEpoch, // from your analytics SDK
  );

  SessionReplay.instance.init(config);
  await SessionReplay.instance.start();

  runApp(const MyApp());
}

Hybrid Mode (Add-to-App) #

If your app already initializes the native Amplitude Session Replay SDK (iOS or Android — for example, an add-to-app embedding inside a host native application), call attach() instead of init(). The Flutter SDK installs its binary channel handler and lets the native SDK drive the recording lifecycle:

import 'package:amplitude_session_replay/amplitude_session_replay.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SessionReplay.instance.attach();
  runApp(const MyApp());
}

In hybrid mode, the native SDK owns recording state. start(), stop(), flush(), setOptOut(), setSessionId(), and setDeviceId() are no-ops in this mode (they log a warning and return) — set those options on the native SDK directly. dispose() tears down the Dart channel handler and engine but leaves the native SDK alone, since the host app owns its lifecycle.

Need Help? #

If you have any problems or issues over our SDK, feel free to create a GitHub issue or submit a request on Amplitude Help.