okgrow / analytics

UNMAINTAINED! - Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor
https://atmospherejs.com/okgrow/analytics
MIT License
213 stars 61 forks source link

Not working on iOS #115

Closed v3rron closed 8 years ago

v3rron commented 8 years ago

I'm on a latest Meteor 1.3 version. The package works perfectly fine on the browser and I can see all the events in my Mixpanel, however when I make a build for iOS, it doesn't send any data from iPhone.

After a lot of research and reading on the issue, I thought that the problem is hidden inside NSAppTransportSecurity introduced in iOS 9. So I followed this http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http and whitelisted mixpanel.com and mxpnl.com domains with their subdomains. I also switched on the Allow Arbitrary Loads option.

But still not getting any data for Mixpanel from iOS simulator or actual device.

My settings.json looks like this:

{
  "public": {
    "analyticsSettings": {
      "Google Analytics" : {"trackingId": "UA-xxxxxxxxxx-x"},
      "Keen IO"          : {"projectId": "xxxxxxxxxxxxxxxx", "writeKey": "xxxxxxxxxxxxxxxxxx"},
      "Mixpanel"         : {"token":  "xxxxxxxxxxxxxxxxxx", "people": true}
    }
  }
}

PS: also, maybe I didn't get the documentation right, but I'm not getting any Google Analytics or Keen.io data even from the browser when calling analytics.track("My Event", { custom: "data" }) function. Is this function supposed to send data to all providers at once?

PPS: I'm not using browser-policy package.

xjonsson commented 8 years ago

Having the same issue on Android, i think it could be a Meteor 1.3 issue with mobile devices. Currently using Google Analytics. Works fine on desktop.

pauldowman commented 8 years ago

Thanks for reporting it, we'll take a look.

@v3rron you said "The package works perfectly fine on the browser" but you also said "I'm not getting any Google Analytics or Keen.io data even from the browser when calling analytics.track("My Event", { custom: "data" }) function", can you give a bit more detail about what's working and what isn't?

Thanks.

v3rron commented 8 years ago

@pauldowman my bad, Google Analytics actually works on browser. I started seeing users activity a couple hours later.

I only signed up for 3 services, Keen.io, GA and Mixpanel. I'm only finding Mixpanel useful so far, Google Analytics UX/UI is horrible and not user friendly. I couldn't find the events I sent from my app to Google Analytics, only User Activity.

Keen.io still not getting any events, even though I provided right project_id and write_key.

AnthonyAstige commented 8 years ago

I'm also not seeing data reported from an android app build.

Works fine from browsers (chrome on desktop and android).

Feels like an issue with Cordova maybe.

Debugging

Watching my physical Android device with Android Studio >> Tools >> Android Device Monitor >> LogCat I think an error like this comes up whenever I click a link

06-14 09:29:03.144: E/chromium(5951): [ERROR:xwalk_autofill_client.cc(172)] Not implemented reached in virtual void xwalk::XWalkAutofillClient::OnFirstUserGestureObserved()

screenshot from 2016-06-14 09-30-34

I don't know enough to say right away if / how this would be exactly related.

Environment details

JWPapi commented 8 years ago

Could be because of missing Access Rules:

https://docs.meteor.com/api/mobile-config.html#App-accessRule

JWPapi commented 8 years ago

Im pretty Sure its bc of the Access Rulles you need to:

App.accessRule('http://www.google-analytics.com'); App.accessRule('https://stats.g.doubleclick.net');

Can be closed!

v3rron commented 8 years ago

@JWPapi my current accessRule is:

// Bugfix for Meteor 1.2 on Android
App.accessRule("blob:*");
// source for analytics
App.accessRule('http://api.mixpanel.com/*');
App.accessRule('http://www.google-analytics.com');
App.accessRule('https://stats.g.doubleclick.net');

but still not working

JWPapi commented 8 years ago

Are you on the newest meteor ? Did you use YOUR Tracking Code ? Not the example one ? Also it might happen that the first Pageview is not counted ? Also which router are you using ?

arrygoo commented 8 years ago

I wasn't able to reproduce this issue on Meteor 1.3.3 with IOS Using this branch which has the examples in 1.3.3 .

I just ran the example app on iPhone and immediately saw page views on GA.

@v3rron Responding your first question, analytics.track("My Event", { custom: "data" }) should trigger an event in all of them. I just tried it and it showed up in my GA under Realtime/Events.

If you want to check the documentation, checkout Segment.io's docs, which is the library that we are wrapping.

@JWPapi's questions are heading the right direction. Those might be the cause of your issue.

AnthonyAstige commented 8 years ago

I've recompiled and it now works showing in Google Analytics Real-Time Overview results pretty much instantly between clicking links on the Cordova Android app.

I think the only newly notable environment variables in the context of my above comment is:

cfnelson commented 8 years ago

@v3rron Could you let us know if their is a bug still effecting you ? We have been unable to reproduce.

arrygoo commented 8 years ago

Closing this. Please re-open if it's still occurring.

v3rron commented 8 years ago

Yes, unfortunately this is still occuring for me. I'm on METEOR@1.3.5.1 now. Even updated this package to v2.0.0. Same thing. Only getting analytics to Mixpanel through browser but not from iOS/Android apps. My mobile-config settings:

