Giter VIP home page Giter VIP logo

cordova-mixpanel-plugin's Introduction

NOTE: unmaintained & looking for maintainers (since 07-2022)

First: This plugin works! so don't be afraid to try it.

I wasn't able to find any time in the last year (2022) to actively update the libs. It's gotten to the point that my dev env is not even setup correctly anymore (new computer) and I can't even find time to set it up properly anymore.

If anyone wants to continue maintaining this contact me.

Maintenance is pretty simple: just update the libs, cordova build android/ios to see that it works after the update, and maybe update the api a little once in a while.

If your'e interested but want to totally rewrite / refactor that's also fine by me. as long as you release as a major version so you don't break versions that are actively used.

Cordova Plugin that wraps Mixpanel sdk for android and ios

Install

Requires Cordova > 5.x.x

  cordova plugin add cordova-plugin-mixpanel

Initialization and quick start

Init the plugin with your mixpanel project token with

  mixpanel.init(your-token,
    function(){ /* successful init */ },
    function(){ /* fail */},
    trackAutomaticEvents)

and then followup with all your favorite mixpanel functionality.
mixpanel.track to track events.
alias or identify (depending on use case) to set the id for people events (after login or register).
people.set to set properties on the people entity identified before.
You can read more about mixpanel api in their reference: https://mixpanel.com/help/reference

Usage

window.mixpanel:

  • alias(aliasId, originalId, onSuccess, onFail)
    • also available as createAlias
  • alias(aliasId, onSuccess, onFail)
    • will use distinctId from mixpanel sdk as originalId
  • distinctId(function onSuccess(distinctId), onFail)
  • flush(onSuccess, onFail)
  • getSuperProperties(onSuccess, onFail)
  • identify(distinctId, onSuccess, onFail)
  • identify(distinctId, usePeople, onSuccess, onFail)
    • only affects ios: will pass usePeople to the ios mixpanel sdk identify method
  • init(token, onSuccess, onFail, trackAutomaticEvents)
    • trackAutomaticEvents only affects android, and defaults to true if not provided.
      trackAutomaticEvents indicates whether or not to collect common mobile events include app sessions, first app opens, app updated, etc.
  • registerSuperProperties(superProperties, onSuccess, onFail)
  • registerSuperPropertiesOnce(superProperties, onSuccess, onFail)
  • reset(onSuccess, onFail)
  • timeEvent(eventName, onSuccess, onFail)
  • track(eventName, eventProperties, onSuccess, onFail)
  • unregisterSuperProperty(superPropertyName, onSuccess, onFail)
  • setGroup(GroupKey, GroupId, onSuccess, onFail)
  • addGroup(GroupKey, GroupId, onSuccess, onFail)
  • removeGroup(GroupKey, GroupId, onSuccess, onFail)
  • setGroupKeyValue(GroupKey, GroupId, key, value, onSuccess, onFail)

window.mixpanel.people:

  • append(appendObject, onSuccess, onFail)
  • deleteUser(onSuccess, onFail)
  • increment(peopleProperties, onSuccess, onFail)
  • set(peopleProperties, onSuccess, onFail)
  • setOnce(peopleProperties, onSuccess, onFail)
  • trackCharge(amount, chargeProperties, onSuccess, onFail)
  • unset(propertiesArray, onSuccess, onFail)
  • union(unionObject, onSuccess, onFail)

Contributing and Testing

Contributions of all sorts to the source code are more than welcome. Any contribution will be noted in the changelog (for FAME! :-D ).

Please try to test your contributions using your cordova project or a dummy test project. You may use mine which i've published to NPM: https://www.npmjs.com/package/cordova-mixpanel-plugin-testapp

License Notice

All Mixpanel ios sdk source files under src/ios/Mixpanel are licensed under the apache license.
A copy of the license is located at src/ios/Mixpanel/LICENSE.

The rest of the code is MIT license, located at /LICENSE.

Troubleshooting

IOS

Hey I installed the plugin and now build fails, why?

Open your xcode proj, goto build phases -> link binary with libraries:

  • drag all files under folder 'frameworks' (on the left) to here
  • add the following if missing:
    • libicucore
    • cfnetwork

