Track Events (Flutter)
Record user actions within your mobile or desktop application.
Overview
The EmpAnalytics.track() method is how you send data to Emp-Mix. It safely queues the event in the local SQLite database. If the device is offline, the event remains in the queue and will be synced the next time the app opens with an active internet connection.
Syntax
EmpAnalytics.track(String eventName, {Map<String, dynamic>? properties});| Parameter | Type | Required | Description |
|---|---|---|---|
| eventName | String | Yes | The name of the event (e.g., 'Level Completed'). |
| properties | Map<String, dynamic> | No | A dictionary of key-value pairs describing the event. |
Basic Example
// Tracking with properties
EmpAnalytics.track("Purchase Completed", properties: {
"Plan": "Premium",
"Price": 29.99,
"Currency": "USD",
});Super Properties
Super Properties are automatically attached to every single event you track (e.g., App Version, User Role).
EmpAnalytics.registerSuperProperties({
"App Version": "2.1.0",
"Beta User": true
});Force Flush
If you have critical events that must be sent immediately (e.g., just before the app is closed manually), you can bypass the batch timer and force a flush.
await EmpAnalytics.flush();