-
Notifications
You must be signed in to change notification settings - Fork 627
Using deferred Analytics with Crashlytics. #2555
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
Conversation
Coverage ReportAffected SDKs
Test Logs
NotesHTML coverage reports can be produced locally with Head commit (ebdf28f3) is created by Prow via merging commits: 129d7e5 2c0c76c. |
Binary Size ReportAffected SDKs
Test Logs
NotesHead commit (ebdf28f3) is created by Prow via merging commits: 129d7e5 2c0c76c. |
...e-crashlytics/src/main/java/com/google/firebase/crashlytics/AnalyticsDeferredComponents.java
Outdated
Show resolved
Hide resolved
import java.util.concurrent.TimeUnit; | ||
|
||
/** @hide */ | ||
public class AnalyticsDeferredComponents { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am missing something, it looks like we have 2 classes that depend on the connector:
- BreadcrumbSource
- AnalyticsEventLogger
I wonder if it would be cleaner to have separate implementations for both of them that depend on Deferred<AnalyticsConnector>
as opposed to having them exposed through getters of this class. This would achieve 2 things:
- reduce coupling since all dependent classes won't have to depend on this "components" class with getters[1]
- Would make it easier to achieve thread safety in both classes, which your current implementation does not seem to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since both objects that depend on the deferred objects are interfaces in Crashlytics , I've addressed your comment as follows:
- Created new "proxy" implementations of the interfaces, these implementations are inner classes to the
AnalyticsDeferredComponent
object. - These proxy objects simply channel any calls to the actual implementing object in the
AnalyticsDeferredComponent
object. - The
AnalyticsDeferredComponent
by default creates 2 objects which are the default implementations Crashlytics use when there's noAnalyticsConnector
present. - When the
AnalyticsConnector
becomes available, we switch the default implementation objects with new ones that use Analytics.
This is transparent to any other objects using BreadcrumbSource
and AnalyticsEventLogger
since the proxy implementations will switch to the right objects cleanly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
// Set the breadcrumb event receiver as the breadcrumb source for Crashlytics. | ||
breadcrumbSource = breadcrumbReceiver; | ||
// Set the blocking analytics event logger for Crashlytics. | ||
analyticsEventLogger = blockingAnalyticsEventLogger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look thread-safe, i.e. other threads may never see these writes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
...e-crashlytics/src/main/java/com/google/firebase/crashlytics/AnalyticsDeferredComponents.java
Outdated
Show resolved
Hide resolved
/retest |
/test device-check-changed |
No description provided.