예제 #1
0
  @Override
  public void onCreate() {
    super.onCreate();
    long startDate = SystemClock.elapsedRealtime();

    mContext = this;

    ProfilingUtils.start("App Startup");
    // Enable log recording
    AppLog.enableRecording(true);
    AppLog.i(T.UTILS, "WordPress.onCreate");

    if (!PackageUtils.isDebugBuild()) {
      Fabric.with(this, new Crashlytics());
    }

    versionName = PackageUtils.getVersionName(this);
    initWpDb();
    enableHttpResponseCache(mContext);

    // EventBus setup
    EventBus.TAG = "WordPress-EVENT";
    EventBus.builder()
        .logNoSubscriberMessages(false)
        .sendNoSubscriberEvent(false)
        .throwSubscriberException(true)
        .installDefaultEventBus();
    EventBus.getDefault().register(this);

    RestClientUtils.setUserAgent(getUserAgent());

    // Volley networking setup
    setupVolleyQueue();

    AppLockManager.getInstance().enableDefaultAppLockIfAvailable(this);
    if (AppLockManager.getInstance().isAppLockFeatureEnabled()) {
      AppLockManager.getInstance()
          .getCurrentAppLock()
          .setDisabledActivities(
              new String[] {"org.wordpress.android.ui.ShareIntentReceiverActivity"});
    }

    HelpshiftHelper.init(this);

    ApplicationLifecycleMonitor applicationLifecycleMonitor = new ApplicationLifecycleMonitor();
    registerComponentCallbacks(applicationLifecycleMonitor);
    registerActivityLifecycleCallbacks(applicationLifecycleMonitor);

    initAnalytics(SystemClock.elapsedRealtime() - startDate);
  }
예제 #2
0
  private void initAnalytics(final long elapsedTimeOnCreate) {
    AnalyticsTracker.registerTracker(
        new AnalyticsTrackerMixpanel(getContext(), BuildConfig.MIXPANEL_TOKEN));
    AnalyticsTracker.registerTracker(new AnalyticsTrackerNosara(getContext()));
    AnalyticsTracker.init(getContext());
    AnalyticsUtils.refreshMetadata();

    // Track app upgrade
    int versionCode = PackageUtils.getVersionCode(getContext());
    int oldVersionCode = AppPrefs.getLastAppVersionCode();
    if (oldVersionCode != 0 && oldVersionCode < versionCode) {
      Map<String, Long> properties = new HashMap<String, Long>(1);
      properties.put("elapsed_time_on_create", elapsedTimeOnCreate);
      // app upgraded
      AnalyticsTracker.track(AnalyticsTracker.Stat.APPLICATION_UPGRADED, properties);
    }
    AppPrefs.setLastAppVersionCode(versionCode);
  }
예제 #3
0
 public static String getUserAgent() {
   if (mUserAgent == null) {
     mUserAgent =
         USER_AGENT_APPNAME
             + "/"
             + PackageUtils.getVersionName(getContext())
             + " (Android "
             + Build.VERSION.RELEASE
             + "; "
             + Locale.getDefault().toString()
             + "; "
             + Build.MANUFACTURER
             + " "
             + Build.MODEL
             + "/"
             + Build.PRODUCT
             + ")";
   }
   return mUserAgent;
 }