gpt4 book ai didi

Azure Application Insights - 禁用记录页面 View

转载 作者:行者123 更新时间:2023-12-02 23:16:18 25 4
gpt4 key购买 nike

我有一个用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com