Source:
void trackNewAppDownloadInternal(@NonNull ExtraIdentifier extra) { Logy.d(LOGGER_TAG, "Tracking app download..."); StringBuilder installationIdentifier = new StringBuilder(); try { installationIdentifier.append("http://").append(mPackageName); PackageInfo pkgInfo = mPackMan.getPackageInfo(mPackageName, 0); installationIdentifier.append(":").append(pkgInfo.versionCode); if (extra == ExtraIdentifier.APK_CHECKSUM) { ApplicationInfo appInfo = mPackMan.getApplicationInfo(mPackageName, 0); if (appInfo.sourceDir != null) { String md5Identifier = null; try { md5Identifier = Checksum.getMD5Checksum(new File(appInfo.sourceDir)); } catch (Exception e) { e.printStackTrace(); } if (md5Identifier != null) installationIdentifier.append("/").append(md5Identifier); } } String referringApp = mPackMan.getInstallerPackageName(mPackageName); if (referringApp != null && referringApp.length() > 200) referringApp = referringApp.substring(0, 200); if (referringApp != null && referringApp.equals("com.android.vending")) { String referrerExtras = mPreferences.getString(InstallReferrerReceiver.PREF_KEY_INSTALL_REFERRER_EXTRAS, null); if (referrerExtras != null) { referringApp = referringApp + "/?" + referrerExtras; } } if (referringApp != null) referringApp = "http://" + referringApp; mTracker.track(new TrackMe() .set(QueryParams.EVENT_CATEGORY, "Application") .set(QueryParams.EVENT_ACTION, "downloaded") .set(QueryParams.ACTION_NAME, "application/downloaded") .set(QueryParams.URL_PATH, "/application/downloaded") .set(QueryParams.DOWNLOAD, installationIdentifier.toString()) .set(QueryParams.REFERRER, referringApp)); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } Logy.d(LOGGER_TAG, "... app download tracked."); }

Target:
void trackNewAppDownloadInternal(@NonNull ExtraIdentifier extra) { Logy.d(LOGGER_TAG, "Tracking app download..."); PackageInfo pkgInfo = null; try { pkgInfo = mPackMan.getPackageInfo(mPackageName, 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } if (pkgInfo == null) return; StringBuilder installIdentifier = new StringBuilder(); installIdentifier.append("http://").append(mPackageName).append(":").append(pkgInfo.versionCode); if (extra == ExtraIdentifier.APK_CHECKSUM) { if (pkgInfo.applicationInfo != null && pkgInfo.applicationInfo.sourceDir != null) { try { String md5Identifier = Checksum.getMD5Checksum(new File(pkgInfo.applicationInfo.sourceDir)); if (md5Identifier != null) installIdentifier.append("/").append(md5Identifier); } catch (Exception e) { e.printStackTrace(); } } } String referringApp = mPackMan.getInstallerPackageName(mPackageName); if (referringApp != null && referringApp.length() > 200) referringApp = referringApp.substring(0, 200); if (referringApp != null && referringApp.equals(INSTALL_SOURCE_GOOGLE_PLAY)) { String referrerExtras = mPreferences.getString(InstallReferrerReceiver.PREF_KEY_INSTALL_REFERRER_EXTRAS, null); if (referrerExtras != null) referringApp = referringApp + "/?" + referrerExtras; } if (referringApp != null) referringApp = "http://" + referringApp; mTracker.track(new TrackMe() .set(QueryParams.EVENT_CATEGORY, "Application") .set(QueryParams.EVENT_ACTION, "downloaded") .set(QueryParams.ACTION_NAME, "application/downloaded") .set(QueryParams.URL_PATH, "/application/downloaded") .set(QueryParams.DOWNLOAD, installIdentifier.toString()) .set(QueryParams.REFERRER, referringApp)); Logy.d(LOGGER_TAG, "... app download tracked."); }