mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
[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:
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user