Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cordova-plugin-mixpanel-remove-watchkit

honeyfi3MIT4.5.4TypeScript support: included

Mixpanel Cordova Plugin for iOS, Android and Browser Platforms

mixpanel, cordova, phonegap, ionic, plugin, ios, android, browser, ecosystem:cordova, cordova-android, cordova-ios

readme

FORKED ON May 8, 2020 by @stanjw4

Forked due to fix issue with Apple WatchKit references. The newer versions of this plugin do remove all of the WatchKit stuff, but upgrading the plugin adds Firebase stuff that creates other issues.

This fork is v5.4.5 minus all WatchKit references. Used this fork for inspiration:

https://github.com/laurant/cordova-mixpanel-plugin/commits/master

Cordova Plugin that wraps Mixpanel sdk for android and ios

Install

requires cordova >5.x.x

  cordova plugin add cordova-plugin-mixpanel-remove-watchkit

Optional: If you want to explicitly specify a google play services version to work with other existing plugins in your project, you can specify a flag PLAY_SERVICES_VERSION during installation. e.g. 11.8.0. If you don't provide this flag, it will assume the default '+' wildcard version

cordova plugin add cordova-plugin-mixpanel-remove-watchkit --variable PLAY_SERVICES_VERSION="11.8.0"

Initialization and quick start

init the plugin with your mixpanel project token with

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

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)
  • registerSuperProperties(superProperties, onSuccess, onFail)
  • registerSuperPropertiesOnce(superProperties, onSuccess, onFail)
  • reset(onSuccess, onFail)
  • timeEvent(eventName, onSuccess, onFail)
  • track(eventName, eventProperties, onSuccess, onFail)
  • unregisterSuperProperty(superPropertyName, onSuccess, onFail)

window.mixpanel.people:

  • append(appendObject, onSuccess, onFail)
  • deleteUser(onSuccess, onFail)
  • increment(peopleProperties, onSuccess, onFail)
  • initPushHandling(senderId, onSuccess, onFail) -- Android Only
    • NOTE: Only use this if you are not using another third party plugin (such as PhoneGap Push Plugin). This will create the GCM receiver for you and your push notifications will be fully handled within Mixpanel. For more information on this, take a look here.
  • setPushId(pushId, onSuccess, onFail)
    • More info about push notifications at:
    • Usage example using the PhoneGap Push Plugin:
      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)
  • 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 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

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 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

changelog

Changelog

4.5.4 2019-03-30

  • removed all watchkit references from src/ios

4.5.3 2019-03-30

  • update android lib from 5.4.4 to 5.4.5
  • update ios lib from 3.3.7 to 3.4.1

4.5.2 2018-12-27

  • update android lib from 5.4.1 to 5.4.4
  • update ios lib from 3.3.3 to 3.3.7

4.5.1 2018-12-27

  • mixpanel.people.initPushHandling : android only (thanks Todd Vrba)

4.5.0 2018-08-25

  • mixpanel.people.append
  • mixpanel.people.union
  • update android lib from 5.4.0 to 5.4.1
  • update ios lib from 3.3.2 to 3.3.3

4.4.1 2018-05-29

  • update android lib from 5.2.4 to 5.4.0
  • update ios lib from 3.2.3 to 3.3.2

4.4.0 2018-05-28 (DEPRECATED)

  • unpublished from npm due to bug

4.3.2 2018-05-29

4.3.1 2018-05-28 (DEPRECATED)

  • unpublished from npm due to bug

4.3.0 2018-04-24

  • play-services version can be pinned via variable when adding the plugin (thanks akhatri).
    • example: cordova plugin add cordova-plugin-mixpanel --variable PLAY_SERVICES_VERSION="11.8.0"
    • when not specifying variable default is '+' (as it was before)

4.2.0 2018-01-28

  • update android lib from 5.2.1 to 5.2.4
  • mixpanel.alias will use mixpanel.distinctId if originalId is invalid
  • mixpanel.alias can be called with just alias and callback functions
    • this variant of alias will call and use mixpanel.distinctId as the originalId

4.1.0 2017-12-09

4.0.0 2017-09-15

major version upgrade from 3.x->4.x:
reverted usage of cocoapods for ios lib installation, mixpanel source is included in repo.

  • update ios lib from 3.1.9 to 3.2.0
  • mixpanel.unregisterSuperProperty
  • mixpanel.getSuperProperties
  • mixpanel.registerSuperPropertiesOnce

