flutter_estatisticas 0.0.12
flutter_estatisticas: ^0.0.12 copied to clipboard
A Flutter package for integrating Umami Analytics into your apps. Track navigation and custom events easily, providing privacy-friendly analytics for your users.
Flutter Umami Analytics Integration #
This package integrates Umami Analytics into your Flutter app, allowing navigation tracking and custom event logging.
Installation #
Add to your pubspec.yaml:
dependencies:
flutter_estatisticas: ^0.0.12
Usage #
1. Import the services #
import 'package:flutter_estatisticas/umami_service.dart';
import 'package:flutter_estatisticas/umami_navigation_observer.dart';
2. Instantiate the Umami service #
final umamiService = UmamiService(
endpoint: 'https://michelmelo.pt', // Your Umami endpoint
website: 'id-website', // Your Umami website ID
hostname: 'seusite.com.pt', // Your app's hostname
);
3. Add the observer to your MaterialApp #
MaterialApp(
// ... other parameters ...
navigatorObservers: [
UmamiNavigationObserver(umamiService),
],
)
4. Send custom events #
Simple click event
umamiService.enviarClique(
context,
'Page Title', // The title of the page or event
'spotify', // The name of the widget that was clicked
);
Replace 'Page Title' and 'spotify' with your desired values.
Custom event
umamiService.enviarEvento(
context,
title: 'Custom Page Title',
name: 'custom_event',
data: {
'key': 'value',
'foo': 'bar',
},
);
Use enviarEvento to send a custom event with a title, name, and additional data.
Notes #
- The
websiteparameter should be your site ID from the Umami dashboard. - The
hostnameshould be your app's domain or identifier. - The
endpointshould be your Umami server URL. - The observer will automatically track navigation events in your app.
- Use
enviarCliquefor simple click events andenviarEventofor custom/page view events.
License #
MIT