diff --git a/src/lib/Preview.js b/src/lib/Preview.js index 93c0b522f..343df5240 100644 --- a/src/lib/Preview.js +++ b/src/lib/Preview.js @@ -190,7 +190,7 @@ class Preview extends EventEmitter { */ destroy() { // Log all load metrics - this.emitLoadMetrics(); + this.emitLoadMetrics({}); // Destroy viewer if (this.viewer && typeof this.viewer.destroy === 'function') { diff --git a/src/lib/__tests__/Preview-test.js b/src/lib/__tests__/Preview-test.js index c7bd6b1a6..d75836e20 100644 --- a/src/lib/__tests__/Preview-test.js +++ b/src/lib/__tests__/Preview-test.js @@ -8,7 +8,7 @@ import PreviewError from '../PreviewError'; import DownloadReachability from '../DownloadReachability'; import * as file from '../file'; import * as util from '../util'; -import { API_HOST, CLASS_NAVIGATION_VISIBILITY, PERMISSION_PREVIEW } from '../constants'; +import { API_HOST, CLASS_NAVIGATION_VISIBILITY, PERMISSION_PREVIEW, ENCODING_TYPES } from '../constants'; import { VIEWER_EVENT, ERROR_CODE, LOAD_METRIC, PREVIEW_METRIC } from '../events'; import Timer from '../Timer'; @@ -2320,7 +2320,7 @@ describe('lib/Preview', () => { sandbox.stub(Timer, 'reset'); sandbox.stub(preview, 'emit'); preview.file = undefined; - preview.emitLoadMetrics(); + preview.emitLoadMetrics({}); expect(Timer.reset).to.not.be.called; expect(preview.emit).to.not.be.called; }); @@ -2329,7 +2329,7 @@ describe('lib/Preview', () => { preview.once(PREVIEW_METRIC, () => { done(); }); - preview.emitLoadMetrics(); + preview.emitLoadMetrics({}); }); it('should emit a preview_metric event with event_name "load"', (done) => { @@ -2337,7 +2337,7 @@ describe('lib/Preview', () => { expect(metric.event_name).to.equal(LOAD_METRIC.previewLoadEvent); done(); }); - preview.emitLoadMetrics(); + preview.emitLoadMetrics({}); }); it('should emit a preview_metric event where the value property equals the sum of all load events', (done) => { @@ -2354,7 +2354,7 @@ describe('lib/Preview', () => { expect(metric.value).to.equal(expectedTime); done(); }); - preview.emitLoadMetrics(); + preview.emitLoadMetrics({}); }); it('should emit a preview_metric event with an object, with all of the proper load properties', (done) => { @@ -2365,13 +2365,13 @@ describe('lib/Preview', () => { expect(metric[LOAD_METRIC.fullDocumentLoadTime]).to.exist; done(); }); - preview.emitLoadMetrics(); + preview.emitLoadMetrics({}); }); it('should reset the Timer', () => { sandbox.stub(Timer, 'reset'); sandbox.stub(preview, 'emit'); - preview.emitLoadMetrics(); + preview.emitLoadMetrics({}); expect(Timer.reset).to.be.called; expect(preview.emit).to.be.called; }); @@ -2385,7 +2385,15 @@ describe('lib/Preview', () => { expect(metric[LOAD_METRIC.fullDocumentLoadTime]).to.equal(0); done(); }); - preview.emitLoadMetrics(); + preview.emitLoadMetrics({}); + }); + + it('should append encoding field to load metric, when provided', (done) => { + preview.once(PREVIEW_METRIC, (metric) => { + expect(metric.encoding).to.equal(ENCODING_TYPES.GZIP); + done(); + }); + preview.emitLoadMetrics({ encoding: ENCODING_TYPES.GZIP }); }); }); diff --git a/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js b/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js index 9192c746f..f8d357830 100644 --- a/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js +++ b/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js @@ -1445,9 +1445,11 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => { }; docBase.loaded = false; docBase.pdfViewer.pagesCount = 5; + docBase.encoding = 'gzip'; docBase.pagesinitHandler(); expect(stubs.emit).to.be.calledWith(VIEWER_EVENT.load, { + encoding: docBase.encoding, endProgress: false, numPages: 5, scale: sinon.match.any