Skip to main content

easyslo 0.2.0 copy "easyslo: ^0.2.0" to clipboard
easyslo: ^0.2.0 copied to clipboard

Lightweight outcome monitoring for Flutter. Persistent batching, offline retries, and success-rate SLOs.

EasySLO Flutter SDK #

An Android/iOS Flutter package for reporting operation success and failure with a persistent offline queue. Track checkout, sign-in, and other user journeys against success-rate SLOs at easyslo.com.

Version 0.2.0 renames the public API from Sdk to EasySlo. Migrate existing 0.1.x calls to EasySlo when upgrading. The package import and SDK keys stay the same.

Install and initialize #

dependencies:
  easyslo: ^0.2.0

Or run flutter pub add easyslo. Then run flutter pub get. The SDK’s Android plugin declares the internet permission, which is merged into your app automatically. No manual Android manifest edit or runtime permission prompt is needed.

Use an SDK key from the dashboard’s SDK keys page. The SDK manages the service address:

import 'package:flutter/widgets.dart';
import 'package:easyslo/easyslo.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasySlo.init("MOBILESLO_KEY");
  runApp(const MyApp());
}

Replace MOBILESLO_KEY with your actual SDK key and MyApp with your root widget. Awaiting initialization completes local setup so the first startup outcomes can be captured; it does not wait for network delivery. Setup failures are recorded in EasySlo.diagnostics and your app continues. Only Android and iOS are supported.

The dashboard’s Setup page walks through installation, initialization, and first-event verification. Get your SDK key at easyslo.com.

Report outcomes #

New event keys automatically appear in the dashboard with a 95% SLO target. Open a monitor to adjust its target.

EasySlo.success('checkout');
EasySlo.failure('checkout', e);

failure accepts any Object, so you can pass the value from catch directly without a type guard:

try {
  await completeCheckout();
  await EasySlo.success('checkout');
} catch (error) {
  await EasySlo.failure('checkout', error);
}

The SDK stores one of five stable cause buckets:

Cause Recognized failures
NETWORK Dart SocketException/TlsException (including TLS handshakes), http.ClientException, and Dio connection/certificate errors
TIMEOUT Dart TimeoutException and Dio connection/send/receive/transform timeouts
HTTP_4XX HTTP status 400–499, including authentication failures and rate limits
HTTP_5XX HTTP status 500–599
OTHER Unrecognized exceptions, parsing/business errors, and explicitly reported cancellations

Dio response status codes are detected automatically. Dio exceptions with an unknown type can also expose an underlying standard exception. For other HTTP clients, supply a known response status explicitly:

await EasySlo.failure('checkout', exception, statusCode: response.statusCode);

A supplied 4xx/5xx status takes precedence over exception classification. Statuses outside those ranges fall back to the exception. dart:io's HttpException and package:http's ClientException do not expose HTTP response status codes; the SDK never guesses a status from their messages. Starting with SDK 0.2.0, the bucket and runtime class name (exception_name, up to 128 characters) are persisted/uploaded. For example, catching a SocketException reports NETWORK and SocketException. Dio failures report DioException, the caught wrapper type. Obfuscated release builds may report obfuscated names. The exact status, exception message, stack trace, URL, headers, and response body are excluded. Names that cannot be read safely or validated are omitted. Intentional cancellations should be skipped by the caller; if reported, Dio cancellations and http.RequestAbortedException map to OTHER. Dart Error instances and other unrecognized objects map to OTHER. Failure objects are never stringified, persisted, or uploaded.

Each call creates a new UUID and persists an immutable occurrence with the app’s version/build and platform. Calls return Future<void>: awaiting confirms the persistence attempt has completed, not server delivery. Initialization, capture, flush, and cleanup contain SDK errors; inspect diagnostics for initialization, storage, and delivery failures. Calls before initialization are ignored and counted in EasySlo.callsBeforeInitialization. Initialization failures leave monitoring disabled; the app can continue normally. Concurrent initialization calls share the in-progress attempt. Repeating initialization with the same key and namespace leaves the current client, timer, observer, and queue intact. Initialization and disposal are serialized so disposing during setup cannot leave a client running. Await initialization before reporting if you need to capture the first startup outcomes.

