samzilverberg / cordova-mixpanel-plugin

A Cordova Plugin that wraps Mixpanel's sdk
MIT License
78 stars 98 forks source link

Events are not showing up in Mixpanel #73

Closed vargaendre closed 7 years ago

vargaendre commented 7 years ago

Hi!

I am sending many events to Mixpanel, just recently switched to this plugin, was using the JS SDK before. What I noticed is that even though the init and track calls are successful (got "OK" in the successCallbacks) there's no network traffic to Mixpanel servers and I don't see any new events in Mixpanel either.

What could be the issue? What am I doing wrong?

samzilverberg commented 7 years ago

try pausing the app and resuming, thats the number 1 misunderstanding of ppl coming to native sdk from js lib.

if that doenst work, it could be lots of reasons, need more info than what you supplied to be able to help

sebaferreras commented 7 years ago

Another thing that you could try is to track several events (10 or more), because I've noticed that sometimes when I track an event, that data is not being sent immediately to Mixpanel, but if you track several events, that information is then shown in the dashboard without the need of pausing/resuming the app (probably the SDK has a queue or something like that, and sends the data collected locally after a certain amount of events).

vargaendre commented 7 years ago

Thank you for the quick answers!

So, I tried pausing and resuming the app, also created ~50 events but still no network traffic to mixpanel.com.

I am using the 3.1.0 version of this plugin, cordova 7.0.0. I deal with everything mixpanel-related in a separate service. I call the init function in $ionicPlatform.ready(), it calls the successCallback with message "OK", then I can get the distinctId from the plugin with no problems. Calling track() always results in a call to the successCallback with message "OK".

List of plugins I use:

branch-cordova-sdk 2.6.8 "branch-cordova-sdk"
cordova-android-support-gradle-release 0.0.2 "cordova-android-support-gradle-release"
cordova-fabric-plugin 1.1.9 "cordova-fabric-plugin"
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-crosswalk-webview 2.2.0 "Crosswalk WebView Engine"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-dialogs 1.3.3 "Notification"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
cordova-plugin-mixpanel 3.1.0 "Mixpanel"
cordova-plugin-network-information 1.3.3 "Network Information"
cordova-plugin-screen-orientation 2.0.2-dev "Screen Orientation"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-plugin-x-toast 2.6.0 "Toast"
es6-promise-plugin 4.1.0 "Promise"
phonegap-plugin-push 2.0.0 "PushPlugin"
uk.co.workingedge.phonegap.plugin.launchnavigator 4.0.4 "Launch Navigator"

What other info should I provide?

samzilverberg commented 7 years ago

the most basic info: what platform are you trying on? ios? android? on a real device? in emulator?

vargaendre commented 7 years ago

I am testing on my phone, Android 5, HTC One M7

samzilverberg commented 7 years ago

honestly i dont know and cant really help you remotely. its obviously not a plugin bug because its working for other (and me).

the "OK" message on the success callback just means the native sdk code was used successfully, nothing more... the native code itself(the mixpanel sdk) could still have some error of some kind which would only visible on adb logcat. I intend to try and improve it sometime, though i'm not sure its possible.

i can only advise to debug further:

vargaendre commented 7 years ago

Since I get the distinct id, I think the communication with the native sdk works to some extent. There's internet connection, I can reach my servers. I was checking network traffic through Chrome dev console. I'll give a try to adb logcat.

samzilverberg commented 7 years ago

good that you eliminated the network comm quickly, that can be an annoying thing, especially on ios :)

another thought: check that you init correctly with the right token for your mixpanel project.

FYI as far as i know getting distinctId doesnt require any internet connection, mixpanel sdk just generates it "offline".

vargaendre commented 7 years ago

Yes, distincId is basically the deviceUUID, so it's offline.

So, adb logcat | grep -i "mixpanel" shows that events are successfully sent to Mixpanel.

V/MixpanelAPI.Messages(24631): Flushing queue due to scheduled or forced flush (Thread 78731)
V/MixpanelAPI.Messages(24631): Average send frequency approximately 37 seconds. (Thread 78731)
V/MixpanelAPI.Message(24631): ConnectivityManager says we are online
V/MixpanelAPI.Message(24631): Attempting request to https://api.mixpanel.com/track?ip=1
V/MixpanelAPI.Messages(24631): Successfully posted to https://api.mixpanel.com/track?ip=1: 
(...)
V/MixpanelAPI.Messages(24631): Response was {"status": 1, "error": null} (Thread 78731)
V/MixpanelAPI.Messages(24631): Not retrying this batch of events, deleting them from DB. (Thread 78731)

I guess this is the expected log, isn't it? Does status: 1 mean everything's fine?

I don't know why I can't see the events in Mixpanel Live view or People view. Also, it's quite strange Chrome doesn't show any of the Mixpanel network traffic.

samzilverberg commented 7 years ago

chrome will not show you the network activity of the mixpanel sdk. the chrome console only spits out console.logs happening from the JS part of code, the network activity messages of mixpanel are lower level from the native sdk code.

i dont know if status 1 is ok, but error:null seems to imply it ;)

according to log everything seems fine from the plugin side. i'd suggest to check settings like mixpanel token, to check if your looking in the right project in mixpanel, check if you are over your quota (maybe your events are just ignored).

vargaendre commented 7 years ago

Makes sense.

I checked my token a million times, I get it from the project I'm looking at. I don't think we are over quota, since other events (from earlier versions of the app - still using JS SDK) are arriving. I think if I misspelled the token or something, the API would give an error.

Anyway, thanks a lot for your help! I am closing this issue as it seems I have a problem unrelated to your plugin.

samzilverberg commented 7 years ago

sorry i couldn't help more and good luck ! debugging these kind of issues are usually very frustrating! 😢

migburillo commented 6 years ago

@vargaendre did you find a solution?

I'm facing exactly the same after upgrading ionic and cordova plugins, and can not find any clue. The events are queued but never sent. Mixpanel token is correct and I'm using the same project in web platform, from which events are received correctly.

vargaendre commented 6 years ago

@migburillo I don't remember what was the solution. Looking at adb logcat helped quite a lot.

shawns582 commented 4 years ago

@samzilverberg First of thanks for this plugin! I am seeing this issue with an Ionic 3 app...any idea what might be causing it or how to fix? The SDK calls (init, track, etc) are reaching the success callbacks so it seems like it is working, but I am not seeing any data in Mixpanel.

shawns582 commented 4 years ago

turns out I was using the Api Key instead of the Token. All is working now. Hope this helps anyone else that might run into the same issue

Natnaelk commented 2 years ago

I am facing the exact problem. i'm using mixpanel_flutter 2.0.0.

rclong1221 commented 1 year ago

I am facing the exact problem. i'm using mixpanel_flutter 2.0.0.

Did you figure it out? Mine was working fine but has stopped collecting data for days. Same issue. Token is fine.

blakehawkins commented 11 months ago

I also have this issue (in mixpanel_flutter)

I turned on setLoggingEnabled and copied the json being sent by plugin and used it in a CURL request. With curl I got the same response back and still the event didn't show up.

Then I simplified the json and instead sent a minimal event. Got the same resposne from curl but this time the event showed up

It's clear that mixpanel backends aren't processing events reliably, either because they're accepting invalid events or because they're failing to process valid events.

I don't think this is a plugin problem.