service.eventmanager.live
Database schema for MVP
Find unique user per stage sortable by time
app |
date |
stage |
user |
007 |
today |
/home |
u1 |
007 |
today |
/home |
u2 |
007 |
today |
/products |
u1 |
For this table the partition key is: app
. The date, stage
and user
fields serve as clustering key
.
With the keys set like so one can use the following query to retrieve the information of unique users per stage: select app, date, stage, count(user) from table where app = '007' and date = 'today' group by date, stage;
. Since the partition keys
are referenced in the query, the group by and the count will still be performant.
Find avg time users spend per stage
app |
stage |
elapsed |
hit |
007 |
/home |
24 |
4 |
007 |
/products |
12 |
2 |
Here the app
serves as the partition key
(data will not be well balanced, in prod might need to use some hash along the app
to distribute the data evenly). stage
is the clustering key
and both elapsed
and hit
are Cassandra counter types
. To query the data: select * from table where app = '007' and stage = '/home';
. Finally, divide elapsed
by hit
to get the avg time. (elapsed is in seconds)
app |
xpath |
hover_leave |
elapsed_leave |
hover_click |
elapsed_click |
hit |
007 |
div/button |
16 |
24 |
4 |
10 |
20 |
007 |
div/div/button |
12 |
5 |
2 |
4 |
14 |
partition key
is the app uuid
(might need an extra field to be better distributed across a cluster but YOLO for now). xapth
forms the clustering key
. hover/elapsed_leave, hover/elapsed_click, hit
are all counter types
Query would simply query for one app/xpath and compute the percents of both actions
Event Definitions
Raw-Event: Click
{
"type": "int", // indicates what type of event
"timestamp": "int64",
"device_id": "string", // most likly the devices IP address
"target": "string", // clicked HTML element - if given HTML-Name-Tag else whatever if find lol
"elapsed_time": "int64", // passed time since last click
"current_url": "string" // URL clicked happened
}
Raw-Event: URL-Change
{
"type": "int", // indicates what type of event
"timestamp": "int64",
"device_id": "string", // most likly the devices IP address
"from": "string", // URL jumped from
"to": "string", // URL jumped to
"elapsed_time": "int64", // passed time on "from" URL
}
Config-Based-Event: BTN-Time
{
"type": "int", // see above
"timestamp": "int64",
"device_id": "string", // see above
"target": "string", // HTML element triggered by
"action": "string", // can be hover-then-leave or hover-then-clicked
"elapsed_time": "int64", // passed time from click to action
}
Config-Based-Event: Funnel-Change (onClick / URL-Change if part of funnel config)
{
"type": "int", // see above
"timestamp": "int64",
"device_id": "string", // see above
"action": "string", // onClick || onUrlChange
"entered": "int", // stage id
"elapsed_time": "int64"
}