Skip to content

Commit 139444c

Browse files
committed
chore: update Bugsee integration documentation and event caputring method
1 parent e7cb678 commit 139444c

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

src/app/lib/business/bugsee/bugsee_manager.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ abstract interface class BugseeManager {
4545
required Exception exception,
4646
StackTrace? stackTrace,
4747
Map<String, dynamic> traces,
48-
Map<String, Map<String, dynamic>?> events,
4948
});
5049

5150
/// Manually update the current BugseeEnabled flag in shared prefs and in current manager singleton.
@@ -76,7 +75,7 @@ abstract interface class BugseeManager {
7675
Future<void> inteceptExceptions(Object error, StackTrace stackTrace);
7776

7877
/// Intercept all unhandled rending exception thrown by the Flutter framework
79-
Future<void> inteceptRenderExceptions(FlutterErrorDetails error);
78+
Future<void> inteceptRenderingExceptions(FlutterErrorDetails error);
8079

8180
/// Manually add a map of attributes
8281
/// - the map entry key is the attribute name
@@ -97,6 +96,9 @@ abstract interface class BugseeManager {
9796

9897
/// Manually remove an attribute by the given key attached using [addAttributes]
9998
Future<void> clearAttribute(String attribute);
99+
100+
/// Manually log Bugsee events that will be attached to the reported issues
101+
void logEvents(Map<String, Map<String, dynamic>> events);
100102
}
101103

102104
final class _BugseeManager implements BugseeManager {
@@ -260,15 +262,11 @@ final class _BugseeManager implements BugseeManager {
260262
required Exception exception,
261263
StackTrace? stackTrace,
262264
Map<String, dynamic> traces = const {},
263-
Map<String, Map<String, dynamic>?> events = const {},
264265
}) async {
265266
if (_currentState.isBugseeEnabled) {
266267
for (var trace in traces.entries) {
267268
await Bugsee.trace(trace.key, trace.value);
268269
}
269-
for (var event in events.entries) {
270-
await Bugsee.event(event.key, event.value);
271-
}
272270
await Bugsee.logException(exception, stackTrace);
273271
}
274272
}
@@ -404,10 +402,17 @@ final class _BugseeManager implements BugseeManager {
404402
}
405403

406404
@override
407-
Future<void> inteceptRenderExceptions(FlutterErrorDetails error) async {
405+
Future<void> inteceptRenderingExceptions(FlutterErrorDetails error) async {
408406
await logException(
409407
exception: Exception(error.exception),
410408
stackTrace: error.stack,
411409
);
412410
}
411+
412+
@override
413+
void logEvents(Map<String, Map<String, dynamic>> events) async {
414+
for (var event in events.entries) {
415+
Bugsee.event(event.key, event.value);
416+
}
417+
}
413418
}

src/app/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Future<void> main() async {
4141
runZonedGuarded(
4242
() async {
4343
FlutterError.onError =
44-
GetIt.I.get<BugseeManager>().inteceptRenderExceptions;
44+
GetIt.I.get<BugseeManager>().inteceptRenderingExceptions;
4545
await initializeComponents();
4646
await registerBugseeManager();
4747
runApp(const App());

src/app/lib/presentation/diagnostic/bugsee_configuration_widget.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class _BugseeConfigurationWidgetState extends State<BugseeConfigurationWidget> {
8989
},
9090
),
9191
DiagnosticSwitch(
92-
label: 'Enabling log collection',
92+
label: 'Log collection enabled',
9393
value: state.isLogCollectionEnabled,
9494
onChanged: (value) async {
9595
await bugseeManager.setIsLogsCollectionEnabled(value);
@@ -99,7 +99,7 @@ class _BugseeConfigurationWidgetState extends State<BugseeConfigurationWidget> {
9999
},
100100
),
101101
DiagnosticSwitch(
102-
label: 'Enable log filter',
102+
label: 'Filter log enabled',
103103
value: state.isLogFilterEnabled,
104104
onChanged: (value) async {
105105
await bugseeManager.setIsLogFilterEnabeld(value);
@@ -109,7 +109,7 @@ class _BugseeConfigurationWidgetState extends State<BugseeConfigurationWidget> {
109109
},
110110
),
111111
DiagnosticSwitch(
112-
label: 'Attach log file',
112+
label: 'Log file attached',
113113
value: state.attachLogFile,
114114
onChanged: (value) async {
115115
bugseeManager.setAttachLogFileEnabled(value);
@@ -127,11 +127,10 @@ class _BugseeConfigurationWidgetState extends State<BugseeConfigurationWidget> {
127127
},
128128
),
129129
DiagnosticButton(
130-
label: 'Log Exception with events',
130+
label: 'Add events to the exception',
131131
onPressed: () {
132-
bugseeManager.logException(
133-
exception: Exception(),
134-
events: {
132+
bugseeManager.logEvents(
133+
{
135134
'data': {
136135
'date': DateTime.now().millisecondsSinceEpoch,
137136
'id': Random().nextInt(20),

0 commit comments

Comments
 (0)