Dbrant has submitted this change and it was merged.

Change subject: Add EventLogging for widget taps.
......................................................................


Add EventLogging for widget taps.

This patch adds EventLogging for widget taps so that we can see how much users
are using them and know whether to invest further resources in improving them.

Change-Id: Ie71cb6726701a6a979f0267526c507d8822a1092
---
A wikipedia/src/main/java/org/wikipedia/analytics/WidgetsFunnel.java
M wikipedia/src/main/java/org/wikipedia/page/PageActivity.java
M wikipedia/src/main/java/org/wikipedia/widgets/WidgetProviderFeaturedPage.java
3 files changed, 65 insertions(+), 0 deletions(-)

Approvals:
  Dbrant: Looks good to me, approved



diff --git a/wikipedia/src/main/java/org/wikipedia/analytics/WidgetsFunnel.java 
b/wikipedia/src/main/java/org/wikipedia/analytics/WidgetsFunnel.java
new file mode 100644
index 0000000..e23f5ca
--- /dev/null
+++ b/wikipedia/src/main/java/org/wikipedia/analytics/WidgetsFunnel.java
@@ -0,0 +1,50 @@
+package org.wikipedia.analytics;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.wikipedia.Site;
+import org.wikipedia.WikipediaApp;
+
+public class WidgetsFunnel extends Funnel {
+    private static final String SCHEMA_NAME = "MobileWikiAppWidgets";
+    private static final int REV_ID = 11312870;
+
+    private final String appInstallID;
+    private final Site site;
+
+    public WidgetsFunnel(WikipediaApp app, Site site) {
+        super(app, SCHEMA_NAME, REV_ID);
+
+        //Retrieve this app installation's unique ID, used to record unique 
users of features
+        appInstallID = app.getAppInstallID();
+
+        this.site = site;
+    }
+
+    @Override
+    protected JSONObject preprocessData(JSONObject eventData) {
+        try {
+            eventData.put("appInstallID", appInstallID);
+        } catch (JSONException e) {
+            throw new RuntimeException(e);
+        }
+        return eventData;
+    }
+
+    protected void log(Object... params) {
+        super.log(site, params);
+    }
+
+    public void logSearchWidgetTap() {
+        log(
+                "action", "searchwidgettap"
+        );
+    }
+
+    public void logFeaturedArticleWidgetTap() {
+        log(
+                "action", "featuredarticlewidgettap"
+        );
+    }
+
+}
\ No newline at end of file
diff --git a/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java 
b/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java
index 73555a8..d49b4cf 100644
--- a/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java
+++ b/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java
@@ -10,6 +10,7 @@
 import org.wikipedia.Utils;
 import org.wikipedia.ViewAnimations;
 import org.wikipedia.WikipediaApp;
+import org.wikipedia.analytics.WidgetsFunnel;
 import org.wikipedia.events.ChangeTextSizeEvent;
 import org.wikipedia.events.ThemeChangeEvent;
 import org.wikipedia.events.WikipediaZeroStateChangeEvent;
@@ -63,6 +64,7 @@
     public static final String EXTRA_PAGETITLE = "org.wikipedia.pagetitle";
     public static final String EXTRA_HISTORYENTRY  = 
"org.wikipedia.history.historyentry";
     public static final String EXTRA_SEARCH_FROM_WIDGET = "searchFromWidget";
+    public static final String EXTRA_FEATURED_ARTICLE_FROM_WIDGET = 
"featuredArticleFromWidget";
     private static final String ZERO_ON_NOTICE_PRESENTED = 
"org.wikipedia.zero.zeroOnNoticePresented";
 
     private static final String KEY_LAST_FRAGMENT = "lastFragment";
@@ -387,7 +389,13 @@
             // FIXME: Design something better for this?
             displayMainPage();
         }
+
+        //Check to see if user tapped on an app widget to open the app, and 
take appropriate action
         if (intent.hasExtra(EXTRA_SEARCH_FROM_WIDGET)) {
+            // Log that the user tapped on the search widget
+            // Instantiate the funnel anonymously to save on memory overhead
+            new WidgetsFunnel(app, app.getPrimarySite()).logSearchWidgetTap();
+
             // we were sent here from the Search widget, so go straight to the 
search fragment!
             fragmentContainerView.post(new Runnable() {
                 @Override
@@ -396,6 +404,12 @@
                     searchFragment.openSearch();
                 }
             });
+        } else if (intent.hasExtra(EXTRA_FEATURED_ARTICLE_FROM_WIDGET)) {
+            // Log that the user tapped on the featured article widget
+            // Instantiate the funnel anonymously to save on memory overhead
+            new WidgetsFunnel(app, 
app.getPrimarySite()).logFeaturedArticleWidgetTap();
+
+            // We don't need to do anything else, because the main page is 
already being displayed
         }
     }
 
diff --git 
a/wikipedia/src/main/java/org/wikipedia/widgets/WidgetProviderFeaturedPage.java 
b/wikipedia/src/main/java/org/wikipedia/widgets/WidgetProviderFeaturedPage.java
index 073f05d..c5514ea 100644
--- 
a/wikipedia/src/main/java/org/wikipedia/widgets/WidgetProviderFeaturedPage.java
+++ 
b/wikipedia/src/main/java/org/wikipedia/widgets/WidgetProviderFeaturedPage.java
@@ -82,6 +82,7 @@
             // Create a PendingIntent to act as the onClickListener
             Intent intent = new Intent(context, PageActivity.class);
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            intent.putExtra(PageActivity.EXTRA_FEATURED_ARTICLE_FROM_WIDGET, 
true);
             PendingIntent pendingIntent = PendingIntent.getActivity(context, 
1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
 
             // If we want to update the widget itself from the click event, 
then do something like this:

-- 
To view, visit https://gerrit.wikimedia.org/r/191536
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie71cb6726701a6a979f0267526c507d8822a1092
Gerrit-PatchSet: 2
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Deskana <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to