Bug 986095 - Part 3: Track adding article to Reading List r=liuche

This commit is contained in:
Mark Finkle 2014-05-01 22:09:41 -04:00
Родитель e986d4f44c
Коммит 0d5d1844c2
1 изменённых файлов: 13 добавлений и 2 удалений

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

@ -7,6 +7,9 @@ let Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm")
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry",
"resource://gre/modules/UITelemetry.jsm");
XPCOMUtils.defineLazyGetter(window, "gChromeWin", function ()
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
@ -286,12 +289,18 @@ AboutReader.prototype = {
this._isReadingListItem = (this._isReadingListItem == 1) ? 0 : 1;
this._updateToggleButton();
// Create a relative timestamp for telemetry
let uptime = Date.now() - Services.startup.getStartupInfo().linkerInitialized;
if (this._isReadingListItem == 1) {
gChromeWin.Reader.storeArticleInCache(this._article, function(success) {
dump("Reader:Add (in reader) success=" + success);
let result = (success ? gChromeWin.Reader.READER_ADD_SUCCESS :
gChromeWin.Reader.READER_ADD_FAILED);
let result = gChromeWin.Reader.READER_ADD_FAILED;
if (success) {
result = gChromeWin.Reader.READER_ADD_SUCCESS;
UITelemetry.addEvent("save.1", "button", uptime, "reader");
}
let json = JSON.stringify({ fromAboutReader: true, url: this._article.url });
Services.obs.notifyObservers(null, "Reader:Add", json);
@ -310,6 +319,8 @@ AboutReader.prototype = {
// browser.js), sending this message will cause the toggle button to be
// updated (handled in this file).
Services.obs.notifyObservers(null, "Reader:Remove", this._article.url);
UITelemetry.addEvent("unsave.1", "button", uptime, "reader");
}
},