Search in sources :

Example 1 with AnalyticsConnector

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);
}
Also used : FirebaseInstanceIdInternal(com.google.firebase.iid.internal.FirebaseInstanceIdInternal) FirebaseApp(com.google.firebase.FirebaseApp) CrashlyticsNativeComponent(com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent) AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector)

Example 2 with 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;
}
Also used : AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector)

Example 3 with AnalyticsConnector

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);
}
Also used : AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector) Test(org.junit.Test)

Example 4 with AnalyticsConnector

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");
    }
}
Also used : Bundle(android.os.Bundle) AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 5 with AnalyticsConnector

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);
}
Also used : AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector) Test(org.junit.Test)

Aggregations

AnalyticsConnector (com.google.firebase.analytics.connector.AnalyticsConnector)16 Test (org.junit.Test)7 Bundle (android.os.Bundle)6 Matchers.anyString (org.mockito.Matchers.anyString)4 FirebaseApp (com.google.firebase.FirebaseApp)3 NonNull (androidx.annotation.NonNull)2 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)2 AnalyticsConnectorHandle (com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorHandle)2 AnalyticsConnectorListener (com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener)2 CrashlyticsNativeComponent (com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent)2 Deferred (com.google.firebase.inject.Deferred)2 FirebaseInstallationsApi (com.google.firebase.installations.FirebaseInstallationsApi)2 Collections (java.util.Collections)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 JSONObject (org.json.JSONObject)2 Before (org.junit.Before)2 RunWith (org.junit.runner.RunWith)2 Matchers.any (org.mockito.Matchers.any)2 Mockito.mock (org.mockito.Mockito.mock)2