Skip to content

Commit

Permalink
fix(crashlytics): parameter information accepts Iterable<Object>
Browse files Browse the repository at this point in the history
…for further diagnostic logging information (#9678)
  • Loading branch information
russellwheatley committed Oct 6, 2022
1 parent 235b346 commit 2d2b5b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
14 changes: 13 additions & 1 deletion docs/crashlytics/_customize-crash-reports.md
Expand Up @@ -97,7 +97,7 @@ event is reported or when the app restarts.
Note: {{crashlytics}} only stores the most recent eight recorded non-fatal
exceptions. If your app throws more than eight, older exceptions are lost. This
count is reset each time a fatal exception is thrown, since this causes a report
to be sent to {{crashlytics}}.
to be sent to {{crashlytics}}.

Use the `recordError` method to record non-fatal exceptions in your app's catch
blocks. For example:
Expand All @@ -110,6 +110,18 @@ await FirebaseCrashlytics.instance.recordError(
);
```

You may also wish to log further information about the error which is possible
using the `information` property:

```dart
await FirebaseCrashlytics.instance.recordError(
error,
stackTrace,
reason: 'a non-fatal error',
information: ['further diagnostic information about the error', 'version 2.0'],
);
```

Warning: If you want to include a unique value (for example, a user ID or a
timestamp) in your exception message, use a [custom key](#add-keys) instead of
adding the value directly in the exception message. Adding values directly can
Expand Down
Expand Up @@ -6,7 +6,7 @@
library firebase_crashlytics;

import 'package:flutter/foundation.dart'
show kDebugMode, FlutterErrorDetails, FlutterError, DiagnosticsNode;
show kDebugMode, FlutterErrorDetails, FlutterError;

import 'package:firebase_crashlytics_platform_interface/firebase_crashlytics_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
Expand Down
Expand Up @@ -79,7 +79,7 @@ class FirebaseCrashlytics extends FirebasePluginPlatform {
/// Submits a Crashlytics report of a caught error.
Future<void> recordError(dynamic exception, StackTrace? stack,
{dynamic reason,
Iterable<DiagnosticsNode> information = const [],
Iterable<Object> information = const [],
bool? printDetails,
bool fatal = false}) async {
// Use the debug flag if printDetails is not provided
Expand Down Expand Up @@ -139,13 +139,13 @@ class FirebaseCrashlytics extends FirebasePluginPlatform {
{bool fatal = false}) {
FlutterError.presentError(flutterErrorDetails);

final information = flutterErrorDetails.informationCollector?.call() ?? [];

return recordError(
flutterErrorDetails.exceptionAsString(),
flutterErrorDetails.stack,
reason: flutterErrorDetails.context,
information: flutterErrorDetails.informationCollector == null
? []
: flutterErrorDetails.informationCollector!(),
information: information,
printDetails: false,
fatal: fatal,
);
Expand Down

0 comments on commit 2d2b5b0

Please sign in to comment.