Просмотр исходного кода

Merge pull request #13091 from overleaf/jpa-metric-blg

[web] add metric for blg file usage

GitOrigin-RevId: 5a6bd4185d5f236a56994331cfe3b25c1998d0db
Jakob Ackermann 3 лет назад
Родитель
Сommit
21950fdb30

+ 17 - 0
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

+ 1 - 0
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: {