Skip to content

Commit 83a8bbc

Browse files
committed
Nudge customers to update if on an old Firebase Analytics
We can infer the customer is on an outdated version of FA if we cannot attach a listener with the "clx" origin. If that is the case, use the old "crash" origin and write a logcat warning with a nudge to upgrade.
1 parent 7a925e6 commit 83a8bbc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/analytics/AnalyticsConnectorReceiver.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public interface BreadcrumbHandler {
3131
}
3232

3333
static final String CRASHLYTICS_ORIGIN = "clx";
34+
static final String LEGACY_CRASH_ORIGIN = "crash";
3435
public static final String EVENT_NAME_KEY = "name";
3536
public static final String APP_EXCEPTION_EVENT_NAME = "_ae";
3637
private static final String EVENT_ORIGIN_KEY = "_o";
@@ -66,6 +67,29 @@ public boolean register() {
6667
analyticsConnectorHandle =
6768
analyticsConnector.registerAnalyticsConnectorListener(CRASHLYTICS_ORIGIN, this);
6869

70+
if (analyticsConnectorHandle == null) {
71+
Logger.getLogger()
72+
.d(
73+
"Could not register AnalyticsConnectorListener with origin "
74+
+ "\""
75+
+ CRASHLYTICS_ORIGIN
76+
+ "\"");
77+
// Older versions of FA don't support CRASHLYTICS_ORIGIN. We can try using the old Firebase
78+
// Crash Reporting origin
79+
analyticsConnectorHandle =
80+
analyticsConnector.registerAnalyticsConnectorListener(LEGACY_CRASH_ORIGIN, this);
81+
82+
// If FA allows us to connect with the legacy origin, but not the new one, nudge customers
83+
// to update their FA version.
84+
if (analyticsConnectorHandle != null) {
85+
Logger.getLogger()
86+
.w(
87+
"Outdated version of Firebase Analytics detected. For improved "
88+
+ "performance and compatibility with Crashlytics, please update to the latest "
89+
+ "version of Firebase Analytics.");
90+
}
91+
}
92+
6993
return analyticsConnectorHandle != null;
7094
}
7195

0 commit comments

Comments
 (0)