Skip to content

Commit

Permalink
Merge pull request #180 from LezdCS/develop
Browse files Browse the repository at this point in the history
Setup Talker Flutter for logging
  • Loading branch information
LezdCS authored May 17, 2024
2 parents aa3b0b2 + b29f6c7 commit 0873ba3
Show file tree
Hide file tree
Showing 18 changed files with 324 additions and 153 deletions.
96 changes: 56 additions & 40 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PODS:
- Firebase/RemoteConfig (= 10.24.0)
- firebase_core
- Flutter
- FirebaseABTesting (10.24.0):
- FirebaseABTesting (10.25.0):
- FirebaseCore (~> 10.0)
- FirebaseAnalytics (10.24.0):
- FirebaseAnalytics/AdIdSupport (= 10.24.0)
Expand All @@ -58,9 +58,9 @@ PODS:
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.12)
- GoogleUtilities/Logger (~> 7.12)
- FirebaseCoreExtension (10.24.0):
- FirebaseCoreExtension (10.25.0):
- FirebaseCore (~> 10.0)
- FirebaseCoreInternal (10.24.0):
- FirebaseCoreInternal (10.25.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseCrashlytics (10.24.0):
- FirebaseCore (~> 10.5)
Expand All @@ -71,7 +71,7 @@ PODS:
- GoogleUtilities/Environment (~> 7.8)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesObjC (~> 2.1)
- FirebaseInstallations (10.24.0):
- FirebaseInstallations (10.25.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
Expand All @@ -84,16 +84,17 @@ PODS:
- FirebaseSharedSwift (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseRemoteConfigInterop (10.24.0)
- FirebaseSessions (10.24.0):
- FirebaseRemoteConfigInterop (10.25.0)
- FirebaseSessions (10.25.0):
- FirebaseCore (~> 10.5)
- FirebaseCoreExtension (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleDataTransport (~> 9.2)
- GoogleUtilities/Environment (~> 7.10)
- GoogleUtilities/Environment (~> 7.13)
- GoogleUtilities/UserDefaults (~> 7.13)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesSwift (~> 2.1)
- FirebaseSharedSwift (10.24.0)
- FirebaseSharedSwift (10.25.0)
- fk_user_agent (2.0.0):
- Flutter
- Flutter (1.0.0)
Expand Down Expand Up @@ -125,9 +126,9 @@ PODS:
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- GoogleDataTransport (9.3.0):
- GoogleDataTransport (9.4.1):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleMLKit/BarcodeScanning (4.0.0):
- GoogleMLKit/MLKitCore
Expand All @@ -146,25 +147,34 @@ PODS:
- GoogleToolboxForMac/Defines (= 2.3.2)
- "GoogleToolboxForMac/NSString+URLArguments (= 2.3.2)"
- "GoogleToolboxForMac/NSString+URLArguments (2.3.2)"
- GoogleUtilities/AppDelegateSwizzler (7.12.0):
- GoogleUtilities/AppDelegateSwizzler (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.12.0):
- GoogleUtilities/Privacy
- GoogleUtilities/Environment (7.13.3):
- GoogleUtilities/Privacy
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.12.0):
- GoogleUtilities/Logger (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (7.12.0):
- GoogleUtilities/Privacy
- GoogleUtilities/MethodSwizzler (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/Network (7.12.0):
- GoogleUtilities/Privacy
- GoogleUtilities/Network (7.13.3):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Privacy
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.12.0)"
- GoogleUtilities/Reachability (7.12.0):
- "GoogleUtilities/NSData+zlib (7.13.3)":
- GoogleUtilities/Privacy
- GoogleUtilities/Privacy (7.13.3)
- GoogleUtilities/Reachability (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (7.12.0):
- GoogleUtilities/Privacy
- GoogleUtilities/UserDefaults (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- GoogleUtilitiesComponents (1.1.0):
- GoogleUtilities/Logger
- GTMSessionFetcher/Core (2.3.0)
Expand Down Expand Up @@ -194,20 +204,22 @@ PODS:
- GoogleMLKit/BarcodeScanning (~> 4.0.0)
- move_to_background (0.0.1):
- Flutter
- nanopb (2.30909.1):
- nanopb/decode (= 2.30909.1)
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
- nanopb (2.30910.0):
- nanopb/decode (= 2.30910.0)
- nanopb/encode (= 2.30910.0)
- nanopb/decode (2.30910.0)
- nanopb/encode (2.30910.0)
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- PromisesObjC (2.3.1)
- PromisesSwift (2.3.1):
- PromisesObjC (= 2.3.1)
- ReachabilitySwift (5.0.0)
- PromisesObjC (2.4.0)
- PromisesSwift (2.4.0):
- PromisesObjC (= 2.4.0)
- ReachabilitySwift (5.2.2)
- share_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand Down Expand Up @@ -237,6 +249,7 @@ DEPENDENCIES:
- move_to_background (from `.symlinks/plugins/move_to_background/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- wakelock (from `.symlinks/plugins/wakelock/ios`)
Expand Down Expand Up @@ -309,6 +322,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
url_launcher_ios:
Expand All @@ -327,28 +342,28 @@ SPEC CHECKSUMS:
firebase_core: 66b99b4fb4e5d7cc4e88d4c195fe986681f3466a
firebase_crashlytics: 7ccf6bc9a3310a5c53bca1150203f9b91b42732a
firebase_remote_config: 42902611d62a925c8c0e58a7cd5b453a3b3423e5
FirebaseABTesting: 4431c2c56ac6e56f463b9cab05cc111078639f99
FirebaseABTesting: e6e3c3e0e35813874f571d1b7bdae2aab319dd38
FirebaseAnalytics: b5efc493eb0f40ec560b04a472e3e1a15d39ca13
FirebaseCore: 11dc8a16dfb7c5e3c3f45ba0e191a33ac4f50894
FirebaseCoreExtension: af5fd85e817ea9d19f9a2659a376cf9cf99f03c0
FirebaseCoreInternal: bcb5acffd4ea05e12a783ecf835f2210ce3dc6af
FirebaseCoreExtension: 8a47811d0b155501559ef05d089518152a0a1677
FirebaseCoreInternal: 910a81992c33715fec9263ca7381d59ab3a750b7
FirebaseCrashlytics: af38ea4adfa606f6e63fcc22091b61e7938fcf66
FirebaseInstallations: 8f581fca6478a50705d2bd2abd66d306e0f5736e
FirebaseInstallations: 91950fe859846fff0fbd296180909dd273103b09
FirebaseRemoteConfig: 95dddc50496b37eef199dadce850d5652b534b43
FirebaseRemoteConfigInterop: 6c349a466490aeace3ce9c091c86be1730711634
FirebaseSessions: 2651b464e241c93fd44112f995d5ab663c970487
FirebaseSharedSwift: 76e1529c32101d80e4f1ca2fba7c39d59f0a390a
FirebaseRemoteConfigInterop: b25018791b204c0d78a90e394d6c62d9b1f22da8
FirebaseSessions: c0939656253a1fa0e94ecc266ccf770cc8b33732
FirebaseSharedSwift: 0274086954b1b2d5fd7e829eccc587044d72a4ba
fk_user_agent: 1f47ec39291e8372b1d692b50084b0d54103c545
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_background_service_ios: e30e0d3ee69e4cee66272d0c78eacd48c2e94aac
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
flutter_tts: 0f492aab6accf87059b72354fcb4ba934304771d
flutter_web_auth: c25208760459cec375a3c39f6a8759165ca0fa4d
GoogleAppMeasurement: f3abf08495ef2cba7829f15318c373b8d9226491
GoogleDataTransport: 57c22343ab29bc686febbf7cbb13bad167c2d8fe
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleMLKit: 2bd0dc6253c4d4f227aad460f69215a504b2980e
GoogleToolboxForMac: 8bef7c7c5cf7291c687cf5354f39f9db6399ad34
GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
in_app_purchase_storekit: 0e4b3c2e43ba1e1281f4f46dd71b0593ce529892
Expand All @@ -358,12 +373,13 @@ SPEC CHECKSUMS:
MLKitVision: 8baa5f46ee3352614169b85250574fde38c36f49
mobile_scanner: 38dcd8a49d7d485f632b7de65e4900010187aef2
move_to_background: 39a5b79b26d577b0372cbe8a8c55e7aa9fcd3a2d
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
nanopb: 438bc412db1928dac798aa6fd75726007be04262
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
ReachabilitySwift: 2128f3a8c9107e1ad33574c6e58e8285d460b149
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586
wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f
Expand Down
19 changes: 17 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import 'package:get_storage/get_storage.dart';
import 'package:irllink/routes/app_pages.dart';
import 'package:irllink/src/bindings/login_bindings.dart';
import 'package:irllink/src/core/resources/themes.dart';
import 'package:irllink/src/core/utils/crashlytics_talker_observer.dart';
import 'package:irllink/src/presentation/views/login_view.dart';
import 'package:kick_chat/kick_chat.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:talker_flutter/talker_flutter.dart';
import 'package:upgrader/upgrader.dart';
import 'package:wakelock/wakelock.dart';
import 'firebase_options.dart';
Expand All @@ -22,6 +24,11 @@ import 'src/core/utils/globals.dart' as globals;

void main() async {
WidgetsFlutterBinding.ensureInitialized();
final crashlyticsTalkerObserver = CrashlyticsTalkerObserver();
final talker = TalkerFlutter.init(
settings: TalkerSettings(),
observer: crashlyticsTalkerObserver,
);
await initializeService();
await GetStorage.init();
await Wakelock.enable();
Expand All @@ -34,8 +41,9 @@ void main() async {
globals.buildNumber = packageInfo.buildNumber;
globals.appName = packageInfo.appName;
globals.packageName = packageInfo.packageName;
globals.talker = talker;
AppTranslations.initLanguages();
runApp(const Main());
runApp(Main(talker: talker,));
}

const notificationChannelId = 'irllink_foreground';
Expand Down Expand Up @@ -171,7 +179,11 @@ void notificationTapBackground(NotificationResponse notificationResponse) {
}

class Main extends StatelessWidget {
const Main({super.key});
const Main({
super.key,
required this.talker,
});
final Talker talker;

@override
Widget build(BuildContext context) {
Expand All @@ -190,6 +202,9 @@ class Main extends StatelessWidget {
translations: AppTranslations(),
locale: Get.deviceLocale,
fallbackLocale: const Locale('en', 'US'),
navigatorObservers: [
TalkerRouteObserver(talker),
],
);
}
}
24 changes: 24 additions & 0 deletions lib/src/core/utils/crashlytics_talker_observer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:talker_flutter/talker_flutter.dart';

class CrashlyticsTalkerObserver extends TalkerObserver {
CrashlyticsTalkerObserver();

@override
void onError(err) {
FirebaseCrashlytics.instance.recordError(
err.error,
err.stackTrace,
reason: err.message,
);
}

@override
void onException(err) {
FirebaseCrashlytics.instance.recordError(
err.exception,
err.stackTrace,
reason: err.message,
);
}
}
3 changes: 3 additions & 0 deletions lib/src/core/utils/globals.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
library globals;

import 'package:talker_flutter/talker_flutter.dart';

String appName = "IRL Link";
String packageName = "com.irllink";
String version = "1.0.0";
String buildNumber = "1";
Talker? talker;
21 changes: 21 additions & 0 deletions lib/src/core/utils/init_dio.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:talker_dio_logger/talker_dio_logger_interceptor.dart';
import 'package:talker_dio_logger/talker_dio_logger_settings.dart';
import 'package:irllink/src/core/utils/globals.dart' as globals;

Dio initDio() {
final talker = globals.talker;
var dio = Dio();
dio.interceptors.add(
TalkerDioLogger(
talker: talker,
settings: TalkerDioLoggerSettings(
requestFilter: (RequestOptions options) => kDebugMode ? true : !options.path.contains('api.twitch.tv'),
responseFilter: (response) => kDebugMode ? true : ![200, 202].contains(response.statusCode),
),
),
);

return dio;
}
11 changes: 6 additions & 5 deletions lib/src/core/utils/twitch_event_sub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'package:irllink/src/core/utils/init_dio.dart';
import 'package:irllink/src/data/entities/twitch/twitch_poll_dto.dart';
import 'package:irllink/src/data/entities/twitch/twitch_prediction_dto.dart';
import 'package:irllink/src/domain/entities/twitch/twitch_hype_train.dart';
import 'package:irllink/src/domain/entities/twitch/twitch_poll.dart';
import 'package:irllink/src/domain/entities/twitch/twitch_prediction.dart';
import 'package:twitch_chat/twitch_chat.dart';
import 'package:web_socket_channel/io.dart';
import 'package:irllink/src/core/utils/globals.dart' as globals;

import '../../data/entities/twitch/twitch_hype_train_dto.dart';
import 'constants.dart';
Expand Down Expand Up @@ -137,13 +139,12 @@ class TwitchEventSub {
}

void _onDone() {
debugPrint("Twitch Sub Event: Connection closed");
globals.talker?.debug("Twitch Sub Event: Connection closed");
close();
}

void _onError(Object o, StackTrace s) {
debugPrint('Twitch event sub error: $o');
debugPrint('Twitch event sub error: $s');
globals.talker?.error("Twitch Sub Event: error", o, s);
}

Future<String> _getChannelId() async {
Expand All @@ -154,7 +155,7 @@ class TwitchEventSub {

void subscribeToEvent(String type, String version, String sessionId,
Map<String, String> condition) async {
var dio = Dio();
var dio = initDio();
try {
dio.options.headers['Client-Id'] = kTwitchAuthClientId;
dio.options.headers["authorization"] = "Bearer $accessToken";
Expand All @@ -167,7 +168,7 @@ class TwitchEventSub {
"transport": {"method": "websocket", "session_id": sessionId}
});
} on DioException catch (e) {
debugPrint(e.response.toString());
globals.talker?.error(e.response.toString());
}
}
}
Loading

0 comments on commit 0873ba3

Please sign in to comment.