Skip to content

teamvio/cordova-mixpanel-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova Plugin that wraps Mixpanel sdk for android and ios

Install

for cordova version > 5.x.x:
  cordova plugin add cordova-plugin-mixpanel

older versions:
  cordova plugin add https://github.com/samzilverberg/cordova-mixpanel-plugin.git

Usage

window.mixpanel:

  • alias(aliasId, originalId, onSuccess, onFail)
    • also available as createAlias
  • distinctId(function onSuccess(distinctId), onFail)
  • flush(onSuccess, onFail)
  • identify(distinctId, onSuccess, onFail)
  • init(token, onSuccess, onFail)
  • registerSuperProperties(superProperties, onSuccess, onFail)
  • reset(onSuccess, onFail)
  • track(eventName, eventProperties, onSuccess, onFail)
  • showSurvey(onSuccess, onFail) currently only iOS
    • by default the SDK attempts to show any available survey at app launch. If you'd like to trigger a survey after a particular action though use this.

window.mixpanel.people:

  • increment(peopleProperties, onSuccess, onFail)
  • setPushId(pushId, onSuccess, onFail)
      var push = PushNotification.init({
          'android': {'senderID': '<GCM Sender ID>'},
          'ios': {'alert': 'true', 'badge': 'true', 'sound': 'true'}
      });
      push.on('registration', function(data) {
        mixpanel.people.setPushId(data.registrationId, function onSuccess(){}, function onFail(){});
      });
    
  • set(peopleProperties, onSuccess, onFail)
  • setOnce(peopleProperties, onSuccess, onFail)
  • trackCharge(amount, chargeProperties, onSuccess, onFail)
  • unset(propertiesArray, onSuccess, onFail)

TODOs

  • add more Mixpanel People operations
    • unset, delete (more?)
  • make sure ios/android use same error messages
  • refactor ios code
    • remove code duplication of checking that mixpanel was init

Contributing and Testing

contributions of all sorts to the source code are more than welcome. any contribution will be noted in the changeslog (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

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 proj 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 iOS9 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.

Android

my build fails, wat? why?

mixpanel lib depends on google play services 3.1 or higher.
you can install this through the android sdk under extras category.
FYI this plugin registers a dependency on ANY version of play services so it doesnt conflict with other plugins in any way.

Keywords

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

About

A Cordova Plugin that wraps Mixpanel's sdk

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 71.5%
  • JavaScript 27.2%
  • Java 1.3%