Giter VIP home page Giter VIP logo

react-mixpanel's Introduction

React Mixpanel

Build Status

The project provides MixpanelProvider which uses mixpanel-browser to ease using Mixpanel in your React app.

Usage

Install with: npm i react-mixpanel --save

Then use it like you would use react-redux. In your root App.js:

  1. Import required modules:
import mixpanel from 'mixpanel-browser';
import MixpanelProvider from 'react-mixpanel';
  1. Initialize your Mixpanel instance:
mixpanel.init("YOUR_TOKEN");
  1. Render your app using MixpanelProvider:
ReactDOM.render(
    <MixpanelProvider mixpanel={mixpanel}>
        <App/>
    </MixpanelProvider>,
    document.getElementById('app')
);
  1. Then all child components will be able to use mixpanel from their context:
class App extends React.Component {
    componentDidMount() {
        this.context.mixpanel.track('App did mount.');
    }

    render() {
        return <span>This is the app!</span>;
    }
}
App.contextTypes = {
    mixpanel: PropTypes.object.isRequired
};

Note that you have to add contextTypes property to your component.

Example

You can play with included Simple Example in examples directory.

react-mixpanel's People

Contributors

neciu avatar alexeybondarenko avatar

Watchers

James Cloos avatar Andrew Dryga avatar  avatar  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.