From 32d7b3cb93d455dff1645592c5f2e8352c3fbe55 Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Sat, 6 Sep 2014 20:30:50 -0700 Subject: [PATCH] Bug 1061409: Telemetry for share overlays. r=rnewman --- mobile/android/base/TelemetryContract.java | 6 ++++++ mobile/android/base/overlays/ui/SendTabList.java | 8 ++++++++ mobile/android/base/overlays/ui/ShareDialog.java | 15 +++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/mobile/android/base/TelemetryContract.java b/mobile/android/base/TelemetryContract.java index 9ee4c1b4f7fb..494db71e6970 100644 --- a/mobile/android/base/TelemetryContract.java +++ b/mobile/android/base/TelemetryContract.java @@ -79,6 +79,9 @@ public interface TelemetryContract { // Sharing content. SHARE("share.1"), + // Show a UI element. + SHOW("show.1"), + // Undoing a user action. // Note: Only used in JavaScript for now, but here for completeness. UNDO("undo.1"), @@ -161,6 +164,9 @@ public interface TelemetryContract { // Action triggered from a settings screen. SETTINGS("settings"), + // Actions triggered from the share overlay. + SHARE_OVERLAY("shareoverlay"), + // Action triggered from a suggestion provided to the user. SUGGESTION("suggestion"), diff --git a/mobile/android/base/overlays/ui/SendTabList.java b/mobile/android/base/overlays/ui/SendTabList.java index aa1885cca942..12e896dd712c 100644 --- a/mobile/android/base/overlays/ui/SendTabList.java +++ b/mobile/android/base/overlays/ui/SendTabList.java @@ -12,6 +12,8 @@ import java.util.Arrays; import org.mozilla.gecko.Assert; import org.mozilla.gecko.R; +import org.mozilla.gecko.Telemetry; +import org.mozilla.gecko.TelemetryContract; import org.mozilla.gecko.overlays.service.sharemethods.ParcelableClientRecord; import android.app.AlertDialog; @@ -143,6 +145,12 @@ public class SendTabList extends ListView { public void onClick(DialogInterface dialog, int index) { listener.onSendTabTargetSelected(records[index].guid); } + }) + .setOnCancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialogInterface) { + Telemetry.sendUIEvent(TelemetryContract.Event.CANCEL, TelemetryContract.Method.SHARE_OVERLAY, "device_selection_cancel"); + } }); return builder.create(); diff --git a/mobile/android/base/overlays/ui/ShareDialog.java b/mobile/android/base/overlays/ui/ShareDialog.java index 0fc04b82de97..88f8f98e2b98 100644 --- a/mobile/android/base/overlays/ui/ShareDialog.java +++ b/mobile/android/base/overlays/ui/ShareDialog.java @@ -12,6 +12,8 @@ import org.mozilla.gecko.Assert; import org.mozilla.gecko.GeckoProfile; import org.mozilla.gecko.LocaleAware; import org.mozilla.gecko.R; +import org.mozilla.gecko.Telemetry; +import org.mozilla.gecko.TelemetryContract; import org.mozilla.gecko.db.LocalBrowserDB; import org.mozilla.gecko.overlays.OverlayConstants; import org.mozilla.gecko.overlays.service.OverlayActionService; @@ -147,12 +149,17 @@ public class ShareDialog extends LocaleAware.LocaleAwareActivity implements Send // If provided, we use the subject text to give us something nice to display. // If not, we wing it with the URL. + // TODO: Consider polling Fennec databases to find better information to display. String subjectText = intent.getStringExtra(Intent.EXTRA_SUBJECT); + + String telemetryExtras = "title=" + (subjectText != null); if (subjectText != null) { ((TextView) findViewById(R.id.title)).setText(subjectText); } + Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.SHARE_OVERLAY, telemetryExtras); + title = subjectText; url = pageUrl; @@ -321,16 +328,22 @@ public class ShareDialog extends LocaleAware.LocaleAwareActivity implements Send startService(serviceIntent); slideOut(); + + Telemetry.sendUIEvent(TelemetryContract.Event.SHARE, TelemetryContract.Method.SHARE_OVERLAY, "sendtab"); } public void addToReadingList() { startService(getServiceIntent(ShareMethod.Type.ADD_TO_READING_LIST)); slideOut(); + + Telemetry.sendUIEvent(TelemetryContract.Event.SAVE, TelemetryContract.Method.SHARE_OVERLAY, "reading_list"); } public void addBookmark() { startService(getServiceIntent(ShareMethod.Type.ADD_BOOKMARK)); slideOut(); + + Telemetry.sendUIEvent(TelemetryContract.Event.SAVE, TelemetryContract.Method.SHARE_OVERLAY, "bookmark"); } public void launchBrowser() { @@ -386,6 +399,7 @@ public class ShareDialog extends LocaleAware.LocaleAwareActivity implements Send @Override public void onBackPressed() { slideOut(); + Telemetry.sendUIEvent(TelemetryContract.Event.CANCEL, TelemetryContract.Method.SHARE_OVERLAY); } /** @@ -394,6 +408,7 @@ public class ShareDialog extends LocaleAware.LocaleAwareActivity implements Send @Override public boolean onTouchEvent(MotionEvent event) { slideOut(); + Telemetry.sendUIEvent(TelemetryContract.Event.CANCEL, TelemetryContract.Method.SHARE_OVERLAY); return true; } }