Unconditionally report telemetry, in the viewer, regardless of build target

Given the dummy-methods on `DefaultExternalServices`, there's no longer any compelling reason not to (attempt to) report telemetry unconditionally.

The only larger change consists of moving the `KNOWN_VERSIONS` and `KNOWN_GENERATORS` arrays ouf of the `PDFViewerApplication._initializeMetadata` method.

*Please note:* Most of this patch consists of whitespace-only changes.
This commit is contained in:
Jonas Jenwald 2020-07-08 15:35:09 +02:00
parent 625f8a6f51
commit f9157ec243

View File

@ -86,6 +86,51 @@ const ViewOnLoad = {
INITIAL: 1,
};
// Keep these in sync with mozilla-central's Histograms.json.
const KNOWN_VERSIONS = [
"1.0",
"1.1",
"1.2",
"1.3",
"1.4",
"1.5",
"1.6",
"1.7",
"1.8",
"1.9",
"2.0",
"2.1",
"2.2",
"2.3",
];
// Keep these in sync with mozilla-central's Histograms.json.
const KNOWN_GENERATORS = [
"acrobat distiller",
"acrobat pdfwriter",
"adobe livecycle",
"adobe pdf library",
"adobe photoshop",
"ghostscript",
"tcpdf",
"cairo",
"dvipdfm",
"dvips",
"pdftex",
"pdfkit",
"itext",
"prince",
"quarkxpress",
"mac os x",
"microsoft",
"openoffice",
"oracle",
"luradocument",
"pdf-xchange",
"antenna house",
"aspose.cells",
"fpdf",
];
class DefaultExternalServices {
constructor() {
throw new Error("Cannot initialize DefaultExternalServices.");
@ -870,10 +915,6 @@ const PDFViewerApplication = {
* @private
*/
_delayedFallback(featureId) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
// Ensure that telemetry is always reported, since it's not guaranteed
// that the fallback bar will be shown (depends on user interaction).
this.externalServices.reportTelemetry({
@ -887,14 +928,9 @@ const PDFViewerApplication = {
this.triggerDelayedFallback = null;
};
}
}
},
fallback(featureId) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
this.externalServices.reportTelemetry({
type: "unsupportedFeature",
featureId,
@ -918,7 +954,6 @@ const PDFViewerApplication = {
PDFViewerApplication.download();
}
);
}
},
/**
@ -1319,7 +1354,6 @@ const PDFViewerApplication = {
);
let pdfTitle;
const infoTitle = info && info.Title;
if (infoTitle) {
pdfTitle = infoTitle;
@ -1339,7 +1373,6 @@ const PDFViewerApplication = {
pdfTitle = metadataTitle;
}
}
if (pdfTitle) {
this.setTitle(
`${pdfTitle} - ${contentDispositionFilename || document.title}`
@ -1353,61 +1386,12 @@ const PDFViewerApplication = {
this._delayedFallback(UNSUPPORTED_FEATURES.forms);
}
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
// Telemetry labels must be C++ variable friendly.
let versionId = "other";
// Keep these in sync with mozilla central's Histograms.json.
const KNOWN_VERSIONS = [
"1.0",
"1.1",
"1.2",
"1.3",
"1.4",
"1.5",
"1.6",
"1.7",
"1.8",
"1.9",
"2.0",
"2.1",
"2.2",
"2.3",
];
if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
versionId = `v${info.PDFFormatVersion.replace(".", "_")}`;
}
let generatorId = "other";
// Keep these in sync with mozilla central's Histograms.json.
const KNOWN_GENERATORS = [
"acrobat distiller",
"acrobat pdfwriter",
"adobe livecycle",
"adobe pdf library",
"adobe photoshop",
"ghostscript",
"tcpdf",
"cairo",
"dvipdfm",
"dvips",
"pdftex",
"pdfkit",
"itext",
"prince",
"quarkxpress",
"mac os x",
"microsoft",
"openoffice",
"oracle",
"luradocument",
"pdf-xchange",
"antenna house",
"aspose.cells",
"fpdf",
];
if (info.Producer) {
const producer = info.Producer.toLowerCase();
KNOWN_GENERATORS.some(function (generator) {
@ -1418,7 +1402,6 @@ const PDFViewerApplication = {
return true;
});
}
let formType = null;
if (info.IsAcroFormPresent) {
formType = info.IsXFAPresent ? "xfa" : "acroform";
@ -1429,7 +1412,6 @@ const PDFViewerApplication = {
generator: generatorId,
formType,
});
}
},
/**
@ -1642,14 +1624,9 @@ const PDFViewerApplication = {
printService.layout();
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
this.externalServices.reportTelemetry({
type: "print",
});
}
},
afterPrint() {
@ -2091,10 +2068,6 @@ function webViewerPageRendered(evt) {
});
}
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
PDFViewerApplication.externalServices.reportTelemetry({
type: "pageInfo",
timestamp: evt.timestamp,
@ -2107,7 +2080,6 @@ function webViewerPageRendered(evt) {
});
});
}
}
function webViewerPageMode({ mode }) {
// Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`.