* 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 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

* feat(chalice): autocomplete return top 10 with stats

* fix(chalice): fixed autocomplete top 10 meta-filters

* refactor(chalice): changed funnels&webVitals users count

* feat(chalice): table of referrers&requests by users count

* dev(chalice): changed JWT expiration for test
This commit is contained in:
Kraiem Taha Yassine 2024-08-14 16:14:31 +02:00 committed by GitHub
parent 339640ffce
commit c245e9d977
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 20 additions and 18 deletions

View file

@ -48,7 +48,7 @@ def __get_funnel_chart(project_id: int, data: schemas.CardFunnel, user_id: int =
return funnels.get_top_insights_on_the_fly_widget(project_id=project_id,
data=data.series[0].filter,
metric_of=data.metric_of)
metric_format=data.metric_format)
def __get_errors_list(project_id, user_id, data: schemas.CardSchema):

View file

@ -37,20 +37,20 @@ def __fix_stages(f_events: List[schemas.SessionSearchEventSchema2]):
# def get_top_insights_on_the_fly_widget(project_id, data: schemas.FunnelInsightsPayloadSchema):
def get_top_insights_on_the_fly_widget(project_id, data: schemas.CardSeriesFilterSchema,
metric_of: schemas.MetricOfFunnels):
metric_format: schemas.MetricExtendedFormatType):
data.events = filter_stages(__parse_events(data.events))
data.events = __fix_stages(data.events)
if len(data.events) == 0:
return {"stages": [], "totalDropDueToIssues": 0}
insights, total_drop_due_to_issues = significance.get_top_insights(filter_d=data,
project_id=project_id,
metric_of=metric_of)
metric_format=metric_format)
insights = helper.list_to_camel_case(insights)
if len(insights) > 0:
if metric_of == schemas.MetricOfFunnels.SESSION_COUNT and total_drop_due_to_issues > (
if metric_format == schemas.MetricFormatType.SESSION_COUNT and total_drop_due_to_issues > (
insights[0]["sessionsCount"] - insights[-1]["sessionsCount"]):
total_drop_due_to_issues = insights[0]["sessionsCount"] - insights[-1]["sessionsCount"]
elif metric_of == schemas.MetricOfFunnels.USER_COUNT and total_drop_due_to_issues > (
elif metric_format == schemas.MetricExtendedFormatType.USER_COUNT and total_drop_due_to_issues > (
insights[0]["usersCount"] - insights[-1]["usersCount"]):
total_drop_due_to_issues = insights[0]["usersCount"] - insights[-1]["usersCount"]
insights[-1]["dropDueToIssues"] = total_drop_due_to_issues

View file

@ -431,9 +431,10 @@ def count_users(rows, n_stages, user_key="user_uuid"):
return users_count
def get_stages(stages, rows, metric_of=schemas.MetricOfFunnels.SESSION_COUNT):
def get_stages(stages, rows,
metric_format: schemas.MetricExtendedFormatType = schemas.MetricExtendedFormatType.SESSION_COUNT):
n_stages = len(stages)
if metric_of == "sessionCount":
if metric_format == schemas.MetricExtendedFormatType.SESSION_COUNT:
base_counts = count_sessions(rows, n_stages)
else:
base_counts = count_users(rows, n_stages, user_key="user_id")
@ -456,7 +457,7 @@ def get_stages(stages, rows, metric_of=schemas.MetricOfFunnels.SESSION_COUNT):
"dropDueToIssues": 0
}
)
if metric_of == "sessionCount":
if metric_format == schemas.MetricExtendedFormatType.SESSION_COUNT:
stages_list[-1]["sessionsCount"] = base_counts[i + 1]
else:
stages_list[-1]["usersCount"] = base_counts[i + 1]
@ -543,7 +544,8 @@ def get_issues(stages, rows, first_stage=None, last_stage=None, drop_only=False)
return n_critical_issues, issues_dict, total_drop_due_to_issues
def get_top_insights(filter_d: schemas.CardSeriesFilterSchema, project_id, metric_of: schemas.MetricOfFunnels):
def get_top_insights(filter_d: schemas.CardSeriesFilterSchema, project_id,
metric_format: schemas.MetricExtendedFormatType):
output = []
stages = filter_d.events
@ -554,7 +556,7 @@ def get_top_insights(filter_d: schemas.CardSeriesFilterSchema, project_id, metri
# The result of the multi-stage query
rows = get_stages_and_events(filter_d=filter_d, project_id=project_id)
# Obtain the first part of the output
stages_list = get_stages(stages, rows, metric_of=metric_of)
stages_list = get_stages(stages, rows, metric_format=metric_format)
if len(rows) == 0:
return stages_list, 0

View file

@ -33,7 +33,7 @@ JWT_REFRESH_SECRET="SET A RANDOM STRING HERE"
JWT_SPOT_REFRESH_EXPIRATION=604800
JWT_SPOT_REFRESH_SECRET="SET A RANDOM STRING HERE"
JWT_SPOT_SECRET=SECRET
JWT_SPOT_EXPIRATION=300
JWT_SPOT_EXPIRATION=3600
jwt_secret="SET A RANDOM STRING HERE"
pg_dbname=postgres
pg_host=postgresql.db.svc.cluster.local

View file

@ -998,7 +998,7 @@ class MetricOfWebVitals(str, Enum):
AVG_VISITED_PAGES = "avgVisitedPages"
COUNT_REQUESTS = "countRequests"
COUNT_SESSIONS = "countSessions"
COUNT_USERS = "countUsers"
COUNT_USERS = "userCount"
class MetricOfTable(str, Enum):
@ -1024,7 +1024,6 @@ class MetricOfTimeseries(str, Enum):
class MetricOfFunnels(str, Enum):
SESSION_COUNT = MetricOfTimeseries.SESSION_COUNT.value
USER_COUNT = MetricOfTimeseries.USER_COUNT.value
class MetricOfHeatMap(str, Enum):
@ -1179,7 +1178,8 @@ class CardTable(__CardSchema):
def __validator(self):
if self.metric_of not in (MetricOfTable.ISSUES, MetricOfTable.USER_BROWSER,
MetricOfTable.USER_DEVICE, MetricOfTable.USER_COUNTRY,
MetricOfTable.VISITED_URL):
MetricOfTable.VISITED_URL, MetricOfTable.REFERRER,
MetricOfTable.FETCH):
assert self.metric_format == MetricExtendedFormatType.SESSION_COUNT, \
f'metricFormat:{MetricExtendedFormatType.USER_COUNT.value} is not supported for this metricOf'
return self
@ -1189,6 +1189,7 @@ class CardFunnel(__CardSchema):
metric_type: Literal[MetricType.FUNNEL]
metric_of: MetricOfFunnels = Field(default=MetricOfFunnels.SESSION_COUNT)
view_type: MetricOtherViewType = Field(...)
metric_format: MetricExtendedFormatType = Field(default=MetricExtendedFormatType.SESSION_COUNT)
@model_validator(mode="before")
@classmethod

