Dbrant has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/296611

Change subject: Integrate eventlogging for pages navigated from the Feed.
......................................................................

Integrate eventlogging for pages navigated from the Feed.

- Extended the LinkPreviewFunnel (which was already sending 'navigate'
  events for every link clicked) to contain a 'source' parameter which
  maps to the HistoryEntry source that we use when navigating to pages.
- Made the Feed callback interfaces return HistoryEntry objects instead of
  plain PageTitles, and allow different card types to specify their own
  history source parameter.

Bug: T129085
Change-Id: I2bad6d8f08b6de4ad58bf9485add911c12548581
---
M app/src/main/java/org/wikipedia/MainActivity.java
M app/src/main/java/org/wikipedia/analytics/LinkPreviewFunnel.java
M app/src/main/java/org/wikipedia/feed/FeedFragment.java
M app/src/main/java/org/wikipedia/feed/FeedViewCallback.java
M 
app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadCardView.java
M 
app/src/main/java/org/wikipedia/feed/continuereading/ContinueReadingCardView.java
M app/src/main/java/org/wikipedia/feed/featured/FeaturedArticleCardView.java
M app/src/main/java/org/wikipedia/feed/model/BigPictureCard.java
M app/src/main/java/org/wikipedia/feed/mostread/MostReadCardView.java
M app/src/main/java/org/wikipedia/feed/view/PageTitleListCardItemView.java
M app/src/main/java/org/wikipedia/history/HistoryEntry.java
M app/src/main/java/org/wikipedia/page/PageFragment.java
M app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
13 files changed, 62 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/11/296611/1

diff --git a/app/src/main/java/org/wikipedia/MainActivity.java 
b/app/src/main/java/org/wikipedia/MainActivity.java
index 2ffa8b4..4735350 100644
--- a/app/src/main/java/org/wikipedia/MainActivity.java
+++ b/app/src/main/java/org/wikipedia/MainActivity.java
@@ -51,6 +51,7 @@
 import org.wikipedia.activity.ActivityUtil;
 import org.wikipedia.activity.ThemedActionBarActivity;
 import org.wikipedia.analytics.IntentFunnel;
+import org.wikipedia.analytics.LinkPreviewFunnel;
 import org.wikipedia.analytics.ReadingListsFunnel;
 import org.wikipedia.analytics.WikipediaZeroUsageFunnel;
 import org.wikipedia.events.ChangeTextSizeEvent;
@@ -655,6 +656,10 @@
             return;
         }
 
+        if (entry.getSource() != HistoryEntry.SOURCE_INTERNAL_LINK || 
!app.isLinkPreviewEnabled()) {
+            new LinkPreviewFunnel(app, entry.getSource()).logNavigate();
+        }
+
         // Close the link preview, if one is open.
         hideLinkPreview();
 
@@ -841,18 +846,18 @@
     }
 
     @Override
