Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document and recommend usage of the time parameter #18

Open
winhamwr opened this issue Dec 3, 2013 · 4 comments
Open

Document and recommend usage of the time parameter #18

winhamwr opened this issue Dec 3, 2013 · 4 comments

Comments

@winhamwr
Copy link
Owner

winhamwr commented Dec 3, 2013

Since the events are thrown on the queue (which might be delayed), folks should be using the time parameter to ensure that events are recorded as happening when they actually occurred.

time param docs

@dfejgelis
Copy link

In the Mixpanel docs, explain the use of Consumer classes to fix this. If I can implement it correctly, I'll try to send a pull request.

@winhamwr
Copy link
Owner Author

winhamwr commented Jun 4, 2015

Hello Diego,

If I can implement it correctly, I'll try to send a pull request.

That would be excellent!

-Wes

@dfejgelis
Copy link

Hey Wes, sorry but I won't be able to fix this.
I thought the lib used the official mixpanel python lib, which provide a Consumer class to send the information.

In my project, I've used this code, in case anybody would be interested.

import mixpanel

@shared_task
def async_mixpanel_consumer(consumer, endpoint, json_message):
    consumer.send(endpoint, json_message)

class CeleryConsumer(object):
    """
    Consumer class to Queue mixpanel.Consumer.send() into celery
    """
    def __init__(self):
        self.consumer = mixpanel.Consumer()

    def send(self, endpoint, json_message):
        async_mixpanel_consumer.delay(self.consumer, endpoint, json_message)

# Use CeleryConsumer instead of default consumer
mp = mixpanel.Mixpanel(MIXPANEL_TOKEN, CeleryConsumer())

# Then simply use the default track as the docs
mp.track(user_id, event_name, extra_props)

@winhamwr
Copy link
Owner Author

winhamwr commented Jun 4, 2015

the official mixpanel python lib

That totally didn't exist when this project was created, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants