From 3f7e897320a2a17df8d4cfc4187b5bddd2fd0f73 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 15 May 2023 14:55:35 +0100 Subject: [PATCH] Merge pull request #13091 from overleaf/jpa-metric-blg [web] add metric for blg file usage GitOrigin-RevId: 5a6bd4185d5f236a56994331cfe3b25c1998d0db --- .../web/app/src/Features/Compile/ClsiManager.js | 17 +++++++++++++++++ .../test/unit/src/Compile/ClsiManagerTests.js | 1 + 2 files changed, 18 insertions(+) diff --git a/services/web/app/src/Features/Compile/ClsiManager.js b/services/web/app/src/Features/Compile/ClsiManager.js index e71e44e4f5..5c19b9a4c4 100644 --- a/services/web/app/src/Features/Compile/ClsiManager.js +++ b/services/web/app/src/Features/Compile/ClsiManager.js @@ -24,6 +24,22 @@ const Errors = require('../Errors/Errors') const VALID_COMPILERS = ['pdflatex', 'latex', 'xelatex', 'lualatex'] +function collectMetricsOnBlgFiles(outputFiles) { + let topLevel = 0 + let nested = 0 + for (const outputFile of outputFiles) { + if (outputFile.type === 'blg') { + if (outputFile.path.includes('/')) { + nested++ + } else { + topLevel++ + } + } + } + Metrics.count('blg_output_file', topLevel, 1, { path: 'top-level' }) + Metrics.count('blg_output_file', nested, 1, { path: 'nested' }) +} + const ClsiManager = { sendRequest(projectId, userId, options, callback) { if (options == null) { @@ -265,6 +281,7 @@ const ClsiManager = { projectId, response && response.compile && response.compile.outputFiles ) + collectMetricsOnBlgFiles(outputFiles) const compile = (response && response.compile) || {} const status = compile.status const stats = compile.stats diff --git a/services/web/test/unit/src/Compile/ClsiManagerTests.js b/services/web/test/unit/src/Compile/ClsiManagerTests.js index 2042de8b13..f805cae748 100644 --- a/services/web/test/unit/src/Compile/ClsiManagerTests.js +++ b/services/web/test/unit/src/Compile/ClsiManagerTests.js @@ -33,6 +33,7 @@ describe('ClsiManager', function () { } }, inc: sinon.stub(), + count: sinon.stub(), } this.ClsiManager = SandboxedModule.require(modulePath, { requires: {