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, 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 { class DefaultExternalServices {
constructor() { constructor() {
throw new Error("Cannot initialize DefaultExternalServices."); throw new Error("Cannot initialize DefaultExternalServices.");
@ -870,10 +915,6 @@ const PDFViewerApplication = {
* @private * @private
*/ */
_delayedFallback(featureId) { _delayedFallback(featureId) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
// Ensure that telemetry is always reported, since it's not guaranteed // Ensure that telemetry is always reported, since it's not guaranteed
// that the fallback bar will be shown (depends on user interaction). // that the fallback bar will be shown (depends on user interaction).
this.externalServices.reportTelemetry({ this.externalServices.reportTelemetry({
@ -887,14 +928,9 @@ const PDFViewerApplication = {
this.triggerDelayedFallback = null; this.triggerDelayedFallback = null;
}; };
} }
}
}, },
fallback(featureId) { fallback(featureId) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
this.externalServices.reportTelemetry({ this.externalServices.reportTelemetry({
type: "unsupportedFeature", type: "unsupportedFeature",
featureId, featureId,
@ -918,7 +954,6 @@ const PDFViewerApplication = {
PDFViewerApplication.download(); PDFViewerApplication.download();
} }
); );
}
}, },
/** /**
@ -1319,7 +1354,6 @@ const PDFViewerApplication = {
); );
let pdfTitle; let pdfTitle;
const infoTitle = info && info.Title; const infoTitle = info && info.Title;
if (infoTitle) { if (infoTitle) {
pdfTitle = infoTitle; pdfTitle = infoTitle;
@ -1339,7 +1373,6 @@ const PDFViewerApplication = {
pdfTitle = metadataTitle; pdfTitle = metadataTitle;
} }
} }
if (pdfTitle) { if (pdfTitle) {
this.setTitle( this.setTitle(
`${pdfTitle} - ${contentDispositionFilename || document.title}` `${pdfTitle} - ${contentDispositionFilename || document.title}`
@ -1353,61 +1386,12 @@ const PDFViewerApplication = {
this._delayedFallback(UNSUPPORTED_FEATURES.forms); this._delayedFallback(UNSUPPORTED_FEATURES.forms);
} }
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
// Telemetry labels must be C++ variable friendly. // Telemetry labels must be C++ variable friendly.
let versionId = "other"; 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)) { if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
versionId = `v${info.PDFFormatVersion.replace(".", "_")}`; versionId = `v${info.PDFFormatVersion.replace(".", "_")}`;
} }
let generatorId = "other"; 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) { if (info.Producer) {
const producer = info.Producer.toLowerCase(); const producer = info.Producer.toLowerCase();
KNOWN_GENERATORS.some(function (generator) { KNOWN_GENERATORS.some(function (generator) {
@ -1418,7 +1402,6 @@ const PDFViewerApplication = {
return true; return true;
}); });
} }
let formType = null; let formType = null;
if (info.IsAcroFormPresent) { if (info.IsAcroFormPresent) {
formType = info.IsXFAPresent ? "xfa" : "acroform"; formType = info.IsXFAPresent ? "xfa" : "acroform";
@ -1429,7 +1412,6 @@ const PDFViewerApplication = {
generator: generatorId, generator: generatorId,
formType, formType,
}); });
}
}, },
/** /**
@ -1642,14 +1624,9 @@ const PDFViewerApplication = {
printService.layout(); printService.layout();
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
this.externalServices.reportTelemetry({ this.externalServices.reportTelemetry({
type: "print", type: "print",
}); });
}
}, },
afterPrint() { afterPrint() {
@ -2091,10 +2068,6 @@ function webViewerPageRendered(evt) {
}); });
} }
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || GENERIC")
) {
PDFViewerApplication.externalServices.reportTelemetry({ PDFViewerApplication.externalServices.reportTelemetry({
type: "pageInfo", type: "pageInfo",
timestamp: evt.timestamp, timestamp: evt.timestamp,
@ -2106,7 +2079,6 @@ function webViewerPageRendered(evt) {
stats, stats,
}); });
}); });
}
} }
function webViewerPageMode({ mode }) { function webViewerPageMode({ mode }) {