Bug 1255202 - Add UI Telemetry probes for DoorHangers. r=margaret a=ritu

MozReview-Commit-ID: 5gsoxiMlFr1
This commit is contained in:
Mark Finkle 2016-03-18 10:46:19 -04:00
parent 3cff7a768a
commit 1b1c5c5390
8 changed files with 40 additions and 9 deletions

View File

@ -120,6 +120,8 @@ public class DoorHangerPopup extends AnchoredPopup
doorhangerType = DoorHanger.Type.GEOLOCATION;
} else if (DoorHanger.Type.DESKTOPNOTIFICATION2.toString().equals(typeString)) {
doorhangerType = DoorHanger.Type.DESKTOPNOTIFICATION2;
} else if (DoorHanger.Type.WEBRTC.toString().equals(typeString)) {
doorhangerType = DoorHanger.Type.WEBRTC;
}
final DoorhangerConfig config = new DoorhangerConfig(tabId, id, doorhangerType, this);

View File

@ -148,6 +148,9 @@ public interface TelemetryContract {
// Action triggered from a dialog.
DIALOG("dialog"),
// Action triggered from a doorhanger popup prompt.
DOORHANGER("doorhanger"),
// Action triggered from a view grid item, like a thumbnail.
GRID_ITEM("griditem"),

View File

@ -15,6 +15,9 @@ import org.json.JSONObject;
import android.content.Context;
import android.view.View;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.toolbar.SiteIdentityPopup;
import org.mozilla.gecko.util.ColorUtils;
@ -94,10 +97,13 @@ public class ContentSecurityDoorHanger extends DoorHanger {
}
@Override
protected OnClickListener makeOnButtonClickListener(final int id) {
protected OnClickListener makeOnButtonClickListener(final int id, final String telemetryExtra) {
return new Button.OnClickListener() {
@Override
public void onClick(View v) {
final String expandedExtra = mType.toString().toLowerCase() + "-" + telemetryExtra;
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.DOORHANGER, expandedExtra);
final JSONObject response = new JSONObject();
try {
switch (mType) {

View File

@ -11,6 +11,8 @@ import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.prompts.PromptInput;
import org.mozilla.gecko.util.ColorUtils;
@ -127,10 +129,13 @@ public class DefaultDoorHanger extends DoorHanger {
}
@Override
protected OnClickListener makeOnButtonClickListener(final int id) {
protected OnClickListener makeOnButtonClickListener(final int id, final String telemetryExtra) {
return new Button.OnClickListener() {
@Override
public void onClick(View v) {
final String expandedExtra = mType.toString().toLowerCase() + "-" + telemetryExtra;
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.DOORHANGER, expandedExtra);
final JSONObject response = new JSONObject();
try {
response.put("callback", id);

View File

@ -20,6 +20,8 @@ import org.json.JSONObject;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.util.ColorUtils;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
public abstract class DoorHanger extends LinearLayout {
@ -35,7 +37,7 @@ public abstract class DoorHanger extends LinearLayout {
}
// Doorhanger types created from Gecko are checked against enum strings to determine type.
public static enum Type { DEFAULT, LOGIN, TRACKING, GEOLOCATION, DESKTOPNOTIFICATION2 }
public static enum Type { DEFAULT, LOGIN, TRACKING, GEOLOCATION, DESKTOPNOTIFICATION2, WEBRTC }
public interface OnButtonClickListener {
public void onButtonClick(JSONObject response, DoorHanger doorhanger);
@ -97,6 +99,9 @@ public abstract class DoorHanger extends LinearLayout {
final ViewStub contentStub = (ViewStub) findViewById(R.id.content);
contentStub.setLayoutResource(getContentResource());
contentStub.inflate();
final String typeExtra = mType.toString().toLowerCase();
Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.DOORHANGER, typeExtra);
}
protected abstract int getContentResource();
@ -123,13 +128,13 @@ public abstract class DoorHanger extends LinearLayout {
if (negativeButtonConfig != null) {
mNegativeButton.setText(negativeButtonConfig.label);
mNegativeButton.setOnClickListener(makeOnButtonClickListener(negativeButtonConfig.callback));
mNegativeButton.setOnClickListener(makeOnButtonClickListener(negativeButtonConfig.callback, "negative"));
mNegativeButton.setVisibility(VISIBLE);
}
if (positiveButtonConfig != null) {
mPositiveButton.setText(positiveButtonConfig.label);
mPositiveButton.setOnClickListener(makeOnButtonClickListener(positiveButtonConfig.callback));
mPositiveButton.setOnClickListener(makeOnButtonClickListener(positiveButtonConfig.callback, "positive"));
mPositiveButton.setVisibility(VISIBLE);
}
}
@ -160,13 +165,15 @@ public abstract class DoorHanger extends LinearLayout {
mLink.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Tabs.getInstance().loadUrlInTab(url);
final String typeExtra = mType.toString().toLowerCase();
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.DOORHANGER, typeExtra);
Tabs.getInstance().loadUrlInTab(url);
}
});
mLink.setVisibility(VISIBLE);
}
protected abstract OnClickListener makeOnButtonClickListener(final int id);
protected abstract OnClickListener makeOnButtonClickListener(final int id, final String telemetryExtra);
/*
* Checks with persistence and timeout options to see if it's okay to remove a doorhanger.

View File

@ -28,6 +28,8 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.favicons.Favicons;
import org.mozilla.gecko.favicons.OnFaviconLoadedListener;
@ -77,10 +79,13 @@ public class LoginDoorHanger extends DoorHanger {
}
@Override
protected OnClickListener makeOnButtonClickListener(final int id) {
protected OnClickListener makeOnButtonClickListener(final int id, final String telemetryExtra) {
return new Button.OnClickListener() {
@Override
public void onClick(View v) {
final String expandedExtra = mType.toString().toLowerCase() + "-" + telemetryExtra;
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.DOORHANGER, expandedExtra);
final JSONObject response = new JSONObject();
try {
response.put("callback", id);

View File

@ -302,6 +302,6 @@ var WebrtcUI = {
let buttons = this.getDeviceButtons(audioDevices, videoDevices, aCallID, uri);
NativeWindow.doorhanger.show(message, "webrtc-request", buttons, BrowserApp.selectedTab.id, options);
NativeWindow.doorhanger.show(message, "webrtc-request", buttons, BrowserApp.selectedTab.id, options, "WEBRTC");
}
}

View File

@ -197,6 +197,9 @@ Methods
``dialog``
Action triggered from a dialog.
``doorhanger``
Action triggered from a doorhanger popup prompt.
``griditem``
Action triggered from a griditem, such as those used in Top Sites panel.