View file

@ -59,7 +59,7 @@ def __get_funnel_chart(project_id: int, data: schemas.CardFunnel, user_id: int =
return funnels.get_top_insights_on_the_fly_widget(project_id=project_id,
data=data.series[0].filter,
metric_of=data.metric_of)
metric_format=data.metric_format)
def __get_errors_list(project_id, user_id, data: schemas.CardSchema):

View file

@ -469,8 +469,7 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de
main_query = f"""SELECT COUNT(DISTINCT {main_col}) OVER () AS main_count,
{main_col} AS name,
count(DISTINCT user_id) AS user_count
FROM (SELECT s.user_id AS user_id,
{extra_col}
FROM (SELECT s.user_id AS user_id {extra_col}
{query_part}
WHERE isNotNull(user_id)
AND user_id != '') AS filtred_sessions

View file

@ -51,7 +51,7 @@ JWT_REFRESH_SECRET="SET A RANDOM STRING HERE"
JWT_SPOT_REFRESH_EXPIRATION=604800
JWT_SPOT_REFRESH_SECRET="SET A RANDOM STRING HERE"
JWT_SPOT_SECRET=SECRET
JWT_SPOT_EXPIRATION=300
JWT_SPOT_EXPIRATION=3600
jwt_secret="SET A RANDOM STRING HERE"
KAFKA_SERVERS=kafka.db.svc.cluster.local:9092
KAFKA_USE_SSL=false