Sentinel Analytics Realm – Dart SDK
Thin Dart/Flutter client for sending events to the Sentinel Analytics Realm HTTP ingestion API.
Install
Add to your pubspec.yaml:
dependencies:
sentinel_analytics_realm_dart: ^0.0.3
Then run dart pub get or flutter pub get.
Usage
import 'package:sentinel_analytics_realm_dart/sentinel_analytics_realm_dart.dart';
void main() async {
final client = SentinelAnalyticsRealmPlugin(
projectId: 'YOUR_PROJECT_ID',
appId: 'YOUR_APP_ID',
// baseUrl: 'https://api.sentinelanalyticsrealm.com', // default
// env: 'prod', // default
);
await client.track('page_view', visitorId: 'v_123');
await client.identify(userId: 'u_456', visitorId: 'v_123', traits: {
'email': 'user@example.com',
});
await client.trackBatch([
SentinelAnalyticsRealmEvent(name: 'click', visitorId: 'v_123', properties: {'button': 'buy'}),
SentinelAnalyticsRealmEvent(name: 'hover', visitorId: 'v_123'),
]);
}
Environment configuration
The client can read configuration from environment variables when available (Dart VM/Flutter mobile/desktop). On the web, pass values explicitly.
SENTINEL_ANALYTICS_REALM_PROJECT_IDSENTINEL_ANALYTICS_REALM_APP_IDSENTINEL_ANALYTICS_REALM_ENV(defaults toprod)SENTINEL_ANALYTICS_REALM_URL(defaults tohttps://api.sentinelanalyticsrealm.com)
For Flutter builds you can also use --dart-define and read via String.fromEnvironment, or pass values directly to the constructor.
API
track(name, ...)– sends a single event.trackBatch(List<SentinelAnalyticsRealmEvent>)– sends a batch of events.identify(userId, {visitorId, traits})– convenience method.
All calls return Future<Map<String, dynamic>?> containing the decoded JSON response or null on error/non-2xx.
Notes
- The SDK is lightweight and performs best-effort error handling (no exceptions on HTTP failures by default).
- For the browser, prefer batching and reusing a single client instance per app.