diff --git a/packages/rocketchat-api/server/api.js b/packages/rocketchat-api/server/api.js index db08016e8c5f..6d56354ccd40 100644 --- a/packages/rocketchat-api/server/api.js +++ b/packages/rocketchat-api/server/api.js @@ -151,8 +151,10 @@ class API extends Restivus { const rocketchatRestApiEnd = RocketChat.metrics.rocketchatRestApi.startTimer({ method, version, + user_agent: this.request.headers['user-agent'], entrypoint: route }); + this.logger.debug(`${ this.request.method.toUpperCase() }: ${ this.request.url }`); let result; try { diff --git a/packages/rocketchat-lib/server/functions/notifications/audio.js b/packages/rocketchat-lib/server/functions/notifications/audio.js index d98384db11bc..5553e7aa96fd 100644 --- a/packages/rocketchat-lib/server/functions/notifications/audio.js +++ b/packages/rocketchat-lib/server/functions/notifications/audio.js @@ -24,7 +24,7 @@ export function shouldNotifyAudio({ } export function notifyAudioUser(userId, message, room) { - RocketChat.metrics.notificationsSent.inc({ notification_type: 'audio' }, 1, new Date()); + RocketChat.metrics.notificationsSent.inc({ notification_type: 'audio' }); RocketChat.Notifications.notifyUser(userId, 'audioNotification', { payload: { _id: message._id, diff --git a/packages/rocketchat-lib/server/functions/notifications/desktop.js b/packages/rocketchat-lib/server/functions/notifications/desktop.js index b3baf33921c0..bb58be4ec0ba 100644 --- a/packages/rocketchat-lib/server/functions/notifications/desktop.js +++ b/packages/rocketchat-lib/server/functions/notifications/desktop.js @@ -30,7 +30,7 @@ export function notifyDesktopUser({ return; } - RocketChat.metrics.notificationsSent.inc({ notification_type: 'desktop' }, 1, new Date()); + RocketChat.metrics.notificationsSent.inc({ notification_type: 'desktop' }); RocketChat.Notifications.notifyUser(userId, 'notification', { title, text, diff --git a/packages/rocketchat-lib/server/functions/notifications/email.js b/packages/rocketchat-lib/server/functions/notifications/email.js index 2c206b6e9155..11531192f200 100644 --- a/packages/rocketchat-lib/server/functions/notifications/email.js +++ b/packages/rocketchat-lib/server/functions/notifications/email.js @@ -137,7 +137,7 @@ export function sendEmail({ message, user, subscription, room, emailAddress, toA } Meteor.defer(() => { - RocketChat.metrics.notificationsSent.inc({ notification_type: 'email' }, 1, new Date()); + RocketChat.metrics.notificationsSent.inc({ notification_type: 'email' }); Email.send(email); }); } diff --git a/packages/rocketchat-lib/server/lib/PushNotification.js b/packages/rocketchat-lib/server/lib/PushNotification.js index 50b61dfe396e..c99976903cb9 100644 --- a/packages/rocketchat-lib/server/lib/PushNotification.js +++ b/packages/rocketchat-lib/server/lib/PushNotification.js @@ -47,7 +47,7 @@ class PushNotification { }; } - RocketChat.metrics.notificationsSent.inc({ notification_type: 'mobile' }, 1, new Date()); + RocketChat.metrics.notificationsSent.inc({ notification_type: 'mobile' }); return Push.send(config); } } diff --git a/packages/rocketchat-lib/server/lib/metrics.js b/packages/rocketchat-lib/server/lib/metrics.js index a4a7391bc514..fc50e9cb812d 100644 --- a/packages/rocketchat-lib/server/lib/metrics.js +++ b/packages/rocketchat-lib/server/lib/metrics.js @@ -31,7 +31,7 @@ RocketChat.metrics.rocketchatHooks = new client.Summary({ RocketChat.metrics.rocketchatRestApi = new client.Summary({ name: 'rocketchat_rest_api', help: 'summary of rocketchat rest api count and time', - labelNames: ['method', 'entrypoint', 'status', 'version'] + labelNames: ['method', 'entrypoint', 'user_agent', 'status', 'version'] }); RocketChat.metrics.meteorSubscriptions = new client.Summary({ @@ -41,7 +41,7 @@ RocketChat.metrics.meteorSubscriptions = new client.Summary({ }); RocketChat.metrics.messagesSent = new client.Counter({'name': 'rocketchat_message_sent', 'help': 'cumulated number of messages sent'}); -RocketChat.metrics.notificationsSent = new client.Counter({'name': 'rocketchat_notification_sent', labelNames: ['type'], 'help': 'cumulated number of notifications sent'}); +RocketChat.metrics.notificationsSent = new client.Counter({'name': 'rocketchat_notification_sent', labelNames: ['notification_type'], 'help': 'cumulated number of notifications sent'}); RocketChat.metrics.ddpSessions = new client.Gauge({'name': 'rocketchat_ddp_sessions_count', 'help': 'number of open ddp sessions'}); RocketChat.metrics.ddpAthenticatedSessions = new client.Gauge({'name': 'rocketchat_ddp_sessions_auth', 'help': 'number of authenticated open ddp sessions'}); diff --git a/packages/rocketchat-setup-wizard/client/setupWizard.js b/packages/rocketchat-setup-wizard/client/setupWizard.js index 25ea2e2cce53..445cb3b504c9 100644 --- a/packages/rocketchat-setup-wizard/client/setupWizard.js +++ b/packages/rocketchat-setup-wizard/client/setupWizard.js @@ -22,11 +22,22 @@ const setSettingsAndGo = (settings, registerServer = true) => { Template.setupWizard.onCreated(function() { const userId = Meteor.userId(); - const Show_Setup_Wizard = RocketChat.settings.get('Show_Setup_Wizard'); - if (!userId || Show_Setup_Wizard === 'completed' || !RocketChat.authz.hasRole(userId, 'admin')) { - FlowRouter.go('home'); - } + this.autorun((c) => { + const Show_Setup_Wizard = RocketChat.settings.get('Show_Setup_Wizard'); + const user = Meteor.user(); + + // Wait for roles and setup wizard setting + if ((userId && (!user || !user.status)) || !Show_Setup_Wizard) { + return; + } + + c.stop(); + + if ((!userId && Show_Setup_Wizard !== 'pending') || Show_Setup_Wizard === 'completed' || (userId && !RocketChat.authz.hasRole(userId, 'admin'))) { + FlowRouter.go('home'); + } + }); if (localStorage.getItem('wizardFinal')) { FlowRouter.go('setup-wizard-final'); @@ -253,11 +264,22 @@ Template.setupWizard.helpers({ Template.setupWizardFinal.onCreated(function() { this.autorun(() => { const userId = Meteor.userId(); - const Show_Setup_Wizard = RocketChat.settings.get('Show_Setup_Wizard'); - if (!userId || Show_Setup_Wizard === 'completed' || !RocketChat.authz.hasRole(userId, 'admin')) { - FlowRouter.go('home'); - } + this.autorun((c) => { + const Show_Setup_Wizard = RocketChat.settings.get('Show_Setup_Wizard'); + const user = Meteor.user(); + + // Wait for roles and setup wizard setting + if ((userId && (!user || !user.status)) || !Show_Setup_Wizard) { + return; + } + + c.stop(); + + if ((!userId && Show_Setup_Wizard !== 'pending') || Show_Setup_Wizard === 'completed' || (userId && !RocketChat.authz.hasRole(userId, 'admin'))) { + FlowRouter.go('home'); + } + }); }); }); diff --git a/packages/rocketchat-theme/client/imports/components/setup-wizard.css b/packages/rocketchat-theme/client/imports/components/setup-wizard.css index c53a1fb995a3..bcd08e3c6764 100644 --- a/packages/rocketchat-theme/client/imports/components/setup-wizard.css +++ b/packages/rocketchat-theme/client/imports/components/setup-wizard.css @@ -9,7 +9,7 @@ justify-content: center; &-info { - flex: 0 0 auto; + flex: 0 1 auto; margin: 55px 65px 30px 80px;