Bug 1647876 - Instrument window raised and lowered for FOG r=janerik,NeilDeakin

Depends on D81188

Differential Revision: https://phabricator.services.mozilla.com/D82417
This commit is contained in:
Chris H-C 2020-07-09 15:39:52 +00:00
parent e8a302fd2f
commit 77c7ad6ffa
4 changed files with 84 additions and 0 deletions

View File

@ -734,6 +734,11 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
// ATOK, so we need to do it here.
BrowserParent::UnsetTopLevelWebFocusAll();
ActivateOrDeactivate(window, true);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(aWindow, "window-raised", nullptr);
}
}
// retrieve the last focused element within the window that was raised
@ -816,6 +821,11 @@ nsFocusManager::WindowLowered(mozIDOMWindowProxy* aWindow) {
// is called.
if (XRE_IsParentProcess()) {
ActivateOrDeactivate(window, false);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(aWindow, "window-lowered", nullptr);
}
}
// keep track of the window being lowered, so that attempts to raise the

View File

@ -15386,5 +15386,18 @@
"bug_numbers": [1647876],
"description": "Seconds between `user-interaction-active` and `user-interaction-inactive`. For use in evaluating baseline engagement for Project FOG.",
"releaseChannelCollection": "opt-out"
},
"FOG_EVAL_WINDOW_RAISED_S" : {
"products": ["firefox"],
"record_in_processes": ["main"],
"alert_emails": ["chutten@mozilla.com"],
"expires_in_version": "85",
"kind": "exponential",
"keyed": false,
"high": 7200,
"n_buckets": 50,
"bug_numbers": [1647876],
"description": "Seconds between a Firefox window being raised and lowered. For use in evaluating baseline engagement for Project FOG.",
"releaseChannelCollection": "opt-out"
}
}

View File

@ -5002,6 +5002,22 @@ fog.eval:
record_in_processes:
- 'main'
window_raised:
bug_numbers:
- 1647876
description: >
Whether a Firefox window is presently raised.
For use in evaluating baseline engagement for Project FOG.
expires: '85'
kind: 'boolean'
notification_emails:
- 'chutten@mozilla.com'
release_channel_collection: 'opt-out'
products:
- 'firefox'
record_in_processes:
- 'main'
user_active_error:
bug_numbers:
- 1647876
@ -5020,6 +5036,24 @@ fog.eval:
record_in_processes:
- 'main'
window_raised_error:
bug_numbers:
- 1647876
description: >
How many Telemetry stopwatch errors did we have while trying to measure window raising?
These could be attempts to start a started timer or finish an unstarted timer or so forth.
See Stopwatch::Start and Stopwatch::Finish for details.
For use in evaluating baseline engagement for Project FOG.
expires: '85'
kind: 'uint'
notification_emails:
- 'chutten@mozilla.com'
release_channel_collection: 'opt-out'
products:
- 'firefox'
record_in_processes:
- 'main'
# The following section is for probes testing the Telemetry system. They will not be
# submitted in pings and are only used for testing.
telemetry.test:

View File

@ -856,6 +856,9 @@ var Impl = {
// Attach the active-ticks related observers.
this.addObserver("user-interaction-active");
this.addObserver("user-interaction-inactive");
// For FOG Engagement Evaluation, attach window observers.
this.addObserver("window-raised");
this.addObserver("window-lowered");
},
/**
@ -1146,6 +1149,24 @@ var Impl = {
return this.send(REASON_TEST_PING);
},
/**
* Instruments window raises and lowers during a Telemetry Session.
*/
_onWindowChange(aWindow, aRaised) {
Telemetry.scalarSet("fog.eval.window_raised", aRaised);
let error = false;
if (aRaised) {
error = !TelemetryStopwatch.start("FOG_EVAL_WINDOW_RAISED_S", aWindow, {
inSeconds: true,
});
} else {
error = !TelemetryStopwatch.finish("FOG_EVAL_WINDOW_RAISED_S", aWindow);
}
if (error) {
Telemetry.scalarAdd("fog.eval.window_raised_error", 1);
}
},
/**
* Tracks the number of "ticks" the user was active in.
*/
@ -1255,6 +1276,12 @@ var Impl = {
case "user-interaction-inactive":
this._onActiveTick(false);
break;
case "window-raised":
this._onWindowChange(aSubject, true);
break;
case "window-lowered":
this._onWindowChange(aSubject, false);
break;
}
return undefined;
},