Analytics: Use Fullstory to get behavioral data (#53732)

This commit is contained in:
Ivan Ortega Alba 2022-08-16 10:32:00 +02:00 committed by GitHub
parent a7dd095231
commit 961479b111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 63 additions and 0 deletions

View File

@ -215,6 +215,9 @@ google_analytics_ua_id =
# Google Tag Manager ID, only enabled if you specify an id here
google_tag_manager_id =
# Fullstory org id, only enabled if you specify an org id here
fullstory_org_id =
# Rudderstack write key, enabled only if rudderstack_data_plane_url is also set
rudderstack_write_key =

View File

@ -250,6 +250,7 @@
"dependencies": {
"@emotion/css": "11.9.0",
"@emotion/react": "11.9.3",
"@fullstory/browser": "^1.6.1",
"@grafana/agent-core": "0.4.0",
"@grafana/agent-web": "0.4.0",
"@grafana/aws-sdk": "0.0.37",

View File

@ -211,6 +211,7 @@ export interface GrafanaConfig {
feedbackLinksEnabled: boolean;
secretsManagerPluginEnabled: boolean;
googleAnalyticsId: string | undefined;
fullstoryOrgId: string | undefined;
rudderstackWriteKey: string | undefined;
rudderstackDataPlaneUrl: string | undefined;
rudderstackSdkUrl: string | undefined;

View File

@ -63,4 +63,5 @@ export interface FeatureToggles {
internationalization?: boolean;
topnav?: boolean;
customBranding?: boolean;
fullstoryUserTracking?: boolean;
}

View File

@ -134,6 +134,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
enabled: true,
};
googleAnalyticsId: undefined;
fullstoryOrgId: undefined;
rudderstackWriteKey: undefined;
rudderstackDataPlaneUrl: undefined;
rudderstackSdkUrl: undefined;

View File

@ -83,6 +83,7 @@ export enum EchoEventType {
Interaction = 'interaction',
ExperimentView = 'experimentview',
GrafanaJavascriptAgent = 'grafana-javascript-agent',
Fullstory = 'fullstory-sdk',
}
/**

View File

@ -107,6 +107,13 @@ export interface InteractionEchoEventPayload {
*/
export type InteractionEchoEvent = EchoEvent<EchoEventType.Interaction, InteractionEchoEventPayload>;
/**
* Describes Fullstory custom interaction event with predefined {@link EchoEventType.EchoEventType} type.
*
* @public
*/
export type FullstoryEchoEvent = EchoEvent<EchoEventType.Fullstory, InteractionEchoEventPayload>;
/**
* Describes the payload of an experimentview event.
*

View File

@ -118,6 +118,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
"profileEnabled": setting.ProfileEnabled,
"queryHistoryEnabled": hs.Cfg.QueryHistoryEnabled,
"googleAnalyticsId": setting.GoogleAnalyticsId,
"fullstoryOrgId": setting.FullstoryOrgId,
"rudderstackWriteKey": setting.RudderstackWriteKey,
"rudderstackDataPlaneUrl": setting.RudderstackDataPlaneUrl,
"rudderstackSdkUrl": setting.RudderstackSdkUrl,

View File

@ -262,5 +262,9 @@ var (
Description: "Replaces whitelabeling with the new custom branding feature",
State: FeatureStateAlpha,
},
{
Name: "fullstoryUserTracking",
Description: "Enables Fullstory cliend SDK to do user analytics",
},
}
)

View File

@ -194,4 +194,8 @@ const (
// FlagCustomBranding
// Replaces whitelabeling with the new custom branding feature
FlagCustomBranding = "customBranding"
// FlagFullstoryUserTracking
// Enables Fullstory cliend SDK to do user analytics
FlagFullstoryUserTracking = "fullstoryUserTracking"
)

View File

@ -137,6 +137,7 @@ var (
// analytics
GoogleAnalyticsId string
GoogleTagManagerId string
FullstoryOrgId string
RudderstackDataPlaneUrl string
RudderstackWriteKey string
RudderstackSdkUrl string
@ -953,6 +954,7 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
cfg.CheckForPluginUpdates = analytics.Key("check_for_plugin_updates").MustBool(true)
GoogleAnalyticsId = analytics.Key("google_analytics_ua_id").String()
GoogleTagManagerId = analytics.Key("google_tag_manager_id").String()
FullstoryOrgId = analytics.Key("fullstory_org_id").String()
RudderstackWriteKey = analytics.Key("rudderstack_write_key").String()
RudderstackDataPlaneUrl = analytics.Key("rudderstack_data_plane_url").String()
RudderstackSdkUrl = analytics.Key("rudderstack_sdk_url").String()

View File

@ -53,6 +53,7 @@ import { Echo } from './core/services/echo/Echo';
import { reportPerformance } from './core/services/echo/EchoSrv';
import { PerformanceBackend } from './core/services/echo/backends/PerformanceBackend';
import { ApplicationInsightsBackend } from './core/services/echo/backends/analytics/ApplicationInsightsBackend';
import { FullstoryBackend } from './core/services/echo/backends/analytics/FullstoryBackend';
import { GAEchoBackend } from './core/services/echo/backends/analytics/GABackend';
import { RudderstackBackend } from './core/services/echo/backends/analytics/RudderstackBackend';
import { GrafanaJavascriptAgentBackend } from './core/services/echo/backends/grafana-javascript-agent/GrafanaJavascriptAgentBackend';
@ -206,6 +207,12 @@ function initEchoSrv() {
registerEchoBackend(new PerformanceBackend({}));
}
if (config.featureToggles.fullstoryUserTracking && config.fullstoryOrgId) {
registerEchoBackend(
new FullstoryBackend({ orgId: config.fullstoryOrgId, devMode: process.env.NODE_ENV === 'development' })
);
}
if (config.sentry.enabled) {
registerEchoBackend(
new SentryEchoBackend({

View File

@ -0,0 +1,22 @@
import { init } from '@fullstory/browser';
import { EchoBackend, EchoEventType, FullstoryEchoEvent } from '@grafana/runtime';
export interface FullstoryBackendOptions {
orgId: string;
devMode?: boolean;
}
export class FullstoryBackend implements EchoBackend<FullstoryEchoEvent, FullstoryBackendOptions> {
supportedEvents = [EchoEventType.Fullstory];
constructor(public options: FullstoryBackendOptions) {
init({ orgId: options.orgId, devMode: options.devMode ?? false, debug: options.devMode ?? false });
}
// Not using custom events, Fullstory track every interaction automatically
addEvent = (e: FullstoryEchoEvent) => {};
// Not using Echo buffering
flush = () => {};
}

View File

@ -4719,6 +4719,13 @@ __metadata:
languageName: node
linkType: hard
"@fullstory/browser@npm:^1.6.1":
version: 1.6.1
resolution: "@fullstory/browser@npm:1.6.1"
checksum: 79bb1c05b92b6bb6163566eeceb2ddf8e7e7bf5b9d629d99a937cecc21eafc019a0149c78d968e623424cbc84e9ce10e162e8ab56e59d47d259ca8e364f5c249
languageName: node
linkType: hard
"@gar/promisify@npm:^1.0.1":
version: 1.1.2
resolution: "@gar/promisify@npm:1.1.2"
@ -21642,6 +21649,7 @@ __metadata:
"@emotion/css": 11.9.0
"@emotion/eslint-plugin": 11.7.0
"@emotion/react": 11.9.3
"@fullstory/browser": ^1.6.1
"@grafana/agent-core": 0.4.0
"@grafana/agent-web": 0.4.0
"@grafana/api-documenter": 7.11.2