// Bugfix for Meteor 1.2 on Android
App.accessRule("blob:*");
// source for analytics
App.accessRule('http://api.mixpanel.com/');
App.accessRule('https://api.mixpanel.com/');
App.accessRule('http://www.google-analytics.com');
App.accessRule('https://stats.g.doubleclick.net');

// Set PhoneGap/Cordova preferences
App.setPreference('StatusBarOverlaysWebView', 'false');
App.setPreference('StatusBarStyle', 'default');
App.setPreference('StatusBarBackgroundColor', '#f9f9f9');
App.setPreference('AutoHideSplashScreen', 'true');
App.setPreference('ShowSplashScreenSpinner', 'false');
App.setPreference('android-minSdkVersion', '19');

I'm using kadira/flow-router, and this is my list of packages:

# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base             # Packages every Meteor app needs to have
mobile-experience       # Packages for a great mobile UX
mongo                   # The database Meteor supports right now
session                 # Client-side reactive dictionary for your app
tracker                 # Meteor's client-side reactive programming library

es5-shim                # ECMAScript 5 compatibility for older browsers.
ecmascript              # Enable ECMAScript2015+ syntax in app code

logging
reload
random
ejson
check
service-configuration
fastclick
accounts-password
crosswalk

matb33:collection-hooks
aldeed:collection2
reywood:publish-composite
tmeasday:publish-counts

mystor:device-detection
mvrx:bluebird
mizzao:timesync
alanning:roles
fourseven:scss
semantic:ui
mdg:reload-on-resume
mixmax:smart-disconnect
jparker:crypto-md5
richsilv:owl-carousel
cfs:standard-packages
cfs:gridfs
cwaring:modernizr
infinitedg:gsap
mcbrumagin:jquery-requestanimationframe
cfs:ui
flemay:less-autoprefixer
static-html
cunneen:mailgun
yogiben:pretty-email
wizonesolutions:canonical
numtel:cfs-image-resize

meteorhacks:sikka

verron:paginated-subscription
verron:autosize
accounts-ui
standard-minifier-js
stevezhu:lodash
aldeed:simple-schema
react-meteor-data
kadira:flow-router
meteorhacks:kadira
mizzao:user-status
heysailor:accounts-facebook-cordova
raix:push
okgrow:analytics
standard-minifier-css
force-ssl

PS: All the API keys are correct, because they work from Chrome/Safari browsers

jamielob commented 8 years ago

Hi @v3rron, could you provide us with a minimal repo that reproduces the issue?

nschulte commented 8 years ago

Not working for me either on Cordova. Using GA and Mixpanel, neither work on Cordova, but both work on browser. Using Galaxy as host.

Meteor v1.4.1.1 okgrow:analytics v2.0.0 App.accessRule("http://*.google-analytics.com/*"); App.accessRule("https://*.google-analytics.com/*"); App.accessRule("https://stats.g.doubleclick.net/*"); App.accessRule("http://stats.g.doubleclick.net/*"); App.accessRule("http://api.mixpanel.com/*"); App.accessRule("https://api.mixpanel.com/*"); App.accessRule("https://cdn.mxpnl.com/*"); App.accessRule("http://cdn.mxpnl.com/*");

"public": { "analyticsSettings": { "Google Analytics": { "trackingId": "_id_" }, "Mixpanel": { "token": "_token_" } }, }

bergjs commented 7 years ago

I'm having the same issue. Intercom works on iOS, browser and when running on Android in development. But when I build the app it does not work on Android anymore. Did anyone find a solution for this?

bergjs commented 7 years ago

I set up a minimal repo and I can reproduce the issue there. Please give it a try.

Working part

git clone https://github.com/bergjs/analytics-test.git

cd analytics-test

npm install

meteor --settings settings.json

The app should start and should show the Intercom widget. Clicking on "Launch Intercom" should work.

Not working part

Now the production build for Android:

Create a key:

keytool -genkey -alias analytics-test -keyalg RSA -keysize 2048 -validity 10000

Build, sign and pack:

npm run 1-build

npm run 2-sign-android

npm run 3-pack-android

Install it on your device. Here the widget is not showing and clicking on the link has no affect.

bergjs commented 7 years ago

I had to add the cordova-plugin-whitelist package and set the correct access rules. Using the hint from @AnthonyAstige (Android Studio >> Tools >> Android Device Monitor >> LogCat) and filtering for "whitelist" I found all the urls that were still blocked. This is the relevant part of my mobile-config.js

App.accessRule('https://js.intercomcdn.com/*');
App.accessRule('https://static.intercomcdn.com/*');
App.accessRule('https://api-iam.intercom.io/*');
App.accessRule('https://widget.intercom.io/*');
App.accessRule('https://nexus-websocket-a.intercom.io/*');
App.accessRule('https://nexus-websocket-b.intercom.io/*');
App.accessRule('https://api.segment.io/*');

This cost me so much time that I think it would be great if it was mentioned in the readme somewhere that you need to set up the correct access rules for Android.

cfnelson commented 7 years ago

@bergjs Thanks for the detailed response and providing your solution for others. We would be happy to accept a PR from yourself updating the Readme (otherwise we will update it this Friday). I think it would belong after the Browser Policy section.

bergjs commented 7 years ago

Happy to help: https://github.com/okgrow/analytics/pull/171