Feat: Extending report interaction with static context that can be appended to all interaction events (#88927)

* Extending report interaction with static context that can be appended to all requests
This commit is contained in:
Timur Olzhabayev
2024-07-08 16:37:45 +02:00
committed by GitHub
parent cff9ecbd6d
commit f763f2085b
8 changed files with 24 additions and 0 deletions
+1
View File
@@ -231,6 +231,7 @@ type FrontendSettingsDTO struct {
SupportBundlesEnabled bool `json:"supportBundlesEnabled"`
SnapshotEnabled bool `json:"snapshotEnabled"`
SecureSocksDSProxyEnabled bool `json:"secureSocksDSProxyEnabled"`
ReportingStaticContext map[string]string `json:"reportingStaticContext"`
Azure FrontendSettingsAzureDTO `json:"azure"`
+1
View File
@@ -226,6 +226,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
SharedWithMeFolderUID: folder.SharedWithMeFolderUID,
RootFolderUID: accesscontrol.GeneralFolderUID,
LocalFileSystemAvailable: hs.Cfg.LocalFileSystemAvailable,
ReportingStaticContext: hs.Cfg.ReportingStaticContext,
BuildInfo: dtos.FrontendSettingsBuildInfoDTO{
HideVersion: hideVersion,
+10
View File
@@ -366,6 +366,7 @@ type Cfg struct {
ApplicationInsightsConnectionString string
ApplicationInsightsEndpointUrl string
FeedbackLinksEnabled bool
ReportingStaticContext map[string]string
// Frontend analytics
GoogleAnalyticsID string
@@ -1156,6 +1157,15 @@ func (cfg *Cfg) parseINIFile(iniFile *ini.File) error {
cfg.ApplicationInsightsEndpointUrl = analytics.Key("application_insights_endpoint_url").String()
cfg.FeedbackLinksEnabled = analytics.Key("feedback_links_enabled").MustBool(true)
// parse reporting static context string of key=value, key=value pairs into an object
cfg.ReportingStaticContext = make(map[string]string)
for _, pair := range strings.Split(analytics.Key("reporting_static_context").String(), ",") {
kv := strings.Split(pair, "=")
if len(kv) == 2 {
cfg.ReportingStaticContext[strings.TrimSpace("_static_context_"+kv[0])] = strings.TrimSpace(kv[1])
}
}
if err := cfg.readAlertingSettings(iniFile); err != nil {
return err
}