jenkins-bot has submitted this change and it was merged. Change subject: Persist channel parameter from install referrer. ......................................................................
Persist channel parameter from install referrer. This introduces a new parameter for our install referrer string, called "channel". If this parameter is present, we will save the channel in SharedPreferences, so that it will be passed through to the userAgent that the app uses for all network requests. (The logic of putting the channel into the userAgent is already there.) Bug: T149917 Change-Id: Ia4ea46765dacde8e1c1957dc6f94bd36d5807462 --- M app/src/main/java/org/wikipedia/analytics/InstallReceiver.java M app/src/main/java/org/wikipedia/analytics/InstallReferrerFunnel.java M app/src/main/java/org/wikipedia/util/ReleaseUtil.java 3 files changed, 12 insertions(+), 11 deletions(-) Approvals: jenkins-bot: Verified Niedzielski: Looks good to me, approved diff --git a/app/src/main/java/org/wikipedia/analytics/InstallReceiver.java b/app/src/main/java/org/wikipedia/analytics/InstallReceiver.java index ff7cb72..b06fae4 100644 --- a/app/src/main/java/org/wikipedia/analytics/InstallReceiver.java +++ b/app/src/main/java/org/wikipedia/analytics/InstallReceiver.java @@ -9,6 +9,7 @@ import org.wikipedia.WikipediaApp; import org.wikipedia.page.PageActivity; +import org.wikipedia.settings.Prefs; import org.wikipedia.util.ReleaseUtil; import org.wikipedia.util.ShareUtil; import org.wikipedia.util.log.L; @@ -62,12 +63,14 @@ String refUrl = null; String refCampaignId = null; String refCampaignInstallId = null; + String refChannel = null; try { // build a proper dummy URI with the referrer appended to it, so that we can parse it. Uri uri = Uri.parse("/?" + referrerStr); refUrl = uri.getQueryParameter(InstallReferrerFunnel.PARAM_REFERRER_URL); refCampaignId = uri.getQueryParameter(InstallReferrerFunnel.PARAM_CAMPAIGN_ID); refCampaignInstallId = uri.getQueryParameter(InstallReferrerFunnel.PARAM_CAMPAIGN_INSTALL_ID); + refChannel = uri.getQueryParameter(InstallReferrerFunnel.PARAM_CHANNEL); } catch (UnsupportedOperationException e) { // Can be thrown by getQueryParameter() if the referrer is malformed. // Don't worry about it. @@ -81,6 +84,9 @@ if (!TextUtils.isEmpty(refUrl) && ShareUtil.canOpenUrlInApp(ctx, refUrl)) { openPageFromUrl(ctx, refUrl); } + if (!TextUtils.isEmpty(refChannel)) { + Prefs.setAppChannel(refChannel); + } } private void recordChannelId(@NonNull Context ctx) { diff --git a/app/src/main/java/org/wikipedia/analytics/InstallReferrerFunnel.java b/app/src/main/java/org/wikipedia/analytics/InstallReferrerFunnel.java index aeca557..469f8fa 100644 --- a/app/src/main/java/org/wikipedia/analytics/InstallReferrerFunnel.java +++ b/app/src/main/java/org/wikipedia/analytics/InstallReferrerFunnel.java @@ -14,6 +14,7 @@ public static final String PARAM_REFERRER_URL = "referrer_url"; public static final String PARAM_CAMPAIGN_ID = "campaign_id"; public static final String PARAM_CAMPAIGN_INSTALL_ID = "install_id"; + public static final String PARAM_CHANNEL = "channel"; public InstallReferrerFunnel(WikipediaApp app) { super(app, SCHEMA_NAME, REV_ID); diff --git a/app/src/main/java/org/wikipedia/util/ReleaseUtil.java b/app/src/main/java/org/wikipedia/util/ReleaseUtil.java index 582c3be..76a8ce0 100644 --- a/app/src/main/java/org/wikipedia/util/ReleaseUtil.java +++ b/app/src/main/java/org/wikipedia/util/ReleaseUtil.java @@ -3,6 +3,7 @@ import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.support.annotation.NonNull; import org.wikipedia.BuildConfig; import org.wikipedia.settings.Prefs; @@ -42,11 +43,11 @@ /** * Gets the distribution channel for the app from SharedPreferences */ - public static String getChannel(Context ctx) { + @NonNull public static String getChannel(@NonNull Context ctx) { String channel = Prefs.getAppChannel(); if (channel == null) { - channel = getChannelDescriptor(ctx); - setChannel(channel); + channel = getChannelFromManifest(ctx); + Prefs.setAppChannel(channel); } return channel; } @@ -68,7 +69,7 @@ * Returns the distribution channel for the app from AndroidManifest.xml * @return The channel (the empty string if not defined) */ - private static String getChannelDescriptor(Context ctx) { + @NonNull private static String getChannelFromManifest(@NonNull Context ctx) { try { ApplicationInfo info = ctx.getPackageManager() .getApplicationInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_META_DATA); @@ -77,13 +78,6 @@ } catch (Throwable t) { return ""; } - } - - /** - * Sets the distribution channel for the app into SharedPreferences - */ - private static void setChannel(String channel) { - Prefs.setAppChannel(channel); } private ReleaseUtil() { -- To view, visit https://gerrit.wikimedia.org/r/322143 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia4ea46765dacde8e1c1957dc6f94bd36d5807462 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Dbrant <dbr...@wikimedia.org> Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org> Gerrit-Reviewer: Niedzielski <sniedziel...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits