Skip to main content

An async client for mixpanel.

Project description

Tornado Mixpanel is an async library for Mixpanel service. This library allows for server-side integration of Mixpanel.

Installation

Automatic installation:

$ pip install tornado-mixpanel

Tornado Mixpanel is listed in PyPI and can be installed with pip or easy_install.

Manual installation: Download the latest source from PyPI.

tar xvzf tornado-mixpanel-$VERSION.tar.gz
cd tornado-mixpanel-$VERSION
python setup.py build
sudo python setup.py install

The Tornado Mixpanel source code is hosted on GitHub.

Example

Here is a simple example:

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

import traceback
from tornado import gen, ioloop
from tornado_mixpanel.client import AsyncMixpanelClient


@gen.coroutine
def run():
    client = AsyncMixpanelClient('<mixpanel-token>')
    raw_input('Press (enter) to continue...')

    try:
        r = yield client.track(
            'user-xxxx', 'steps', {'step_one': True, 'step_two': False})
        print r

        r = yield client.people_set(
            'client-xxxx', {'fullname': 'Alejandro Bernardis'})
        print r

        r = yield client.people_append(
            'client-xxxx', {'age': 31, 'locale': 'es_AR'})
        print r

    except:
        print traceback.format_exc()

    ioloop.IOLoop.current().stop()


if __name__ == '__main__':
    run()
    ioloop.IOLoop.instance().start()

And buffer example:

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

import time
import traceback
from tornado import gen, ioloop
from tornado_mixpanel.client import AsyncMixpanelClient


@gen.coroutine
def run():
    client = AsyncMixpanelClient('<mixpanel-token>', True)
    raw_input('Press (enter) to continue...')

    try:
        username = int(time.time())
        print 'Tracking...'

        for i in xrange(10):
            yield client.track(username, 'item_%s' % i, {'i': i})
            time.sleep(1)
        print '-*-' * 20

        r = yield client.consumer.flush()
        print r

    except:
        print traceback.format_exc()

    ioloop.IOLoop.current().stop()


if __name__ == '__main__':
    run()
    ioloop.IOLoop.instance().start()

License

The MIT License (MIT)

Copyright (c) 2015 Alejandro Bernardis and contributors. See AUTHORS for more details.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tornado-mixpanel-0.2.tar.gz (9.2 kB view details)

Uploaded Source

File details

Details for the file tornado-mixpanel-0.2.tar.gz.

File metadata

File hashes

Hashes for tornado-mixpanel-0.2.tar.gz
Algorithm Hash digest
SHA256 e14bb67febbc9ee20eccfb35cc28d1deee561f49216225815abd8a077bff4479
MD5 664b84163c46aa895a4cbe34f806490b
BLAKE2b-256 d6f2c0c39b53777a6cb1703dfa7fd165d57fe0dd565442a59586ce305c567184

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page