[WEB] Add analytics events for importing and exporting to different file types (#33614)

* adding events for success and failure for import and export from latex

* adding the operation property to capture the import/export keyword

GitOrigin-RevId: 2e5482b3c7517b402fc151966975ca8718729683
This commit is contained in:
Davinder Singh
2026-05-14 08:06:30 +00:00
committed by Copybot
parent 75a12dda17
commit a3a508d193
4 changed files with 117 additions and 6 deletions
@@ -112,6 +112,16 @@ describe('ProjectUploadController', function () {
})
)
ctx.AnalyticsManager = {
recordEventForUserInBackground: sinon.stub(),
}
vi.doMock(
'../../../../app/src/Features/Analytics/AnalyticsManager.mjs',
() => ({
default: ctx.AnalyticsManager,
})
)
vi.doMock('node:fs', () => ({
default: (ctx.fs = {}),
}))
@@ -525,6 +535,20 @@ describe('ProjectUploadController', function () {
ctx.req.file.path
)
})
it('should record a successful convert-format analytics event', function (ctx) {
sinon.assert.calledWith(
ctx.AnalyticsManager.recordEventForUserInBackground,
ctx.user_id,
'convert-format',
{
sourceFormat: 'docx',
targetFormat: 'latex',
status: 'success',
operation: 'import',
}
)
})
})
})
@@ -581,6 +605,20 @@ describe('ProjectUploadController', function () {
it('should unlink the uploaded file', function (ctx) {
expect(ctx.fsPromises.unlink).to.have.been.calledWith(ctx.req.file.path)
})
it('should record a successful convert-format analytics event', function (ctx) {
sinon.assert.calledWith(
ctx.AnalyticsManager.recordEventForUserInBackground,
ctx.user_id,
'convert-format',
{
sourceFormat: 'markdown',
targetFormat: 'latex',
status: 'success',
operation: 'import',
}
)
})
})
describe('with an invalid conversionType', async function () {
@@ -639,6 +677,20 @@ describe('ProjectUploadController', function () {
it('should return http 500', function (ctx) {
expect(ctx.res.statusCode).to.equal(500)
})
it('should record a failed convert-format analytics event', function (ctx) {
sinon.assert.calledWith(
ctx.AnalyticsManager.recordEventForUserInBackground,
ctx.user_id,
'convert-format',
{
sourceFormat: 'docx',
targetFormat: 'latex',
status: 'failure',
operation: 'import',
}
)
})
})
describe('when the converted archive is too large', async function () {