My build still fails, got a compile error at UIImage+MPAverageColor.m

If your got this error: "variable-sized object may not be initialized" from char colorIndices[kNumberOfHexColors] = {0};.
This is caused by compiler using a wrong C dialect (C99 for example).
To fix:

  • open your project in xcode
  • goto build settings tab
  • scroll down to "apple llvm 8.0 - language"
  • set "C language dialect" to be default

I get error 'Mixpanel' plugin not found, check config.xml

Appears to be some problem of the Xcode project settings.
Only working solution I found so far is to

cordova platform remove ios
cordova platform add ios
cordova build ios

and setting up the build phase correctly again, as described in last question.

Hey I'm on iOS>9 and nothing is happening, why?

Google for NSAppTransportSecurity.
Since iOS 9 they are more strict about what your app is allowed to connect to.
You will have to manually add some entries to your app plist file to allow network connectivity to mixpanel server.

Ionic Capacitor & Android

Manifest merger failed

If you get a similar message to this

ERROR: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
	is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-43:19 to override.

Open the build gradle for android, and in the section of allprojects add the following:

allprojects {
    ...

    configurations.all {
        resolutionStrategy {
            force "com.google.android.gms:play-services-base:16.0.1"
            force "com.google.firebase:firebase-messaging:18.0.0"
        }
    }
}

This will force to use those packages to use those specified versions (adapt the versions to the ones you use/wish). Capacitor is not compatible with androidx yet.

Keywords

mixpanel, plugin cordova, phonegap, ionic, android, ios

cordova-mixpanel-plugin's People

Contributors

akhatri avatar akrmr avatar alexeybondarenko avatar arneson avatar brunosfreitas avatar damienfa avatar eddyorzsik avatar eprochassoncag avatar guillenotfound avatar jonsmart avatar joshdover avatar jpike88 avatar jqrgen avatar julienroubieu avatar rubenpera avatar samzilverberg avatar sfeast avatar sircon avatar soupman99 avatar timanrebel avatar victorsosa avatar vrenan avatar walski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-mixpanel-plugin's Issues

Error in example?

Hey man, took a look at your readme. Is it an error that it says registerPushId in the example? Should it be setPushIdInstead? I got "not a function" when I copy pasted the example.

setPushId(pushId, onSuccess, onFail)

Usage example using the PhoneGap Push Plugin: var push = PushNotification.init({ 'android': {'senderID': ''}, 'ios': {'alert': 'true', 'badge': 'true', 'sound': 'true'} }); push.on('registration', function(data) { mixpanel.people.registerPushId(data.registrationId); });

Android identify function ignores new email as parameter

When I specify an email as parameter for identify it ignores it and uses a previous email for tracking events. If I append a space to the variable that contains the email address and pass that instead it works fine... but I don't want the email address to have a space appended to it because I want it to have the same unique ID for the desktop browser as well...

Essentially this does not work

window.mixpanel.identify(dEmail, mixpanelIdentifySuccess, mixpanelIdentifyFailure);

but this below does... note the appended space

window.mixpanel.identify(dEmail + ' ', mixpanelIdentifySuccess, mixpanelIdentifyFailure);

update to latest native sdks

android 4.9.2

with some PN enhancements.
NOTE this from changes logs:

Upgrade GCM and avoid using deprecated GCM APIs. Your Google Play Services library must be 7.5.0 or above

ios 3.0.3

adds support for ios 10

Double Mixpanel tracking in same application

As per Mixpanel Support team , they have said that the init function should be initialised twice (or more times depending on how many projects).

mixpanel.init("new token", { your: "config" }, "library_name");

init function for multiple projects

The 3rd parameter can take a library name (to differentiate between projects).

For three projects:

  • Project 1. Token: abc
  • Project 2. Token: def
  • Project 3. Token: ghi

The initialisations will be like this:

//initialize projects
mixpanel.init("abc",{},"project1");
mixpanel.init("def",{},"project2");
mixpanel.init("ghi",{},"project3");

To send data to project 1, project 2:

mixpanel.project1.track("sample event");
mixpanel.project1.track("sample event");

