Last updated:
0 purchases
mtc analytics
MTC - Analytics #
All in one. This package was created to simplify the job of logging events across different analytics platforms.
Getting Started #
Amplitude #
If you want to use Amplitude in iOS, you need to add platform :ios, '10.0' to your Podfile.
Amplitude - Documentation
Firebase Analytics #
To use Firebase Analytics, you need to add your app to your Firebase project in the Firebase console.
Firebase - Documentation
Features #
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
Usage #
Initialization #
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);
copied to clipboard
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);
copied to clipboard
Set user properties #
To set user properties simply call AnalyticsService.instance.setUserProperties
AnalyticsService.instance.setUserProperties(
{
"name": "MTC - Flutter Team",
"email": "[email protected]",
},
);
copied to clipboard
Log events #
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},
);
}
copied to clipboard
After that, you can call AnalyticsService.instance.track and pass it the created event
AnalyticsService.instance.track(
IncrementCounterEvent(count: _counter),
);
copied to clipboard
Additional information #
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
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.