VS2015 Cordova的应用见解“无法发送遥测”

时间:2016-05-24 02:59:28

标签: visual-studio-2015 azure-application-insights apache-cordova

我使用VS2015使用Application Insights开发Cordova App。

我按照this article集成AppInsights并将其放入onDeviceReady()

     var snippet: any = {
            config: {
                instrumentationKey: "f2c1b11a-e3ec-4d3a-b96b-xxxxxxxx"
            }
        };
        var init = new Microsoft.ApplicationInsights.Initialization(snippet);
        var appInsights = init.loadAppInsights();
        appInsights.trackPageView();

在init.loadAppInsights()中运行良好但在运行到 appInsights.trackPageView()之后,我收到以下错误消息:

AI (Internal): NONUSRACT_OnError message:"Failed to send telemetry." props:"{message:{}}"

我在index.html中检查过,https://dc.services.visualstudio.com是在CSP中

<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://*.azurewebsites.net https://dc.services.visualstudio.com http://dc.services.visualstudio.com data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *">

并且config.xml中的域访问允许* URI

有人可以帮助我让Cordova与AppInsights合作吗?

非常感谢。

1 个答案:

答案 0 :(得分:1)

我相信您遇到的问题是由Cordova Ripple模拟器无法执行跨域请求引起的。请将跨域代理设置设置为&#34;禁用&#34;:

enter image description here

或者,您可以查看other ways以禁用Ripple的跨域请求。当我改变时,我可以毫无问题地从Cordova应用程序向AI发送遥测,就像文章中描述的那样 - 我完全按照你的描述完成,这就是我放置文件的方式。

enter image description here