But I just notices that that cordova-plugin-mixpanel plugin has the init() defined as

mixpanel.init = function(token, onSuccess, onFail) {
if (!token || typeof token != 'string') {
return onFail(errors.invalid('token', token));
}
exec(onSuccess, onFail, 'Mixpanel', 'init', [token]);
};

So, I think mixpanel.init("new token", { your: "config" }, "library_name"); is not matching with the defined code in the plugin.

There is no way to initialise more than one project and track individual project tracking area.

So, can you please provide me a solution of this problem by updating the mixpanel plugin. I need it urgent.

Mixpanel tracing same event in diffferent places

We have one event that we need to track in different places for e.g find the Syncing start time and end time.

I placed the mix panel sync event in the sync start function and also in the success call back to capture the sync end time. But this get tracked as two events on the Mix panel. But we need that two properties (sync start time and end time) should capture in the same event call.

Could you please advice how do we do that?

Failed to load resource: net::ERR_FILE_NOT_FOUND

Hello!

Apologies if this has already been answered else where (or if it is a stupid one!) but this thing has me stumped.

I keep getting this issue
Failed to load resource: net::ERR_FILE_NOT_FOUND file://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js

This file: mixpanel-jslib-snippet.js references this //cdn.mxpnl.com/libs/mixpanel-2-latest.min.js

This file does exists here http://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js

I've tried modifying the jslib-snippet.js so it points to a http://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js

but this results in a ERR_CONNECTION_REFUSED

How can i reference the local version of mixpanel.min.js I am stumped

Thank you

window.mixpanel.identify(x) returns "invalid id" only for people who exist!

This is my first time with Mixpanel so this might be entirely my fault. However... on my server I create a user by doing (PHP):

    $mp->people->set(123, array(
        '$email' => $useremail
    ));

This goes ahead and creates a user in the panel. Yay!

However, now in my app, just after initialising Mixpanel, I do:

    window.mixpanel.identify(123)

This, unfortunately, calls the failure callback saying "invalid id: 123". If I change it to be a userid that doesn't exist, it works fine. If I call:

    window.mixpanel.people.identify(123)

it works fine. Am I misunderstanding how this thing works?

alias method is not working

I used following code

window.mixpanel.alias(userData.customerId, function() {
console.log("alias success");
}, function() {
console.log("alias fail");
});

but it not working for my project

Ionic 1 & Angular 1 - TypeError

