/** * Initialize the analytics tracker in use by the application. This should only be called * once, when the TOS is signed. The {@code applicationContext} parameter MUST be the * application context or an object leak could occur. */ private static synchronized void initializeAnalyticsTracker(Context applicationContext) { sAppContext = applicationContext; if (mTracker == null) { int useProfile; if (BuildConfig.DEBUG) { LOGD(TAG, "Analytics manager using DEBUG ANALYTICS PROFILE."); useProfile = R.xml.analytics_debug; } else { useProfile = R.xml.analytics_release; } try { mTracker = GoogleAnalytics.getInstance(applicationContext).newTracker(useProfile); } catch (Exception e) { // If anything goes wrong, force an opt-out of tracking. It's better to accidentally // protect privacy than accidentally collect data. setAnalyticsEnabled(false); } } }
/** * Allows to turn on/off sharing statistics ability. */ private void toggleShareStatistics() { if(mShareStatsCheckBox == null) { return; } boolean shareStatistics = mShareStatsCheckBox.isChecked(); if(shareStatistics) { GoogleAnalytics.getInstance(this).reportActivityStart(this); } else { GoogleAnalytics.getInstance(this).reportActivityStop(this); } mPrefs.edit().putBoolean(getString(R.string.prefs_share_stats_status), shareStatistics).apply(); logi("shareStatistics = " + shareStatistics); GoogleAnalyticsManager.getInstance().setShareStatistic(shareStatistics); GoogleAnalyticsManager.getInstance(). sendStatSharing(HomeActivity.class.getSimpleName(), shareStatistics); }
public static void initGATracker(DroidPlannerApp app) { if (sAppTracker == null) { final Context context = app.getApplicationContext(); final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); // Call is needed for now to allow dispatching of auto activity // reports // (http://stackoverflow.com/a/23256722/1088814) analytics.enableAutoActivityReports(app); analytics.setAppOptOut(!new DroidPlannerPrefs(context).isUsageStatisticsEnabled()); // If we're in debug mode, set log level to verbose. if (BuildConfig.DEBUG) { analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE); } sAppTracker = analytics.newTracker(R.xml.google_analytics_tracker); } }
private void initGoogleAnalytics() { analytics = GoogleAnalytics.getInstance(this); if(BuildConfig.DEBUG) { // true = for log output, it does not sent data to Google Analytics analytics.setDryRun(true); // To enable debug logging on a device run: // adb shell setprop log.tag.GAv4 DEBUG // adb logcat -s GAv4 // true = disable google analytics on the app // analytics.setAppOptOut(true); } tracker = analytics.newTracker(getString(R.string.ga_trackingId)); tracker.enableExceptionReporting(true); tracker.enableAdvertisingIdCollection(true); tracker.enableAutoActivityTracking(false); }
/** * Gets the google analytics tracker. * * @return the google analytics tracker. */ private Tracker getTracker() { if (mTracker == null) { int checkExistence = mContext.getResources().getIdentifier("global_tracker", "xml", mContext.getPackageName()); if (checkExistence == 0) { Log.e(AnalyticsManager.class.getCanonicalName(), "Please check if you have global-services.json"); } else { mTracker = GoogleAnalytics.getInstance(mContext).newTracker(checkExistence); mTracker.enableAutoActivityTracking(false); mTracker.enableAdvertisingIdCollection(false); mTracker.enableExceptionReporting(false); } } return mTracker; }
public synchronized Tracker get(Target target) { if (!mTrackers.containsKey(target)) { Tracker tracker; switch (target) { case APP: tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker); tracker.enableAdvertisingIdCollection(true); break; default: throw new IllegalArgumentException("Unhandled analytics target " + target); } mTrackers.put(target, tracker); } return mTrackers.get(target); }
public static void initGATracker(DroidPlannerApp app) { if (sAppTracker == null) { final Context context = app.getApplicationContext(); final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); // Call is needed for now to allow dispatching of auto activity reports // (http://stackoverflow.com/a/23256722/1088814) analytics.enableAutoActivityReports(app); analytics.setAppOptOut(!DroidPlannerPrefs.getInstance(context).isUsageStatisticsEnabled()); // If we're in debug mode, set log level to verbose. if (BuildConfig.DEBUG) { analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE); } sAppTracker = analytics.newTracker(R.xml.google_analytics_tracker); } }
public static void initGATracker(DroidPlannerApp app) { if (sAppTracker == null) { final Context context = app.getApplicationContext(); final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); // Call is needed for now to allow dispatching of auto activity reports // (http://stackoverflow.com/a/23256722/1088814) analytics.enableAutoActivityReports(app); analytics.setAppOptOut(!new DroidPlannerPrefs(context).isUsageStatisticsEnabled()); // If we're in debug mode, set log level to verbose. if (BuildConfig.DEBUG) { analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE); } sAppTracker = analytics.newTracker(R.xml.google_analytics_tracker); } }
synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // Чтобы включить ведение журнала отладки, используйте adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker("global_tracker"); } return mTracker; }
public synchronized Tracker get(Target target) { if (!mTrackers.containsKey(target)) { Tracker tracker; switch (target) { case APP: tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker); break; default: throw new IllegalArgumentException("Unhandled analytics target " + target); } mTrackers.put(target, tracker); } return mTrackers.get(target); }
synchronized static Tracker getGATracker(Context context) { if (tracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); tracker = analytics.newTracker(R.xml.ga_app_tracker); } return tracker; }
public void init(final Context context){ if (tracker==null) { if (context==null){ throw new IllegalArgumentException("No context set."); } // Create new tracker final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE); tracker = analytics.newTracker(R.xml.analytics); } }
synchronized public 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.app_tracker); } return mTracker; }
synchronized private Tracker getDefaultTracker(Context context) { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); mTracker = analytics.newTracker(mGaConfigLocation); } return mTracker; }
public synchronized Tracker getTracker(TrackerName trackerId) { if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); Tracker t = analytics.newTracker(R.xml.global_tracker); mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); }
/** * Gets the default {@link Tracker} for this {@link Application}. * @return tracker */ synchronized public 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.global_tracker); } return mTracker; }
/** * Enables or disables Analytics. * @param enableAnalytics Whether analytics should be enabled. */ private static void setAnalyticsEnabled(boolean enableAnalytics) { GoogleAnalytics instance = GoogleAnalytics.getInstance(sAppContext); if (instance != null) { instance.setAppOptOut(!enableAnalytics); LOGD(TAG, "Analytics enabled: " + enableAnalytics); } }
synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(mContext); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker(R.xml.app_tracker); } return mTracker; }
public synchronized Tracker getTracker() { if (gaTracker != null) return gaTracker; GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.setAppOptOut(isDebuggable); if (isDebuggable) analytics.getLogger().setLogLevel(LogLevel.VERBOSE); gaTracker = analytics.newTracker(ApiObjects.analytics .get("property_id")); gaTracker.enableAdvertisingIdCollection(true); gaTracker.setSessionTimeout(-1); return gaTracker; }
synchronized public void track(String s) { 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.global_tracker); } mTracker.setScreenName(s); mTracker.send(new HitBuilders.ScreenViewBuilder().build()); }
public void event(String s) { 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.global_tracker); } mTracker.send(new HitBuilders.EventBuilder() .setCategory("Action") .setAction(s) .build()); }
/** * Gets the default {@link Tracker} for this {@link Application}. * @return tracker */ synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mTracker = analytics.newTracker(R.xml.global_tracker); mTracker.enableAdvertisingIdCollection(true); } return mTracker; }
public void trackScreenView(String screenName) { Tracker t = getGoogleAnalyticsTracker(); // Set screen name. t.setScreenName(screenName); // Send a screen view. t.send(new HitBuilders.ScreenViewBuilder().build()); GoogleAnalytics.getInstance(this).dispatchLocalHits(); }
private void initGoogleAnalytics() { analytics = GoogleAnalytics.getInstance(this); analytics.setLocalDispatchPeriod(1800); tracker = analytics.newTracker("UA-106256858-1"); // Replace with actual tracker id tracker.enableExceptionReporting(true); tracker.enableAdvertisingIdCollection(true); tracker.enableAutoActivityTracking(true); }
/** * Gets the default {@link Tracker} for this {@link Application}. * * @return tracker */ public synchronized Tracker getDefaultGATracker() { if (mGTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mGTracker = analytics.newTracker(R.xml.global_tracker); mGTracker.enableAdvertisingIdCollection(true); mGTracker.enableExceptionReporting(true); } return mGTracker; }
@Override public void enableAppender(Context context) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); //This can be configured via XML or code. Since we need to maintain this code on the lib, it must // be via xml (dummy file) that will ne replaced by the apps real file // examples of both configurations are available: https://developers.google.com/analytics/devguides/collection/android/v4/advanced mTracker = analytics.newTracker(mConfigurationFileId); }
public void init(Context context, boolean optOut) { GoogleAnalytics ga = GoogleAnalytics.getInstance(context); ga.setAppOptOut(optOut); if (!optOut) { // Initializing the google analytics this.mTracker = ga.newTracker(R.xml.app_tracker); // Initializing the mixpanelapi analytics this.mMixpanelAPI = MixpanelAPI.getInstance(context, "0f9f5280a4fb76478215544e42fa1299"); } }
synchronized public 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.global_tracker); mTracker.enableAutoActivityTracking(true); mTracker.enableExceptionReporting(true); } return mTracker; }
GoogleAnalyticsHelper(Context context, boolean enable, GoogleAnalyticsServiceIdentifier serviceIdentifier) throws AnalyticsInstantiationException { super(context, enable, serviceIdentifier); enabled = enable; if (enable && tracker == null) { tracker = GoogleAnalytics.getInstance(context).newTracker(serviceIdentifier.getTrackingId()); } }
synchronized Tracker getTracker() { TrackerName trackerId = TrackerName.APP_TRACKER; if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); Tracker t = analytics.newTracker("UA-55342416-1"); mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); }
/** * Gets the default {@link Tracker} for this {@link Application}. * @return tracker */ synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mTracker = analytics.newTracker(R.xml.app_tracker); } return mTracker; }
@Override public void onCreate() { sInstance = this; super.onCreate(); MultiDex.install(this); GoogleAnalytics analytics = GoogleAnalytics.getInstance(getApplicationContext()); mTracker = analytics.newTracker(R.xml.global_tracker); mAppComponent = DaggerAppComponent.builder() .appModule(new AppModule(this)) .build(); HockeyAppUtils.checkForCrashes(this); }