The Atatus mobile SDK lets you send logs from your Flutter applications directly to Atatus. Logs are sent over HTTP, batched on the device, and can be enriched with attributes and tags and correlated with your RUM sessions.

Note: This guide covers Android targets only. iOS instrumentation is not part of this guide.

Prerequisites

  • The Atatus SDK is initialized in your application. See Flutter (Android) setup for the initialization steps.
  • A RUM application created in Atatus, which gives you a License Key.
Note: The SDK requires a License Key. Do not use your account API key in a mobile application, because it would be exposed in the application's byte code.

Setup

1. Add the Plugin

If you have not already added the SDK, add the atatus_flutter_plugin dependency to your pubspec.yaml:

copy
icon/buttons/copy
dependencies:
  atatus_flutter_plugin: ^1.0.0

Then fetch the package:

copy
icon/buttons/copy
flutter pub get

2. Enable Logging

Enable logging by passing a loggingConfiguration when you initialize the SDK. See Flutter (Android) setup for the full initialization:

copy
icon/buttons/copy
import 'package:atatus_flutter_plugin/atatus_flutter_plugin.dart';
import 'package:flutter/widgets.dart';

void main() {
  final configuration = AtatusConfiguration(
    licenseKey: '<LICENSE_KEY>',
    env: '<ENV_NAME>',
    variant: 'release',
    loggingConfiguration: AtatusLoggingConfiguration(),
    rumConfiguration: AtatusRumConfiguration(),
  );

  AtatusSdk.runApp(configuration, TrackingConsent.granted, () async {
    runApp(const MyApp());
  });
}

3. Create a Logger

After the SDK is initialized, create a logger and configure it with the options you need:

copy
icon/buttons/copy
final logConfiguration = AtatusLoggerConfiguration(
  remoteLogThreshold: LogLevel.debug,
  networkInfoEnabled: true,
  bundleWithRumEnabled: true,
);

final logger = AtatusSdk.instance.logs?.createLogger(logConfiguration);

AtatusLoggerConfiguration options:

Option Description
service Sets the service name attribute for this logger.
name Sets the logger name attribute.
networkInfoEnabled Adds network connectivity attributes to each log.
bundleWithRumEnabled Links logs to the current RUM context.
remoteLogThreshold Minimum LogLevel that is sent to Atatus.
remoteSampleRate Percentage of logs sent to Atatus, from 0.0 to 100.0.

4. Send Log Messages

Use the logger to send messages at the level you need:

copy
icon/buttons/copy
logger?.debug('A debug message.');
logger?.info('Some relevant information.');
logger?.warn('An important warning.');
logger?.error('An error was met!');

Attach custom attributes to a single log entry:

copy
icon/buttons/copy
logger?.info('User tapped checkout', attributes: {
  'cart.items': 3,
  'cart.total': 49.99,
});

5. Create Additional Loggers

You can create multiple loggers, each with its own service and name, to separate logs from different parts of your application:

copy
icon/buttons/copy
final myLogger = AtatusSdk.instance.logs?.createLogger(
  AtatusLoggerConfiguration(
    service: 'com.example.custom_service',
    name: 'Additional logger',
  ),
);

6. Manage Attributes and Tags

Attributes are key-value pairs attached to your logs. Add or remove them on a logger at any time:

copy
icon/buttons/copy
logger?.addAttribute('version_name', '1.4.0');
logger?.removeAttribute('version_name');

Tags help you filter and group your logs in Atatus:

copy
icon/buttons/copy
logger?.addTag('build_type', 'release');
logger?.removeTag('build_type');

7. Sending Data When the Device Is Offline

Logs are batched locally and sent to Atatus when network availability and battery levels permit. Even if your users open the application while offline, no data is lost. Batches are uploaded once connectivity is restored, and old data automatically expires to keep disk usage bounded.

Next Steps