atatus_flutter_plugin 1.0.0
atatus_flutter_plugin: ^1.0.0 copied to clipboard
Flutter bindings and tools for utilizing atatus Mobile SDks
Atatus Flutter Plugin #
The official Flutter plugin for Atatus — Real User Monitoring (RUM) and Log Management for Flutter applications on Android, iOS, and Web.
Features #
- 📊 Real User Monitoring (RUM) — Track user sessions, views, actions, resources, and errors
- 📝 Log Management — Send structured logs to Atatus from Flutter
- 🔍 Distributed Tracing — Correlate network requests with backend traces
- 💥 Crash Reporting — Automatic native crash detection on Android and iOS
- ⚡ Performance Monitoring — Track long tasks, mobile vitals, and Flutter frame timings
- 👤 User & Account Tracking — Attach user and account context to all events
Requirements #
| Platform | Minimum Version |
|---|---|
| Flutter | >= 3.27.0 |
| Dart SDK | ^3.6.0 |
Android minSdkVersion |
23 |
| iOS | >= 13.0 |
Installation #
Add the plugin to your pubspec.yaml:
dependencies:
atatus_flutter_plugin: ^1.0.0
Then run:
flutter pub get
Platform Setup #
Android #
Ensure your android/app/build.gradle has:
android {
defaultConfig {
minSdkVersion 23
}
}
iOS #
Your ios/Podfile must target iOS 13.0 or higher:
platform :ios, '13.0'
Web #
Add the Atatus Browser SDK scripts to the <head> section of your web/index.html:
<script type="text/javascript" src="https://www.atatus-browser-agent.com/us1/v6/atatus-logs.js"></script>
<script type="text/javascript" src="https://www.atatus-browser-agent.com/us1/v6/atatus-rum-slim.js"></script>
Quick Start #
1. Initialize the SDK #
In your main.dart, initialize Atatus before running the app:
import 'package:atatus_flutter_plugin/atatus_flutter_plugin.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final configuration = AtatusConfiguration(
licenseKey: '<YOUR_LICENSE_KEY>',
env: 'production',
appName: 'MyFlutterApp',
nativeCrashReportEnabled: true,
loggingConfiguration: AtatusLoggingConfiguration(),
rumConfiguration: AtatusRumConfiguration(),
);
await AtatusSdk.instance.initialize(configuration, TrackingConsent.granted);
runApp(const MyApp());
}
Using AtatusSdk.runApp (recommended — auto sets up error reporting)
void main() async {
final configuration = AtatusConfiguration(
licenseKey: '<YOUR_LICENSE_KEY>',
env: 'production',
appName: 'MyFlutterApp',
nativeCrashReportEnabled: true,
loggingConfiguration: AtatusLoggingConfiguration(),
rumConfiguration: AtatusRumConfiguration(),
);
await AtatusSdk.runApp(configuration, TrackingConsent.granted, () {
runApp(const MyApp());
});
}
Configuration #
AtatusConfiguration #
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
licenseKey |
String |
✅ | — | Your Atatus license key |
env |
String |
✅ | — | Environment name (e.g. production, staging) |
appName |
String? |
— | — | Application name |
site |
AtatusSite |
— | AtatusSite.ATATUS |
Data center endpoint |
customEndpoint |
String? |
— | — | Custom ingestion endpoint URL |
nativeCrashReportEnabled |
bool |
— | false |
Enable native crash reporting |
service |
String? |
— | — | Service name tag |
version |
String? |
— | — | App version (for symbolication) |
batchSize |
BatchSize? |
— | — | Upload batch size (small, medium, large) |
uploadFrequency |
UploadFrequency? |
— | — | Upload frequency (frequent, average, rare) |
firstPartyHosts |
List<String> |
— | [] |
Hosts for distributed tracing |
loggingConfiguration |
AtatusLoggingConfiguration? |
— | — | Enable logging feature |
rumConfiguration |
AtatusRumConfiguration? |
— | — | Enable RUM feature |
AtatusRumConfiguration #
| Parameter | Type | Default | Description |
|---|---|---|---|
applicationId |
String? |
— | RUM application ID (uses licenseKey if omitted) |
sessionSamplingRate |
double |
100.0 |
% of sessions to track (0–100) |
traceSampleRate |
double |
100.0 |
% of resources to include APM traces (0–100) |
traceContextInjection |
TraceContextInjection |
sampled |
all or sampled |
detectLongTasks |
bool |
true |
Detect long tasks on main thread |
longTaskThreshold |
double |
0.1 |
Threshold in seconds to consider a long task |
reportFlutterPerformance |
bool |
false |
Report Flutter build/raster times |
trackFrustrations |
bool |
true |
Track user frustration signals |
vitalUpdateFrequency |
VitalsFrequency? |
average |
Mobile vitals collection frequency |
trackAnonymousUser |
bool |
true |
Track anonymous user ID across sessions |
trackBackgroundEvents |
bool |
false |
Track events when app is in background |
appHangThreshold |
double? |
null |
iOS only: non-fatal app hang threshold in seconds |
trackNonFatalAnrs |
bool? |
— | Android only: track non-fatal ANRs |
AtatusLoggingConfiguration #
| Parameter | Type | Default | Description |
|---|---|---|---|
customEndpoint |
String? |
— | Override logs endpoint |
eventMapper |
LogEventMapper? |
— | Modify or drop log events before sending |
Logging #
After initializing with loggingConfiguration, create a logger:
final logger = AtatusSdk.instance.logs.createLogger(
AtatusLoggerConfiguration(
name: 'MyLogger',
remoteLogThreshold: LogLevel.debug,
networkInfoEnabled: true,
),
);
logger.debug('App started');
logger.info('User signed in', attributes: {'user_id': '123'});
logger.warn('Low memory warning');
logger.error('Payment failed', errorMessage: 'Insufficient funds');
Logger Configuration #
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
String? |
— | Logger name (set as logger.name attribute) |
service |
String? |
— | Override service name |
remoteLogThreshold |
LogLevel |
debug |
Minimum level to send to Atatus |
remoteSampleRate |
double |
100.0 |
% of logs to send (0–100) |
bundleWithRumEnabled |
bool |
true |
Enrich logs with current RUM view info |
bundleWithTraceEnabled |
bool |
true |
Enrich logs with active trace context |
networkInfoEnabled |
bool |
true |
Add network info to each log |
RUM — View Tracking #
Automatic View Tracking with Navigator Observer #
MaterialApp(
navigatorObservers: [
AtatusNavigationObserver(AtatusSdk.instance),
],
home: HomeScreen(),
);
Custom View Name Mapping #
RumViewInfo? viewInfoExtractor(Route<dynamic> route) {
if (route.settings.name == '/checkout') {
return RumViewInfo(
name: 'Checkout',
attributes: {'flow': 'purchase'},
);
}
return defaultViewInfoExtractor(route);
}
AtatusNavigationObserver(
atatusSdk: AtatusSdk.instance,
viewInfoExtractor: viewInfoExtractor,
);
Mixin-based View Tracking #
class _HomeScreenState extends State<HomeScreen>
with RouteAware, AtatusRouteAwareMixin {
@override
RumViewInfo get rumViewInfo => RumViewInfo(name: 'HomeScreen');
}
RUM — User & Account Info #
// Set user
AtatusSdk.instance.setUserInfo(
id: 'user-123',
name: 'Prakash',
email: 'prakash@example.com',
extraInfo: {'plan': 'pro'},
);
// Set account
AtatusSdk.instance.setAccountInfo(
id: 'account-456',
name: 'Acme Corp',
extraInfo: {'tier': 'enterprise'},
);
// Clear
AtatusSdk.instance.clearUserInfo();
AtatusSdk.instance.clearAccountInfo();
Network Tracking & Distributed Tracing #
Install the companion package:
dependencies:
atatus_tracking_http_client: ^1.0.0
Enable HTTP tracking in your configuration:
final configuration = AtatusConfiguration(
licenseKey: '<YOUR_LICENSE_KEY>',
env: 'production',
appName: 'MyApp',
firstPartyHosts: ['api.myapp.com'],
rumConfiguration: AtatusRumConfiguration(
traceSampleRate: 100.0,
traceContextInjection: TraceContextInjection.all,
),
)..enableHttpTracking();
Tracking Consent (GDPR) #
Control whether the SDK collects data based on user consent:
// Before user accepts — buffer events in pending state
await AtatusSdk.instance.initialize(configuration, TrackingConsent.pending);
// After user grants consent
AtatusSdk.instance.setTrackingConsent(TrackingConsent.granted);
// If user declines — discard all buffered and future data
AtatusSdk.instance.setTrackingConsent(TrackingConsent.notGranted);
| Value | Behaviour |
|---|---|
TrackingConsent.granted |
Data is collected and sent |
TrackingConsent.notGranted |
Data is discarded |
TrackingConsent.pending |
Data is buffered until consent is set |
Additional Packages #
| Package | Description |
|---|---|
atatus_tracking_http_client |
Automatic HTTP resource tracking |
atatus_dio |
Dio interceptor for RUM + tracing |
atatus_gql_link |
GraphQL link for RUM tracking |
atatus_grpc_interceptor |
gRPC interceptor |
atatus_webview_tracking |
WebView tracking |
atatus_inappwebview_tracking |
InAppWebView tracking |
Contributing #
Pull requests are welcome. Please open an issue first to discuss what you would like to change.
License #
Apache License 2.0