Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crashlytics): parameter information accepts Iterable<Object> for further diagnostic logging information #9678

Merged
merged 2 commits into from Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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