From 9849b6ea126c472562bf441e1fc9fd03ed27aaf6 Mon Sep 17 00:00:00 2001 From: retoor Date: Thu, 2 Jan 2025 19:59:59 +0100 Subject: [PATCH] 1337. --- src/metriki/app.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/metriki/app.py b/src/metriki/app.py index dee24b7..f66eb51 100644 --- a/src/metriki/app.py +++ b/src/metriki/app.py @@ -58,12 +58,15 @@ class BaseView(web.View): class EventView(BaseView): document_fields = ['title','html','domain','href'] - + click_fields = ["event", "target"] event_fields = ['target','event','tag','scroll_height','scroll_left','scroll_top','client_width','client_height','page_x','page_y','screen_x','screen_y','client_x','client_y','target_x','target_y'] def is_document_record(self, data): return data.get('html') and True or False + def is_click_record(self,data): + return data.get('event') == 'click' + def get_record(self, data): try: @@ -86,6 +89,16 @@ class EventView(BaseView): except: pass + try: + record = {} + for field in self.click_fields: + if field in data: + record[field] = data[field] + if len(record.keys()) == len(self.click_fields): + return record + except: + pass + return None async def get(self): @@ -123,6 +136,10 @@ class EventView(BaseView): ) self.insert('visit', record) self.app.view_count += 1 + elif self.is_click_record(data): + data['visit_id'] = visit_id + record = data + self.insert('click', record) else: data['visit_id'] = visit_id record = data