-    public void onFeedSelectPage(PageTitle title) {
-        loadPage(title, new HistoryEntry(title, HistoryEntry.SOURCE_FEED));
+    public void onFeedSelectPage(HistoryEntry entry) {
+        loadPage(entry.getTitle(), entry);
     }
 
     @Override
-    public void onFeedAddPageToList(PageTitle title) {
-        showAddToListDialog(title, AddToReadingListDialog.InvokeSource.FEED);
+    public void onFeedAddPageToList(HistoryEntry entry) {
+        showAddToListDialog(entry.getTitle(), 
AddToReadingListDialog.InvokeSource.FEED);
     }
 
     @Override
-    public void onFeedSharePage(PageTitle title) {
-        ShareUtil.shareText(this, title);
+    public void onFeedSharePage(HistoryEntry entry) {
+        ShareUtil.shareText(this, entry.getTitle());
     }
 
     private void loadMainPageIfNoTabs() {
diff --git a/app/src/main/java/org/wikipedia/analytics/LinkPreviewFunnel.java 
b/app/src/main/java/org/wikipedia/analytics/LinkPreviewFunnel.java
index 9b69a19..8a8309d 100644
--- a/app/src/main/java/org/wikipedia/analytics/LinkPreviewFunnel.java
+++ b/app/src/main/java/org/wikipedia/analytics/LinkPreviewFunnel.java
@@ -8,16 +8,19 @@
 
 public class LinkPreviewFunnel extends TimedFunnel {
     private static final String SCHEMA_NAME = "MobileWikiAppLinkPreview";
-    private static final int REV_ID = 14095177;
+    private static final int REV_ID = 15730939;
     private static final int PROD_LINK_PREVIEW_VERSION = 3;
+    private final int source;
 
-    public LinkPreviewFunnel(WikipediaApp app) {
+    public LinkPreviewFunnel(WikipediaApp app, int source) {
         super(app, SCHEMA_NAME, REV_ID, app.isProdRelease() ? 
Funnel.SAMPLE_LOG_100 : Funnel.SAMPLE_LOG_ALL);
+        this.source = source;
     }
 
     @Override
     protected JSONObject preprocessData(@NonNull JSONObject eventData) {
         preprocessData(eventData, "version", PROD_LINK_PREVIEW_VERSION);
+        preprocessData(eventData, "source", source);
         return super.preprocessData(eventData);
     }
 
diff --git a/app/src/main/java/org/wikipedia/feed/FeedFragment.java 
b/app/src/main/java/org/wikipedia/feed/FeedFragment.java
index 067640b..729d98c 100644
--- a/app/src/main/java/org/wikipedia/feed/FeedFragment.java
+++ b/app/src/main/java/org/wikipedia/feed/FeedFragment.java
@@ -22,8 +22,8 @@
 import org.wikipedia.activity.FragmentUtil;
 import org.wikipedia.feed.model.Card;
 import org.wikipedia.feed.view.FeedView;
+import org.wikipedia.history.HistoryEntry;
 import org.wikipedia.settings.Prefs;
-import org.wikipedia.page.PageTitle;
 import org.wikipedia.util.DimenUtil;
 
 import java.util.List;
@@ -50,9 +50,9 @@
     public interface Callback extends CallbackFragment.Callback {
         void onFeedSearchRequested();
         void onFeedVoiceSearchRequested();
-        void onFeedSelectPage(PageTitle title);
-        void onFeedAddPageToList(PageTitle title);
-        void onFeedSharePage(PageTitle title);
+        void onFeedSelectPage(HistoryEntry entry);
+        void onFeedAddPageToList(HistoryEntry entry);
+        void onFeedSharePage(HistoryEntry entry);
     }
 
     public static FeedFragment newInstance() {
@@ -159,23 +159,23 @@
         }
 
         @Override
-        public void onSelectPage(@NonNull PageTitle title) {
+        public void onSelectPage(@NonNull HistoryEntry entry) {
             if (getCallback() != null) {
-                getCallback().onFeedSelectPage(title);
+                getCallback().onFeedSelectPage(entry);
             }
         }
 
         @Override
-        public void onAddPageToList(@NonNull PageTitle title) {
+        public void onAddPageToList(@NonNull HistoryEntry entry) {
             if (getCallback() != null) {
-                getCallback().onFeedAddPageToList(title);
+                getCallback().onFeedAddPageToList(entry);
             }
         }
 
         @Override
-        public void onSharePage(@NonNull PageTitle title) {
+        public void onSharePage(@NonNull HistoryEntry entry) {
             if (getCallback() != null) {
-                getCallback().onFeedSharePage(title);
+                getCallback().onFeedSharePage(entry);
             }
         }
 
diff --git a/app/src/main/java/org/wikipedia/feed/FeedViewCallback.java 
b/app/src/main/java/org/wikipedia/feed/FeedViewCallback.java
index af94359..01b7684 100644
--- a/app/src/main/java/org/wikipedia/feed/FeedViewCallback.java
+++ b/app/src/main/java/org/wikipedia/feed/FeedViewCallback.java
@@ -2,13 +2,13 @@
 
 import android.support.annotation.NonNull;
 
-import org.wikipedia.page.PageTitle;
+import org.wikipedia.history.HistoryEntry;
 
 public interface FeedViewCallback {
     void onRequestMore();
-    void onSelectPage(@NonNull PageTitle title);
-    void onAddPageToList(@NonNull PageTitle title);
-    void onSharePage(@NonNull PageTitle title);
+    void onSelectPage(@NonNull HistoryEntry entry);
+    void onAddPageToList(@NonNull HistoryEntry entry);
+    void onSharePage(@NonNull HistoryEntry entry);
     void onSearchRequested();
     void onVoiceSearchRequested();
 }
diff --git 
a/app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadCardView.java
 
b/app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadCardView.java
index 95ac568..41429b9 100644
--- 
a/app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadCardView.java
+++ 
b/app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadCardView.java
@@ -10,6 +10,7 @@
 import org.wikipedia.feed.view.CardLargeHeaderView;
 import org.wikipedia.feed.view.PageTitleListCardItemView;
 import org.wikipedia.feed.view.PageTitleListCardView;
+import org.wikipedia.history.HistoryEntry;
 import org.wikipedia.views.DefaultViewHolder;
 
 import java.util.List;
@@ -49,7 +50,7 @@
         @Override
         public void 
onBindViewHolder(DefaultViewHolder<PageTitleListCardItemView> holder, int i) {
             BecauseYouReadItemCard card = item(i);
-            holder.getView().setPageTitle(card.pageTitle());
+            holder.getView().setHistoryEntry(new 
HistoryEntry(card.pageTitle(), HistoryEntry.SOURCE_FEED_BECAUSE_YOU_READ));
             holder.getView().setCallback(callback);
         }
     }
diff --git 
a/app/src/main/java/org/wikipedia/feed/continuereading/ContinueReadingCardView.java
 
b/app/src/main/java/org/wikipedia/feed/continuereading/ContinueReadingCardView.java
index a2bb24e..712630e 100644
--- 
a/app/src/main/java/org/wikipedia/feed/continuereading/ContinueReadingCardView.java
+++ 
b/app/src/main/java/org/wikipedia/feed/continuereading/ContinueReadingCardView.java
@@ -11,6 +11,7 @@
 import org.wikipedia.feed.view.CardHeaderView;
 import org.wikipedia.feed.view.CardLargeHeaderView;
 import org.wikipedia.feed.view.ListCardView;
+import org.wikipedia.history.HistoryEntry;
 
 public class ContinueReadingCardView extends ListCardView<ContinueReadingCard> 
{
     private ContinueReadingCard card;
@@ -50,7 +51,7 @@
         @Override
         public void onClick(View v) {
             if (callback != null) {
-                callback.onSelectPage(card.pageTitle());
+                callback.onSelectPage(new HistoryEntry(card.pageTitle(), 
HistoryEntry.SOURCE_FEED_CONTINUE_READING));
             }
         }
     }
diff --git 
a/app/src/main/java/org/wikipedia/feed/featured/FeaturedArticleCardView.java 
b/app/src/main/java/org/wikipedia/feed/featured/FeaturedArticleCardView.java
index 44f0996..96930d9 100644
--- a/app/src/main/java/org/wikipedia/feed/featured/FeaturedArticleCardView.java
+++ b/app/src/main/java/org/wikipedia/feed/featured/FeaturedArticleCardView.java
@@ -11,6 +11,7 @@
 import org.wikipedia.feed.view.BigPictureCardView;
 import org.wikipedia.feed.view.CardHeaderView;
 import org.wikipedia.feed.view.FeaturedCardFooterView;
+import org.wikipedia.history.HistoryEntry;
 
 public class FeaturedArticleCardView extends BigPictureCardView {
     private FeaturedArticleCard card;
@@ -62,7 +63,7 @@
         @Override
         public void onClick(View v) {
             if (callback != null) {
-                callback.onSelectPage(card.pageTitle());
+                
callback.onSelectPage(card.historyEntry(HistoryEntry.SOURCE_FEED_FEATURED));
             }
         }
     }
@@ -71,7 +72,7 @@
         @Override
         public void onClick(View v) {
             if (callback != null) {
-                callback.onAddPageToList(card.pageTitle());
+                
callback.onAddPageToList(card.historyEntry(HistoryEntry.SOURCE_FEED_FEATURED));
             }
         }
     }
@@ -80,7 +81,7 @@
         @Override
         public void onClick(View v) {
             if (callback != null) {
-                callback.onSharePage(card.pageTitle());
+                
callback.onSharePage(card.historyEntry(HistoryEntry.SOURCE_FEED_FEATURED));
             }
         }
     }
diff --git a/app/src/main/java/org/wikipedia/feed/model/BigPictureCard.java 
b/app/src/main/java/org/wikipedia/feed/model/BigPictureCard.java
index 967f9d0..bbea5d1 100644
--- a/app/src/main/java/org/wikipedia/feed/model/BigPictureCard.java
+++ b/app/src/main/java/org/wikipedia/feed/model/BigPictureCard.java
@@ -7,6 +7,7 @@
 
 import org.wikipedia.Site;
 import org.wikipedia.feed.UtcDate;
+import org.wikipedia.history.HistoryEntry;
 import org.wikipedia.page.PageTitle;
 import org.wikipedia.util.DateUtil;
 import org.wikipedia.util.StringUtil;
@@ -58,7 +59,7 @@
     }
 
     @NonNull
-    public PageTitle pageTitle() {
+    public HistoryEntry historyEntry(int source) {
         PageTitle title = new PageTitle(articleTitle, site);
         if (image != null) {
             title.setThumbUrl(image.toString());
@@ -66,6 +67,6 @@
         if (!TextUtils.isEmpty(articleSubtitle)) {
             title.setDescription(articleSubtitle);
         }
-        return title;
+        return new HistoryEntry(title, source);
     }
 }
diff --git 
a/app/src/main/java/org/wikipedia/feed/mostread/MostReadCardView.java 
b/app/src/main/java/org/wikipedia/feed/mostread/MostReadCardView.java
index c818d45..863bbf1 100644
--- a/app/src/main/java/org/wikipedia/feed/mostread/MostReadCardView.java
+++ b/app/src/main/java/org/wikipedia/feed/mostread/MostReadCardView.java
@@ -11,6 +11,7 @@
 import org.wikipedia.feed.view.CardHeaderView;
 import org.wikipedia.feed.view.PageTitleListCardItemView;
 import org.wikipedia.feed.view.PageTitleListCardView;
+import org.wikipedia.history.HistoryEntry;
 import org.wikipedia.views.DefaultViewHolder;
 
 import java.util.List;
@@ -54,7 +55,7 @@
         @Override
         public void 
onBindViewHolder(DefaultViewHolder<PageTitleListCardItemView> holder, int 
position) {
             MostReadItemCard card = item(position);
-            holder.getView().setPageTitle(card.pageTitle());
+            holder.getView().setHistoryEntry(new 
HistoryEntry(card.pageTitle(), HistoryEntry.SOURCE_FEED_MOST_READ));
             holder.getView().setCallback(callback);
         }
     }
diff --git 
a/app/src/main/java/org/wikipedia/feed/view/PageTitleListCardItemView.java 
b/app/src/main/java/org/wikipedia/feed/view/PageTitleListCardItemView.java
index ed8682e..0bc84ed 100644
--- a/app/src/main/java/org/wikipedia/feed/view/PageTitleListCardItemView.java
+++ b/app/src/main/java/org/wikipedia/feed/view/PageTitleListCardItemView.java
@@ -11,19 +11,19 @@
 
 import org.wikipedia.R;
 import org.wikipedia.feed.FeedViewCallback;
-import org.wikipedia.page.PageTitle;
+import org.wikipedia.history.HistoryEntry;
 
 public class PageTitleListCardItemView extends ListCardItemView {
     @Nullable private FeedViewCallback callback;
-    @Nullable private PageTitle title;
+    @Nullable private HistoryEntry entry;
 
     public PageTitleListCardItemView(Context context) {
         super(context);
         setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View view) {
-                if (callback != null && title != null) {
-                    callback.onSelectPage(title);
+                if (callback != null && entry != null) {
+                    callback.onSelectPage(entry);
                 }
             }
         });
@@ -40,11 +40,11 @@
         return this;
     }
 
-    @NonNull public PageTitleListCardItemView setPageTitle(@NonNull PageTitle 
title) {
-        this.title = title;
-        titleView.setText(title.getDisplayText());
-        subtitleView.setText(title.getDescription());
-        imageView.setImageURI(TextUtils.isEmpty(title.getThumbUrl()) ? null : 
Uri.parse(title.getThumbUrl()));
+    @NonNull public PageTitleListCardItemView setHistoryEntry(@NonNull 
HistoryEntry entry) {
+        this.entry = entry;
+        titleView.setText(entry.getTitle().getDisplayText());
+        subtitleView.setText(entry.getTitle().getDescription());
+        
imageView.setImageURI(TextUtils.isEmpty(entry.getTitle().getThumbUrl()) ? null 
: Uri.parse(entry.getTitle().getThumbUrl()));
         return this;
     }
 
@@ -60,13 +60,13 @@
         public boolean onMenuItemClick(MenuItem item) {
             switch (item.getItemId()) {
                 case R.id.menu_feed_card_item_save:
-                    if (callback != null && title != null) {
-                        callback.onAddPageToList(title);
+                    if (callback != null && entry != null) {
+                        callback.onAddPageToList(entry);
                     }
                     break;
                 case R.id.menu_feed_card_item_share:
-                    if (callback != null && title != null) {
-                        callback.onSharePage(title);
+                    if (callback != null && entry != null) {
+                        callback.onSharePage(entry);
                     }
                     break;
                 default:
diff --git a/app/src/main/java/org/wikipedia/history/HistoryEntry.java 
b/app/src/main/java/org/wikipedia/history/HistoryEntry.java
index eb78b29..349fa48 100644
--- a/app/src/main/java/org/wikipedia/history/HistoryEntry.java
+++ b/app/src/main/java/org/wikipedia/history/HistoryEntry.java
@@ -20,7 +20,11 @@
     public static final int SOURCE_NEARBY = 9;
     public static final int SOURCE_DISAMBIG = 10;
     public static final int SOURCE_READING_LIST = 11;
-    public static final int SOURCE_FEED = 12;
+    public static final int SOURCE_FEED_CONTINUE_READING = 12;
+    public static final int SOURCE_FEED_BECAUSE_YOU_READ = 13;
+    public static final int SOURCE_FEED_MOST_READ = 14;
+    public static final int SOURCE_FEED_FEATURED = 15;
+    public static final int SOURCE_FEED_NEWS = 16;
 
     private final PageTitle title;
     private final Date timestamp;
diff --git a/app/src/main/java/org/wikipedia/page/PageFragment.java 
b/app/src/main/java/org/wikipedia/page/PageFragment.java
index 5c7df81..62280f7 100755
--- a/app/src/main/java/org/wikipedia/page/PageFragment.java
+++ b/app/src/main/java/org/wikipedia/page/PageFragment.java
@@ -39,7 +39,6 @@
 import org.wikipedia.MainActivity;
 import org.wikipedia.analytics.FindInPageFunnel;
 import org.wikipedia.analytics.GalleryFunnel;
-import org.wikipedia.analytics.LinkPreviewFunnel;
 import org.wikipedia.analytics.PageScrollFunnel;
 import org.wikipedia.analytics.TabFunnel;
 import org.wikipedia.bridge.CommunicationBridge;
@@ -389,7 +388,6 @@
         if (title.namespace() != Namespace.MAIN || 
!app.isLinkPreviewEnabled()) {
             HistoryEntry historyEntry = new HistoryEntry(title, 
HistoryEntry.SOURCE_INTERNAL_LINK);
             getMainActivity().loadPage(title, historyEntry);
-            new LinkPreviewFunnel(app).logNavigate();
         } else {
             getMainActivity().showLinkPreview(title, 
HistoryEntry.SOURCE_INTERNAL_LINK);
         }
diff --git 
a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java 
b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
index e2a90de..5881aa3 100755
--- a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
+++ b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
@@ -173,7 +173,7 @@
         // and kick off the task to load all the things...
         loadContent();
 
-        funnel = new LinkPreviewFunnel(app);
+        funnel = new LinkPreviewFunnel(app, entrySource);
         funnel.logLinkClick();
 
         return rootView;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2bad6d8f08b6de4ad58bf9485add911c12548581
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <dbr...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to