Bug 914481 - Patch 4 - Track why we fail to deliver notifications to Service Workers. r=kitcambridge

--HG--
extra : rebase_source : 66bb02452a4b5ffb77157d0f7a44d56b327c360c
This commit is contained in:
Nikhil Marathe 2015-08-06 16:59:35 -07:00
Родитель 6e258d2336
Коммит ea76ea7a04
2 изменённых файлов: 52 добавлений и 1 удалений

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

@ -52,6 +52,16 @@ const PUSH_SERVICE_CONNECTION_DISABLE = 3;
const PUSH_SERVICE_ACTIVE_OFFLINE = 4;
const PUSH_SERVICE_RUNNING = 5;
// Telemetry failure to send push notification to Service Worker reasons.
// Key not found in local database.
const kDROP_NOTIFICATION_REASON_KEY_NOT_FOUND = 0;
// User cleared history.
const kDROP_NOTIFICATION_REASON_NO_HISTORY = 1;
// Version of message received not newer than previous one.
const kDROP_NOTIFICATION_REASON_NO_VERSION_INCREMENT = 2;
// Subscription has expired.
const kDROP_NOTIFICATION_REASON_EXPIRED = 3;
/**
* State is change only in couple of functions:
* init - change state to PUSH_SERVICE_INIT if state was PUSH_SERVICE_UNINIT
@ -673,6 +683,7 @@ this.PushService = {
scope: record.scope
};
Services.telemetry.getHistogramById("PUSH_API_NOTIFY_REGISTRATION_LOST").add();
this._notifyListeners('pushsubscriptionchange', data);
},
@ -724,6 +735,12 @@ this.PushService = {
.then(record => this._notifySubscriptionChangeObservers(record));
},
_recordDidNotNotify: function(reason) {
Services.telemetry.
getHistogramById("PUSH_API_NOTIFICATION_RECEIVED_BUT_DID_NOT_NOTIFY").
add(reason);
},
/**
* Dispatches an incoming message to a service worker, recalculating the
* quota for the associated push registration. If the quota is exceeded,
@ -740,10 +757,12 @@ this.PushService = {
*/
receivedPushMessage: function(keyID, message, updateFunc) {
debug("receivedPushMessage()");
Services.telemetry.getHistogramById("PUSH_API_NOTIFICATION_RECEIVED").add();
let shouldNotify = false;
return this.getByKeyID(keyID).then(record => {
if (!record) {
this._recordDidNotNotify(kDROP_NOTIFICATION_REASON_KEY_NOT_FOUND);
throw new Error("No record for key ID " + keyID);
}
return record.getLastVisit();
@ -751,15 +770,21 @@ this.PushService = {
// As a special case, don't notify the service worker if the user
// cleared their history.
shouldNotify = isFinite(lastVisit);
if (!shouldNotify) {
this._recordDidNotNotify(kDROP_NOTIFICATION_REASON_NO_HISTORY);
}
return this._db.update(keyID, record => {
let newRecord = updateFunc(record);
if (!newRecord) {
this._recordDidNotNotify(kDROP_NOTIFICATION_REASON_NO_VERSION_INCREMENT);
return null;
}
// FIXME(nsm): WHY IS expired checked here but then also checked in the next case?
if (newRecord.isExpired()) {
// Because `unregister` is advisory only, we can still receive messages
// for stale registrations from the server.
debug("receivedPushMessage: Ignoring update for expired key ID " + keyID);
this._recordDidNotNotify(kDROP_NOTIFICATION_REASON_EXPIRED);
return null;
}
newRecord.receivedPush(lastVisit);
@ -825,6 +850,7 @@ this.PushService = {
scope: aPushRecord.scope
};
Services.telemetry.getHistogramById("PUSH_API_NOTIFY").add();
this._notifyListeners('push', data);
return true;
},

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

@ -9431,7 +9431,7 @@
"high": "31622400",
"n_buckets": 20,
"description": "Time taken for a push subscription to expire its quota (seconds). The maximum is just over an year."
}
},
"PUSH_API_QUOTA_RESET_TO": {
"alert_emails": ["push@mozilla.com"],
"expires_in_version": "55",
@ -9440,6 +9440,31 @@
"n_buckets": 10,
"description": "The value a push record quota (a count) is reset to based on the user's browsing history."
},
"PUSH_API_NOTIFICATION_RECEIVED": {
"alert_emails": ["push@mozilla.com"],
"expires_in_version": "55",
"kind": "count",
"description": "Push notification was received from server."
},
"PUSH_API_NOTIFICATION_RECEIVED_BUT_DID_NOT_NOTIFY": {
"alert_emails": ["push@mozilla.com"],
"expires_in_version": "55",
"kind": "enumerated",
"n_values": 15,
"description": "Push notification was received from server, but not delivered to ServiceWorker. Enumeration values are defined in dom/push/PushService.jsm as kDROP_NOTIFICATION_REASON_*."
},
"PUSH_API_NOTIFY": {
"alert_emails": ["push@mozilla.com"],
"expires_in_version": "55",
"kind": "count",
"description": "Attempt to notify ServiceWorker of push notification."
},
"PUSH_API_NOTIFY_REGISTRATION_LOST": {
"alert_emails": ["push@mozilla.com"],
"expires_in_version": "55",
"kind": "count",
"description": "Attempt to notify ServiceWorker of push notification resubscription."
},
"FXA_CONFIGURED": {
"alert_emails": ["fx-team@mozilla.com"],
"expires_in_version": "45",