[api-minor] Remove all the useless telemetry stuff in the viewer (bug 1802468)
Add a deprecation notification for PDFDocumentLoadingTask.onUnsupportedFeature and PDFDocumentProxy.stats which are likely useless. The unsupported feature stuff have initially been added in (#4048) in order to be able to display a warning bar and to help to have some numbers to know how a feature was used. Those data are no more used in Firefox.
This commit is contained in:
parent
33f9d1aab2
commit
b9cb651c44
@ -559,6 +559,8 @@ async function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
class PDFDocumentLoadingTask {
|
class PDFDocumentLoadingTask {
|
||||||
static #docId = 0;
|
static #docId = 0;
|
||||||
|
|
||||||
|
#onUnsupportedFeature = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._capability = createPromiseCapability();
|
this._capability = createPromiseCapability();
|
||||||
this._transport = null;
|
this._transport = null;
|
||||||
@ -591,13 +593,26 @@ class PDFDocumentLoadingTask {
|
|||||||
* @type {function}
|
* @type {function}
|
||||||
*/
|
*/
|
||||||
this.onProgress = null;
|
this.onProgress = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for when an unsupported feature is used in the PDF document.
|
* @type {function | null} The current callback used with unsupported
|
||||||
* The callback receives an {@link UNSUPPORTED_FEATURES} argument.
|
* features.
|
||||||
* @type {function}
|
*/
|
||||||
*/
|
get onUnsupportedFeature() {
|
||||||
this.onUnsupportedFeature = null;
|
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.
|
* structures, or `null` when no statistics exists.
|
||||||
*/
|
*/
|
||||||
get stats() {
|
get stats() {
|
||||||
|
deprecated(
|
||||||
|
"The PDFDocumentProxy stats property will be removed in the future."
|
||||||
|
);
|
||||||
return this._transport.stats;
|
return this._transport.stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
114
web/app.js
114
web/app.js
@ -49,7 +49,6 @@ import {
|
|||||||
PDFWorker,
|
PDFWorker,
|
||||||
shadow,
|
shadow,
|
||||||
UnexpectedResponseException,
|
UnexpectedResponseException,
|
||||||
UNSUPPORTED_FEATURES,
|
|
||||||
version,
|
version,
|
||||||
} from "pdfjs-lib";
|
} from "pdfjs-lib";
|
||||||
import { AppOptions, OptionKind } from "./app_options.js";
|
import { AppOptions, OptionKind } from "./app_options.js";
|
||||||
@ -93,51 +92,6 @@ const ViewerCssTheme = {
|
|||||||
DARK: 2,
|
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 {
|
class DefaultExternalServices {
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error("Cannot initialize DefaultExternalServices.");
|
throw new Error("Cannot initialize DefaultExternalServices.");
|
||||||
@ -257,7 +211,6 @@ const PDFViewerApplication = {
|
|||||||
_contentDispositionFilename: null,
|
_contentDispositionFilename: null,
|
||||||
_contentLength: null,
|
_contentLength: null,
|
||||||
_saveInProgress: false,
|
_saveInProgress: false,
|
||||||
_docStats: null,
|
|
||||||
_wheelUnusedTicks: 0,
|
_wheelUnusedTicks: 0,
|
||||||
_PDFBug: null,
|
_PDFBug: null,
|
||||||
_hasAnnotationEditors: false,
|
_hasAnnotationEditors: false,
|
||||||
@ -866,7 +819,6 @@ const PDFViewerApplication = {
|
|||||||
this._contentDispositionFilename = null;
|
this._contentDispositionFilename = null;
|
||||||
this._contentLength = null;
|
this._contentLength = null;
|
||||||
this._saveInProgress = false;
|
this._saveInProgress = false;
|
||||||
this._docStats = null;
|
|
||||||
this._hasAnnotationEditors = false;
|
this._hasAnnotationEditors = false;
|
||||||
|
|
||||||
promises.push(this.pdfScriptingManager.destroyPromise);
|
promises.push(this.pdfScriptingManager.destroyPromise);
|
||||||
@ -959,9 +911,6 @@ const PDFViewerApplication = {
|
|||||||
this.progress(loaded / total);
|
this.progress(loaded / total);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Listen for unsupported features to report telemetry.
|
|
||||||
loadingTask.onUnsupportedFeature = this.fallback.bind(this);
|
|
||||||
|
|
||||||
return loadingTask.promise.then(
|
return loadingTask.promise.then(
|
||||||
pdfDocument => {
|
pdfDocument => {
|
||||||
this.load(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
|
* Report the error; used for errors affecting loading and/or parsing of
|
||||||
* the entire PDF document.
|
* the entire PDF document.
|
||||||
@ -1104,7 +1046,6 @@ const PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.error(`${message}\n\n${moreInfoText.join("\n")}`);
|
console.error(`${message}\n\n${moreInfoText.join("\n")}`);
|
||||||
this.fallback();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
progress(level) {
|
progress(level) {
|
||||||
@ -1434,7 +1375,6 @@ const PDFViewerApplication = {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
console.warn("Warning: JavaScript support is not enabled");
|
console.warn("Warning: JavaScript support is not enabled");
|
||||||
this.fallback(UNSUPPORTED_FEATURES.javaScript);
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1509,49 +1449,17 @@ const PDFViewerApplication = {
|
|||||||
} else {
|
} else {
|
||||||
console.warn("Warning: XFA support is not enabled");
|
console.warn("Warning: XFA support is not enabled");
|
||||||
}
|
}
|
||||||
this.fallback(UNSUPPORTED_FEATURES.forms);
|
|
||||||
} else if (
|
} else if (
|
||||||
(info.IsAcroFormPresent || info.IsXFAPresent) &&
|
(info.IsAcroFormPresent || info.IsXFAPresent) &&
|
||||||
!this.pdfViewer.renderForms
|
!this.pdfViewer.renderForms
|
||||||
) {
|
) {
|
||||||
console.warn("Warning: Interactive form support is not enabled");
|
console.warn("Warning: Interactive form support is not enabled");
|
||||||
this.fallback(UNSUPPORTED_FEATURES.forms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.IsSignaturesPresent) {
|
if (info.IsSignaturesPresent) {
|
||||||
console.warn("Warning: Digital signatures validation is not supported");
|
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 });
|
this.eventBus.dispatch("metadataloaded", { source: this });
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1802,10 +1710,6 @@ const PDFViewerApplication = {
|
|||||||
|
|
||||||
printService.layout();
|
printService.layout();
|
||||||
|
|
||||||
this.externalServices.reportTelemetry({
|
|
||||||
type: "print",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this._hasAnnotationEditors) {
|
if (this._hasAnnotationEditors) {
|
||||||
this.externalServices.reportTelemetry({
|
this.externalServices.reportTelemetry({
|
||||||
type: "editing",
|
type: "editing",
|
||||||
@ -2098,21 +2002,6 @@ const PDFViewerApplication = {
|
|||||||
this._unblockDocumentLoadEvent = () => {};
|
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
|
* Used together with the integration-tests, to enable awaiting full
|
||||||
* initialization of the scripting/sandbox.
|
* initialization of the scripting/sandbox.
|
||||||
@ -2310,9 +2199,6 @@ function webViewerPageRendered({ pageNumber, error }) {
|
|||||||
PDFViewerApplication._otherError(msg, error);
|
PDFViewerApplication._otherError(msg, error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is a good time to report stream and font types.
|
|
||||||
PDFViewerApplication._reportDocumentStatsTelemetry();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerPageMode({ mode }) {
|
function webViewerPageMode({ mode }) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user