A Python wrapper for backend reporting via a worker/queue system.
System flow:
Store event quickly on webserver [e.g. within a flask endpoint]:
from event_reporter import EventReporter
from redis import StrictRedis
er = EventReporter(conn=StrictRedis())
er.store('ga', 'event', '<uuid4 clientid>', category='event_category', action='action_name', aip='1', uip='1.2.3.4', ds='web')
Fetch event within worker and dispatch to final destination:
from event_reporter import EventReporter
from redis import StrictRedis
er = EventReporter(conn=StrictRedis())
r = er.fetch()
er.dispatch(r)
EVENTREPORTER_QUEUE_NAME
(redis key)UA_ID
(GA UA ID)EVENTREPORTER_TTL
(int: controls whether to set expire time for redis keys)HONEYCOMB_WRITEKEY
(optional)
export UA_ID='My_UA_ID'
nosetests -s
ga
: GAhoney
: honeycomb.ioslack
: slack
er.store('slack', 'event', '<uuid4>', webhook='<slack_webhook_uri>', message='text')
er.store('slack', 'event', '<uuid4>', webhook='<slack_webhook_uri>', blocks=<list_of_dicts>)
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello
}
}
]
.. and check your GA property, honeycomb dash, or slack channel to see the data.