检查是否正确安装了Application Insights SDK。确保你已经按照官方文档中的指示正确安装了Application Insights SDK。
如果你在使用SPAs(单页应用程序),则需要确保你已经正确设置了应用配置文件,以允许 Application Insights SDK 记录浏览器数据。请确保在应用配置文件中指定了以下设置:
"applicationInsights": {
"instrumentationKey": "YOUR_INSTRUMENTATION_KEY",
"disableFetchTracking": false,
"disableAjaxTracking": false
}
其中 instrumentationKey
是你的 Application Insights 实例的仪表板中提供的仪表板密钥。
const appInsights = window.appInsights || function (config) {
function g(tag){return e['ai.'+tag];}function setCookie(name, value) {...}
const init = {...};
const script = document.createElement('script');
script.src = 'https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js';
document.head.appendChild(script);
window.appInsights = appInsights;
return appInsights;
}({
instrumentationKey: 'YOUR_INSTRUMENTATION_KEY'
});
appInsights.trackPageView();
确保你已经在你的JavaScript文件中包含了这段代码,并且在 appInsights.trackPageView()
方法中指定了正确的仪表板密钥。
如果你仍然无法记录浏览器数据,请检查你的仪表板设置是否正确,并确保你的应用程序正在使用与仪表板密钥相匹配的实例。