Skip to main content

kubesense_session_replay 1.0.0 copy "kubesense_session_replay: ^1.0.0" to clipboard
kubesense_session_replay: ^1.0.0 copied to clipboard

Support for Flutter Session Replay in Kubesense

example/lib/main.dart

// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2025-Present Datadog, Inc.
// Modifications copyright 2026 KubeSense Technologies.
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:kubesense_flutter_plugin/kubesense_flutter_plugin.dart';
import 'package:kubesense_session_replay/kubesense_session_replay.dart';

import 'app.dart';

void main() async {
  await dotenv.load();

  var applicationId = dotenv.maybeGet('KUBESENSE_APPLICATION_ID');

  final configuration = KubesenseConfiguration(
    clientToken: dotenv.get('KUBESENSE_CLIENT_TOKEN', fallback: ''),
    env: dotenv.get('KUBESENSE_ENV', fallback: ''),
    service: 'ai.kubesense.example.flutter',
    version: '1.2.3',
    kubesenseRumEndpoint:
        dotenv.get('KUBESENSE_RUM_ENDPOINT', fallback: 'us2.kubesense.ai'),
    nativeCrashReportEnabled: true,
    loggingConfiguration: KubesenseLoggingConfiguration(),
    rumConfiguration: applicationId != null
        ? KubesenseRumConfiguration(
            sessionSamplingRate: 100.0,
            applicationId: applicationId,
            detectLongTasks: true,
            reportFlutterPerformance: true,
          )
        : null,
  )..enableSessionReplay(
      KubesenseSessionReplayConfiguration(
        textAndInputPrivacyLevel: TextAndInputPrivacyLevel.maskSensitiveInputs,
        touchPrivacyLevel: TouchPrivacyLevel.show,
        replaySampleRate: 1.0,
      ),
    );

  final ddsdk = KubesenseSdk.instance;
  ddsdk.sdkVerbosity = CoreLoggerLevel.debug;
  await KubesenseSdk.runApp(configuration, TrackingConsent.granted, () async {
    return runApp(const MyApp());
  });
}