AceCentre / AACSpeakHelper

Copies the pasteboard. Translates to defined lang, Reads aloud and replaces pasteboard with translated text
https://docs.acecentre.org.uk/products/v/aac-speak-helper-tool/
MIT License
0 stars 1 forks source link

Add in potshog support #6

Closed willwade closed 1 year ago

willwade commented 1 year ago

https://posthog.com/docs/libraries/python

def read_or_generate_uuid(config_file, section, option):
    config = configparser.ConfigParser()
    config.read(config_file)

    if section in config and option in config[section]:
        return config[section][option]
    else:
        new_uuid = str(uuid.uuid4())
        config[section] = {option: new_uuid}

        with open(config_file, 'w') as configfile:
            config.write(configfile)
        return new_uuid
 from posthog import Posthog

def capture_event(event_name, properties={}):
    try:
       posthog = Posthog(project_api_key='phc_L5wgGTFZYVC1q8Hk7Qu0dp3YKuU1OUPSPGAx7kADWcs', host='https://app.posthog.com')
        # Attempt to send the event to PostHog
        posthog.capture(event_name, properties=properties)
        print(f"Event '{event_name}' captured successfully!")
    except posthog.RequestError as e:
        # Handle the case when there's an issue with sending the event
        print(f"Failed to capture event '{event_name}': {e}")
        # You can add further logic here if needed, such as logging the error or continuing the script

# Example usage
event_name = 'App Run'
event_properties = {'user_id': userID, 'source': 'app', from_lang:fromLan,to_lang:toLang,voice_emgine,engine}
capture_event(event_name, event_properties)