Merge pull request #15758 from calixteman/cleanup_telemetry
[api-minor] Remove all the useless telemetry stuff in the viewer (bug 1802468)
This commit is contained in:
commit
44bc315444
@ -559,6 +559,8 @@ async function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
||||
class PDFDocumentLoadingTask {
|
||||
static #docId = 0;
|
||||
|
||||
#onUnsupportedFeature = null;
|
||||
|
||||
constructor() {
|
||||
this._capability = createPromiseCapability();
|
||||
this._transport = null;
|
||||
@ -591,13 +593,26 @@ class PDFDocumentLoadingTask {
|
||||
* @type {function}
|
||||
*/
|
||||
this.onProgress = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for when an unsupported feature is used in the PDF document.
|
||||
* The callback receives an {@link UNSUPPORTED_FEATURES} argument.
|
||||
* @type {function}
|
||||
*/
|
||||
this.onUnsupportedFeature = null;
|
||||
/**
|
||||
* @type {function | null} The current callback used with unsupported
|
||||
* features.
|
||||
*/
|
||||
get onUnsupportedFeature() {
|
||||
return this.#onUnsupportedFeature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for when an unsupported feature is used in the PDF document.
|
||||
* The callback receives an {@link UNSUPPORTED_FEATURES} argument.
|
||||
* @type {function}
|
||||
*/
|
||||
set onUnsupportedFeature(callback) {
|
||||
deprecated(
|
||||
"The PDFDocumentLoadingTask onUnsupportedFeature property will be removed in the future."
|
||||
);
|
||||
this.#onUnsupportedFeature = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -758,6 +773,9 @@ class PDFDocumentProxy {
|
||||
* structures, or `null` when no statistics exists.
|
||||
*/
|
||||
get stats() {
|
||||
deprecated(
|
||||
"The PDFDocumentProxy stats property will be removed in the future."
|
||||
);
|
||||
return this._transport.stats;
|
||||
}
|
||||
|
||||
|
114
web/app.js
114
web/app.js
@ -49,7 +49,6 @@ import {
|
||||
PDFWorker,
|
||||
shadow,
|
||||
UnexpectedResponseException,
|
||||
UNSUPPORTED_FEATURES,
|
||||
version,
|
||||
} from "pdfjs-lib";
|
||||
import { AppOptions, OptionKind } from "./app_options.js";
|
||||
@ -93,51 +92,6 @@ const ViewerCssTheme = {
|
||||
DARK: 2,
|
||||
};
|
||||
|
||||
// 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.");
|
||||
@ -257,7 +211,6 @@ const PDFViewerApplication = {
|
||||
_contentDispositionFilename: null,
|
||||
_contentLength: null,
|
||||
_saveInProgress: false,
|
||||
_docStats: null,
|
||||
_wheelUnusedTicks: 0,
|
||||
_PDFBug: null,
|
||||
_hasAnnotationEditors: false,
|
||||
@ -866,7 +819,6 @@ const PDFViewerApplication = {
|
||||
this._contentDispositionFilename = null;
|
||||
this._contentLength = null;
|
||||
this._saveInProgress = false;
|
||||
this._docStats = null;
|
||||
this._hasAnnotationEditors = false;
|
||||
|
||||
promises.push(this.pdfScriptingManager.destroyPromise);
|
||||
@ -959,9 +911,6 @@ const PDFViewerApplication = {
|
||||
this.progress(loaded / total);
|
||||
};
|
||||
|
||||
// Listen for unsupported features to report telemetry.
|
||||
loadingTask.onUnsupportedFeature = this.fallback.bind(this);
|
||||
|
||||
return loadingTask.promise.then(
|
||||
pdfDocument => {
|
||||
this.load(pdfDocument);
|
||||
@ -1056,13 +1005,6 @@ const PDFViewerApplication = {
|
||||
}
|
||||
},
|
||||
|
||||
fallback(featureId) {
|
||||
this.externalServices.reportTelemetry({
|
||||
type: "unsupportedFeature",
|
||||
featureId,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Report the error; used for errors affecting loading and/or parsing of
|
||||
* the entire PDF document.
|
||||
@ -1104,7 +1046,6 @@ const PDFViewerApplication = {
|
||||
}
|
||||
|
||||
console.error(`${message}\n\n${moreInfoText.join("\n")}`);
|
||||
this.fallback();
|
||||
},
|
||||
|
||||
progress(level) {
|
||||
@ -1434,7 +1375,6 @@ const PDFViewerApplication = {
|
||||
return false;
|
||||
}
|
||||
console.warn("Warning: JavaScript support is not enabled");
|
||||
this.fallback(UNSUPPORTED_FEATURES.javaScript);
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -1509,49 +1449,17 @@ const PDFViewerApplication = {
|
||||
} else {
|
||||
console.warn("Warning: XFA support is not enabled");
|
||||
}
|
||||
this.fallback(UNSUPPORTED_FEATURES.forms);
|
||||
} else if (
|
||||
(info.IsAcroFormPresent || info.IsXFAPresent) &&
|
||||
!this.pdfViewer.renderForms
|
||||
) {
|
||||
console.warn("Warning: Interactive form support is not enabled");
|
||||
this.fallback(UNSUPPORTED_FEATURES.forms);
|
||||
}
|
||||
|
||||
if (info.IsSignaturesPresent) {
|
||||
console.warn("Warning: Digital signatures validation is not supported");
|
||||
this.fallback(UNSUPPORTED_FEATURES.signatures);
|
||||
}
|
||||
|
||||
// Telemetry labels must be C++ variable friendly.
|
||||
let versionId = "other";
|
||||
if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
|
||||
versionId = `v${info.PDFFormatVersion.replace(".", "_")}`;
|
||||
}
|
||||
let generatorId = "other";
|
||||
if (info.Producer) {
|
||||
const producer = info.Producer.toLowerCase();
|
||||
KNOWN_GENERATORS.some(function (generator) {
|
||||
if (!producer.includes(generator)) {
|
||||
return false;
|
||||
}
|
||||
generatorId = generator.replace(/[ .-]/g, "_");
|
||||
return true;
|
||||
});
|
||||
}
|
||||
let formType = null;
|
||||
if (info.IsXFAPresent) {
|
||||
formType = "xfa";
|
||||
} else if (info.IsAcroFormPresent) {
|
||||
formType = "acroform";
|
||||
}
|
||||
this.externalServices.reportTelemetry({
|
||||
type: "documentInfo",
|
||||
version: versionId,
|
||||
generator: generatorId,
|
||||
formType,
|
||||
});
|
||||
|
||||
this.eventBus.dispatch("metadataloaded", { source: this });
|
||||
},
|
||||
|
||||
@ -1802,10 +1710,6 @@ const PDFViewerApplication = {
|
||||
|
||||
printService.layout();
|
||||
|
||||
this.externalServices.reportTelemetry({
|
||||
type: "print",
|
||||
});
|
||||
|
||||
if (this._hasAnnotationEditors) {
|
||||
this.externalServices.reportTelemetry({
|
||||
type: "editing",
|
||||
@ -2098,21 +2002,6 @@ const PDFViewerApplication = {
|
||||
this._unblockDocumentLoadEvent = () => {};
|
||||
},
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
_reportDocumentStatsTelemetry() {
|
||||
const { stats } = this.pdfDocument;
|
||||
if (stats !== this._docStats) {
|
||||
this._docStats = stats;
|
||||
|
||||
this.externalServices.reportTelemetry({
|
||||
type: "documentStats",
|
||||
stats,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Used together with the integration-tests, to enable awaiting full
|
||||
* initialization of the scripting/sandbox.
|
||||
@ -2310,9 +2199,6 @@ function webViewerPageRendered({ pageNumber, error }) {
|
||||
PDFViewerApplication._otherError(msg, error);
|
||||
});
|
||||
}
|
||||
|
||||
// It is a good time to report stream and font types.
|
||||
PDFViewerApplication._reportDocumentStatsTelemetry();
|
||||
}
|
||||
|
||||
function webViewerPageMode({ mode }) {
|
||||
|
Loading…
Reference in New Issue
Block a user