Reputation: 10062
I have a webapp - I use google analytics and mixpanel for tacking.
Lately some users have registered but aren't appearing in mixpanel. I want to see if these users are blocking mixpanel / using disconnect.me.
If I use Disconnect.me myself, Chrome shows an error in the console but it is async to my
mixpanel.track
The error is appearing from (index):1 with no stacktrace
XMLHttpRequest cannot load https://api.mixpanel.com/engage/?data=eyIkcIjogeyIkbiTGludXgiLCIkY…2YiLCIkZGlY3RfaWQiOiAiY2hlb0YWtpcGkuY29n0%3D&ip=1&_=1396192302485. The request was redirected to a URL ('about:blank') which has a disallowed scheme for cross-origin requests.
so I can't catch it.
What Javascript code can I use to answer "is mixpanel connected?"
Upvotes: 2
Views: 1186
Reputation: 1806
You could simply emit a track event or something else and see if you get a response for mixpanel. Their HTTP spec shows what they respond. If you get a success you're connected.
Another solution that might fit you better though would be to proxy all mixpanel events. You simply send them from the JS lib via your server. I don't think disconnect will block that since it'll look like normal async requests to you server.
Upvotes: 1