mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 18:55:30 +00:00
Bug 1560590 - Add Telemetry event probes to determine if users tend to move or resize the Picture-in-Picture window after opening it. data-review=chutten,r=JSON_voorhees
Depends on D36359 Differential Revision: https://phabricator.services.mozilla.com/D36360 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
b867fd4d06
commit
e7d722404c
@ -20,6 +20,12 @@ const WINDOW_TYPE = "Toolkit:PictureInPicture";
|
||||
*/
|
||||
let gCloseReasons = new WeakMap();
|
||||
|
||||
/**
|
||||
* To differentiate windows in the Telemetry Event Log, each Picture-in-Picture
|
||||
* player window is given a unique ID.
|
||||
*/
|
||||
let gNextWindowID = 0;
|
||||
|
||||
/**
|
||||
* This module is responsible for creating a Picture in Picture window to host
|
||||
* a clone of a video element running in web content.
|
||||
@ -133,7 +139,9 @@ var PictureInPicture = {
|
||||
// set attribute which shows pip icon in tab
|
||||
let tab = parentWin.gBrowser.getTabForBrowser(browser);
|
||||
tab.setAttribute("pictureinpicture", true);
|
||||
win.setupPlayer(browser, videoData);
|
||||
|
||||
win.setupPlayer(gNextWindowID.toString(), browser, videoData);
|
||||
gNextWindowID++;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -5,11 +5,16 @@
|
||||
const { PictureInPicture } = ChromeUtils.import(
|
||||
"resource://gre/modules/PictureInPicture.jsm"
|
||||
);
|
||||
const { Services } = ChromeUtils.import(
|
||||
"resource://gre/modules/Services.jsm"
|
||||
);
|
||||
const {DeferredTask} = ChromeUtils.import("resource://gre/modules/DeferredTask.jsm");
|
||||
|
||||
// Time to fade the Picture-in-Picture video controls after first opening.
|
||||
const CONTROLS_FADE_TIMEOUT = 3000;
|
||||
const CONTROLS_FADE_TIMEOUT_MS = 3000;
|
||||
const RESIZE_DEBOUNCE_RATE_MS = 500;
|
||||
|
||||
async function setupPlayer(originatingBrowser, videoData) {
|
||||
async function setupPlayer(id, originatingBrowser, videoData) {
|
||||
let holder = document.querySelector(".player-holder");
|
||||
let browser = document.getElementById("browser");
|
||||
browser.remove();
|
||||
@ -43,10 +48,6 @@ async function setupPlayer(originatingBrowser, videoData) {
|
||||
PictureInPicture.closePipWindow({ reason: "browser-crash" });
|
||||
});
|
||||
|
||||
window.addEventListener("unload", () => {
|
||||
PictureInPicture.unload(window);
|
||||
});
|
||||
|
||||
let close = document.getElementById("close");
|
||||
close.addEventListener("click", () => {
|
||||
PictureInPicture.closePipWindow({ reason: "close-button" });
|
||||
@ -55,5 +56,47 @@ async function setupPlayer(originatingBrowser, videoData) {
|
||||
document.getElementById("controls").setAttribute("showing", true);
|
||||
setTimeout(() => {
|
||||
document.getElementById("controls").removeAttribute("showing");
|
||||
}, CONTROLS_FADE_TIMEOUT);
|
||||
}, CONTROLS_FADE_TIMEOUT_MS);
|
||||
|
||||
Services.telemetry.setEventRecordingEnabled("pictureinpicture", true);
|
||||
|
||||
let resizeDebouncer = new DeferredTask(() => {
|
||||
Services.telemetry.recordEvent("pictureinpicture", "resize", "player", id, {
|
||||
"width": window.outerWidth.toString(),
|
||||
"height": window.outerHeight.toString(),
|
||||
});
|
||||
}, RESIZE_DEBOUNCE_RATE_MS);
|
||||
|
||||
addEventListener("resize", e => {
|
||||
resizeDebouncer.disarm();
|
||||
resizeDebouncer.arm();
|
||||
});
|
||||
|
||||
let lastScreenX = window.screenX;
|
||||
let lastScreenY = window.screenY;
|
||||
|
||||
addEventListener("mouseout", e => {
|
||||
if (window.screenX != lastScreenX ||
|
||||
window.screenY != lastScreenY) {
|
||||
Services.telemetry.recordEvent("pictureinpicture", "move", "player", id, {
|
||||
"screenX": window.screenX.toString(),
|
||||
"screenY": window.screenY.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
lastScreenX = window.screenX;
|
||||
lastScreenY = window.screenY;
|
||||
});
|
||||
|
||||
Services.telemetry.recordEvent("pictureinpicture", "create", "player", id, {
|
||||
"width": window.outerWidth.toString(),
|
||||
"height": window.outerHeight.toString(),
|
||||
"screenX": window.screenX.toString(),
|
||||
"screenY": window.screenY.toString(),
|
||||
});
|
||||
|
||||
window.addEventListener("unload", () => {
|
||||
resizeDebouncer.disarm();
|
||||
PictureInPicture.unload(window);
|
||||
});
|
||||
}
|
||||
|
@ -1310,3 +1310,55 @@ security.ui.permissionprompt:
|
||||
thisPermGranted: How many permissions of the same kind were granted by the user in total
|
||||
products:
|
||||
- firefox
|
||||
|
||||
pictureinpicture:
|
||||
create:
|
||||
objects: ["player"]
|
||||
description: >
|
||||
Recorded when the Picture-in-Picture player window is created.
|
||||
extra_keys:
|
||||
width: The width that the window was created at
|
||||
height: The height that the window was created at
|
||||
screenX: The screen X coordinate that the window was created at
|
||||
screenY: The screen Y coordinate that the window was created at
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
- astevenson@mozilla.com
|
||||
record_in_processes:
|
||||
- main
|
||||
bug_numbers:
|
||||
- 1560590
|
||||
expiry_version: "74"
|
||||
release_channel_collection: opt-in
|
||||
resize:
|
||||
objects: ["player"]
|
||||
description: >
|
||||
Recorded when the Picture-in-Picture player window is resized.
|
||||
extra_keys:
|
||||
width: The width that the window was resized to
|
||||
height: The height that the window was resize to
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
- astevenson@mozilla.com
|
||||
record_in_processes:
|
||||
- main
|
||||
bug_numbers:
|
||||
- 1560590
|
||||
expiry_version: "74"
|
||||
release_channel_collection: opt-in
|
||||
move:
|
||||
objects: ["player"]
|
||||
description: >
|
||||
Recorded when the Picture-in-Picture player window is moved.
|
||||
extra_keys:
|
||||
screenX: The screen X coordinate that the window was moved to
|
||||
screenY: The screen Y coordinate that the window was moved to
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
- astevenson@mozilla.com
|
||||
record_in_processes:
|
||||
- main
|
||||
bug_numbers:
|
||||
- 1560590
|
||||
expiry_version: "74"
|
||||
release_channel_collection: opt-in
|
||||
|
Loading…
Reference in New Issue
Block a user