Merge pull request #11029 from brendandahl/pdfjs-telemetry-update

[api-minor] Update telemetry to use 'categorical' histograms.
This commit is contained in:
Tim van der Meij 2019-08-02 00:11:02 +02:00 committed by GitHub
commit e0b38bed3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 25 deletions

View File

@ -696,7 +696,7 @@ class Parser {
return new CCITTFaxStream(stream, maybeLength, params); return new CCITTFaxStream(stream, maybeLength, params);
} }
if (name === 'RunLengthDecode' || name === 'RL') { if (name === 'RunLengthDecode' || name === 'RL') {
xrefStreamStats[StreamType.RL] = true; xrefStreamStats[StreamType.RLX] = true;
return new RunLengthStream(stream, maybeLength); return new RunLengthStream(stream, maybeLength);
} }
if (name === 'JBIG2Decode') { if (name === 'JBIG2Decode') {

View File

@ -153,30 +153,30 @@ const AnnotationBorderStyleType = {
}; };
const StreamType = { const StreamType = {
UNKNOWN: 0, UNKNOWN: 'UNKNOWN',
FLATE: 1, FLATE: 'FLATE',
LZW: 2, LZW: 'LZW',
DCT: 3, DCT: 'DCT',
JPX: 4, JPX: 'JPX',
JBIG: 5, JBIG: 'JBIG',
A85: 6, A85: 'A85',
AHX: 7, AHX: 'AHX',
CCF: 8, CCF: 'CCF',
RL: 9, RLX: 'RLX', // PDF short name is 'RL', but telemetry requires three chars.
}; };
const FontType = { const FontType = {
UNKNOWN: 0, UNKNOWN: 'UNKNOWN',
TYPE1: 1, TYPE1: 'TYPE1',
TYPE1C: 2, TYPE1C: 'TYPE1C',
CIDFONTTYPE0: 3, CIDFONTTYPE0: 'CIDFONTTYPE0',
CIDFONTTYPE0C: 4, CIDFONTTYPE0C: 'CIDFONTTYPE0C',
TRUETYPE: 5, TRUETYPE: 'TRUETYPE',
CIDFONTTYPE2: 6, CIDFONTTYPE2: 'CIDFONTTYPE2',
TYPE3: 7, TYPE3: 'TYPE3',
OPENTYPE: 8, OPENTYPE: 'OPENTYPE',
TYPE0: 9, TYPE0: 'TYPE0',
MMTYPE1: 10, MMTYPE1: 'MMTYPE1',
}; };
const VerbosityLevel = { const VerbosityLevel = {

View File

@ -1141,8 +1141,10 @@ let PDFViewerApplication = {
if (typeof PDFJSDev !== 'undefined' && if (typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('FIREFOX || MOZCENTRAL')) { PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
let versionId = String(info.PDFFormatVersion).slice(-1) | 0; // Telemetry labels must be C++ variable friendly.
let generatorId = 0; const versionId = `v${info.PDFFormatVersion.replace('.', '_')}`;
let generatorId = 'other';
// Keep these in sync with mozilla central's Histograms.json.
const KNOWN_GENERATORS = [ const KNOWN_GENERATORS = [
'acrobat distiller', 'acrobat pdfwriter', 'adobe livecycle', 'acrobat distiller', 'acrobat pdfwriter', 'adobe livecycle',
'adobe pdf library', 'adobe photoshop', 'ghostscript', 'tcpdf', 'adobe pdf library', 'adobe photoshop', 'ghostscript', 'tcpdf',
@ -1155,7 +1157,7 @@ let PDFViewerApplication = {
if (!generator.includes(s)) { if (!generator.includes(s)) {
return false; return false;
} }
generatorId = i + 1; generatorId = s.replace(/[ .\-]/g, '_');
return true; return true;
}.bind(null, info.Producer.toLowerCase())); }.bind(null, info.Producer.toLowerCase()));
} }