kubesense_webview_tracking 1.0.0
kubesense_webview_tracking: ^1.0.0 copied to clipboard
A package for tracking Kubesense sessions in a webview
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 2023-Present Datadog, Inc.
// Modifications copyright 2026 KubeSense Technologies.
import 'dart:async';
import 'dart:io';
import 'package:kubesense_flutter_plugin/kubesense_flutter_plugin.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'app.dart';
String? customEndpoint;
Future<void> main() async {
await dotenv.load(mergeWith: Platform.environment);
var clientToken = dotenv.get('KUBESENSE_CLIENT_TOKEN', fallback: '');
var applicationId = dotenv.maybeGet('KUBESENSE_APPLICATION_ID');
customEndpoint ??= dotenv.maybeGet('KUBESENSE_RUM_ENDPOINT');
KubesenseSdk.instance.sdkVerbosity = CoreLoggerLevel.debug;
final configuration = KubesenseConfiguration(
kubesenseRumEndpoint: customEndpoint ?? 'us2.kubesense.ai',
clientToken: clientToken,
env: dotenv.get('KUBESENSE_ENV', fallback: ''),
uploadFrequency: UploadFrequency.frequent,
batchSize: BatchSize.small,
nativeCrashReportEnabled: true,
firstPartyHosts: [],
loggingConfiguration: KubesenseLoggingConfiguration(),
rumConfiguration: applicationId != null
? KubesenseRumConfiguration(
detectLongTasks: false,
applicationId: applicationId,
traceSampleRate: 100,
)
: null,
);
// This is only needed for interation testing, as the mock server doesn't support https
if (customEndpoint != null) {
configuration.additionalConfig['_kubesense.needsClearTextHttp'] = true;
}
await KubesenseSdk.runApp(configuration, TrackingConsent.granted, () async {
runApp(const MyApp());
});
}