Skip to content

Commit

Permalink
add analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Feb 12, 2024
1 parent 28eef24 commit 6bfdc4f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/Frontend/GoRouterConfig.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:plausible_analytics/navigator_observer.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:tail_app/Frontend/pages/DirectGearControl.dart';
import 'package:tail_app/Frontend/pages/Shell.dart';
Expand All @@ -9,6 +10,7 @@ import 'package:tail_app/Frontend/pages/move_list.dart';
import 'package:tail_app/Frontend/pages/settings.dart';
import 'package:tail_app/Frontend/pages/triggers.dart';

import '../main.dart';
import 'pages/Actions.dart';

final GlobalKey<NavigatorState> _rootNavigatorKey = GlobalKey<NavigatorState>();
Expand All @@ -18,7 +20,10 @@ final GlobalKey<NavigatorState> _shellNavigatorKey = GlobalKey<NavigatorState>()
final GoRouter router = GoRouter(
debugLogDiagnostics: kDebugMode,
navigatorKey: _rootNavigatorKey,
observers: [SentryNavigatorObserver()],
observers: [
SentryNavigatorObserver(),
PlausibleNavigatorObserver(plausible),
],
routes: [
ShellRoute(
navigatorKey: _shellNavigatorKey,
Expand Down
8 changes: 7 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging_flutter/logging_flutter.dart';
import 'package:path_provider/path_provider.dart';
import 'package:plausible_analytics/plausible_analytics.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:sentry_logging/sentry_logging.dart';
Expand All @@ -37,6 +38,11 @@ FutureOr<SentryEvent?> beforeSend(SentryEvent event, {Hint? hint}) async {
}
}

const String serverUrl = "https://plausible.io";
const String domain = "com.codel1417.tail_app";

final plausible = Plausible(serverUrl, domain);

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Flogger.init(config: const FloggerConfig(showDebugLogs: true, printClassName: true, printMethodName: true, showDateTime: false));
Expand Down Expand Up @@ -74,7 +80,7 @@ Future<void> main() async {
SentryHive.openBox<Trigger>('triggers');
SentryHive.openBox<MoveList>('sequences');
SentryHive.openBox<BaseStoredDevice>('devices');

plausible.enabled = false;
await SentryFlutter.init(
(options) {
options.dsn = 'http://30dbd2cb36374c448885ee81aeae1419@192.168.50.189:8000/3';
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.4"
plausible_analytics:
dependency: "direct main"
description:
name: plausible_analytics
sha256: be9f0b467d23cd94861737f10101431ad8b7d280dc0c14f7251e0e24655b07fa
url: "https://pub.dev"
source: hosted
version: "0.3.0"
plugin_platform_interface:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies:
hive_flutter: ^1.1.0
path_provider: ^2.1.2
uuid: ^4.3.3
plausible_analytics: ^0.3.0
dev_dependencies:
build_runner:
flutter_test:
Expand Down

0 comments on commit 6bfdc4f

Please sign in to comment.