【发布时间】:2015-11-27 07:45:34
【问题描述】:
我正在尝试将 Application Insight 用于基于 Cordova(离子)的应用程序并面临以下问题。
应用洞察力 JS 请求 file:// dc.services.visualstudio.com/v2/track 而不是 https://
我了解这是因为应用程序使用 file://
托管在 android 设备中我也尝试使用MS提供的cordova插件,appInsight对象变为null。
下面是我正在使用的代码
var appInsights=window.appInsights||function(config){
function r(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s=u.createElement(o),i,f;for(s.src=config.url||"http://az416426.vo.msecnd.net/scripts/a/ai.0.js",u.getElementsByTagName(o)[0].parentNode.appendChild(s),t.cookie=u.cookie,t.queue=[],i=["Event","Exception","Metric","PageView","Trace"];i.length;)r("track"+i.pop());return r("setAuthenticatedUserContext"),r("clearAuthenticatedUserContext"),config.disableExceptionTracking||(i="onerror",r("_"+i),f=e[i],e[i]=function(config,r,u,e,o){var s=f&&f(config,r,u,e,o);return s!==!0&&t["_"+i](config,r,u,e,o),s}),t
}({
instrumentationKey: "--key--"
});
window.appInsights=appInsights;
请注意,在上面的代码中我添加了 http:// 来下载 ai.0.js 文件。否则,该请求也会发送到 file://
【问题讨论】:
标签: cordova ionic azure-application-insights