-
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.
feat: Added ImpaktfullAnalyticsUtil and ImpaktfullCrashReportingUtil
- Loading branch information
1 parent
4d2a0f6
commit 90dcdf0
Showing
6 changed files
with
155 additions
and
0 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
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,15 @@ | ||
abstract class ImpaktfullAnalyticsUtil { | ||
Future<void> init({ | ||
bool enabled = false, | ||
}); | ||
|
||
Future<void> setEnabled(bool enabled); | ||
|
||
void logEvent(String eventName, {Map<String, dynamic>? data}); | ||
|
||
void setUserProperty(String property, String value); | ||
|
||
void setUserId(String userId); | ||
|
||
void setScreenName(String screenName); | ||
} |
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,53 @@ | ||
import 'package:impaktfull_architecture/src/util/analytics/analytics_util.dart'; | ||
|
||
class MultiInstanceAnalyticsUtil extends ImpaktfullAnalyticsUtil { | ||
final List<ImpaktfullAnalyticsUtil> analyticsUtils; | ||
|
||
MultiInstanceAnalyticsUtil( | ||
this.analyticsUtils, | ||
); | ||
|
||
@override | ||
Future<void> init({bool enabled = false}) async { | ||
await Future.wait(analyticsUtils.map( | ||
(util) => util.init( | ||
enabled: enabled, | ||
), | ||
)); | ||
} | ||
|
||
@override | ||
Future<void> setEnabled(bool enabled) async { | ||
await Future.wait(analyticsUtils.map( | ||
(util) => util.setEnabled(enabled), | ||
)); | ||
} | ||
|
||
@override | ||
void setUserId(String userId) { | ||
for (var util in analyticsUtils) { | ||
util.setUserId(userId); | ||
} | ||
} | ||
|
||
@override | ||
void setUserProperty(String property, String value) { | ||
for (var util in analyticsUtils) { | ||
util.setUserProperty(property, value); | ||
} | ||
} | ||
|
||
@override | ||
void logEvent(String eventName, {Map<String, dynamic>? data}) { | ||
for (var util in analyticsUtils) { | ||
util.logEvent(eventName, data: data); | ||
} | ||
} | ||
|
||
@override | ||
void setScreenName(String screenName) { | ||
for (var util in analyticsUtils) { | ||
util.setScreenName(screenName); | ||
} | ||
} | ||
} |
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,17 @@ | ||
abstract class ImpaktfullCrashReportingUtil { | ||
Future<void> init({bool enabled = false}); | ||
|
||
Future<void> setEnabled(bool enabled); | ||
|
||
void setUserId(String userId); | ||
|
||
void setUserProperty(String property, String value); | ||
|
||
void logError({ | ||
required Object error, | ||
required StackTrace stackTrace, | ||
String? message, | ||
}); | ||
|
||
void log(String message, {Map<String, dynamic>? data}); | ||
} |
61 changes: 61 additions & 0 deletions
61
lib/src/util/crash_reporting/multi_instance_crashreporting_util.dart
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,61 @@ | ||
import 'package:impaktfull_architecture/src/util/crash_reporting/crash_reporting_util.dart'; | ||
|
||
class MultiInstanceCrashReportingUtil extends ImpaktfullCrashReportingUtil { | ||
final List<ImpaktfullCrashReportingUtil> crashReportingUtils; | ||
|
||
MultiInstanceCrashReportingUtil( | ||
this.crashReportingUtils, | ||
); | ||
|
||
@override | ||
Future<void> init({bool enabled = false}) async { | ||
await Future.wait( | ||
crashReportingUtils.map( | ||
(util) => util.init( | ||
enabled: enabled, | ||
), | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Future<void> setEnabled(bool enabled) async { | ||
await Future.wait( | ||
crashReportingUtils.map( | ||
(util) => util.setEnabled(enabled), | ||
), | ||
); | ||
} | ||
|
||
@override | ||
void setUserId(String userId) { | ||
for (final util in crashReportingUtils) { | ||
util.setUserId(userId); | ||
} | ||
} | ||
|
||
@override | ||
void setUserProperty(String property, String value) { | ||
for (final util in crashReportingUtils) { | ||
util.setUserProperty(property, value); | ||
} | ||
} | ||
|
||
@override | ||
void log(String message, {Map<String, dynamic>? data}) { | ||
for (final util in crashReportingUtils) { | ||
util.log(message, data: data); | ||
} | ||
} | ||
|
||
@override | ||
void logError({ | ||
required Object error, | ||
required StackTrace stackTrace, | ||
String? message, | ||
}) { | ||
for (final util in crashReportingUtils) { | ||
util.logError(error: error, stackTrace: stackTrace, message: message); | ||
} | ||
} | ||
} |