Far after successfully -so it seems- initing mixpanel with
$ionicPlatform.ready( () => { if ( window.cordova ) { window.mixpanel.init( _TOKEN, function onSuccess(e){ }, function onFail(e){ }); } })
Any attempt to use a functionnality results in a "TypeError: (intermediate value) is not a constructor"
which is triggered in an angular function (from what i got reading this unrelated post https://stackoverflow.com/questions/42470961/function-prototype-bind-apply-meaning-not-understood)
function instantiate(Type, locals, serviceName) { // Check if Type is annotated and use just the given function at n-1 as parameter // e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]); var ctor = (isArray(Type) ? Type[Type.length - 1] : Type); var args = injectionArgs(Type, locals, serviceName); // Empty object at position 0 is ignored for invocation withnew, but required. args.unshift(null); return new (Function.prototype.bind.apply(ctor, args))(); }
The app is currently based on Ionic 1 and angular1.5.8. Is there any requirements on the versions of either of them ?
I'll be around if more details are required.

Mixpanel methods not working

Trying to create user profile in mixpanel but below methods are not working.
window.mixpanel.people:
set(peopleProperties, onSuccess, onFail)
setOnce(peopleProperties, onSuccess, onFail)

Installing the plugin asks for CocoaPods on Linux

Hi,

I have an app for two platforms, iOS and Android. I am mainly developing on Ubuntu, I only use a Mac for building for iOS.
When I run ionic plugin add [email protected] --save I get the following output:
Installing "cordova-plugin-mixpanel" for android
Subproject Path: CordovaLib
Installing "cordova-plugin-mixpanel" for ios
Failed to install 'cordova-plugin-mixpanel': undefined
Error: CocoaPods was not found. Please install version 1.0.1 or greater from https://cocoapods.org/

I am not sure if the plugin is actually installed for android. When I run the command again, I get an error that platforms/ios/Myapp/Plugins/cordova-plugin-mixpanel/MixpanelPlugin.m" already exists! so I guess it is installed. Still the error is not comforting.

Weird behaviour

I implemented Mixpanel in my app but for some weird reason mixpanel tracks only my phone, if I install it on another phone nothing gets sent to Mixpanel. Any idea what could cause this behaviour ?

I'm running on Android and the app is built on the latest Ionic framework.

People are not set

I have installed and used the plugin correctly. When I run window.init(...)and window.mixpanel.track(...) they both are registered by Mixpanel. However when I run, the next script then it does not work. The script is:

var u = {
    "id": 1,
    "$email": "user@email",
    ...
}
window.mixpanel.people.set(u, function () {
    console.log('people set Ok')
}, function (error) {
    console.log('people set Fail ' + error)
});

Nonetheless, I get this log: people set Ok

It does work if I use mixpanel.people.identify(user_id)however all the previous actions are lost.

Ionic 2 - Mixpanel.h not found on iOS

iOS build failed after adding this plugin.
Steps to reproduce (assuming there is an existing ionic 2 project),

  1. ionic plugin add cordova-plugin-mixpanel
  2. npm install --save @ionic-native/mixpanel
  3. ionic build ios

Build Error
"..........Plugins/cordova-plugin-mixpanel/MixpanelPlugin.h:3:9: fatal error: 'Mixpanel.h' file not found"
mixpanel h_not_found

Ionic Info
Your system information:

Cordova CLI: 7.0.1
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.1.14
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 1.1.4
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: OS X El Capitan
Node Version: v7.0.0
Xcode version: Xcode 8.2.1 Build version 8C1002

Any idea how to resolve this?

Can't see my data in mixpanel

Hi,

I unsuccessfully tried to use your plugin to track events and "add people" to mixpanel. I get no errors while initializing it.

Here's my code, I wrapped it in a mixpanel service :

init: function () {
                mixpanel.init(
                    "MY_API_KEY",
                    function (data) {
                        mixpanel.distinctId(
                            function(data){
                                mixpanel.identify(
                                    function(data){
                                        mixpanel.people.set({
                                            test : "test"
                                        },
                                            this.err,
                                            this.err
                                        );
                                    },
                                    this.err
                                )
                            },
                            this.err
                        )
                    },
                    this.err
                )
            },

Help, I'm starting to feel very very stupid.

Building iOS app its through the error in mixpanel

** BUILD FAILED **

The following build commands failed:

**CompileC build/CareShield.build/Debug-iphonesimulator/CareShield.build/Objects-normal/x86_64/UIImage+MPAverageColor.o CareShield/Plugins/cordova-plugin-mixpanel/Mixpanel/UIImage+MPAverageColor.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler

(1 failure)**

But its working in android

Push notifications not being marked as opened in Mixpanel Dashboard

Hi, thanks for such an amazing plugin!

We're using this plugin to send push notifications to both Android and iOS devices, and the notifications are being sent and received properly. The only thing we noticed, is that all these push notifications are not being marked as opened in the People/Notifications section.

Is there anything we should do when receiving a push notification, to let Mixpanel know that it was opened by the user? Maybe something related to the mp_campaign_id? (the url from Mixpanel where you can see the analytics related to each push notification is https://mixpanel.com/report/1234567/triggers/#analytics/2131180, being 2131180 the mp_campaign_id)

{
    additionalData {
        bar : "foo",
        coldstart : false,
        foo : "bar",
        foreground : true,
        google.message_id : "0:1001747124596863%9c7e33bbf9fd7ecd",
        mp_campaign_id : "2131180",
        mp_message_id : "1513200" 
    },
    message : "This is a test message"
}

We're using the 3.0.0 version of this plugin.

Conflict with Phonegap push plugin

When building an app with this plugin and with Phonegap push plugin I get the following error:

* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
   > For input string: "+"

Looks like this plugin tries to use a different version from the GoogleServicesPlugin than the push plugin. I don't know how to resolve this, there's a thread for this problem on the push plugin side: phonegap/phonegap-plugin-push#1718

Getting the SDK to work.

I've successfully gotten it to work on Android, but iOS I'm not having as much luck.

Everything is compiling fine, and window.mixpanel is defined, but no events are sending through, so I assume it's not the plugin is talking with the native library.

Here's my Link Binary With Libraries:

screen shot 2015-10-15 at 11 08 44 am

My Frameworks:

screen shot 2015-10-15 at 11 08 57 am

And my Compile Sources:

screen shot 2015-10-15 at 11 11 21 am
screen shot 2015-10-15 at 11 11 29 am

Not sure why it's not working.

re: error 'Mixpanel' plugin not found,

I was refactoring my code today and came across this error. Turns out it was ngCordva that was causing the error. When I remove ngCordva and roll with regular Cordova it works fine. Not sure what the issue is, but wanted to raise the flag at least.

window.mixpanel.track throws error "Uncaught SyntaxError: Invalid or unexpected token"

this is the code in my app.js in my ionic app related to mixpanel

var mixpanelTrackSuccess = function() {
   console.log('Mixpanel Track Success');
};

var mixpanelTrackFailure = function() {
   console.log('Mixpanel Track Failure');
};

var mixpanelIdentifySuccess = function() {
   console.log('Mixpanel Identify Success');
   window.mixpanel.track(“Opened Mobile App”, {"platform": "mobile app"}, mixpanelTrackSuccess, mixpanelTrackFailure);
};

var mixpanelIdentifyFailure = function() {
   console.log('Mixpanel Identify Failure');
};

var mixpanelInitSuccess = function(response) {
   console.log('Mixpanel Init Success');
   window.mixpanel.identify('[email protected]', mixpanelIdentifySuccess, mixpanelIdentifyFailure);

};

var mixpanelInitFailure = function(response) {
   console.log('Mixpanel Init Failure');
};

in ionic.Platform.ready

        ionic.Platform.ready(function() {

           window.mixpanel.init("5481a4bgh6ef4d52f6790474e222b89d6", mixpanelInitSuccess, mixpanelInitFailure);

this error only occurs when trying to perform track... When that line is commented init and identify works without issue

mixpanel_no_track
mixpanel_track

iOS: Undefined symbols for architecture i386

Trying to build with taco build ios, I get the following error message:

Undefined symbols for architecture i386:
"OBJC_CLASS$_WKInterfaceDevice", referenced from:
objc-class-ref in MixpanelWatchOS.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

Queuing the events

I have added the Cordova Mixpanel plugin (cordova plugin add cordova-plugin-mixpanel) to our Hybrid mobile app for event tracking.

Could you please clarify is this plugin handle queuing the events and sending them in batches (if its have no internet connection) or do we need to implement that separately?

NPE when opening the app

In some android devices, the app crashes on opening due to a mixpanel bug. This bug is reported to be solved in version 4.9.3, so I hope you can update library. Here is the conversation with support:

we are getting NullPointerException in android since we created some notifications. After removing them, problem has been solved. Ionic plugin is up-to-date, which includes api version 4.9.2. Here is the stacktrace:

01-26 11:37:52.108: V/MixpanelAPI.DecideUpdts(16759): Recording notification com.mixpanel.android.mpmetrics.InAppNotification@5b47d98 as seen.
01-26 11:37:52.138: V/MixpanelAPI.API(16759): Attempting to show mini notification.
01-26 11:37:52.140: D/AndroidRuntime(16759): Shutting down VM
01-26 11:37:52.143: E/AndroidRuntime(16759): FATAL EXCEPTION: main
01-26 11:37:52.143: E/AndroidRuntime(16759): Process: com.wefitter.app, PID: 16759
01-26 11:37:52.143: E/AndroidRuntime(16759): java.lang.RuntimeException: Unable to resume activity {com.wefitter.app/com.wefitter.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.mixpanel.android.mpmetrics.MixpanelAPI$People.append(java.lang.String, java.lang.Object)' on a null object reference
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3171)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3202)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.os.Handler.dispatchMessage(Handler.java:102)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.os.Looper.loop(Looper.java:152)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.ActivityThread.main(ActivityThread.java:5497)
01-26 11:37:52.143: E/AndroidRuntime(16759): at java.lang.reflect.Method.invoke(Native Method)
01-26 11:37:52.143: E/AndroidRuntime(16759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-26 11:37:52.143: E/AndroidRuntime(16759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-26 11:37:52.143: E/AndroidRuntime(16759): Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.mixpanel.android.mpmetrics.MixpanelAPI$People.append(java.lang.String, java.lang.Object)' on a null object reference
01-26 11:37:52.143: E/AndroidRuntime(16759): at com.mixpanel.android.mpmetrics.MixpanelAPI$PeopleImpl.trackNotificationSeen(MixpanelAPI.java:1641)
01-26 11:37:52.143: E/AndroidRuntime(16759): at com.mixpanel.android.mpmetrics.MixpanelAPI$PeopleImpl$4.run(MixpanelAPI.java:2053)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.Activity.runOnUiThread(Activity.java:5562)
01-26 11:37:52.143: E/AndroidRuntime(16759): at com.mixpanel.android.mpmetrics.MixpanelAPI$PeopleImpl.showGivenOrAvailableNotification(MixpanelAPI.java:1959)
01-26 11:37:52.143: E/AndroidRuntime(16759): at com.mixpanel.android.mpmetrics.MixpanelAPI$PeopleImpl.showNotificationIfAvailable(MixpanelAPI.java:1679)
01-26 11:37:52.143: E/AndroidRuntime(16759): at com.mixpanel.android.mpmetrics.MixpanelActivityLifecycleCallbacks.onActivityStarted(MixpanelActivityLifecycleCallbacks.java:32)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.Application.dispatchActivityStarted(Application.java:205)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.Activity.onStart(Activity.java:1155)
01-26 11:37:52.143: E/AndroidRuntime(16759): at org.apache.cordova.CordovaActivity.onStart(CordovaActivity.java:287)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1277)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.Activity.performStart(Activity.java:6306)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.Activity.performRestart(Activity.java:6352)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.Activity.performResume(Activity.java:6357)
01-26 11:37:52.143: E/AndroidRuntime(16759): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3156)
01-26 11:37:52.143: E/AndroidRuntime(16759): ... 8 more
01-26 11:37:52.147: D/AppTracker(16759): App Event: crash

Answer:

A very similar NPE was reported and fixed in v4.9.3: mixpanel/mixpanel-android#404

I think this patch might fix your crash too, although I can't be certain. Could you please upgrade and test?

This crash seems to occur when the Mixpanel People object has a null value for the distinct_id, so ensuring that you have called mixpanel.getPeople().identify() will prevent that.

In the patch you can see that we no longer track if the People distinct_id is null: https://github.com/mixpanel/mixpanel-android/pull/412/files#diff-179d9baf7f01397d18afff626dfe3f6dL295

That said, if a user is receiving in-app notifications, then you probably want them to be have a People distinct_id, so you should ensure that your app has called mixpanel.getPeople().identify(), in addition to mixpanel.identify()

If your app always calls mixpanel.getPeople().identify() then the People distinct_id will never be null.

You don't have to do it like this, but these are often the first 3 lines of Mixpanel code I write in an Android app...

MixpanelAPI mixpanel = MixpanelAPI.getInstance(this, projectToken);
mixpanel.identify(mixpanel.getDistinctId());
mixpanel.getPeople().identify(mixpanel.getDistinctId());

If upgrading to v4.9.3 doesn't fix the crash, please open a Github issue with the stacktrace and logs from a test using v4.9.3

`cordova build ios` fails after installing plugin

I get the following error after running cordova build ios:

** BUILD FAILED **


The following build commands failed:
	CompileC build/. . .build/Debug-iphonesimulator/. . ./Objects-normal/i386/UIImage+MPAverageColor.o . . ./Plugins/cordova-plugin-mixpanel/Mixpanel/UIImage+MPAverageColor.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Error: Error code 65 for command: xcodebuild with args: -xcconfig,. . ./platforms/ios/cordova/build-debug.xcconfig,-project,. . .xcodeproj,ARCHS=i386,-target,. . .,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=. . ./platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=. . ./platforms/ios/build/sharedpch

I'm on a Mac running 10.11.6.

$ cordova --version
6.5.0
$ node --version
v7.2.1
$ npm --version
3.10.10
$ cordova plugin list
cc.fovea.cordova.purchase 5.0.2 "Purchase"
cordova-plugin-actionsheet 2.2.2 "ActionSheet"
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-app-version 0.1.8 "AppVersion"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-dialogs 1.2.1 "Notification"
cordova-plugin-disable-bitcode 1.3.2 "DisableBitcode"
cordova-plugin-file 4.2.0 "File"
cordova-plugin-globalization 1.0.3 "Globalization"
cordova-plugin-google-analytics 0.8.1 "Google Universal Analytics Plugin"
cordova-plugin-icloudkv 0.4.1 "iCloudKV"
cordova-plugin-inappbrowser 1.4.0 "InAppBrowser"
cordova-plugin-mixpanel 2.3.3 "Mixpanel"
cordova-plugin-network-information 1.2.1 "Network Information"
cordova-plugin-screen-orientation 1.4.2 "Screen Orientation"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
cordova-plugin-x-socialsharing 5.0.12 "SocialSharing"
de.appplant.cordova.plugin.local-notification 0.8.4 "LocalNotification"

`Sam edited npm list out because it was looong and unrelated :)`

people.set() doesn't actually set properties

Hi. I'm currently facing the issue, that window.mixpanel.people.set({'propertyName':'value'}) doesn't actually set value to the property propertyName. Events are being tracked properly. If I pass a success-callback, it will be called instantly, so no error messages which I could deliver.

Edit: Also, "last seen" is set to "two weeks ago", but the latest tracked event for that user appears to be only a few minutes ago.

Plugin cannot be installed

I get this error when trying to install.

cordova plugin add cordova-plugin-mixpanel

Installing "cordova-plugin-mixpanel" for android
Subproject Path: CordovaLib
Installing "cordova-plugin-mixpanel" for ios
Failed to install 'cordova-plugin-mixpanel': Error: pod: Command failed with exit code 1
at ChildProcess.whenDone (/my project/platforms/ios/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

registerPushToken problems

@samzilverberg & @joshdover I haven't been able to get the new push API to work & I have some feedback & observations on it:

  1. It's not clear how it's to be used & the function naming is unclear. The JS API registerPushToken calls for a "Push Token" but on Android the MixPanel API it's leveraging is initPushHandling which requires a 12 digit GCM Sender ID & on iOS it expects a device token that comes from the native didRegisterForRemoteNotificationsWithDeviceToken callback. The point is that not only is it non-obvious but these are two quite different approaches - one is looking for a token tied to a specific instance of the app (iOS) & the other is looking for a high level developer account based id (GCM).

  2. In the iOS implementation there is the following code:

NSData* deviceToken = [[command.arguments objectAtIndex:0] dataUsingEncoding:NSUTF8StringEncoding];

But as far as I know this won't properly convert the device token from NSString to an NSData representation that can be used by mixpanel. Specifically I tried & it didn't - which resulted in being unable to send pushes. Not sure how this could have ever worked?

  1. For whatever reason I was unable to get the Android implementation to work. It just never added a device push id to a mixpanel users profile. Maybe this was something specific to my app not sure. Either way I'm thinking there may be a better approach here, see #4.

  2. Thinking a better approach for Android would be to use Mixpanel's setPushRegistrationId function. This would make this plugin's push strategy more consistent since setPushRegistrationId takes a push registration ID that is similar to what the iOS implementation expects. Also, while this is not territory I'm very familiar with, I think this approach on Android will also give more flexibility to the app developer using the plugin, see https://mixpanel.com/help/reference/android-push-notifications#advanced. Since it sounds like when using initPushHandling you are expected to basically let Mixpanel handle all GCM & not mix in your own handling of these messages, which I think is not acceptable to those doing more sophisticated things with push.

4a) As an added bonus to using the approach in #4 it becomes a perfect fit for the standard Phonegap Push Plugin - https://github.com/phonegap/phonegap-plugin-push This plugin can be used to get the push registration id to pass to this plugin's push API & it can be used to manually handle any push events as well.

I've got a tested fork with these changes and I'll submit a pull request in case you guys think this sounds like a good idea. Let me know if you have any feedback, issues, etc.

Mixpanel is not being added to the window object in browser

I'm using this plugin with Ionic and I am getting a mixpanel as undefined error. How do you think I can fix this? I am using ionic version 1.7.15 and cordova version 6.1.1. It works on emulator and device but not when you run ionic serve.

Product / Archive -> clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm working on an Ionic2 app, and installed the plugin through Ionic Native (using cordova-plugin-mixpanel 3.0.0 "Mixpanel"). On Android everything works great, but on iOS first I was getting this error when trying to build the app:

ios_mixpanel

Please notice that I'm opening the *.xcworkspace file in Xcode instead of the *.xcodeproj file.

I've tried by building both Mixpanel-AppExtension and Pods-{app name} from Product/Scheme and then I was able to build the app successfully.

scheme_mixpanel

But after that, I get the same error when trying to Archive the app. Do you happen to know what could be wrong on my end?

I really appreciate any help you can provide.

Track not associated to ID in android

When I create a track after I've identified someone the tracking events don't show up in the user's track history. The tracked item DOES show up in the segmentation data though. Only an issue on android, works as expected on iOS. Could this be an SDK issue?

mixpanel.people.identify(ionic.Platform.device().uuid)
mixpanel.track('Account Created', {'Account Type':'Paid'});

Initialisation & Setup

Apologies if this is a noob question, but who do you initialise this plugin?

I can't seem to find how to connect this to my Mixpanel account using my API Key etc.

I'm using Ionic :)

Compile Issue: storyboard + xdk

Hi,

I am getting the compile error when I compile on ios. It seems to be a known issue when I look at the codova-mixpanel-ios

The following build commands failed:
CompileStoryboard xxx/Resources/MPNotification.storyboard
CompileStoryboard xxx/Resources/MPSurvey.storyboard

Any chance you will resolve this.

This was using XDK and cli 5.1.1

mixpanel.people.set not working on Android

Hi,

I implemented the plugin in my project a while ago and noticed that only iOS users get registered as people on Mixpanel, not Android users though. It seems mixpanel.people.set and mixpenal.people.setOnce does not register any users on Android.
mixpanel.track works without any issues.
I am using the PGB 6.0.0 (tried also 5.2.0) without success.
For now, instead of the plugin, I embedded the JS snippet for Android, which though does not allow me register Push registrationID and also only records browser meta data instead of phone device and OS data.
Thanks for help!

Push Notification is not working in Mixpanel.

I am implementing ionic2 app. I have setup mix panel and push notification plugin. But I can't get the push notification if I send through mix panel. I get a push notification using firebase console.

This is my code:

    onMixpanelSuccess(resp) {
        console.log("Mixpanel init");
    }
    onMixpanelError(resp) {
        console.log("Mixpanel init Error");
    }
    mixpanelInit() {
        this.mixpanel.init(this.mixpanelToken)
          .then(this.onMixpanelSuccess)
          .catch(this.onMixpanelError);
        this.mixpanelPeople.setPushId(this.PushToken);
    }

Conflicting with phonegap-plugin-push

Hi Team,

We are already using device to device push notification in our app but once after we installed the "cordova-mixpanel-plugin", we could not receive any notifications including our own device to device notification our android devices.

Please advice

Thanks,
Janakiraman

init bug in SDK is preventing queues from flushing

This issue in the iPhone SDK is rendering the plugin useless:
mixpanel/mixpanel-iphone#241

The issue report lists a workaround that could be implemented in this plugin, or one could simply set up a timer in the cordova app and call mixpanel.flush() once per minute (that's the default that happens inside the SDK).

I believe that it's fine to just blindly try the flush() once per minute, regardless of connection state... I think the mixpanel SDK does this internally & if the app isn't connected, it keeps the events around and just tries again a minute later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.