Azure Application Insights - 禁用记录页面 View

标签 azure azure-application-insights

我有一个用 JavaScript 编写的单页应用程序。我当前正在使用 JavaScript API 将事件记录到 Azure Application Insights。我注意到 Application Insights 会自动将所有页面 View 写入 Application Insights。但是,我只对将自定义事件写入 Application Insights 感兴趣。

有没有办法禁用记录页面 View ?换句话说,我可以使用 Application Insights 仅记录自定义事件、自定义指标和异常吗?

我在 API 文档中没有看到任何内容。谢谢。

最佳答案

您可以通过检查类型并在Telemetry Initializer中返回true/false来限制您想要的遥测类型。创建客户端时如下。

import { ApplicationInsights } from '@microsoft/applicationinsights-web'
const appInsights = new ApplicationInsights({ config: {
  instrumentationKey: 'YOUR_INSTRUMENTATION_KEY_GOES_HERE'  
} });
appInsights.addTelemetryInitializer(t => {
  // Update criteria as per your need.
  if (t.baseType == 'PageView') // or anything else
    return false; // disable
  return true; // enable everything else
});

关于Azure Application Insights - 禁用记录页面 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65007124/

相关文章:

c# - 小 Sprite 宇宙 : How to copy a property value of edge as vertex property inside a repeat command

Azure 自托管集成运行时 - 安全问题

Azure App Insights 显示空间消耗指标

azure - Application Insights Visual Studio 集成不适用于控制台应用程序 (WebJob)

c# - 将 Hangfire 作业记录到 Application Insights 并将事件与操作 ID 相关联

无法使用 APIM/VM 中的专用终结点访问 Azure 应用服务

node.js - 为什么 Azure Bot Service Slack 连接器不转发事件和交互式消息?

ASP.NET MVC 5 加载时间非常慢

azure - 在azure日志门户的工作簿中添加参数

azure - 仅在 azure 的仪表板中显示值?