Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/firebase/flutterfire into…
Browse files Browse the repository at this point in the history
… ihorvitruk/master
  • Loading branch information
Salakar committed May 3, 2022
2 parents cd66e5b + 7e3048f commit 4b97133
Show file tree
Hide file tree
Showing 17 changed files with 281 additions and 515 deletions.
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,48 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2022-04-29

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`firebase_crashlytics` - `v2.7.1`](#firebase_crashlytics---v271)

---

#### `firebase_crashlytics` - `v2.7.1`

- **FIX**: re-add support for `recordFlutterFatalError` method from previous EAP API (#8550). ([8ef8b55c](https://github.com/FirebaseExtended/flutterfire/commit/8ef8b55c113f24abac783170723c7f784f5d1fe5))


## 2022-04-29

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`firebase_crashlytics` - `v2.7.0`](#firebase_crashlytics---v270)

---

#### `firebase_crashlytics` - `v2.7.0`

- **FEAT**: add support for on-demand exception reporting (#8540). ([dfec7d60](https://github.com/FirebaseExtended/flutterfire/commit/dfec7d60592abe0a5c6523e13feabffb8b03020b))


## 2022-04-27

### Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.7.1

- **FIX**: re-add support for `recordFlutterFatalError` method from previous EAP API (#8550). ([8ef8b55c](https://github.com/FirebaseExtended/flutterfire/commit/8ef8b55c113f24abac783170723c7f784f5d1fe5))

## 2.7.0

- **FEAT**: add support for on-demand exception reporting (#8540). ([dfec7d60](https://github.com/FirebaseExtended/flutterfire/commit/dfec7d60592abe0a5c6523e13feabffb8b03020b))

## 2.6.3

- Update a dependency to the latest release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ rootProject.allprojects {
}

apply plugin: 'com.android.library'

def firebaseCoreProject = findProject(':firebase_core')
if (firebaseCoreProject == null) {
throw new GradleException('Could not find the firebase_core FlutterFire plugin, have you added it as a dependency in your pubspec?')
Expand Down Expand Up @@ -52,7 +51,9 @@ android {

dependencies {
implementation platform("com.google.firebase:firebase-bom:${getRootProjectExtOrCoreProperty("FirebaseSDKVersion", firebaseCoreProject)}")
implementation 'com.google.firebase:firebase-crashlytics'
// TODO remove specific version and fallback to BoM once 18.2.10 is available in a BoM release
implementation 'com.google.firebase:firebase-crashlytics:18.2.10'
// implementation 'com.google.firebase:firebase-crashlytics'
implementation 'androidx.annotation:annotation:1.1.0'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.google.firebase.crashlytics;

import android.annotation.SuppressLint;
import com.google.firebase.crashlytics.internal.Logger;

/** @hide */
public final class FlutterFirebaseCrashlyticsInternal {
@SuppressLint("VisibleForTests")
public static void recordFatalException(Throwable throwable) {
if (throwable == null) {
Logger.getLogger().w("A null value was passed to recordFatalException. Ignoring.");
return;
}
FirebaseCrashlytics.getInstance().core.logFatalException(throwable);
}

private FlutterFirebaseCrashlyticsInternal() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import androidx.annotation.NonNull;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.FirebaseApp;
import com.google.firebase.analytics.connector.AnalyticsConnector;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.google.firebase.crashlytics.internal.analytics.CrashlyticsOriginAnalyticsEventLogger;
import com.google.firebase.crashlytics.FlutterFirebaseCrashlyticsInternal;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
Expand Down Expand Up @@ -114,7 +112,7 @@ private Task<Void> recordError(final Map<String, Object> arguments) {
final String reason = (String) arguments.get(Constants.REASON);
final String information =
(String) Objects.requireNonNull(arguments.get(Constants.INFORMATION));
final boolean fatal = (boolean) arguments.get(Constants.FATAL);
final boolean fatal = (boolean) Objects.requireNonNull(arguments.get(Constants.FATAL));

Exception exception;
if (reason != null) {
Expand All @@ -126,21 +124,6 @@ private Task<Void> recordError(final Map<String, Object> arguments) {
exception = new FlutterError(dartExceptionMessage);
}

if (fatal) {
AnalyticsConnector connector = FirebaseApp.getInstance().get(AnalyticsConnector.class);
CrashlyticsOriginAnalyticsEventLogger analyticsEventLogger =
new CrashlyticsOriginAnalyticsEventLogger(connector);

Bundle params = new Bundle();
long unixTime = System.currentTimeMillis() / 1000;

params.putInt(Constants.FATAL, 1);
params.putLong(Constants.TIMESTAMP, unixTime);

crashlytics.setCustomKey(Constants.CRASH_EVENT_KEY, unixTime);
analyticsEventLogger.logEvent(Constants.FIREBASE_APPLICATION_EXCEPTION, params);
}

crashlytics.setCustomKey(Constants.FLUTTER_ERROR_EXCEPTION, dartExceptionMessage);

final List<StackTraceElement> elements = new ArrayList<>();
Expand All @@ -162,7 +145,11 @@ private Task<Void> recordError(final Map<String, Object> arguments) {
crashlytics.log(information);
}

crashlytics.recordException(exception);
if (fatal) {
FlutterFirebaseCrashlyticsInternal.recordFatalException(exception);
} else {
crashlytics.recordException(exception);
}
return null;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29
compileSdkVersion 31

lintOptions {
disable 'InvalidPackage'
Expand Down Expand Up @@ -60,4 +60,5 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

0 comments on commit 4b97133

Please sign in to comment.