mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1251362 - Part 14 - Add telemetry for restoring tabs. r=liuche
This adds telemetry for clicking on a closed tab or the "Open all" button. Methods and extras strings are based on those used for the old Recent Tabs panel. MozReview-Commit-ID: 1Kc8fACkmIc --HG-- extra : transplant_source : m%09%FA%DB%8E%E5%DEG%FF%D1%83%AB%EA%D8%3B%10%9E%08%E3%85
This commit is contained in:
parent
6f59a5b498
commit
9c0527fbb4
@ -425,7 +425,10 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
|
||||
dialogBuilder.show();
|
||||
break;
|
||||
case CHILD_RECENT_TABS:
|
||||
mRecentTabsAdapter.restoreAllTabs();
|
||||
final String telemetryExtra = mRecentTabsAdapter.restoreAllTabs();
|
||||
if (telemetryExtra != null) {
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.BUTTON, telemetryExtra);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ public class CombinedHistoryRecyclerView extends RecyclerView
|
||||
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
|
||||
final int viewType = getAdapter().getItemViewType(position);
|
||||
final CombinedHistoryItem.ItemType itemType = CombinedHistoryItem.ItemType.viewTypeToItemType(viewType);
|
||||
final String telemetryExtra;
|
||||
|
||||
switch (itemType) {
|
||||
case RECENT_TABS:
|
||||
@ -124,7 +125,8 @@ public class CombinedHistoryRecyclerView extends RecyclerView
|
||||
break;
|
||||
|
||||
case CLOSED_TAB:
|
||||
((RecentTabsAdapter) getAdapter()).restoreTabFromPosition(position);
|
||||
telemetryExtra = ((RecentTabsAdapter) getAdapter()).restoreTabFromPosition(position);
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM, telemetryExtra);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ public class RecentTabsAdapter extends RecyclerView.Adapter<CombinedHistoryItem>
|
||||
|
||||
private static final int NAVIGATION_BACK_BUTTON_INDEX = 0;
|
||||
|
||||
private static final String TELEMETRY_EXTRA_LAST_TIME = "recent_tabs_last_time";
|
||||
private static final String TELEMETRY_EXTRA_RECENTY_CLOSED = "recent_closed_tabs";
|
||||
private static final String TELEMETRY_EXTRA_MIXED = "recent_tabs_mixed";
|
||||
|
||||
// Recently closed tabs from Gecko.
|
||||
private ClosedTab[] recentlyClosedTabs;
|
||||
|
||||
@ -233,22 +237,33 @@ public class RecentTabsAdapter extends RecyclerView.Adapter<CombinedHistoryItem>
|
||||
}
|
||||
}
|
||||
|
||||
public void restoreTabFromPosition(int position) {
|
||||
public String restoreTabFromPosition(int position) {
|
||||
final List<String> dataList = new ArrayList<>(1);
|
||||
dataList.add(getClosedTabForPosition(position).data);
|
||||
|
||||
final String telemetryExtra =
|
||||
position > getLastRecentTabIndex() ? TELEMETRY_EXTRA_LAST_TIME : TELEMETRY_EXTRA_RECENTY_CLOSED;
|
||||
|
||||
restoreSessionWithHistory(dataList);
|
||||
|
||||
return telemetryExtra;
|
||||
}
|
||||
|
||||
public void restoreAllTabs() {
|
||||
public String restoreAllTabs() {
|
||||
if (recentlyClosedTabs.length == 0 && lastSessionTabs.length == 0) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<String> dataList = new ArrayList<>(getClosedTabsCount());
|
||||
addTabDataToList(dataList, recentlyClosedTabs);
|
||||
addTabDataToList(dataList, lastSessionTabs);
|
||||
|
||||
final String telemetryExtra = recentlyClosedTabs.length > 0 && lastSessionTabs.length > 0 ? TELEMETRY_EXTRA_MIXED :
|
||||
recentlyClosedTabs.length > 0 ? TELEMETRY_EXTRA_RECENTY_CLOSED : TELEMETRY_EXTRA_LAST_TIME;
|
||||
|
||||
restoreSessionWithHistory(dataList);
|
||||
|
||||
return telemetryExtra;
|
||||
}
|
||||
|
||||
private void addTabDataToList(List<String> dataList, ClosedTab[] closedTabs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user