Commit 87485e24 by Torkel Ödegaard Committed by GitHub

MetaAnalytics: Minor fix for meta analytics event (#20888)

* Minor fix for meta analytics event

* Fixed dashboardSrv issue

* Added timeSinceNavigationStart
parent c4c031ef
...@@ -15,7 +15,14 @@ export interface EchoMeta { ...@@ -15,7 +15,14 @@ export interface EchoMeta {
userLogin: string; userLogin: string;
userId: number; userId: number;
userSignedIn: boolean; userSignedIn: boolean;
/**
* A millisecond epoch
*/
ts: number; ts: number;
/**
* A highres timestamp since navigation start
*/
timeSinceNavigationStart: number;
} }
export interface EchoBackend<T extends EchoEvent = any, O = any> { export interface EchoBackend<T extends EchoEvent = any, O = any> {
......
...@@ -82,7 +82,8 @@ export class Echo implements EchoSrv { ...@@ -82,7 +82,8 @@ export class Echo implements EchoSrv {
height: window.screen.height, height: window.screen.height,
}, },
userAgent: window.navigator.userAgent, userAgent: window.navigator.userAgent,
ts: performance.now(), ts: new Date().getTime(),
timeSinceNavigationStart: performance.now(),
url: window.location.href, url: window.location.href,
}; };
}; };
......
...@@ -29,9 +29,6 @@ export class DashboardSrv { ...@@ -29,9 +29,6 @@ export class DashboardSrv {
appEvents.on(CoreEvents.saveDashboard, this.saveDashboard.bind(this), $rootScope); appEvents.on(CoreEvents.saveDashboard, this.saveDashboard.bind(this), $rootScope);
appEvents.on(PanelEvents.panelChangeView, this.onPanelChangeView); appEvents.on(PanelEvents.panelChangeView, this.onPanelChangeView);
appEvents.on(CoreEvents.removePanel, this.onRemovePanel); appEvents.on(CoreEvents.removePanel, this.onRemovePanel);
// Export to react
setDashboardSrv(this);
} }
create(dashboard: any, meta: DashboardMeta) { create(dashboard: any, meta: DashboardMeta) {
......
...@@ -22,7 +22,6 @@ export function getAnalyticsProcessor(datasource: DataSourceApi) { ...@@ -22,7 +22,6 @@ export function getAnalyticsProcessor(datasource: DataSourceApi) {
panelId: data.request.panelId, panelId: data.request.panelId,
dashboardId: data.request.dashboardId, dashboardId: data.request.dashboardId,
// app: 'dashboard', // app: 'dashboard',
// count: 1,
dataSize: 0, dataSize: 0,
duration: data.request.endTime - data.request.startTime, duration: data.request.endTime - data.request.startTime,
eventName: 'data-request', eventName: 'data-request',
...@@ -38,9 +37,9 @@ export function getAnalyticsProcessor(datasource: DataSourceApi) { ...@@ -38,9 +37,9 @@ export function getAnalyticsProcessor(datasource: DataSourceApi) {
eventData.folderName = dashboard.meta.folderTitle; eventData.folderName = dashboard.meta.folderTitle;
} }
if (data.series.length > 0) { if (data.series && data.series.length > 0) {
// estimate size // estimate size
eventData.dataSize = data.series.length * data.series[0].length; eventData.dataSize = data.series.length;
} }
if (data.error) { if (data.error) {
......
...@@ -27,6 +27,7 @@ import { UtilSrv } from 'app/core/services/util_srv'; ...@@ -27,6 +27,7 @@ import { UtilSrv } from 'app/core/services/util_srv';
import { ContextSrv } from 'app/core/services/context_srv'; import { ContextSrv } from 'app/core/services/context_srv';
import { BridgeSrv } from 'app/core/services/bridge_srv'; import { BridgeSrv } from 'app/core/services/bridge_srv';
import { PlaylistSrv } from 'app/features/playlist/playlist_srv'; import { PlaylistSrv } from 'app/features/playlist/playlist_srv';
import { DashboardSrv, setDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { ILocationService, ITimeoutService, IRootScopeService, IAngularEvent } from 'angular'; import { ILocationService, ITimeoutService, IRootScopeService, IAngularEvent } from 'angular';
import { AppEvent, AppEvents } from '@grafana/data'; import { AppEvent, AppEvents } from '@grafana/data';
...@@ -45,6 +46,7 @@ export class GrafanaCtrl { ...@@ -45,6 +46,7 @@ export class GrafanaCtrl {
linkSrv: LinkSrv, linkSrv: LinkSrv,
datasourceSrv: DatasourceSrv, datasourceSrv: DatasourceSrv,
keybindingSrv: KeybindingSrv, keybindingSrv: KeybindingSrv,
dashboardSrv: DashboardSrv,
angularLoader: AngularLoader angularLoader: AngularLoader
) { ) {
// make angular loader service available to react components // make angular loader service available to react components
...@@ -54,6 +56,8 @@ export class GrafanaCtrl { ...@@ -54,6 +56,8 @@ export class GrafanaCtrl {
setTimeSrv(timeSrv); setTimeSrv(timeSrv);
setLinkSrv(linkSrv); setLinkSrv(linkSrv);
setKeybindingSrv(keybindingSrv); setKeybindingSrv(keybindingSrv);
setDashboardSrv(dashboardSrv);
const store = configureStore(); const store = configureStore();
setLocationSrv({ setLocationSrv({
update: (opt: LocationUpdate) => { update: (opt: LocationUpdate) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment