Jquery 如何在单个网页中使用多个应用程序细节

Jquery 如何在单个网页中使用多个应用程序细节,jquery,azure,azure-application-insights,Jquery,Azure,Azure Application Insights,我正在我的web应用程序中使用Azure Application Insights。 我想在第一个应用程序洞察中跟踪一种类型的事件,在第二个应用程序洞察中跟踪第二种类型的事件 是否可以使用客户端API在一个页面中使用Application Insights的两个instrumentation键?您可以基于两个不同的键初始化两个不同的Application Insights对象,并利用它们跟踪不同的遥测 //first object initialization var appInsights1=

我正在我的web应用程序中使用Azure Application Insights。 我想在第一个应用程序洞察中跟踪一种类型的事件,在第二个应用程序洞察中跟踪第二种类型的事件


是否可以使用客户端API在一个页面中使用Application Insights的两个instrumentation键?

您可以基于两个不同的键初始化两个不同的Application Insights对象,并利用它们跟踪不同的遥测

//first object initialization
var appInsights1=window.appInsights1||function(config){
......
    instrumentationKey:"<key1>",
});

window.appInsights1 = appInsights1; //assigning to global variable
appInsights1.trackPageView();       //first object to track Pageview

//second object initialization
var appInsights2=window.appInsights2||function(config){
......
    instrumentationKey:"<key2>",
});

window.appInsights2 = appInsights2; //assigning to global variable
appInsights2.trackException(ex);    //second object to track Exception
//第一个对象初始化
var appInsights1=window.appInsights1 | |函数(配置){
......
instrumentationKey:“”,
});
window.appInsights1=appInsights1//分配给全局变量
appInsights1.trackPageView()//跟踪页面视图的第一个对象
//第二对象初始化
var appInsights2=window.appInsights2 | |函数(配置){
......
instrumentationKey:“”,
});
window.appInsights2=appInsights2//分配给全局变量
appInsights2.trackException(ex)//跟踪异常的第二个对象

为什么要这样做?分离有什么好处?由于数据量大。。。我只是想知道这可能吗?我试过了,但是第二次真正的呼叫怎么对我不起作用怎么/为什么不起作用?您必须创建两个单独的applicationInsights对象,每个对象都用自己的ikey初始化,然后只发送一个或另一个事件。但是,如果发送的数据太多,将内容一分为二似乎只能暂时解决问题。在某个时候,你会在一页中有3个ikey?然后是4?这似乎不是一个可扩展的长期想法。您发送的数据中有多少是您认为需要拆分的?