Brion VIBBER has submitted this change and it was merged. Change subject: Add event logging for reading actions ......................................................................
Add event logging for reading actions Change-Id: Ie1c322fb2c32001807f4a538e094aaa774cc571d --- A wikipedia/src/main/java/org/wikipedia/analytics/ReadingActionFunnel.java M wikipedia/src/main/java/org/wikipedia/page/PageActivity.java 2 files changed, 42 insertions(+), 0 deletions(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/wikipedia/src/main/java/org/wikipedia/analytics/ReadingActionFunnel.java b/wikipedia/src/main/java/org/wikipedia/analytics/ReadingActionFunnel.java new file mode 100644 index 0000000..c232c0c --- /dev/null +++ b/wikipedia/src/main/java/org/wikipedia/analytics/ReadingActionFunnel.java @@ -0,0 +1,36 @@ +package org.wikipedia.analytics; + +import android.content.*; +import android.preference.*; +import android.text.format.*; +import org.wikipedia.*; + +import java.util.*; + +public class ReadingActionFunnel extends Funnel { + private static final String SCHEMA_NAME = "MobileWikiAppReadingAction"; + private static final int REV_ID = 8233801; + + private static final String APP_ID_PREF_NAME = "ANALYTICS_APP_ID_FOR_READING"; + + private final String appInstallReadActionID; + public ReadingActionFunnel(WikipediaApp app) { + super(app, SCHEMA_NAME, REV_ID); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(app); + if (prefs.contains(APP_ID_PREF_NAME)) { + appInstallReadActionID = prefs.getString(APP_ID_PREF_NAME, null); + } else { + appInstallReadActionID = UUID.randomUUID().toString(); + prefs.edit().putString(APP_ID_PREF_NAME, appInstallReadActionID).commit(); + } + } + + public void logSomethingHappened(Site site) { + log( + site, + "appInstallReadActionID", appInstallReadActionID, + // clientSideTS is Unix Timestamp, so is in seconds. Java's is in Milliseconds + "clientSideTS", new Date().getTime() / DateUtils.SECOND_IN_MILLIS + ); + } +} diff --git a/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java b/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java index f5c7471..5d6dbcc 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java +++ b/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java @@ -11,6 +11,7 @@ import com.squareup.otto.*; import de.keyboardsurfer.android.widget.crouton.*; import org.wikipedia.*; +import org.wikipedia.analytics.*; import org.wikipedia.events.*; import org.wikipedia.history.*; import org.wikipedia.interlanguage.*; @@ -38,6 +39,8 @@ private static final int MESSAGE_START_SCREEN = 1; private AlertDialog.Builder alert; + private ReadingActionFunnel readingActionFunnel; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -56,6 +59,8 @@ bus = app.getBus(); bus.register(this); + + readingActionFunnel = new ReadingActionFunnel(app); searchAriclesFragment = (SearchArticlesFragment) getSupportFragmentManager().findFragmentById(R.id.search_fragment); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); @@ -97,6 +102,7 @@ drawerLayout.closeDrawer(Gravity.START); } displayNewPage(event.getTitle(), event.getHistoryEntry()); + readingActionFunnel.logSomethingHappened(event.getTitle().getSite()); } @Subscribe -- To view, visit https://gerrit.wikimedia.org/r/127600 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie1c322fb2c32001807f4a538e094aaa774cc571d Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Yuvipanda <yuvipa...@gmail.com> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits