I use VS2015 to develop Cordova App with Application Insights.
I follow this article to integrate AppInsights and put this in onDeviceReady()
var snippet: any = {
config: {
instrumentationKey: "f2c1b11a-e3ec-4d3a-b96b-xxxxxxxx"
}
};
var init = new Microsoft.ApplicationInsights.Initialization(snippet);
var appInsights = init.loadAppInsights();
appInsights.trackPageView();
Things go well in init.loadAppInsights() but after running to appInsights.trackPageView(), I got the following error message:
AI (Internal): NONUSRACT_OnError message:"Failed to send telemetry." props:"{message:{}}"
I've checked that in index.html, https://dc.services.visualstudio.com is in 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 *">
And also Domain Access in config.xml allow * URI
Can someone help me to get Cordova work with AppInsights?
Much appreciated.
I believe the issue you're getting is caused by Cordova Ripple emulator failing to execute cross-domain request. Please set cross domain proxy setting to "disabled":
Alternatively you can look into other ways to disable cross-domain requests from Ripple. When I changed I can send telemetry to AI from Cordova app without issues, just like described in the article - I did exactly as you described, this is how I placed the files.