All in one. This package was created to simplify the job of logging events across different analytics platforms.
If you want to use Amplitude in iOS, you need to add platform :ios, '10.0'
to your Podfile.
To use Firebase Analytics, you need to add your app to your Firebase project in the Firebase console. Firebase - Documentation
With this package you'll can:
- Use built-in trackers or add new trackers that you need in your application.
- Configure User properties
- Log Events and Event properties
Before try to set user properties or track any event, you must initialize the AnalyticsService
with according trackers.
List<Tracker> trackers = [MyCustomTracker()];
AnalyticsService analyticsService = AnalyticsService.instance;
analyticsService.init(trackers);
At this time, we already implemented a ConsoleTracker
for debugging purpose, AmplitudeTracker
and FirebaseTracker
. You can use them
List<Tracker> trackers = [
MyCustomTracker(),
ConsoleTracker(),
AmplitudeTracker(apiKey: 'api-key'),
FirebaseTracker(),
];
AnalyticsService analyticsService = AnalyticsService.instance;
analyticsService.init(trackers);
To set user properties simply call AnalyticsService.instance.setUserProperties
AnalyticsService.instance.setUserProperties(
{
"name": "MTC - Flutter Team",
"email": "[email protected]",
},
);
To log events you need to create you own event class. For example, if the app needs to log an event when the user increments a counter:
class IncrementCounterEvent extends Event {
final int count;
IncrementCounterEvent({required this.count})
: super(
name: 'increment_count',
properties: {'count': count},
);
}
After that, you can call AnalyticsService.instance.track
and pass it the created event
AnalyticsService.instance.track(
IncrementCounterEvent(count: _counter),
);
Visit our page to know more about us!
If our content like you can help us with a coffee to continue creating and collaborating with the Flutter community