diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-10-30 14:10:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-30 14:10:48 -0400 |
commit | 09c5f5e2eacb9705f5675c51493776c5618e0716 (patch) | |
tree | 1bab6e2155f1b70835f1d24e96e0f35892985b83 | |
parent | 539f66313d4f23231aba73119dfc2e8340df1400 (diff) | |
download | chat-09c5f5e2eacb9705f5675c51493776c5618e0716.tar.gz chat-09c5f5e2eacb9705f5675c51493776c5618e0716.tar.bz2 chat-09c5f5e2eacb9705f5675c51493776c5618e0716.zip |
Add some more diagnostics for plugins (#7669)
-rw-r--r-- | app/diagnostics.go | 54 | ||||
-rw-r--r-- | app/diagnostics_test.go | 1 |
2 files changed, 54 insertions, 1 deletions
diff --git a/app/diagnostics.go b/app/diagnostics.go index c0499bd89..4974d6444 100644 --- a/app/diagnostics.go +++ b/app/diagnostics.go @@ -47,6 +47,7 @@ const ( TRACK_ACTIVITY = "activity" TRACK_LICENSE = "license" TRACK_SERVER = "server" + TRACK_PLUGINS = "plugins" ) var client *analytics.Client @@ -57,6 +58,7 @@ func (a *App) SendDailyDiagnostics() { a.trackActivity() a.trackConfig() trackLicense() + a.trackPlugins() a.trackServer() } } @@ -445,7 +447,9 @@ func (a *App) trackConfig() { }) SendDiagnostic(TRACK_CONFIG_PLUGIN, map[string]interface{}{ - "enable_jira": pluginSetting(&cfg.PluginSettings, "jira", "enabled", false), + "enable_jira": pluginSetting(&cfg.PluginSettings, "jira", "enabled", false), + "enable": *utils.Cfg.PluginSettings.Enable, + "enable_uploads": *utils.Cfg.PluginSettings.EnableUploads, }) SendDiagnostic(TRACK_CONFIG_DATA_RETENTION, map[string]interface{}{ @@ -477,6 +481,54 @@ func trackLicense() { } } +func (a *App) trackPlugins() { + if *a.Config().PluginSettings.Enable { + totalActiveCount := -1 // -1 to indicate disabled or error + webappActiveCount := 0 + backendActiveCount := 0 + totalInactiveCount := -1 // -1 to indicate disabled or error + webappInactiveCount := 0 + backendInactiveCount := 0 + + plugins, _ := a.GetPluginManifests() + + if plugins != nil { + totalActiveCount = len(plugins.Active) + + for _, plugin := range plugins.Active { + if plugin.Webapp != nil { + webappActiveCount += 1 + } + + if plugin.Backend != nil { + backendActiveCount += 1 + } + } + + totalInactiveCount = len(plugins.Inactive) + + for _, plugin := range plugins.Inactive { + if plugin.Webapp != nil { + webappInactiveCount += 1 + } + + if plugin.Backend != nil { + backendInactiveCount += 1 + } + } + } + + SendDiagnostic(TRACK_PLUGINS, map[string]interface{}{ + "active_plugins": totalActiveCount, + "active_webapp_plugins": webappActiveCount, + "active_backend_plugins": backendActiveCount, + "inactive_plugins": totalInactiveCount, + "inactive_webapp_plugins": webappInactiveCount, + "inactive_backend_plugins": backendInactiveCount, + }) + } +} + func (a *App) trackServer() { data := map[string]interface{}{ "edition": model.BuildEnterpriseReady, diff --git a/app/diagnostics_test.go b/app/diagnostics_test.go index 842322e9c..47a5d8a27 100644 --- a/app/diagnostics_test.go +++ b/app/diagnostics_test.go @@ -135,6 +135,7 @@ func TestDiagnostics(t *testing.T) { TRACK_CONFIG_PLUGIN, TRACK_ACTIVITY, TRACK_SERVER, + TRACK_PLUGINS, } { if !strings.Contains(info, item) { t.Fatal("Sent diagnostics missing item: " + item) |