diff --git a/docs/sources/setup-grafana/configure-grafana/_index.md b/docs/sources/setup-grafana/configure-grafana/_index.md index 94663ddbb1e..69b1286ebd7 100644 --- a/docs/sources/setup-grafana/configure-grafana/_index.md +++ b/docs/sources/setup-grafana/configure-grafana/_index.md @@ -518,8 +518,7 @@ Sets a custom value for the `User-Agent` header for outgoing data proxy requests ### enabled -This option is also known as _usage analytics_. When `false`, this option disables the writers that read/write from and to the Grafana databases. The default -value is `true`. +This option is also known as _usage analytics_. When `false`, this option disables the writers that write to the Grafana database and the associated features, such as dashboard and data source insights, presence indicators, and advanced dashboard search. The default value is `true`. ### reporting_enabled diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts index ab29635bbe2..3c6d3a290de 100644 --- a/packages/grafana-runtime/src/config.ts +++ b/packages/grafana-runtime/src/config.ts @@ -143,6 +143,9 @@ export class GrafanaBootConfig implements GrafanaConfig { reporting = { enabled: true, }; + analytics = { + enabled: true, + }; googleAnalyticsId: undefined; googleAnalytics4Id: undefined; googleAnalytics4SendManualPageViews = false; diff --git a/pkg/api/dtos/frontend_settings.go b/pkg/api/dtos/frontend_settings.go index 63389fe5c08..00e12785250 100644 --- a/pkg/api/dtos/frontend_settings.go +++ b/pkg/api/dtos/frontend_settings.go @@ -62,6 +62,10 @@ type FrontendSettingsReportingDTO struct { Enabled bool `json:"enabled"` } +type FrontendSettingsAnalyticsDTO struct { + Enabled bool `json:"enabled"` +} + type FrontendSettingsUnifiedAlertingDTO struct { MinInterval string `json:"minInterval"` AlertStateHistoryBackend string `json:"alertStateHistoryBackend,omitempty"` @@ -209,6 +213,7 @@ type FrontendSettingsDTO struct { Caching FrontendSettingsCachingDTO `json:"caching"` RecordedQueries FrontendSettingsRecordedQueriesDTO `json:"recordedQueries"` Reporting FrontendSettingsReportingDTO `json:"reporting"` + Analytics FrontendSettingsAnalyticsDTO `json:"analytics"` UnifiedAlertingEnabled bool `json:"unifiedAlertingEnabled"` UnifiedAlerting FrontendSettingsUnifiedAlertingDTO `json:"unifiedAlerting"` Oauth map[string]any `json:"oauth"` diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index f5617682007..a06d9ca7af2 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -223,6 +223,9 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro Reporting: dtos.FrontendSettingsReportingDTO{ Enabled: hs.Cfg.SectionWithEnvOverrides("reporting").Key("enabled").MustBool(true), }, + Analytics: dtos.FrontendSettingsAnalyticsDTO{ + Enabled: hs.Cfg.SectionWithEnvOverrides("analytics").Key("enabled").MustBool(true), + }, UnifiedAlerting: dtos.FrontendSettingsUnifiedAlertingDTO{ MinInterval: hs.Cfg.UnifiedAlerting.MinInterval.String(), diff --git a/public/app/features/datasources/state/navModel.ts b/public/app/features/datasources/state/navModel.ts index 9223eaa2e82..ec804d29336 100644 --- a/public/app/features/datasources/state/navModel.ts +++ b/public/app/features/datasources/state/navModel.ts @@ -78,29 +78,31 @@ export function buildNavModel(dataSource: DataSourceSettings, plugin: GenericDat }); } - const analyticsExperimentId = 'feature-highlights-data-source-insights-badge'; - const analytics: NavModelItem = { - active: false, - icon: 'info-circle', - id: `datasource-insights-${dataSource.uid}`, - text: 'Insights', - url: `datasources/edit/${dataSource.uid}/insights`, - }; + if (config.analytics?.enabled) { + const analyticsExperimentId = 'feature-highlights-data-source-insights-badge'; + const analytics: NavModelItem = { + active: false, + icon: 'info-circle', + id: `datasource-insights-${dataSource.uid}`, + text: 'Insights', + url: `datasources/edit/${dataSource.uid}/insights`, + }; - if (highlightTrial() && !isLoadingNav) { - analytics.tabSuffix = () => ProBadge({ experimentId: analyticsExperimentId, eventVariant: 'trial' }); - } + if (highlightTrial() && !isLoadingNav) { + analytics.tabSuffix = () => ProBadge({ experimentId: analyticsExperimentId, eventVariant: 'trial' }); + } - if (featureEnabled('analytics')) { - if (contextSrv.hasPermission(AccessControlAction.DataSourcesInsightsRead)) { - navModel.children!.push(analytics); + if (featureEnabled('analytics')) { + if (contextSrv.hasPermission(AccessControlAction.DataSourcesInsightsRead)) { + navModel.children!.push(analytics); + } + } else if (highlightsEnabled && !isLoadingNav) { + navModel.children!.push({ + ...analytics, + url: analytics.url + '/upgrade', + tabSuffix: () => ProBadge({ experimentId: analyticsExperimentId }), + }); } - } else if (highlightsEnabled && !isLoadingNav) { - navModel.children!.push({ - ...analytics, - url: analytics.url + '/upgrade', - tabSuffix: () => ProBadge({ experimentId: analyticsExperimentId }), - }); } const cachingExperimentId = 'feature-highlights-query-caching-badge';