flutter_estatisticas 0.0.11
flutter_estatisticas: ^0.0.11 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.10
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, 'spotify');
Replace 'spotify' with your desired event name.
Custom event
umamiService.enviarEvento(
context,
title: 'Custom Page Title', // Optional, defaults to 'Viceos'
);
Use enviarEvento to send a page view or custom event.
You can also customize the payload by editing the sendEvent method in your service.
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