Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/firebase_crashlytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.0.4+9

* Fixed custom keys implementation.
* Added tests for custom keys implementation.
* Removed a print statement.

## 0.0.4+8

* Automatically use version from pubspec.yaml when reporting usage to Firebase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ void main() {

test('onError', () async {
// This is currently only testing that we can log errors without crashing.
await Crashlytics.instance.setUserName('testing');
await Crashlytics.instance.setUserIdentifier('hello');
final Crashlytics crashlytics = Crashlytics.instance;
await crashlytics.setUserName('testing');
await crashlytics.setUserIdentifier('hello');
crashlytics.setBool('testBool', true);
crashlytics.setInt('testInt', 42);
crashlytics.setDouble('testDouble', 42.0);
crashlytics.setString('testString', 'bar');
Crashlytics.instance.log('testing');
await Crashlytics.instance.onError(
await crashlytics.onError(
FlutterErrorDetails(
exception: 'testing',
stack: StackTrace.fromString(''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Crashlytics {
Trace.format(details.stack).trimRight().split('\n');
final List<Map<String, String>> stackTraceElements =
getStackTraceElements(stackTraceLines);
final dynamic result = await channel
await channel
.invokeMethod<dynamic>('Crashlytics#onError', <String, dynamic>{
'exception': details.exceptionAsString(),
// FlutterErrorDetails.context has been migrated from a String to a
Expand All @@ -52,7 +52,6 @@ class Crashlytics {
'logs': _logs.toList(),
'keys': _prepareKeys(),
});
print(result);
}
}

Expand Down Expand Up @@ -156,6 +155,7 @@ class Crashlytics {
} else if (value is bool) {
crashlyticsKey['type'] = 'boolean';
}
crashlyticsKeys.add(crashlyticsKey);
}

return crashlyticsKeys;
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_crashlytics/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: firebase_crashlytics
description: Flutter plugin for Firebase Crashlytics. It reports uncaught errors to the
Firebase console.
version: 0.0.4+8
version: 0.0.4+9
author: Flutter Team <flutter-dev@google.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_crashlytics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,28 @@ void main() {
);
crashlytics.enableInDevMode = true;
crashlytics.log('foo');
crashlytics.setBool('testBool', true);
crashlytics.setInt('testInt', 42);
crashlytics.setDouble('testDouble', 42.0);
crashlytics.setString('testString', 'bar');
await crashlytics.onError(details);
expect(log[0].method, 'Crashlytics#onError');
expect(log[0].arguments['exception'], 'foo exception');
expect(log[0].arguments['context'], 'foo context');
expect(log[0].arguments['logs'], isNotEmpty);
expect(log[0].arguments['logs'], contains('foo'));
expect(log[0].arguments['keys'], isEmpty);
expect(log[0].arguments['keys'][0]['key'], 'testBool');
expect(log[0].arguments['keys'][0]['value'], isTrue);
expect(log[0].arguments['keys'][0]['type'], 'boolean');
expect(log[0].arguments['keys'][1]['key'], 'testInt');
expect(log[0].arguments['keys'][1]['value'], 42);
expect(log[0].arguments['keys'][1]['type'], 'int');
expect(log[0].arguments['keys'][2]['key'], 'testDouble');
expect(log[0].arguments['keys'][2]['value'], 42.0);
expect(log[0].arguments['keys'][2]['type'], 'double');
expect(log[0].arguments['keys'][3]['key'], 'testString');
expect(log[0].arguments['keys'][3]['value'], 'bar');
expect(log[0].arguments['keys'][3]['type'], 'string');
});

test('isDebuggable', () async {
Expand Down