Hello :wave: Is it possible to use Mixpanel to tra...
# questions
Hello 👋 Is it possible to use Mixpanel to track events on a Github application that is utilized on the command line? • The application is written in python • I have followed the instructions here and created a tracking.py file as shown below ◦ I’m trying to create a mixpanel log in mixpanel.txt, the read that log and send events to mixpanel So far, my script is running without errors but no event is getting to Mixpanel. I have not used queuing before so it’s possible that some of my syntax in the script is not working as intended. I’m happy to pair with anyone who might have an idea on how to approach this/ has already done this
Copy code
import uuid
import requests
import os
import json

import mixpanel
from mixpanel import Mixpanel
from mixpanel import Consumer

class LoggingConsumer(object):
    def __init__(self):
        self.mp_log = open("MIXPANEL_LOG.txt", "w+")

    def send(self, endpoint, json_message, api_key=NONE ):
        self.mp_log.write("{0}::{1}\n".format(endpoint, json_message))

# Whenever you track with logging_mp, your messages will be written to MIXPANEL_LOG.txt rather than being sent to the Mixpanel servers
logging_mp = Mixpanel(MY_PROJECT_TOKEN, LoggingConsumer())

consumer = mixpanel.Consumer()
with open("MIXPANEL_LOG.txt", "r+") as read_log:
    for line in read_log:
        (endpoint, message) = line.split('::', 1)
        consumer.send(endpoint, message)
print('Log read')      

import multiprocessing
class EnqueueingConsumer(object):
    def send(self, endpoint, json_message, api_key='MY_MIXPANEL_PROJECT_API_KEY'):
        my_queue = queue.Queue()
        # Check why this queue won't work as expected.
        item= my_queue.put('mixpanel_queue', json.dumps([ endpoint, json_message ]))
        print(f'Working on {item}')
        print(f'Finished {item}')

mp = mixpanel.Mixpanel('MY_PROJECT_TOKEN', EnqueueingConsumer())

project_token = 'MY_PROJECT_TOKEN'
# mp = Mixpanel(token=project_token)
user_id = {'id': str(uuid.uuid1())}
    distinct_id = user_id,