* refactor(chalice): upgraded dependencies

* refactor(chalice): upgraded dependencies
feat(chalice): support heatmaps

* feat(chalice): support table-of-browsers showing user-count

* feat(chalice): support table-of-devices showing user-count

* feat(chalice): support table-of-URLs showing user-count

* fix(chalice): fixed Math-operators validation
refactor(chalice): search for sessions that have events for heatmaps

* refactor(chalice): search for sessions that have at least 1 location event for heatmaps

* fix(chalice): fixed heatmap update with no selected session
fix(chalice): fixed heatmap payload schemas
fix(chalice): changed clickmaps permissions
This commit is contained in:
Kraiem Taha Yassine 2024-07-04 17:09:21 +02:00 committed by GitHub
parent 5619629bb7
commit d9ee0c9758
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 11 additions and 15 deletions

View file

@ -403,7 +403,7 @@ def update_card(metric_id, user_id, project_id, data: schemas.CardSchema):
elif data.metric_type == schemas.MetricType.heat_map:
if data.session_id is not None:
params["session_data"] = json.dumps({"sessionId": data.session_id})
elif metric.get("data"):
elif metric.get("data") and metric["data"].get("sessionId"):
params["session_data"] = json.dumps({"sessionId": metric["data"]["sessionId"]})
with pg_client.PostgresClient() as cur:

View file

@ -9,7 +9,7 @@ from chalicelib.utils import pg_client, helper
logger = logging.getLogger(__name__)
def get_by_url(project_id, data: schemas.GetHeatmapPayloadSchema):
def get_by_url(project_id, data: schemas.GetHeatMapPayloadSchema):
args = {"startDate": data.startTimestamp, "endDate": data.endTimestamp,
"project_id": project_id, "url": data.url}
constraints = ["sessions.project_id = %(project_id)s",

View file

@ -412,7 +412,7 @@ def get_live_session_devtools_file(projectId: int, sessionId: Union[int, str],
@app.post('/{projectId}/heatmaps/url', tags=["heatmaps"])
def get_heatmaps_by_url(projectId: int, data: schemas.GetHeatmapPayloadSchema = Body(...),
def get_heatmaps_by_url(projectId: int, data: schemas.GetHeatMapPayloadSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": heatmaps.get_by_url(project_id=projectId, data=data)}

View file

@ -1571,16 +1571,12 @@ class HeatMapFilterSchema(BaseModel):
operator: Literal[SearchEventOperator._is, MathOperator._equal] = Field(...)
class GetHeatmapPayloadSchema(_TimedSchema):
class GetHeatMapPayloadSchema(_TimedSchema):
url: str = Field(...)
filters: List[HeatMapFilterSchema] = Field(default=[])
click_rage: bool = Field(default=False)
class GetHeatMapPayloadSchema(BaseModel):
url: str = Field(...)
class GetClickMapPayloadSchema(GetHeatMapPayloadSchema):
pass

View file

@ -435,7 +435,7 @@ def update_card(metric_id, user_id, project_id, data: schemas.CardSchema):
elif data.metric_type == schemas.MetricType.heat_map:
if data.session_id is not None:
params["session_data"] = json.dumps({"sessionId": data.session_id})
elif metric.get("data"):
elif metric.get("data") and metric["data"].get("sessionId"):
params["session_data"] = json.dumps({"sessionId": metric["data"]["sessionId"]})
with pg_client.PostgresClient() as cur:

View file

@ -17,7 +17,7 @@ from chalicelib.utils import pg_client, helper, ch_client, exp_ch_helper
logger = logging.getLogger(__name__)
def get_by_url(project_id, data: schemas.GetHeatmapPayloadSchema):
def get_by_url(project_id, data: schemas.GetHeatMapPayloadSchema):
args = {"startDate": data.startTimestamp, "endDate": data.endTimestamp,
"project_id": project_id, "url": data.url}
constraints = ["main_events.project_id = toUInt16(%(project_id)s)",
@ -90,7 +90,7 @@ def get_by_url(project_id, data: schemas.GetHeatmapPayloadSchema):
return helper.list_to_camel_case(rows)
def get_x_y_by_url_and_session_id(project_id, session_id, data: schemas.GetHeatmapPayloadSchema):
def get_x_y_by_url_and_session_id(project_id, session_id, data: schemas.GetHeatMapPayloadSchema):
args = {"project_id": project_id, "session_id": session_id, "url": data.url}
constraints = ["main_events.project_id = toUInt16(%(project_id)s)",
"main_events.session_id = %(session_id)s",
@ -120,7 +120,7 @@ def get_x_y_by_url_and_session_id(project_id, session_id, data: schemas.GetHeatm
return helper.list_to_camel_case(rows)
def get_selectors_by_url_and_session_id(project_id, session_id, data: schemas.GetHeatmapPayloadSchema):
def get_selectors_by_url_and_session_id(project_id, session_id, data: schemas.GetHeatMapPayloadSchema):
args = {"project_id": project_id, "session_id": session_id, "url": data.url}
constraints = ["main_events.project_id = toUInt16(%(project_id)s)",
"main_events.session_id = %(session_id)s",

View file

@ -441,7 +441,7 @@ def get_live_session_devtools_file(projectId: int, sessionId: Union[int, str],
@app.post('/{projectId}/heatmaps/url', tags=["heatmaps"], dependencies=[OR_scope(Permissions.session_replay)])
def get_heatmaps_by_url(projectId: int, data: schemas.GetHeatmapPayloadSchema = Body(...),
def get_heatmaps_by_url(projectId: int, data: schemas.GetHeatMapPayloadSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": heatmaps.get_by_url(project_id=projectId, data=data)}
@ -449,13 +449,13 @@ def get_heatmaps_by_url(projectId: int, data: schemas.GetHeatmapPayloadSchema =
@app.post('/{projectId}/sessions/{sessionId}/heatmaps', tags=["heatmaps"],
dependencies=[OR_scope(Permissions.session_replay)])
def get_heatmaps_by_session_id_url(projectId: int, sessionId: int,
data: schemas.GetHeatmapPayloadSchema = Body(...),
data: schemas.GetHeatMapPayloadSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": heatmaps.get_x_y_by_url_and_session_id(project_id=projectId, session_id=sessionId, data=data)}
@app.post('/{projectId}/sessions/{sessionId}/clickmaps', tags=["heatmaps"],
dependencies=[OR_scope(Permissions.session_replay)])
dependencies=[OR_scope(Permissions.session_replay, ServicePermissions.session_replay)])
def get_clickmaps_by_session_id_url(projectId: int, sessionId: int,
data: schemas.GetClickMapPayloadSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):