3.1.0 2017-07-25

  • update android lib from 5.0.2 to 5.1.4
  • update ios lib from 3.1.4 to 3.1.9
  • remove the deprecated showSurvey fn
  • add faq entry for pod problems (thanks Daniel López)

3.0.1 2017-05-31

  • update ios lib from 3.1.3 to 3.1.4
    • 3.1.4 is supposed to solve the C99 dialect problems by replacing any dialect related code with more "vanilla" code
  • drop support for cordova version less than 5.x

3.0.0 2017-04-30

major version upgrade from 2.x->3.x: now using cocoapods for ios lib installation.

  • update android lib from 4.9.8 to 5.0.2
  • update ios lib from 3.0.6 to 3.1.3
    • use cocoapods to install the ios lib
  • remove survey functionality as its been removed in the mixpanel libs
  • specify engine requirements in package.json instead in plugin.xml

2.3.5 2017-04-30

  • C99 dialect build probs in UIImage+MPAverageColor.m:
    manual code fix for it until next mixpanel-iphone version is released
  • support for angulartics by setting __loaded after init (thanks mgregier)
  • update android lib from 4.9.6 to 4.9.8

2.3.4 2017-02-27

  • update android lib from 4.9.2 to 4.9.6
  • mixpanel.people.deleteUser (thanks Julien Roubieu)
  • browser platform: small improvement to error handling on MixpanelProxy.js (thanks Damien Fa)

2.3.3 2016-11-21

  • deprecated mixpanel.people.identify
    • mixpanel.identify will already set the id for use in tracking events and people api

2.3.2 2016-11-19

  • mixpanel.people.trackCharge (thanks Emmanuel Prochasson for providing the base)
  • mixpanel.people.unset

2.3.1 2016-11-19

  • republish because of accidental npmjs mistake

2.3.0 2016-11-19

  • update android lib from 4.9.1 to 4.9.2
    • NOTICE: 4.9.2 requires Google Play Services > 7.5.0
  • update ios lib from 3.0.0 to 3.0.6
    • ios 10 should now be supported in case anyone had problems with it

2.2.1 2016-08-09

  • android play services dependency as wildcard version to avoid conflict with other plugins (thanks ZiFFeL1992)

2.2.0 2016-07-31

  • update ios lib from 2.9.1 to 3.0.0 (thanks Timan Rebel)
  • update android lib from 4.7.0 to 4.9.1 and use maven repo (thanks Timan Rebel)
  • add TimeEvent methods (thanks Jon Smart)
  • add typescript declarations file (thanks Jon Smart)

2.1.0 2015-12-20

  • fix for distinctId by damienfa
  • browser platform supported (thanks Damien Fa)
  • update ios lib from 2.7.2 to 2.9.1
  • fix for flush timer not starting after init

2.0.1 2015-11-07

  • same as 2.0.0, just bumped it because of npm publish problem

2.0.0 2015-11-07

  • release on NPM to support cordova 5.x.x
    • install plugin via cordova add cordova-plugin-mixpanel
  • update android lib from 4.5.3 to 4.7.0 (thanks Simon Arneson)
  • more mixpanel functionality (thanks Justin Young)
    • mixpanel api:
      • showSurvey (only iOS currently)
    • mixpanel people api:
      • increment
      • setOnce

1.3.1 2015-10-17

  • fix registerPushToken functionality (thanks Steven Feaster)
    • use correct fn on android
    • fix data conversion of pushId on ios
    • rename it to setPushId to avoid confusion with 'registration' process

1.3.0 2015-09-24

  • more mixpanel functionality (thanks Josh Dover)
    • mixpanel api:
      • distinctId
      • registerSuperProperties
    • mixpanel people api:
      • registerPushToken
  • perform arguments checks in js instead in native code

1.2.1 2015-05-29

  • plugin.xml - dont use use 'android-minSdkVersion' preference

1.2.0 2015-05-26

  • plugin.xml - use 'android-minSdkVersion' smarter cordova preference instead of 'uses-sdk' (thanks Florian Holzhauer)
  • min required cordova-cli is now 3.5.0, to support the smart preference mentioned above

1.1.0 2015-05-11

  • basic mixpanel people api
    • identify
    • set

1.0.0 2015-04-19

  • basic mixpanel api
    • alias
    • flush
    • identify
    • init
    • reset
    • track