Add event to sync project data more frequently - admin users count + active admin users count (#17857)

Co-authored-by: Marc-Roig <marc12info@gmail.com>
This commit is contained in:
Jim LAURIE 2023-09-07 00:13:09 +02:00 committed by GitHub
parent d109764325
commit 1feb571a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -7,7 +7,7 @@ const { getService } = require('../../server/utils');
const actions = require('./config/admin-actions');
const { persistTablesWithPrefix } = require('./utils/persisted-tables');
module.exports = async () => {
module.exports = async (args) => {
const { actionProvider } = getService('permission');
if (features.isEnabled('sso')) {
@ -37,5 +37,5 @@ module.exports = async () => {
await getService('seat-enforcement').seatEnforcementWorkflow();
await executeCEBootstrap();
await executeCEBootstrap(args);
};

View File

@ -70,7 +70,7 @@ const syncAPITokensPermissions = async () => {
}
};
module.exports = async () => {
module.exports = async ({ strapi }) => {
await registerAdminConditions();
await registerPermissionActions();
registerModelHooks();
@ -93,6 +93,8 @@ module.exports = async () => {
await syncAuthSettings();
await syncAPITokensPermissions();
getService('metrics').startCron(strapi);
apiTokenService.checkSaltIsDefined();
transferService.token.checkSaltIsDefined();
tokenService.checkSecretIsDefined();

View File

@ -20,8 +20,25 @@ const sendDidChangeInterfaceLanguage = async () => {
strapi.telemetry.send('didChangeInterfaceLanguage', { userProperties: { languagesInUse } });
};
const sendUpdateProjectInformation = async () => {
const numberOfActiveAdminUsers = await getService('user').count({ isActive: true });
const numberOfAdminUsers = await getService('user').count();
strapi.telemetry.send('didUpdateProjectInformation', {
groupProperties: { numberOfActiveAdminUsers, numberOfAdminUsers },
});
};
const startCron = (strapi) => {
strapi.cron.add({
'0 0 0 * * *': () => sendUpdateProjectInformation(),
});
};
module.exports = {
sendDidInviteUser,
sendDidUpdateRolePermissions,
sendDidChangeInterfaceLanguage,
sendUpdateProjectInformation,
startCron,
};