Java Code Examples for com.google.firebase.analytics.FirebaseAnalytics#setUserId()

The following examples show how to use com.google.firebase.analytics.FirebaseAnalytics#setUserId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityGlobalAbstract.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    if (!getResources().getBoolean(R.bool.is_tablet))
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);

    if (!BuildConfig.DEBUG && !BuildConfig.BUILD_TYPE.equals("beta"))
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    SharedPreferences prefs = getSharedPreferences();
    if (this instanceof MainActivity || this instanceof LoginActivity || this instanceof SplashActivity) {
        prefs.edit().remove(Constants.PROGRAM_THEME).apply();
    }

    if (!(this instanceof SplashActivity) && !(this instanceof LoginActivity))
        setTheme(prefs.getInt(Constants.PROGRAM_THEME, prefs.getInt(Constants.THEME, R.style.AppTheme)));

    Crashlytics.setString(Constants.SERVER, prefs.getString(Constants.SERVER, null));
    String userName = prefs.getString(Constants.USER, null);
    if (userName != null)
        Crashlytics.setString(Constants.USER, userName);
    mFirebaseAnalytics.setUserId(prefs.getString(Constants.SERVER, null));

    super.onCreate(savedInstanceState);
}
 
Example 2
Source File: AnalyticsManager.java    From zephyr with MIT License 6 votes vote down vote up
public AnalyticsManager(@NonNull Context context,
                        @NonNull ILogger logger,
                        @NonNull IConfigManager configManager,
                        @NonNull IPrivacyManager privacyManager) {
    mContext = context;
    mLogger = logger;
    mConfigManager = configManager;
    mPrivacyManager = privacyManager;

    if (mPrivacyManager.isUsageDataCollectionEnabled()) {
        FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(context);
        firebaseAnalytics.setAnalyticsCollectionEnabled(true);
        firebaseAnalytics.setUserId(privacyManager.getUuid());
    } else {
        logger.log(LogLevel.WARNING, LOG_TAG, "Firebase analytics disabled.");
    }
}