Fix Bug 1483297 - Add search shortcut count to session stats (#4340)

This commit is contained in:
Nan Jiang 2018-08-14 16:55:07 -04:00 коммит произвёл GitHub
Родитель b4046f78aa
Коммит bff4635b97
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 58 добавлений и 12 удалений

Просмотреть файл

@ -64,10 +64,15 @@ export class _TopSites extends React.PureComponent {
const topSites = this._getVisibleTopSites();
const topSitesIconsStats = countTopSitesIconsTypes(topSites);
const topSitesPinned = topSites.filter(site => !!site.isPinned).length;
const searchShortcuts = topSites.filter(site => !!site.searchTopSite).length;
// Dispatch telemetry event with the count of TopSites images types.
this.props.dispatch(ac.AlsoToMain({
type: at.SAVE_SESSION_PERF_DATA,
data: {topsites_icon_stats: topSitesIconsStats, topsites_pinned: topSitesPinned}
data: {
topsites_icon_stats: topSitesIconsStats,
topsites_pinned: topSitesPinned,
topsites_search_shortcuts: searchShortcuts
}
}));
}

Просмотреть файл

@ -223,6 +223,7 @@ and losing focus. | :one:
| `rich_icon` | [Optional] Number of topsites that display a high quality favicon. | :one:
| `no_image` | [Optional] Number of topsites that have no screenshot. | :one:
| `topsites_pinned` | [Optional] Number of topsites that are pinned. | :one:
| `topsites_search_shortcuts` | [Optional] Number of search shortcut topsites. | :one:
| `visibility_event_rcvd_ts` | [Optional][Server Counter][Server Alert for too many omissions] DOMHighResTimeStamp of when the page itself receives an event that document.visibilityState == visible. | :one:
| `tiles` | [Required] A list of tile objects for the Pocket articles. Each tile object mush have a ID, and optionally a "pos" property to indicate the tile position | :one:
| `click` | [Optional] An integer to record the 0-based index when user clicks on a Pocket tile. | :one:

Просмотреть файл

@ -439,6 +439,9 @@ perf: {
// The number of Top Sites that are pinned.
"topsites_pinned": 3,
// The number of search shortcut Top Sites.
"topsites_search_shortcuts": 2,
// How much longer the data took, in milliseconds, to be ready for display
// than it would have been in the ideal case. The user currently sees placeholder
// cards instead of real cards for approximately this length of time. This is

Просмотреть файл

@ -186,6 +186,9 @@ export const SessionPing = Joi.object().keys(Object.assign({}, baseKeys, {
// The count of pinned Top Sites.
topsites_pinned: Joi.number(),
// The count of search shortcut Top Sites.
topsites_search_shortcuts: Joi.number(),
// When the page itself receives an event that document.visibilityState
// == visible.
//

Просмотреть файл

@ -107,7 +107,8 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 0
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});
@ -128,7 +129,8 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 0
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});
@ -149,7 +151,8 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 0
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});
@ -170,7 +173,8 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 0
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});
@ -191,7 +195,8 @@ describe("<TopSites>", () => {
"rich_icon": 1,
"no_image": 0
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});
@ -212,7 +217,8 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 1
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});
@ -233,7 +239,8 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 1
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});
@ -254,7 +261,30 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 3
},
topsites_pinned: 2
topsites_pinned: 2,
topsites_search_shortcuts: 0
}
}));
});
it("should correctly count search shortcut Top Sites", () => {
const rows = [{searchTopSite: true}, {searchTopSite: true}];
sandbox.stub(DEFAULT_PROPS.TopSites, "rows").value(rows);
wrapper.instance()._dispatchTopSitesStats();
assert.calledOnce(DEFAULT_PROPS.dispatch);
assert.calledWithExactly(DEFAULT_PROPS.dispatch, ac.AlsoToMain({
type: at.SAVE_SESSION_PERF_DATA,
data: {
topsites_icon_stats: {
"custom_screenshot": 0,
"screenshot_with_icon": 0,
"screenshot": 0,
"tippytop": 0,
"rich_icon": 0,
"no_image": 2
},
topsites_pinned: 0,
topsites_search_shortcuts: 2
}
}));
});
@ -276,7 +306,8 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 8
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});
@ -297,7 +328,8 @@ describe("<TopSites>", () => {
"rich_icon": 0,
"no_image": 6
},
topsites_pinned: 0
topsites_pinned: 0,
topsites_search_shortcuts: 0
}
}));
});

Просмотреть файл

@ -200,7 +200,8 @@ describe("TelemetryFeed", () => {
"rich_icon": 1,
"no_image": 0
},
topsites_pinned: 3
topsites_pinned: 3,
topsites_search_shortcuts: 2
});
// Create a ping referencing the session
@ -209,6 +210,7 @@ describe("TelemetryFeed", () => {
assert.propertyVal(instance.sessions.get("foo").perf.topsites_icon_stats,
"screenshot_with_icon", 2);
assert.equal(instance.sessions.get("foo").perf.topsites_pinned, 3);
assert.equal(instance.sessions.get("foo").perf.topsites_search_shortcuts, 2);
});
});