0

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.

Paul
  • 437
  • 2
  • 14

1 Answers1

1

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":

enter image description here

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.

enter image description here

Community
  • 1
  • 1
Alex Bulankou
  • 2,396
  • 19
  • 21
  • It works in Ripple Chrome now. However, when I deploy the app in Android device, it shows the same error message again. I've researched for a while. Could you give me some hint on it? Thanks. – Paul May 25 '16 at 02:24
  • I'm not sure why it would work, since this tag is about navigation, not AJAX, but since apparently it worked for others, can you please add as recommended here: http://stackoverflow.com/questions/30060534/ajax-requests-fail-after-upgrading-to-cordova-5-0-cordova-android4-0 – Alex Bulankou May 26 '16 at 05:51