[web] Expose metric for active users in SP (#20130)

* [web] Expose metric for active users in SP

* Removed redundant UserHandler.setupLoginData()

In the past this method was also calling
a now deleted notifyDomainLicence(), but now
this is just an alias for populateTeamInvites()

* Added migration for `lastActive`

* Added secondary read precedence to count active users

GitOrigin-RevId: 86d6db31e1ae74ae40c6599e6acb731d8c4a04bd
This commit is contained in:
Miguel Serrano
2024-10-14 10:57:28 +00:00
committed by Copybot
parent 8309671a8c
commit 3ff142d478
9 changed files with 140 additions and 19 deletions
@@ -0,0 +1,34 @@
const { promisify } = require('util')
const { expect } = require('chai')
const Features = require('../../../app/src/infrastructure/Features')
const {
promises: { getMetric },
} = require('./helpers/metrics')
const User = require('./helpers/User').promises
const sleep = promisify(setTimeout)
async function getActiveUsersMetric() {
return getMetric(line => line.startsWith('num_active_users'))
}
describe('ActiveUsersMetricTests', function () {
before(async function () {
if (Features.hasFeature('saas')) {
this.skip()
}
})
it('updates "num_active_users" metric after a new user opens a project', async function () {
expect(await getActiveUsersMetric()).to.equal(0)
this.user = new User()
await this.user.login()
const projectId = await this.user.createProject('test project')
await this.user.openProject(projectId)
// settings.activeUserMetricInterval is configured to 100ms
await sleep(110)
expect(await getActiveUsersMetric()).to.equal(1)
})
})