atatus_flutter_plugin 1.0.5
atatus_flutter_plugin: ^1.0.5 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 deployment target | 15.0 |
| Web | Any browser supported by Flutter web |
Platform Support #
| Feature | Android | iOS | Web |
|---|---|---|---|
| RUM (views, actions, resources, errors) | ✅ | ✅ | ✅ |
| Logs | ✅ | ✅ | ✅ |
| Distributed tracing | ✅ | ✅ | ✅ |
| Native crash reporting | ✅ | ✅ | — |
Session Replay (atatus_session_replay) |
✅ | ✅ | — |
WebView tracking (atatus_webview_tracking) |
✅ | ✅ | — |
Installation #
Add the plugin to your pubspec.yaml:
dependencies:
atatus_flutter_plugin: ^1.0.5
Then run:
flutter pub get
Platform Setup #
Android #
Ensure your android/app/build.gradle has:
android {
defaultConfig {
minSdkVersion 23
}
}
iOS #
Set the minimum iOS version to 15.0 in ios/Podfile:
platform :ios, '15.0'
Then install the pods:
cd ios && pod install
Web #
On the web, the plugin runs on top of the Atatus Browser agent. Add its
scripts to the <head> of web/index.html, before flutter.js loads your
app:
<script type="text/javascript" src="https://js-cdn.atatus.io/atatus-browser-agent/latest/atatus-logs.js"></script>
<script type="text/javascript" src="https://js-cdn.atatus.io/atatus-browser-agent/latest/atatus-rum.js"></script>
atatus-logs.js is only needed when you set loggingConfiguration, and
atatus-rum.js only when you set rumConfiguration. If a script is missing,
that feature silently sends nothing, so check both are loaded if no data
arrives.
Initialize the SDK from Dart exactly as on mobile (see Quick Start);
no extra JavaScript setup is needed. Native-only options such as
nativeCrashReportEnabled and trackNonFatalAnrs are ignored on the web.
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 |
serverUrl |
String? |
— | — | Custom intake base URL (overrides the site hosts) |
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 |
|---|---|---|---|
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 |
trackNonFatalAnrs |
bool? |
— | Android only: track non-fatal ANRs |
AtatusLoggingConfiguration #
| Parameter | Type | Default | Description |
|---|---|---|---|
serverUrl |
String? |
— | Override logs server URL |
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: 'Example',
email: 'example123@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.5
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