Choose whether business retries count as separate attempts or only report the final outcome, then instrument consistently. Transport retries reuse IDs. Event keys must match [A-Za-z0-9_.:-]{1,128} and must not contain customer data or secrets. Failure causes are generated by the SDK; generic business exceptions map to OTHER. Missing calls, abandoned operations, and crashes are not automatically failures.

await EasySlo.flush(); // Best-effort; respects backoff and Retry-After.
final status = EasySlo.diagnostics.toMap();
await EasySlo.dispose(); // Unregister lifecycle observer and close resources.

Diagnostics include pending, accepted, duplicates, rejected, dropped, expired, retries, storage errors, initialization errors, invalid calls, last error, and next retry time. Counters describe the current process. They contain no business payloads and are not uploaded automatically.

Delivery behavior #

  • Async SQLite persistence, one sender per initialized client, main isolate only.
  • Flush every 15 seconds, after 50 queued events, on initialization, and on resume/inactive/pause.
  • Up to 50 events and roughly 60 KiB per request; request timeout 15 seconds; bounded drain of ten batches.
  • Exponential backoff with jitter, numeric/date Retry-After support, and a 15-minute pause for invalid/revoked credentials. HTTP 413 reduces batch size.
  • Delete only a complete, matching, validated per-event acknowledgment. Accepted/duplicate results and terminal event rejections are removed. Missing/unknown/malformed responses retain the entire batch.
  • Seven-day local expiry; queue bounded to 10,000 events or 10 MiB. At capacity, oldest rows are removed in groups of 100 and counted as dropped.
  • Metadata is captured once. The SDK reads the installed app version and build number using package_info_plus and sends app_version as version+buildNumber (for example, 1.5.0+50). App upgrades, retries, and rebatching do not relabel queued events. Select that version in the dashboard’s app-version dropdown to filter SLOs, hourly usage, and error causes.
  • Mobile operating systems can suspend execution immediately on backgrounding. Lifecycle flush is best effort; SQLite data survives for the next app session. No native background scheduler or guaranteed delivery deadline.

SDK calls should stay in the initialized main isolate. Do not create parallel SDK senders from background isolates. The SDK has no automatic crash reporting, session replay, or persistent device identifiers.

Key rotation #

By default, queue files are isolated by endpoint and key. This prevents events from being accidentally uploaded into another project/environment. Changing a key opens a separate queue; the previous queue is not automatically migrated or drained.

To preserve a queue through rotation, choose a stable namespace before the first release:

await EasySlo.init(key,
  queueNamespace: 'my-app-production',
);

Reuse that namespace only for replacement keys in the same project and environment. Never share it between production and development. Ship the replacement key before revoking the old one and allow an overlap period. A key revoked before an old app upgrades prevents that app from delivering its queue.

SDK development and self-hosting #

App integrations do not supply an endpoint. The SDK uses https://easyslo.com over HTTPS. SDK maintainers and self-hosted builds can select a service at build time with --dart-define=MOBILESLO_INGEST_ORIGIN=https://your-worker.workers.dev; this is optional and not part of EasySlo.init.

For local SDK development, the build override accepts HTTP only on localhost, 127.0.0.1, and the Android emulator host 10.0.2.2. Physical devices need a reachable HTTPS service. Local Android HTTP testing may require a debug-only network security configuration; keep release configuration HTTPS-only. Keys must belong to the selected service. Queue files remain scoped by service and key/namespace.

Example and tests #

example/lib/main.dart shows a minimal integration. To generate platform scaffolding for the example, run flutter create --platforms=android,ios --project-name easyslo_example . from sdk/example/, then run with the key dart define above. The first valid checkout upload creates its monitor automatically.

flutter pub get
flutter analyze
flutter test

Tests cover exception bucketing, payload privacy, bucket and exception-name persistence across restarts/retries, immutable retries, offline recovery, quota backoff, duplicate flushes, malformed acknowledgments, auth failures, batch splitting, expiry, and SQLite close/reopen persistence. Background/battery behavior still needs testing on physical Android/iOS devices.

0
likes
0
points
180
downloads

Publisher

verified publishereasyslo.com

Weekly Downloads

Lightweight outcome monitoring for Flutter. Persistent batching, offline retries, and success-rate SLOs.

Homepage

Topics

#monitoring #observability #reliability #slo

License

unknown (license)

Dependencies

crypto, dio, flutter, http, package_info_plus, path, sqflite, uuid

More

Packages that depend on easyslo

Packages that implement easyslo