diff --git a/api/chalicelib/core/custom_metrics.py b/api/chalicelib/core/custom_metrics.py index 602f1f7d2..24415a072 100644 --- a/api/chalicelib/core/custom_metrics.py +++ b/api/chalicelib/core/custom_metrics.py @@ -572,7 +572,7 @@ def get_funnel_sessions_by_issue(user_id, project_id, metric_id, issue_id, "issue": issue} -def make_chart_from_card(project_id, user_id, metric_id, data: schemas.CardChartSchema, from_dashboard=False): +def make_chart_from_card(project_id, user_id, metric_id, data: schemas.CardChartSchema, ignore_click_map=False): raw_metric: dict = get_card(metric_id=metric_id, project_id=project_id, user_id=user_id, include_data=True) if raw_metric is None: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="card not found") @@ -581,7 +581,7 @@ def make_chart_from_card(project_id, user_id, metric_id, data: schemas.CardChart return get_predefined_metric(key=metric.metric_of, project_id=project_id, data=data.dict()) elif __is_click_map(metric): # TODO: remove this when UI is able to stop this endpoint calls for clickMap - if from_dashboard: + if ignore_click_map: return None if raw_metric["data"]: keys = sessions_mobs. \ diff --git a/api/routers/subs/metrics.py b/api/routers/subs/metrics.py index 9bd92174d..2bf4e56ff 100644 --- a/api/routers/subs/metrics.py +++ b/api/routers/subs/metrics.py @@ -232,10 +232,11 @@ def get_card_chart(projectId: int, metric_id: int, request: Request, data: schem context: schemas.CurrentContext = Depends(OR_context)): # TODO: remove this when UI is able to stop this endpoint calls for clickMap import re - from_dashboard = re.match(r".*\/[0-9]+\/dashboard\/[0-9]+$", request.headers.get('referer')) is not None \ + ignore_click_map = re.match(r".*\/[0-9]+\/dashboard\/[0-9]+$", request.headers.get('referer')) is not None \ + or re.match(r".*\/[0-9]+\/metrics$", request.headers.get('referer')) is not None \ if request.headers.get('referer') else False data = custom_metrics.make_chart_from_card(project_id=projectId, user_id=context.user_id, metric_id=metric_id, - data=data, from_dashboard=from_dashboard) + data=data, ignore_click_map=ignore_click_map) return {"data": data} diff --git a/ee/api/chalicelib/core/custom_metrics.py b/ee/api/chalicelib/core/custom_metrics.py index 0eb0c3333..94b2289b7 100644 --- a/ee/api/chalicelib/core/custom_metrics.py +++ b/ee/api/chalicelib/core/custom_metrics.py @@ -628,7 +628,7 @@ def get_funnel_sessions_by_issue(user_id, project_id, metric_id, issue_id, "issue": issue} -def make_chart_from_card(project_id, user_id, metric_id, data: schemas.CardChartSchema, from_dashboard=False): +def make_chart_from_card(project_id, user_id, metric_id, data: schemas.CardChartSchema, ignore_click_map=False): raw_metric: dict = get_card(metric_id=metric_id, project_id=project_id, user_id=user_id, include_data=True) if raw_metric is None: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="card not found") @@ -637,7 +637,7 @@ def make_chart_from_card(project_id, user_id, metric_id, data: schemas.CardChart return get_predefined_metric(key=metric.metric_of, project_id=project_id, data=data.dict()) elif __is_click_map(metric): # TODO: remove this when UI is able to stop this endpoint calls for clickMap - if from_dashboard: + if ignore_click_map: return None if raw_metric["data"]: keys = sessions_mobs. \ diff --git a/ee/api/routers/subs/metrics.py b/ee/api/routers/subs/metrics.py index 540147a73..574763d65 100644 --- a/ee/api/routers/subs/metrics.py +++ b/ee/api/routers/subs/metrics.py @@ -234,10 +234,11 @@ def get_card_chart(projectId: int, metric_id: int, request: Request, data: schem context: schemas.CurrentContext = Depends(OR_context)): # TODO: remove this when UI is able to stop this endpoint calls for clickMap import re - from_dashboard = re.match(r".*\/[0-9]+\/dashboard\/[0-9]+$", request.headers.get('referer')) is not None \ + ignore_click_map = re.match(r".*\/[0-9]+\/dashboard\/[0-9]+$", request.headers.get('referer')) is not None \ + or re.match(r".*\/[0-9]+\/metrics$", request.headers.get('referer')) is not None \ if request.headers.get('referer') else False data = custom_metrics.make_chart_from_card(project_id=projectId, user_id=context.user_id, metric_id=metric_id, - data=data, from_dashboard=from_dashboard) + data=data, ignore_click_map=ignore_click_map) return {"data": data}