Search in sources :

Example 1 with GoogleAnalytics

use of com.google.android.gms.analytics.GoogleAnalytics in project qksms by moezbhatti.

the class AnalyticsManager method init.

public void init(Context context) {
    if (LOCAL_LOGV)
        Log.v(TAG, "init called. mNeedsInit: " + mNeedsInit);
    if (mNeedsInit) {
        mNeedsInit = false;
        mContext = context;
        // Initialize tracker
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(mContext);
        mTracker = analytics.newTracker(R.xml.google_analytics_tracker);
    }
}
Also used : GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics)

Example 2 with GoogleAnalytics

use of com.google.android.gms.analytics.GoogleAnalytics in project Telecine by JakeWharton.

the class TelecineModule method provideAnalytics.

@Provides
@Singleton
Analytics provideAnalytics() {
    if (BuildConfig.DEBUG) {
        return new Analytics() {

            @Override
            public void send(Map<String, String> params) {
                Timber.tag("Analytics").d(String.valueOf(params));
            }
        };
    }
    GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(app);
    Tracker tracker = googleAnalytics.newTracker(BuildConfig.ANALYTICS_KEY);
    // ms? s? better be s.
    tracker.setSessionTimeout(300);
    return new Analytics.GoogleAnalytics(tracker);
}
Also used : GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics) Tracker(com.google.android.gms.analytics.Tracker) Map(java.util.Map) GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 3 with GoogleAnalytics

use of com.google.android.gms.analytics.GoogleAnalytics in project collect by opendatakit.

the class Collect method getDefaultTracker.

/**
 * Gets the default {@link Tracker} for this {@link Application}.
 *
 * @return tracker
 */
public synchronized Tracker getDefaultTracker() {
    if (tracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        tracker = analytics.newTracker(R.xml.global_tracker);
    }
    return tracker;
}
Also used : GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics)

Example 4 with GoogleAnalytics

use of com.google.android.gms.analytics.GoogleAnalytics in project iosched by google.

the class AnalyticsHelper method autoToggleAnalytics.

/**
 * Checks application state and settings_prefs, then explicitly either enables or
 * disables the tracker.
 */
private static void autoToggleAnalytics() {
    GoogleAnalytics instance = GoogleAnalytics.getInstance(sAppContext);
    try {
        // Analytics shouldn't run unless all the following are true:
        // 1) A tracker has been initialized in this class (as opposed to elsewhere in the app).
        // 2) The user has accepted TOS.
        // 3) "Anonymous usage data" is enabled in settings.
        boolean enableAnalytics = // Has Analytics been initialized?
        isInitialized() && // Analytics enabled in settings.
        SettingsUtils.isAnalyticsEnabled(sAppContext);
        if (instance != null) {
            instance.setAppOptOut(!enableAnalytics);
        }
        if (mFirebaseAnalytics != null) {
            mFirebaseAnalytics.setAnalyticsCollectionEnabled(enableAnalytics);
        }
        LOGD(TAG, "Analytics" + (isInitialized() ? "" : " not") + " initialized" + ", TOS" + (WelcomeUtils.isTosAccepted(sAppContext) ? "" : " not") + " accepted" + ", Setting is" + (SettingsUtils.isAnalyticsEnabled(sAppContext) ? "" : " not") + " checked");
    } catch (Exception e) {
        if (instance != null) {
            instance.setAppOptOut(true);
        }
        if (mFirebaseAnalytics != null) {
            mFirebaseAnalytics.setAnalyticsCollectionEnabled(false);
        }
    }
}
Also used : GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics)

Example 5 with GoogleAnalytics

use of com.google.android.gms.analytics.GoogleAnalytics in project vialer-android by VoIPGRID.

the class AnalyticsApplication method getDefaultTracker.

/**
 * Gets the default {@link Tracker} for this {@link Application}.
 * @return tracker
 */
public synchronized Tracker getDefaultTracker() {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker(R.xml.tracker);
    }
    JsonStorage storage = new JsonStorage(this);
    SystemUser systemuser = (SystemUser) storage.get(SystemUser.class);
    // Set client id as custom dimension on index 1.
    if (systemuser != null) {
        String clientId = systemuser.getClient();
        if (clientId != null) {
            mTracker.set("&cd1", clientId);
        }
    }
    return mTracker;
}
Also used : GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics) SystemUser(com.voipgrid.vialer.api.models.SystemUser) JsonStorage(com.voipgrid.vialer.util.JsonStorage)

Aggregations

GoogleAnalytics (com.google.android.gms.analytics.GoogleAnalytics)17 Tracker (com.google.android.gms.analytics.Tracker)4 Provides (dagger.Provides)2 Map (java.util.Map)2 Singleton (javax.inject.Singleton)2 SharedPreferences (android.content.SharedPreferences)1 SystemUser (com.voipgrid.vialer.api.models.SystemUser)1 JsonStorage (com.voipgrid.vialer.util.JsonStorage)1