#!/usr/bin/env python
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__),'..'))

from papika.client import *

def run_test():
    release_id = 'de4b98ad-3f9a-4aa9-ba7a-9f8cd80eab6e'
    release_key = b'\<KEY>'

    tc = TelemetryClient('http://localhost:5000', release_id, release_key)

    user_id = tc.query_user_id(
        username='pika',
    )
    print("User id: %s" % user_id)

    condition = tc.query_experimental_condition(
        user_id=user_id,
        experiment_id='00000000-0000-0000-0000-000000000000',
    )
    print("Condition: %d" % condition)

    savedata = tc.query_user_savedata(
        user_id=user_id
    )
    print("Save data: %s" % savedata)

    tc.send_user_savedata(
        user_id=user_id,
        savedata={"I'm some":["save","data"]}
    )

    root_logger = tc.log_session(
        user_id=user_id,
        detail={'im':'some data', 'with':[2,'arrays']},
    )

    root_logger.log_event(Event(category_id=1, type_id=23, detail={'Im':['An', 'Event']}))

    task_logger = root_logger.start_task(
        event=Event(category_id=0, type_id=2, detail="I'm a task start"),
        group_id='586c3a14-3659-4975-a28e-d88811a4632b'
    )

    task_events = [
        (2, 10, 'task event 1'),
        (2, 432, 'task event 2'),
        (2, 4, 'task event 3'),
    ]

    for (c, t, d) in task_events:
        task_logger.log_event(Event(category_id=c, type_id=t, detail=d))

    root_events = [
        (1, 62, {'A Different':[None, False, 'Event']}),
        (4, 23, 'blahblahblablablhablhablhahah'),
    ]

    for (c, t, d) in root_events:
        root_logger.log_event(Event(category_id=c, type_id=t, detail=d))

    tc.flush_events()

run_test()


#!/usr/bin/env python
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__),'..'))

from papika.client import *

def run_test():
    release_id = 'de4b98ad-3f9a-4aa9-ba7a-9f8cd80eab6e'
    release_key = b'\<KEY>'

    tc = TelemetryClient('http://localhost:5000', release_id, release_key)

    user_id = tc.query_user_id(
        username='pika',
    )
    print("User id: %s" % user_id)

    condition = tc.query_experimental_condition(
        user_id=user_id,
        experiment_id='00000000-0000-0000-0000-000000000000',
    )
    print("Condition: %d" % condition)

    savedata = tc.query_user_savedata(
        user_id=user_id
    )
    print("Save data: %s" % savedata)

    tc.send_user_savedata(
        user_id=user_id,
        savedata={"I'm some":["save","data"]}
    )

    root_logger = tc.log_session(
        user_id=user_id,
        detail={'im':'some data', 'with':[2,'arrays']},
    )

    root_logger.log_event(Event(category_id=1, type_id=23, detail={'Im':['An', 'Event']}))

    task_logger = root_logger.start_task(
        event=Event(category_id=0, type_id=2, detail="I'm a task start"),
        group_id='586c3a14-3659-4975-a28e-d88811a4632b'
    )

    task_events = [
        (2, 10, 'task event 1'),
        (2, 432, 'task event 2'),
        (2, 4, 'task event 3'),
    ]

    for (c, t, d) in task_events:
        task_logger.log_event(Event(category_id=c, type_id=t, detail=d))

    root_events = [
        (1, 62, {'A Different':[None, False, 'Event']}),
        (4, 23, 'blahblahblablablhablhablhahah'),
    ]

    for (c, t, d) in root_events:
        root_logger.log_event(Event(category_id=c, type_id=t, detail=d))

    tc.flush_events()

run_test()


#!/usr/bin/env python