From 09c5f5e2eacb9705f5675c51493776c5618e0716 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 30 Oct 2017 14:10:48 -0400 Subject: Add some more diagnostics for plugins (#7669) --- app/diagnostics.go | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'app/diagnostics.go') 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, -- cgit v1.2.3-1-g7c22