cxorbi_flutter 0.1.0
cxorbi_flutter: ^0.1.0 copied to clipboard
Cxorbi analytics for Flutter: session replay, heatmaps, screens, gestures, funnels, performance and error capture for iOS and Android.
example/lib/main.dart
import 'package:cxorbi_flutter/cxorbi_flutter.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// 1. Initialize with your organization API key (Dashboard -> Integrations).
await Cxorbi.init(CxorbiConfig(apiKey: 'YOUR_API_KEY'));
// 2. The SDK is opted OUT by default — nothing is captured or sent until
// opt-in. Call it now, or defer to your consent dialog.
await Cxorbi.instance.optIn();
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Cxorbi Flutter Example',
// 3. Automatic screen tracking for every named route.
navigatorObservers: [CxorbiNavigatorObserver()],
initialRoute: '/home',
routes: {
'/home': (_) => const HomeScreen(),
'/details': (_) => const DetailsScreen(),
},
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Home')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
// Attach your user id after login.
Cxorbi.instance.identify('user-123', {'plan': 'premium'});
// Track a custom event (feeds funnels and journeys).
Cxorbi.instance.track('cta_tapped', {'screen': 'home'});
Navigator.of(context).pushNamed('/details');
},
child: const Text('Go to details'),
),
],
),
),
);
}
}
class DetailsScreen extends StatelessWidget {
const DetailsScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Details')),
body: const Center(child: Text('Tap, scroll, and navigate to generate data.')),
);
}
}