feat: integrate Umami analytics for screen tracking via GoRouter observers
This commit is contained in:
25
lib/core/analytics/umami_analytics.dart
Normal file
25
lib/core/analytics/umami_analytics.dart
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import 'package:flutter_estatisticas/umami_service.dart';
|
||||||
|
import 'package:flutter_estatisticas/umami_navigation_observer.dart';
|
||||||
|
|
||||||
|
/// Umami analytics singleton. Configured once at app startup.
|
||||||
|
///
|
||||||
|
/// Reuses the same `website` ID as the web app (re-quest.com) so all traffic
|
||||||
|
/// (web + mobile) aggregates under one dashboard. `hostname` differentiates
|
||||||
|
/// mobile vs. web inside Umami.
|
||||||
|
class UmamiAnalytics {
|
||||||
|
UmamiAnalytics._();
|
||||||
|
|
||||||
|
static const _endpoint = 'https://analytics.superlabs.co';
|
||||||
|
static const _websiteId = '00e1ce31-e174-4519-8b59-63e8d4556b01';
|
||||||
|
static const _hostname = 're-quest-mobile.app';
|
||||||
|
|
||||||
|
static final UmamiService service = UmamiService(
|
||||||
|
endpoint: _endpoint,
|
||||||
|
website: _websiteId,
|
||||||
|
hostname: _hostname,
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Navigator observer that auto-tracks screen transitions in GoRouter.
|
||||||
|
static final UmamiNavigationObserver navigationObserver =
|
||||||
|
UmamiNavigationObserver(service);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:real_estate_mobile/core/analytics/umami_analytics.dart';
|
||||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||||
import 'package:real_estate_mobile/core/widgets/app_shell.dart';
|
import 'package:real_estate_mobile/core/widgets/app_shell.dart';
|
||||||
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
|
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
|
||||||
@@ -44,6 +45,7 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
return GoRouter(
|
return GoRouter(
|
||||||
initialLocation: '/splash',
|
initialLocation: '/splash',
|
||||||
refreshListenable: authRefreshNotifier,
|
refreshListenable: authRefreshNotifier,
|
||||||
|
observers: [UmamiAnalytics.navigationObserver],
|
||||||
redirect: (context, state) {
|
redirect: (context, state) {
|
||||||
final authState = ref.read(authProvider);
|
final authState = ref.read(authProvider);
|
||||||
final isAuthenticated = authState.status == AuthStatus.authenticated;
|
final isAuthenticated = authState.status == AuthStatus.authenticated;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import device_info_plus
|
||||||
import emoji_picker_flutter
|
import emoji_picker_flutter
|
||||||
import facebook_auth_desktop
|
import facebook_auth_desktop
|
||||||
import file_selector_macos
|
import file_selector_macos
|
||||||
@@ -22,6 +23,7 @@ import url_launcher_macos
|
|||||||
import webview_flutter_wkwebview
|
import webview_flutter_wkwebview
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||||
EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin"))
|
EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin"))
|
||||||
FacebookAuthDesktopPlugin.register(with: registry.registrar(forPlugin: "FacebookAuthDesktopPlugin"))
|
FacebookAuthDesktopPlugin.register(with: registry.registrar(forPlugin: "FacebookAuthDesktopPlugin"))
|
||||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||||
|
|||||||
32
pubspec.lock
32
pubspec.lock
@@ -265,6 +265,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.12"
|
version: "0.7.12"
|
||||||
|
device_info_plus:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus
|
||||||
|
sha256: "98f28b42168cc509abc92f88518882fd58061ea372d7999aecc424345c7bff6a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "11.5.0"
|
||||||
|
device_info_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_platform_interface
|
||||||
|
sha256: e1ea89119e34903dca74b883d0dd78eb762814f97fb6c76f35e9ff74d261a18f
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "7.0.3"
|
||||||
dio:
|
dio:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -430,6 +446,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.2.1"
|
version: "5.2.1"
|
||||||
|
flutter_estatisticas:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_estatisticas
|
||||||
|
sha256: "6381caf2e39179c7339cafbd1117c79737567147da9597596fe68c6fe5fa9656"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.2"
|
||||||
flutter_facebook_auth:
|
flutter_facebook_auth:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -1573,6 +1597,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.15.0"
|
version: "5.15.0"
|
||||||
|
win32_registry:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: win32_registry
|
||||||
|
sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ dependencies:
|
|||||||
package_info_plus: ^9.0.0
|
package_info_plus: ^9.0.0
|
||||||
speech_to_text: ^7.3.0
|
speech_to_text: ^7.3.0
|
||||||
|
|
||||||
|
# Analytics (Umami)
|
||||||
|
flutter_estatisticas: ^0.2.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|||||||
Reference in New Issue
Block a user