use of com.google.firebase.analytics.connector.AnalyticsConnector in project GreenHouse by utsanjan.
the class CrashlyticsRegistrar method buildCrashlytics.
/* JADX INFO: Access modifiers changed from: private */
public FirebaseCrashlytics buildCrashlytics(ComponentContainer container) {
FirebaseApp app = (FirebaseApp) container.get(FirebaseApp.class);
CrashlyticsNativeComponent nativeComponent = (CrashlyticsNativeComponent) container.get(CrashlyticsNativeComponent.class);
AnalyticsConnector analyticsConnector = (AnalyticsConnector) container.get(AnalyticsConnector.class);
FirebaseInstanceIdInternal instanceId = (FirebaseInstanceIdInternal) container.getProvider(FirebaseInstanceIdInternal.class).get();
return FirebaseCrashlytics.init(app, instanceId, nativeComponent, analyticsConnector);
}
use of com.google.firebase.analytics.connector.AnalyticsConnector in project GreenHouse by utsanjan.
the class AnalyticsConnectorReceiver method register.
// com.google.firebase.crashlytics.internal.analytics.AnalyticsReceiver
@Override
public boolean register() {
AnalyticsConnector analyticsConnector = this.analyticsConnector;
if (analyticsConnector == null) {
Logger.getLogger().d("Firebase Analytics is not present; you will not see automatic logging of events before a crash occurs.");
return false;
}
AnalyticsConnector.AnalyticsConnectorHandle registerAnalyticsConnectorListener = analyticsConnector.registerAnalyticsConnectorListener(CRASHLYTICS_ORIGIN, this);
this.analyticsConnectorHandle = registerAnalyticsConnectorListener;
if (registerAnalyticsConnectorListener == null) {
Logger.getLogger().d("Could not register AnalyticsConnectorListener with Crashlytics origin.");
AnalyticsConnector.AnalyticsConnectorHandle registerAnalyticsConnectorListener2 = this.analyticsConnector.registerAnalyticsConnectorListener("crash", this);
this.analyticsConnectorHandle = registerAnalyticsConnectorListener2;
if (registerAnalyticsConnectorListener2 != null) {
Logger.getLogger().w("A new version of the Google Analytics for Firebase SDK is now available. For improved performance and compatibility with Crashlytics, please update to the latest version.");
}
}
return this.analyticsConnectorHandle != null;
}
use of com.google.firebase.analytics.connector.AnalyticsConnector in project firebase-android-sdk by firebase.
the class ConfigFetchHandlerTest method fetch_hasAnalyticsSdk_sendsUserProperties.
@Test
public void fetch_hasAnalyticsSdk_sendsUserProperties() throws Exception {
// Provide the mock Analytics SDK.
AnalyticsConnector mockAnalyticsConnector = mock(AnalyticsConnector.class);
fetchHandler = getNewFetchHandler(mockAnalyticsConnector);
Map<String, String> userProperties = ImmutableMap.of("up_key1", "up_val1", "up_key2", "up_val2");
when(mockAnalyticsConnector.getUserProperties(/*includeInternal=*/
false)).thenReturn(ImmutableMap.copyOf(userProperties));
fetchCallToHttpClientUpdatesClockAndReturnsConfig(firstFetchedContainer);
assertWithMessage("Fetch() failed!").that(fetchHandler.fetch().isSuccessful()).isTrue();
verifyBackendIsCalled(userProperties);
}
use of com.google.firebase.analytics.connector.AnalyticsConnector in project firebase-android-sdk by firebase.
the class MessagingAnalytics method logToScion.
/**
* Asynchronously log an event to Scion.
*
* <p>Scion schedules tasks to run on worker threads within the client app to send the event.
*/
@VisibleForTesting
static void logToScion(String event, Bundle extras) {
try {
FirebaseApp.getInstance();
} catch (IllegalStateException e) {
Log.e(TAG, "Default FirebaseApp has not been initialized. Skip logging event to GA.");
return;
}
if (extras == null) {
extras = new Bundle();
}
Bundle scionPayload = new Bundle();
String composerId = getComposerId(extras);
if (composerId != null) {
scionPayload.putString(ScionAnalytics.PARAM_COMPOSER_ID, composerId);
}
String composerLabel = getComposerLabel(extras);
if (composerLabel != null) {
scionPayload.putString(ScionAnalytics.PARAM_MESSAGE_NAME, composerLabel);
}
String messageLabel = getMessageLabel(extras);
if (!TextUtils.isEmpty(messageLabel)) {
scionPayload.putString(ScionAnalytics.PARAM_LABEL, messageLabel);
}
String messageChannel = getMessageChannel(extras);
if (!TextUtils.isEmpty(messageChannel)) {
scionPayload.putString(ScionAnalytics.PARAM_MESSAGE_CHANNEL, messageChannel);
}
String topic = getTopic(extras);
if (topic != null) {
scionPayload.putString(ScionAnalytics.PARAM_TOPIC, topic);
}
String messageTime = getMessageTime(extras);
if (messageTime != null) {
try {
scionPayload.putInt(ScionAnalytics.PARAM_MESSAGE_TIME, Integer.parseInt(messageTime));
} catch (NumberFormatException e) {
Log.w(TAG, "Error while parsing timestamp in GCM event", e);
}
}
String useDeviceTime = getUseDeviceTime(extras);
if (useDeviceTime != null) {
try {
scionPayload.putInt(ScionAnalytics.PARAM_MESSAGE_DEVICE_TIME, Integer.parseInt(useDeviceTime));
} catch (NumberFormatException e) {
Log.w(TAG, "Error while parsing use_device_time in GCM event", e);
}
}
String messageType = getMessageTypeForScion(extras);
if (ScionAnalytics.EVENT_NOTIFICATION_RECEIVE.equals(event) || ScionAnalytics.EVENT_NOTIFICATION_FOREGROUND.equals(event)) {
scionPayload.putString(ScionAnalytics.PARAM_MESSAGE_TYPE, messageType);
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Logging to scion event=" + event + " scionPayload=" + scionPayload);
}
// TODO(b/78465387) Use components dependency framework to get analyticsConnector obj
@SuppressWarnings("FirebaseUseExplicitDependencies") AnalyticsConnector analytics = FirebaseApp.getInstance().get(AnalyticsConnector.class);
if (analytics != null) {
analytics.logEvent(ScionAnalytics.ORIGIN_FCM, event, scionPayload);
} else {
// Client did not include the measurement library
Log.w(TAG, "Unable to log event: analytics library is missing");
}
}
use of com.google.firebase.analytics.connector.AnalyticsConnector in project firebase-android-sdk by firebase.
the class ConfigFetchHandlerTest method fetch_hasAnalyticsSdk_sendsUserPropertiesNoFirstOpenTime.
@Test
public void fetch_hasAnalyticsSdk_sendsUserPropertiesNoFirstOpenTime() throws Exception {
// Provide the mock Analytics SDK.
AnalyticsConnector mockAnalyticsConnector = mock(AnalyticsConnector.class);
fetchHandler = getNewFetchHandler(mockAnalyticsConnector);
Map<String, String> userProperties = ImmutableMap.of("up_key1", "up_val1", "up_key2", "up_val2");
when(mockAnalyticsConnector.getUserProperties(anyBoolean())).thenReturn(ImmutableMap.copyOf(userProperties));
fetchCallToHttpClientUpdatesClockAndReturnsConfig(firstFetchedContainer);
assertWithMessage("Fetch() failed!").that(fetchHandler.fetch().isSuccessful()).isTrue();
verifyBackendIsCalled(userProperties, null);
}
Aggregations