from mixpanel import Mixpanel from django.conf import settings from project.celery import app @app.task def transaction_to_mixpanel(user_id, amount, time, product_type): mix = Mixpanel(settings.MIX_TOKEN) mix.people_track_charge( user_id, amount, { '$time': time, 'product_type': product_type, } ) @app.task def product_payment_to_mixpanel(user_id, event_name, time, properties): mix = Mixpanel(settings.MIX_TOKEN) props = { '$time': time, } props.update(properties) mix.track( user_id, event_name, properties=props, )