[v11.1.x] Analytics: Fix ApplicationInsights integration (#89301)
Analytics: Fix ApplicationInsights integration (#89299)
change ApplicationInsights backend to use SystemJS to load
(cherry picked from commit 7bb883e375)
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
co-authored by
Ashley Harrison
parent
3418e01da5
commit
36dbcbc78a
@@ -1320,10 +1320,6 @@ exports[`better eslint`] = {
|
|||||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||||
],
|
],
|
||||||
"public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts:5381": [
|
|
||||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
|
||||||
],
|
|
||||||
"public/app/core/services/echo/backends/analytics/RudderstackBackend.ts:5381": [
|
"public/app/core/services/echo/backends/analytics/RudderstackBackend.ts:5381": [
|
||||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import {
|
|||||||
PageviewEchoEvent,
|
PageviewEchoEvent,
|
||||||
} from '@grafana/runtime';
|
} from '@grafana/runtime';
|
||||||
|
|
||||||
import { loadScript } from '../../utils';
|
|
||||||
|
|
||||||
interface ApplicationInsights {
|
interface ApplicationInsights {
|
||||||
trackPageView: () => void;
|
trackPageView: () => void;
|
||||||
trackEvent: (event: { name: string; properties?: Record<string, unknown> }) => void;
|
trackEvent: (event: { name: string; properties?: Record<string, unknown> }) => void;
|
||||||
@@ -39,10 +37,12 @@ export class ApplicationInsightsBackend implements EchoBackend<PageviewEchoEvent
|
|||||||
};
|
};
|
||||||
|
|
||||||
const url = 'https://js.monitor.azure.com/scripts/b/ai.2.min.js';
|
const url = 'https://js.monitor.azure.com/scripts/b/ai.2.min.js';
|
||||||
loadScript(url).then(() => {
|
System.import(url)
|
||||||
const init = new (window as any).Microsoft.ApplicationInsights.ApplicationInsights(applicationInsightsOpts);
|
.then((m) => (m.default ? m.default : m))
|
||||||
window.applicationInsights = init.loadAppInsights();
|
.then(({ ApplicationInsights }) => {
|
||||||
});
|
const init = new ApplicationInsights(applicationInsightsOpts);
|
||||||
|
window.applicationInsights = init.loadAppInsights();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addEvent = (e: PageviewEchoEvent | InteractionEchoEvent) => {
|
addEvent = (e: PageviewEchoEvent | InteractionEchoEvent) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user