-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add logging repository for collecting errors and logs
- Loading branch information
1 parent
3a03bc8
commit 49c2580
Showing
10 changed files
with
263 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:appmetrica_plugin/appmetrica_plugin.dart'; | ||
|
||
abstract class ILoggingRepository { | ||
Future<void> logError( | ||
Object exception, | ||
StackTrace stackTrace, { | ||
String? hint, | ||
bool fatal = false, | ||
}); | ||
Future<void> logEvent( | ||
String eventName, [ | ||
Map<String, Object>? attributes, | ||
]); | ||
} | ||
|
||
class AppMetricaLoggingRepository implements ILoggingRepository { | ||
@override | ||
Future<void> logError( | ||
Object exception, | ||
StackTrace stackTrace, { | ||
String? hint, | ||
bool fatal = false, | ||
}) async { | ||
await AppMetrica.reportError( | ||
message: exception.toString(), | ||
errorDescription: AppMetricaErrorDescription.fromObjectAndStackTrace( | ||
exception, | ||
stackTrace, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Future<void> logEvent( | ||
String eventName, [ | ||
Map<String, Object>? attributes, | ||
]) async { | ||
await AppMetrica.reportEventWithMap(eventName, attributes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:appmetrica_plugin/appmetrica_plugin.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:uneconly/common/logging/logging_repository.dart'; | ||
import 'package:uneconly/constants.dart'; | ||
|
||
abstract class ILoggingRepositoryFactory { | ||
Future<ILoggingRepository> create(); | ||
} | ||
|
||
class LoggingRepositoryFactory implements ILoggingRepositoryFactory { | ||
@override | ||
Future<ILoggingRepository> create() async { | ||
await AppMetrica.activate( | ||
kDebugMode | ||
? const AppMetricaConfig(appMetricaDevKey) | ||
: const AppMetricaConfig(appMetricaProductionKey), | ||
); | ||
|
||
return AppMetricaLoggingRepository(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
const serverAddress = 'https://roadmapik.com:5000'; | ||
const appMetricaDevKey = '97b0fe49-d3aa-4ef5-9825-e02dbf9b0efc'; | ||
const appMetricaProductionKey = '1498463f-e5a0-4da7-81fa-ccf7c3e1e131'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.