DevFeedbackHub Analytics SDK for Flutter/Dart
Lightweight analytics SDK for DevFeedbackHub - track tester behavior and goal completion in your app.
Features
- Track custom events from testers during beta testing
- One-time goal completion with credit rewards
- Recurring daily goal tracking (e.g., "7 consecutive days of usage")
- Automatic event batching and retry
- Stable device identity so the server can match testers and grant credits
Getting Started
1. Install
dependencies:
devfeedbackhub_analytics: ^3.0.0
Requires Flutter. Tester matching works on Android only - that is the platform DevFeedbackHub runs closed tests on.
2. Initialize
import 'package:devfeedbackhub_analytics/devfeedbackhub_analytics.dart';
void main() async {
await DFHAnalytics.init(
'YOUR_REQUEST_ID', // From DevFeedbackHub dashboard
onGoalCompleted: (goalName, credits) {
print('$goalName completed! +$credits credits');
},
onRecurringProgress: (goalName, completed, target) {
print('$goalName: $completed/$target days');
},
);
runApp(MyApp());
}
3. Track Events
// Track any event
DFHAnalytics.track('app_open');
DFHAnalytics.track('login');
DFHAnalytics.track('purchase', data: {'item': 'premium'});
DFHAnalytics.track('level_complete', screenName: 'game');
4. Cleanup
// When app is closing
await DFHAnalytics.dispose();
How It Works
- Register events in the DevFeedbackHub dashboard
- Add this SDK to your app
- Testers install your app via DevFeedbackHub
- Events are automatically tracked and matched to testers
- Testers earn credits when they complete goal events
Device Identity (important)
Credits are only granted when the server can match the running device to a
registered, consenting tester. It does that by looking up users.device_id,
which the DevFeedbackHub app fills with Settings.Secure.ANDROID_ID.
This SDK resolves the same value automatically. If it cannot (emulator, or a
non-Android platform) it falls back to a UUID persisted in SharedPreferences:
events are still recorded, but the response reports tester_matched: false and
no credits are awarded. Watch for this line in the debug log:
DFHAnalytics: tester_matched: false
DFHAnalytics: NOTE: device not matched to a consenting tester; no rewards will be granted
Two other things must also be true for rewards to fire: the tester has an active participation in the request, and they granted analytics consent in the DevFeedbackHub app.
Debug Logging
Debug logging follows kDebugMode, so release builds stay quiet. You'll see output like:
DFHAnalytics: Initialized (request: abc-123, device: xxx-yyy)
DFHAnalytics: Events sent: 1
DFHAnalytics: tester_matched: true
DFHAnalytics: goal_completed: true (app_open)
DFHAnalytics: credits_awarded: 3
To force it on or off: DFHAnalytics.init('...', debug: true);
API Reference
DFHAnalytics.init(requestId, {...})
Initialize the SDK. Must be called before track().
| Parameter | Type | Required | Description |
|---|---|---|---|
requestId |
String |
Yes | Your request ID from the dashboard |
deviceId |
String? |
No | Override the resolved device ID. Leave unset in normal use |
onGoalCompleted |
Function? |
No | Callback for one-time goal completion |
onRecurringProgress |
Function? |
No | Callback for recurring goal daily progress |
debug |
bool? |
No | Enable debug logging (default: kDebugMode) |
DFHAnalytics.track(eventName, {...})
Track an event. Events are batched and sent every 5 seconds or when 20 events accumulate.
| Parameter | Type | Required | Description |
|---|---|---|---|
eventName |
String |
Yes | Event name (must match dashboard config) |
data |
Map? |
No | Additional event data |
screenName |
String? |
No | Screen where the event occurred |
DFHAnalytics.flush()
Manually send all queued events immediately.
DFHAnalytics.dispose()
Flush remaining events and clean up resources.
License
MIT
Libraries
- devfeedbackhub_analytics
- Lightweight analytics SDK for DevFeedbackHub.