initializeSessionReplay method

  1. @override
Future<String?> initializeSessionReplay(
  1. CXSessionReplayOptions options
)
override

Implementation

@override
Future<String?> initializeSessionReplay(
    CXSessionReplayOptions options) async {
  try {
    final arguments = options.toMap();
    final result = await methodChannel.invokeMethod<String>(
        'initializeSessionReplay', arguments);

    // Ensure the masking handler is registered (idempotent — no-op if the
    // app already called SessionReplayMasking.initialize() at startup), then
    // apply masking from the options. CXSessionReplayOptions is the single
    // source of truth for masking behaviour.
    SessionReplayMasking.initialize();
    await SessionReplayMasking.applyOptions(
      maskAllTexts: options.maskAllTexts ?? false,
      maskAllImages: options.maskAllImages ?? false,
      captureScale: options.captureScale,
      textsToMask: options.textsToMask,
    );

    return result;
  } on PlatformException catch (e) {
    debugPrint('Error initializing session replay: $e');
    return null;
  }
}