[api-minor] Update telemetry to use 'categorical' histograms.

Firefox telemetry supports using string labels now. Convert our integers
that we used for categories to just use strings.

The upstream work will happen in:
https://bugzilla.mozilla.org/show_bug.cgi?id=1566882
This commit is contained in:
Brendan Dahl 2019-07-31 11:42:34 -07:00
parent 71d9f5f860
commit 31d71808e7
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

@ -1137,8 +1137,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',
@ -1151,7 +1153,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()));
} }