mirror of
https://github.com/grafana/grafana.git
synced 2024-11-21 08:34:25 -06:00
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:
parent
cff9ecbd6d
commit
f763f2085b
@ -312,6 +312,9 @@ application_insights_endpoint_url =
|
||||
# Controls if the UI contains any links to user feedback forms
|
||||
feedback_links_enabled = true
|
||||
|
||||
# Static context that is being added to analytics events
|
||||
reporting_static_context =
|
||||
|
||||
#################################### Security ############################
|
||||
[security]
|
||||
# disable creation of admin user on first start of grafana
|
||||
|
@ -309,6 +309,9 @@
|
||||
# Controls if the UI contains any links to user feedback forms
|
||||
;feedback_links_enabled = true
|
||||
|
||||
# Static context that is being added to analytics events
|
||||
;reporting_static_context = grafanaInstance=12, os=linux
|
||||
|
||||
#################################### Security ####################################
|
||||
[security]
|
||||
# disable creation of admin user on first start of grafana
|
||||
|
@ -232,6 +232,7 @@ export interface GrafanaConfig {
|
||||
cloudMigrationIsTarget?: boolean;
|
||||
listDashboardScopesEndpoint?: string;
|
||||
listScopesEndpoint?: string;
|
||||
reportingStaticContext?: Record<string, string>;
|
||||
|
||||
// The namespace to use for kubernetes apiserver requests
|
||||
namespace: string;
|
||||
|
@ -44,6 +44,10 @@ export const reportPageview = () => {
|
||||
* @public
|
||||
*/
|
||||
export const reportInteraction = (interactionName: string, properties?: Record<string, unknown>) => {
|
||||
// get static reporting context and append it to properties
|
||||
if (config.reportingStaticContext && config.reportingStaticContext instanceof Object) {
|
||||
properties = { ...properties, ...config.reportingStaticContext };
|
||||
}
|
||||
getEchoSrv().addEvent<InteractionEchoEvent>({
|
||||
type: EchoEventType.Interaction,
|
||||
payload: {
|
||||
|
@ -177,6 +177,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
|
||||
rootFolderUID: string | undefined;
|
||||
localFileSystemAvailable: boolean | undefined;
|
||||
cloudMigrationIsTarget: boolean | undefined;
|
||||
reportingStaticContext?: Record<string, string>;
|
||||
|
||||
/**
|
||||
* Language used in Grafana's UI. This is after the user's preference (or deteceted locale) is resolved to one of
|
||||
|
@ -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"`
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user