UsageStatsService: Don't use global state (#31849)

* UsageStatsService: Don't use global state

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2021-03-10 10:14:00 +01:00
committed by GitHub
parent 598a44076a
commit 04e9f6c24f
4 changed files with 254 additions and 270 deletions

View File

@ -141,10 +141,8 @@ var (
appliedEnvOverrides []string
// analytics
ReportingEnabled bool
ReportingDistributor string
GoogleAnalyticsId string
GoogleTagManagerId string
GoogleAnalyticsId string
GoogleTagManagerId string
// LDAP
LDAPEnabled bool
@ -337,7 +335,9 @@ type Cfg struct {
Env string
// Analytics
CheckForUpdates bool
CheckForUpdates bool
ReportingDistributor string
ReportingEnabled bool
// LDAP
LDAPEnabled bool
@ -831,10 +831,10 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg.CheckForUpdates = analytics.Key("check_for_updates").MustBool(true)
GoogleAnalyticsId = analytics.Key("google_analytics_ua_id").String()
GoogleTagManagerId = analytics.Key("google_tag_manager_id").String()
ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true)
ReportingDistributor = analytics.Key("reporting_distributor").MustString("grafana-labs")
if len(ReportingDistributor) >= 100 {
ReportingDistributor = ReportingDistributor[:100]
cfg.ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true)
cfg.ReportingDistributor = analytics.Key("reporting_distributor").MustString("grafana-labs")
if len(cfg.ReportingDistributor) >= 100 {
cfg.ReportingDistributor = cfg.ReportingDistributor[:100]
}
if err := readAlertingSettings(iniFile); err != nil {