@grafana/runtime
Version:
Grafana Runtime Library
1 lines • 4.42 kB
Source Map (JSON)
{"version":3,"file":"types.mjs","sources":["../../../src/analytics/types.ts"],"sourcesContent":["import { CoreApp } from '@grafana/data';\n\nimport { EchoEvent, EchoEventType } from '../services/EchoSrv';\n\n/**\n * Describes the basic dashboard information that can be passed as the meta\n * analytics payload.\n *\n * @public\n */\nexport interface DashboardInfo {\n /** @deprecated -- use UID not internal ID */\n dashboardId: number;\n dashboardUid: string;\n dashboardName: string;\n folderName?: string;\n}\n\n/**\n * Describes the data request information passed as the meta analytics payload.\n *\n * @public\n */\nexport interface DataRequestInfo extends Partial<DashboardInfo> {\n source?: CoreApp | string;\n datasourceName: string;\n datasourceId: number;\n datasourceUid: string;\n datasourceType: string;\n panelId?: number;\n panelPluginId?: string;\n panelName?: string;\n duration: number;\n error?: string;\n dataSize?: number;\n}\n\n/**\n * The meta analytics events that can be added to the echo service.\n *\n * @public\n */\nexport enum MetaAnalyticsEventName {\n DashboardView = 'dashboard-view',\n DataRequest = 'data-request',\n}\n\n/**\n * Describes the payload of a dashboard view event.\n *\n * @public\n */\nexport interface DashboardViewEventPayload extends DashboardInfo {\n eventName: MetaAnalyticsEventName.DashboardView;\n}\n\n/**\n * Describes the payload of a data request event.\n *\n * @public\n */\nexport interface DataRequestEventPayload extends DataRequestInfo {\n eventName: MetaAnalyticsEventName.DataRequest;\n totalQueries?: number;\n cachedQueries?: number;\n}\n\n/**\n * Describes the meta analytics payload passed with the {@link MetaAnalyticsEvent}\n *\n * @public\n */\nexport type MetaAnalyticsEventPayload = DashboardViewEventPayload | DataRequestEventPayload;\n\n/**\n * Describes meta analytics event with predefined {@link EchoEventType.EchoEventType} type.\n *\n * @public\n */\nexport interface MetaAnalyticsEvent extends EchoEvent<EchoEventType.MetaAnalytics, MetaAnalyticsEventPayload> {}\n\n/**\n * Describes the payload of a pageview event.\n *\n * @public\n */\nexport interface PageviewEchoEventPayload {\n page: string;\n}\n\n/**\n * Describes pageview event with predefined {@link EchoEventType.EchoEventType} type.\n *\n * @public\n */\nexport type PageviewEchoEvent = EchoEvent<EchoEventType.Pageview, PageviewEchoEventPayload>;\n\n/**\n * Describes the payload of a user interaction event.\n *\n * @public\n */\nexport interface InteractionEchoEventPayload {\n interactionName: string;\n properties?: Record<string, any>;\n}\n\n/**\n * Describes interaction event with predefined {@link EchoEventType.EchoEventType} type.\n *\n * @public\n */\nexport type InteractionEchoEvent = EchoEvent<EchoEventType.Interaction, InteractionEchoEventPayload>;\n\n/**\n * Describes the payload of an experimentview event.\n *\n * @public\n */\nexport interface ExperimentViewEchoEventPayload {\n experimentId: string;\n experimentGroup: string;\n experimentVariant: string;\n}\n\n/**\n * Describes experimentview event with predefined {@link EchoEventType.EchoEventType} type.\n *\n * @public\n */\nexport type ExperimentViewEchoEvent = EchoEvent<EchoEventType.ExperimentView, ExperimentViewEchoEventPayload>;\n\n/**\n * Pageview event typeguard.\n *\n * @public\n */\nexport const isPageviewEvent = (event: EchoEvent): event is PageviewEchoEvent => {\n return Boolean(event.payload.page);\n};\n\n/**\n * Interaction event typeguard.\n *\n * @public\n */\nexport const isInteractionEvent = (event: EchoEvent): event is InteractionEchoEvent => {\n return Boolean(event.payload.interactionName);\n};\n\n/**\n * Experimentview event typeguard.\n *\n * @public\n */\nexport const isExperimentViewEvent = (event: EchoEvent): event is ExperimentViewEchoEvent => {\n return Boolean(event.payload.experimentId);\n};\n"],"names":["MetaAnalyticsEventName"],"mappings":"AA0CY,IAAA,sBAAA,qBAAAA,uBAAL,KAAA;AACL,EAAAA,wBAAA,eAAgB,CAAA,GAAA,gBAAA;AAChB,EAAAA,wBAAA,aAAc,CAAA,GAAA,cAAA;AAFJ,EAAAA,OAAAA,uBAAAA;AAAA,CAAA,EAAA,sBAAA,IAAA,EAAA;AA+FC,MAAA,eAAA,GAAkB,CAAC,KAAiD,KAAA;AAC/E,EAAO,OAAA,OAAA,CAAQ,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAA;AACnC;AAOa,MAAA,kBAAA,GAAqB,CAAC,KAAoD,KAAA;AACrF,EAAO,OAAA,OAAA,CAAQ,KAAM,CAAA,OAAA,CAAQ,eAAe,CAAA;AAC9C;AAOa,MAAA,qBAAA,GAAwB,CAAC,KAAuD,KAAA;AAC3F,EAAO,OAAA,OAAA,CAAQ,KAAM,CAAA,OAAA,CAAQ,YAAY,CAAA;AAC3C;;;;"}