use of com.google.firebase.crashlytics.internal.analytics.CrashlyticsOriginAnalyticsEventLogger in project firebase-android-sdk by firebase.
the class AnalyticsDeferredProxy method init.
private void init() {
analyticsConnectorDeferred.whenAvailable(analyticsConnector -> {
Logger.getLogger().d("AnalyticsConnector now available.");
AnalyticsConnector connector = analyticsConnector.get();
// If FA is available, create a logger to log events from the Crashlytics origin.
final CrashlyticsOriginAnalyticsEventLogger directAnalyticsEventLogger = new CrashlyticsOriginAnalyticsEventLogger(connector);
// Create a listener to register for events coming from FA, which supplies both
// breadcrumbs
// as well as Crashlytics-origin events through different streams.
final CrashlyticsAnalyticsListener crashlyticsAnalyticsListener = new CrashlyticsAnalyticsListener();
// Registering our listener with FA should return a "handle", in which case we know we've
// registered successfully. Subsequent calls to register a listener will return null.
final AnalyticsConnector.AnalyticsConnectorHandle analyticsConnectorHandle = subscribeToAnalyticsEvents(connector, crashlyticsAnalyticsListener);
if (analyticsConnectorHandle != null) {
Logger.getLogger().d("Registered Firebase Analytics listener.");
// Create the event receiver which will supply breadcrumb events to Crashlytics
final BreadcrumbAnalyticsEventReceiver breadcrumbReceiver = new BreadcrumbAnalyticsEventReceiver();
// Logging events to FA is an asynchronous operation. This logger will send events to
// FA and block until FA returns the same event back to us, from the Crashlytics origin.
// However, in the case that data collection has been disabled on FA, we will not
// receive
// the event back (it will be silently dropped), so we set up a short timeout after
// which
// we will assume that FA data collection is disabled and move on.
final BlockingAnalyticsEventLogger blockingAnalyticsEventLogger = new BlockingAnalyticsEventLogger(directAnalyticsEventLogger, APP_EXCEPTION_CALLBACK_TIMEOUT_MS, TimeUnit.MILLISECONDS);
synchronized (this) {
// objects.
for (BreadcrumbHandler handler : breadcrumbHandlerList) {
breadcrumbReceiver.registerBreadcrumbHandler(handler);
}
// Set the appropriate event receivers to receive events from the FA listener
crashlyticsAnalyticsListener.setBreadcrumbEventReceiver(breadcrumbReceiver);
crashlyticsAnalyticsListener.setCrashlyticsOriginEventReceiver(blockingAnalyticsEventLogger);
// Set the breadcrumb event receiver as the breadcrumb source for Crashlytics.
breadcrumbSource = breadcrumbReceiver;
// Set the blocking analytics event logger for Crashlytics.
analyticsEventLogger = blockingAnalyticsEventLogger;
}
} else {
Logger.getLogger().w("Could not register Firebase Analytics listener; a listener is already registered.");
// FA is enabled, but the listener was not registered successfully.
// We cannot listen for breadcrumbs. Since the default is already
// `DisabledBreadcrumbSource` and `directAnalyticsEventLogger` there's nothing else to
// do.
}
});
}
Aggregations