aws / aws-sdk-mobile-analytics-js

Amazon Mobile Analytics JavaScript SDK
Apache License 2.0
82 stars 38 forks source link

Ioinic with Cordova: Data doesn't appear in the web dashboard #14

Closed stevmachine closed 7 years ago

stevmachine commented 8 years ago

I have been using the aws-sdk-mobile-analytics package with an app based on Ionic#1.2.4 with Cordova i'm able to send events and custom metrics . From console can be displayed as events increase, however the data or information sessions do not appear in the web dashboard for the Ionic app.

I try examples with browser : https://jsfiddle.net/stevmachine/hv4v59c3/ , and thats works wells. I try too an implementation using ionic with the browser and works too.

I've been reviewing the forum and I have been careful in order to settings the AMA.Client, or putting the secrets IDs. I add <access origin="*" /> in config.xml. Something like this tutorial: https://mobile.awsblog.com/post/TxCMBFPXR2XWOF/Use-Amazon-Mobile-Analytics-with-your-JavaScript-enabled-apps.

The info i got when i send the submit event from Ionic App in Chrome: image

image

There is a problem with this request?, maybe something with the headers in cordova?.

My list of plugins installed:

image

I suppose its something with the whitelist so i try this in config.xml

    <access origin="*" />

And in the index.html

    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
stevmachine commented 8 years ago

Its seem is necessary put this info in the meta, the script-src i suppose?, this works but i want to know why

<meta http-equiv="Content-Security-Policy" content="default-src 'self' * data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' localhost:35729 * 'unsafe-eval''unsafe-inline';">`

johnborges commented 8 years ago

I'm experiencing the same issue, however adding the Content-Security-Policy doesn't solve the problem for me. My understanding is that CSP is optional and if you don't use it, the app falls back to the whitelist configuration in config.xml. My network traffic looks correct:

HTTP POST 202 _session.start HTTP POST 202 Custom event HTTP POST 202 _session.stop

Nothing showing in the management console though.

johnborges commented 8 years ago

Solved my issue above! I was sending an invalid platform string which wasn't being picked up by the graphs. Platforms must match one of the five listed: 'Android', 'iPhoneOS', 'WindowsPhone', 'Blackberry', 'Windows', 'MacOS', or 'Linux'.

cheruvian commented 7 years ago

Glad you were able to resolve the issue. A list of valid platforms can be found listed in the README