Code Monkey home page Code Monkey logo

mixpanelcpp's Introduction

#Mixpanel C++ library

This is a barebones Mixpanel library for C++. It is currently only able to track normal mixpanel events and is not setup for Mixpanel People.

The library has two dependencies: libcurl and jsoncpp, which are provided in their respective subdirectories.

This library has been tested in Windows and OSX, and Visual Studio / Xcode projects are provided. For OSX, the Running from Xcode should be enough to build the project. For Windows, you first need to build jsoncpp (you can use the provided build_jsoncpp.bat script).

Usage

#include <mixpanel/eventbuffer.h>

void TrackMixpanel()
{
    Mixpanel::EventBuffer *eb = new Mixpanel::EventBuffer("MIXPANEL_PROJECT_TOKEN");
    Mixpanel::MP_ErrorCode err;
    // You can construct Json objects and pass them to the library
    Json::Value properties = Json::Value(Json::objectValue);
    properties["some_key"] = "some_value";
    // TrackEvent will automatically add the time and project token to the properties object
    err = eb->TrackEvent("some_event_name", properties);

    // Or you can just pass strings representing Json objects
    // err = eb->TrackEvent("some_other_event", "{\"distinct_id\" : \"some_id\"}");

    if (err == Mixpanel::MP_SUCCESS)
    {
        // event has been queued and will be tracked
    }

    delete eb;
}

Runnable sample

Example usage can be found in the mixpanelcppexample subdirectory with an Xcode and Visual Studio project. The example can be easily run in Xcode just by running the mixpanelcppexample target. For the Visual Studio project, copy the lib (and dll if building dynamically) from mixpanelcpp/lib/{CONFIG} to mixpanelcppexample/bin/{CONFIG}. Also, you will need to copy over the libcurl dll's into the same directory.

mixpanelcpp's People

Contributors

al63 avatar

Stargazers

Cédric Verstraeten avatar

Watchers

James Cloos avatar Jackson Owens 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.