mtc_analytics 1.0.0 mtc_analytics: ^1.0.0 copied to clipboard
Package to manage analytics tools
MTC - Analytics #
All in one. This package was created to simplify the job of logging events across different analytics platforms.
TODO #
- Add Firebase Analytics tracker
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);
At this time, we already implemented a ConsoleTracker
for debugging purpose and AmplitudeTracker
. You can use them
List<Tracker> trackers = [
MyCustomTracker(),
ConsoleTracker(),
AmplitudeTracker(apiKey: 'api-key'),
];
AnalyticsService analyticsService = AnalyticsService.instance;
analyticsService.init(trackers);
Set user properties #
To set user properties simply call AnalyticsService.instance.setUserProperties
AnalyticsService.instance.setUserProperties(
{
"name": "MTC - Flutter Team",
"email": "[email protected]",
},
);
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},
);
}
After that, you can call AnalyticsService.instance.track
and pass it the created event
AnalyticsService.instance.track(
IncrementCounterEvent(count: _counter),
);
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