mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
add support for interaction events (#39752)
This commit is contained in:
parent
4682cf5b7c
commit
db8c9122aa
@ -1,5 +1,12 @@
|
|||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import { EchoBackend, EchoEventType, isInteractionEvent, isPageviewEvent, PageviewEchoEvent } from '@grafana/runtime';
|
import {
|
||||||
|
EchoBackend,
|
||||||
|
EchoEventType,
|
||||||
|
InteractionEchoEvent,
|
||||||
|
isInteractionEvent,
|
||||||
|
isPageviewEvent,
|
||||||
|
PageviewEchoEvent,
|
||||||
|
} from '@grafana/runtime';
|
||||||
|
|
||||||
export interface ApplicationInsightsBackendOptions {
|
export interface ApplicationInsightsBackendOptions {
|
||||||
connectionString: string;
|
connectionString: string;
|
||||||
@ -7,7 +14,7 @@ export interface ApplicationInsightsBackendOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ApplicationInsightsBackend implements EchoBackend<PageviewEchoEvent, ApplicationInsightsBackendOptions> {
|
export class ApplicationInsightsBackend implements EchoBackend<PageviewEchoEvent, ApplicationInsightsBackendOptions> {
|
||||||
supportedEvents = [EchoEventType.Pageview];
|
supportedEvents = [EchoEventType.Pageview, EchoEventType.Interaction];
|
||||||
|
|
||||||
constructor(public options: ApplicationInsightsBackendOptions) {
|
constructor(public options: ApplicationInsightsBackendOptions) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -26,7 +33,7 @@ export class ApplicationInsightsBackend implements EchoBackend<PageviewEchoEvent
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addEvent = (e: PageviewEchoEvent) => {
|
addEvent = (e: PageviewEchoEvent | InteractionEchoEvent) => {
|
||||||
if (!(window as any).applicationInsights) {
|
if (!(window as any).applicationInsights) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -36,7 +43,7 @@ export class ApplicationInsightsBackend implements EchoBackend<PageviewEchoEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isInteractionEvent(e)) {
|
if (isInteractionEvent(e)) {
|
||||||
(window as any).applicationInsights.trackPageView({
|
(window as any).applicationInsights.trackEvent({
|
||||||
name: e.payload.interactionName,
|
name: e.payload.interactionName,
|
||||||
properties: e.payload.properties,
|
properties: e.payload.properties,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user