apprvd_tracker 0.4.0
apprvd_tracker: ^0.4.0 copied to clipboard
Tiny event tracker for Apprvd.app. Batches events in memory and posts them to Apprvd.app's ingest endpoint for push audiences and tracker KPIs.
apprvd_tracker #
Tiny event tracker for Apprvd.app.
Events post straight to Apprvd.app and show up on the dashboard in
real time. They power push audiences and tracker KPIs; the charts come from
Google Analytics. Pure Dart, one dependency (http).
Setup #
In Apprvd.app: Data sources → Apprvd.app tracker → Connect source, then copy the generated write key (it's write-only — safe to ship in the binary).
dependencies:
apprvd_tracker: ^0.4.0
import 'package:apprvd_tracker/apprvd_tracker.dart';
void main() {
Apprvd.init(
writeKey: 'pk_…',
endpoint: 'https://…/api/ingest', // from the Data sources page
deviceId: yourStableInstallId, // recommended — accurate unique counts
);
Apprvd.track('app_open');
}
Apprvd.identify(user.id); // after sign-in
Apprvd.track('lesson_completed', {'lesson': 'intro', 'score': 87});
await Apprvd.flush(); // e.g. when backgrounded
Flushing when a Flutter app is backgrounded:
class FlushOnPause extends WidgetsBindingObserver {
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.paused) Apprvd.flush();
}
}
// in main(): WidgetsBinding.instance.addObserver(FlushOnPause());
Rules of the road #
- Event names: letters, digits, underscores, max 60 chars (
lesson_completed). - Params must stay under 8 KB as JSON — and don't put personal data in them.
- Events batch in memory (20 per flush, every 10 s) and retry on network errors. The queue caps at 500 and does not survive an app restart.
- Without a stable
deviceId/identify, unique counts inflate: each launch looks like a new device.