Open Bug 1789845 Opened 3 years ago Updated 3 years ago

Use BrowserUsageTelemetry.jsm in pdf.js

Categories

(Firefox :: PDF Viewer, enhancement)

enhancement

Tracking

()

People

(Reporter: calixte, Unassigned)

Details

It'd help to have some telemetry about any UI elements we want.

I tried to hack around _recordCommand:
https://searchfox.org/mozilla-central/rev/d7d5c89ee7bc70dec0fd846689ca030f94931393/browser/modules/BrowserUsageTelemetry.jsm#773

I'm able to know that the target contains a pdf, thanks to const isPDFJsViewer = sourceEvent.target.contentPrincipal?.spec === "resource://pdf.js/web/viewer.html"; but I don't find a way to know that the real target is an element from:
https://searchfox.org/mozilla-central/source/toolkit/components/pdfjs/content/web/viewer.html

:mossop, would you have any insights ?

Flags: needinfo?(dtownsend)

(In reply to Calixte Denizet (:calixte) from comment #1)

I tried to hack around _recordCommand:
https://searchfox.org/mozilla-central/rev/d7d5c89ee7bc70dec0fd846689ca030f94931393/browser/modules/BrowserUsageTelemetry.jsm#773

I'm able to know that the target contains a pdf, thanks to const isPDFJsViewer = sourceEvent.target.contentPrincipal?.spec === "resource://pdf.js/web/viewer.html"; but I don't find a way to know that the real target is an element from:
https://searchfox.org/mozilla-central/source/toolkit/components/pdfjs/content/web/viewer.html

I assume that the pdf.js content viewer runs in a content process so the event you're getting is just an event targetted at the browser element containing the viewer. The UI telemetry doesn't really expect to deal with other processes as far as I recall. You'd somehow need to call to the content process to get the actual event that fired in order to find its target, I don't know how to do that or if it is even possible by the time you get the even from the main process, the content event may have gone away by then. Someone who knows DOM events may know more, maybe smaug?

I suspect it would be far easier to add your own event listeners in the content document (maybe from PdfStreamConverter.jsm) and then submit telemetry based on that. If you want to re-use the browser usage stuff then you could send the required data up to the main process and call into the module from there but make sure you've engaged with DS folks so they know that that is coming.

Flags: needinfo?(dtownsend)
You need to log in before you can comment on or make changes to this bug.