如何解决应用程序洞察不记录请求、页面视图、自定义事件
我已将我的应用从开发者提升到舞台环境应用服务。
但现在我看不到页面视图,自定义事件记录在我的 Application Insights 中,而在 Dev 中记录正常。
为什么会这样?
注意:
1.我使用了正确的仪器密钥
3.该应用程序是使用 React 构建的 Teams 选项卡应用程序,并使用 React 插件获取应用洞察(在开发中工作正常)
4. 开发环境的运行时堆栈是 Node.Js,但 Stage 是 .NET(这是否导致了这个问题?)
另请注意我已经完成了故障排除指南中的所有场景
解决方法
问题为您解决了吗?
如果没有, 确保你安装了 React.js 的 npm 包,
npm install @microsoft/applicationinsights-react-js
npm install @microsoft/applicationinsights-web
初始化与 Application Insights 的连接:
在 AppInsights.js 中
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
import { ReactPlugin } from '@microsoft/applicationinsights-react-js';
import { createBrowserHistory } from 'history';
const browserHistory = createBrowserHistory({ basename: '' });
const reactPlugin = new ReactPlugin();
const appInsights = new ApplicationInsights({
config: {
instrumentationKey: 'YOUR_INSTRUMENTATION_KEY_GOES_HERE',extensions: [reactPlugin],extensionConfig: {
[reactPlugin.identifier]: { history: browserHistory }
}
}
});
appInsights.loadAppInsights();
export { reactPlugin,appInsights };
然后使用高阶组件函数包装您的组件以在其上启用 Application Insights:
import React from 'react';
import { withAITracking } from '@microsoft/applicationinsights-react-js';
import { reactPlugin,appInsights } from './AppInsights';
// To instrument various React components usage tracking,apply the `withAITracking` higher-order
// component function.
class MyComponent extends React.Component {
...
}
// withAITracking takes 4 parameters ( reactPlugin,Component,ComponentName,className)
// the first two are required and the other two are optional.
export default withAITracking(reactPlugin,MyComponent);
这将帮助您跟踪所有请求、页面浏览量和自定义事件。
另请查看此文档以获取更多参考:Javascript React SDK Plugin
,事实证明这是 Application Insights 实例本身的问题,而不是代码或应用服务配置的问题。 如果您遇到此类问题而不是代码或应用服务的问题,请与您组织的支持团队联系。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。