GithubHelp home page GithubHelp logo

jpike88 / cordova-mixpanel-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facily-tech/cordova-mixpanel-plugin

0.0 0.0 0.0 1.57 MB

A Cordova Plugin that wraps Mixpanel's sdk

License: MIT License

Shell 0.18% JavaScript 49.70% Objective-C 47.25% Java 2.87%

cordova-mixpanel-plugin's Introduction

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 */})

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)
  • 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 alexeybondarenko avatar arneson avatar brunosfreitas avatar damienfa avatar eddyorzsik avatar eprochassoncag avatar guillenotfound avatar jonsmart avatar joshdover avatar jpike88 avatar jqrgen avatar julienroubieu avatar samzilverberg avatar sfeast avatar sircon avatar soupman99 avatar timanrebel avatar vrenan avatar walski avatar

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.