From 51501f920c092791c7d83ac7067874547a37c96a Mon Sep 17 00:00:00 2001 From: David Lu Date: Tue, 6 Sep 2016 18:51:27 -0400 Subject: PLT-3753 Added Segment analytics (#3972) --- mattermost.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'mattermost.go') diff --git a/mattermost.go b/mattermost.go index 391c76096..6d6130604 100644 --- a/mattermost.go +++ b/mattermost.go @@ -279,6 +279,47 @@ func doSecurityAndDiagnostics() { } } } + + if *utils.Cfg.LogSettings.EnableDiagnostics { + utils.SendGeneralDiagnostics() + sendServerDiagnostics() + } +} + +func sendServerDiagnostics() { + var userCount int64 + var activeUserCount int64 + var teamCount int64 + + if ucr := <-api.Srv.Store.User().GetTotalUsersCount(); ucr.Err == nil { + userCount = ucr.Data.(int64) + } + + if ucr := <-api.Srv.Store.Status().GetTotalActiveUsersCount(); ucr.Err == nil { + activeUserCount = ucr.Data.(int64) + } + + if tcr := <-api.Srv.Store.Team().AnalyticsTeamCount(); tcr.Err == nil { + teamCount = tcr.Data.(int64) + } + + utils.SendDiagnostic(utils.TRACK_ACTIVITY, map[string]interface{}{ + "users": userCount, + "active_users": activeUserCount, + "teams": teamCount, + }) + + edition := model.BuildEnterpriseReady + version := model.CurrentVersion + database := utils.Cfg.SqlSettings.DriverName + operatingSystem := runtime.GOOS + + utils.SendDiagnostic(utils.TRACK_VERSION, map[string]interface{}{ + "edition": edition, + "version": version, + "database": database, + "operating_system": operatingSystem, + }) } func runSecurityAndDiagnosticsJob() { -- cgit v1.2.3-1-g7c22