feat(chalice): ios->mobile renaming (#2084)

This commit is contained in:
Alexander 2024-04-15 16:18:21 +02:00 committed by GitHub
parent 911f86530e
commit 94f0277724
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 241 additions and 234 deletions

View file

@ -226,12 +226,12 @@ def __search_errors(project_id, value, key=None, source=None):
return results
def __search_errors_ios(project_id, value, key=None, source=None):
def __search_errors_mobile(project_id, value, key=None, source=None):
if len(value) > 2:
query = f"""(SELECT DISTINCT ON(lg.reason)
lg.reason AS value,
'{events.EventType.CRASH_IOS.ui_type}' AS type
FROM {events.EventType.CRASH_IOS.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
'{events.EventType.CRASH_MOBILE.ui_type}' AS type
FROM {events.EventType.CRASH_MOBILE.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
WHERE
s.project_id = %(project_id)s
AND lg.project_id = %(project_id)s
@ -240,8 +240,8 @@ def __search_errors_ios(project_id, value, key=None, source=None):
UNION ALL
(SELECT DISTINCT ON(lg.name)
lg.name AS value,
'{events.EventType.CRASH_IOS.ui_type}' AS type
FROM {events.EventType.CRASH_IOS.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
'{events.EventType.CRASH_MOBILE.ui_type}' AS type
FROM {events.EventType.CRASH_MOBILE.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
WHERE
s.project_id = %(project_id)s
AND lg.project_id = %(project_id)s
@ -250,8 +250,8 @@ def __search_errors_ios(project_id, value, key=None, source=None):
UNION ALL
(SELECT DISTINCT ON(lg.reason)
lg.reason AS value,
'{events.EventType.CRASH_IOS.ui_type}' AS type
FROM {events.EventType.CRASH_IOS.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
'{events.EventType.CRASH_MOBILE.ui_type}' AS type
FROM {events.EventType.CRASH_MOBILE.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
WHERE
s.project_id = %(project_id)s
AND lg.project_id = %(project_id)s
@ -260,8 +260,8 @@ def __search_errors_ios(project_id, value, key=None, source=None):
UNION ALL
(SELECT DISTINCT ON(lg.name)
lg.name AS value,
'{events.EventType.CRASH_IOS.ui_type}' AS type
FROM {events.EventType.CRASH_IOS.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
'{events.EventType.CRASH_MOBILE.ui_type}' AS type
FROM {events.EventType.CRASH_MOBILE.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
WHERE
s.project_id = %(project_id)s
AND lg.project_id = %(project_id)s
@ -270,8 +270,8 @@ def __search_errors_ios(project_id, value, key=None, source=None):
else:
query = f"""(SELECT DISTINCT ON(lg.reason)
lg.reason AS value,
'{events.EventType.CRASH_IOS.ui_type}' AS type
FROM {events.EventType.CRASH_IOS.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
'{events.EventType.CRASH_MOBILE.ui_type}' AS type
FROM {events.EventType.CRASH_MOBILE.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
WHERE
s.project_id = %(project_id)s
AND lg.project_id = %(project_id)s
@ -280,8 +280,8 @@ def __search_errors_ios(project_id, value, key=None, source=None):
UNION ALL
(SELECT DISTINCT ON(lg.name)
lg.name AS value,
'{events.EventType.CRASH_IOS.ui_type}' AS type
FROM {events.EventType.CRASH_IOS.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
'{events.EventType.CRASH_MOBILE.ui_type}' AS type
FROM {events.EventType.CRASH_MOBILE.table} INNER JOIN public.crashes_ios AS lg USING (crash_id) LEFT JOIN public.sessions AS s USING(session_id)
WHERE
s.project_id = %(project_id)s
AND lg.project_id = %(project_id)s

View file

@ -126,14 +126,14 @@ class EventType:
ERROR = Event(ui_type=schemas.EventType.error, table="events.errors",
column=None) # column=None because errors are searched by name or message
METADATA = Event(ui_type=schemas.FilterType.metadata, table="public.sessions", column=None)
# IOS
CLICK_IOS = Event(ui_type=schemas.EventType.click_ios, table="events_ios.taps", column="label")
INPUT_IOS = Event(ui_type=schemas.EventType.input_ios, table="events_ios.inputs", column="label")
VIEW_IOS = Event(ui_type=schemas.EventType.view_ios, table="events_ios.views", column="name")
SWIPE_IOS = Event(ui_type=schemas.EventType.swipe_ios, table="events_ios.swipes", column="label")
CUSTOM_IOS = Event(ui_type=schemas.EventType.custom_ios, table="events_common.customs", column="name")
REQUEST_IOS = Event(ui_type=schemas.EventType.request_ios, table="events_common.requests", column="path")
CRASH_IOS = Event(ui_type=schemas.EventType.error_ios, table="events_common.crashes",
# MOBILE
CLICK_MOBILE = Event(ui_type=schemas.EventType.click_mobile, table="events_ios.taps", column="label")
INPUT_MOBILE = Event(ui_type=schemas.EventType.input_mobile, table="events_ios.inputs", column="label")
VIEW_MOBILE = Event(ui_type=schemas.EventType.view_mobile, table="events_ios.views", column="name")
SWIPE_MOBILE = Event(ui_type=schemas.EventType.swipe_mobile, table="events_ios.swipes", column="label")
CUSTOM_MOBILE = Event(ui_type=schemas.EventType.custom_mobile, table="events_common.customs", column="name")
REQUEST_MOBILE = Event(ui_type=schemas.EventType.request_mobile, table="events_common.requests", column="path")
CRASH_MOBILE = Event(ui_type=schemas.EventType.error_mobile, table="events_common.crashes",
column=None) # column=None because errors are searched by name or message
@ -161,23 +161,23 @@ SUPPORTED_TYPES = {
query=None),
EventType.METADATA.ui_type: SupportedFilter(get=autocomplete.__search_metadata,
query=None),
# IOS
EventType.CLICK_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.CLICK_IOS),
# MOBILE
EventType.CLICK_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.CLICK_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.CLICK_IOS.ui_type)),
EventType.INPUT_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.INPUT_IOS),
typename=EventType.CLICK_MOBILE.ui_type)),
EventType.INPUT_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.INPUT_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.INPUT_IOS.ui_type)),
EventType.VIEW_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.VIEW_IOS),
typename=EventType.INPUT_MOBILE.ui_type)),
EventType.VIEW_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.VIEW_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.VIEW_IOS.ui_type)),
EventType.CUSTOM_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.CUSTOM_IOS),
typename=EventType.VIEW_MOBILE.ui_type)),
EventType.CUSTOM_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.CUSTOM_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.CUSTOM_IOS.ui_type)),
EventType.REQUEST_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.REQUEST_IOS),
typename=EventType.CUSTOM_MOBILE.ui_type)),
EventType.REQUEST_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.REQUEST_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.REQUEST_IOS.ui_type)),
EventType.CRASH_IOS.ui_type: SupportedFilter(get=autocomplete.__search_errors_ios,
typename=EventType.REQUEST_MOBILE.ui_type)),
EventType.CRASH_MOBILE.ui_type: SupportedFilter(get=autocomplete.__search_errors_mobile,
query=None),
}
@ -204,13 +204,16 @@ def search(text, event_type, project_id, source, key):
# for IOS events autocomplete
# if event_type + "_IOS" in SUPPORTED_TYPES.keys():
# rows += SUPPORTED_TYPES[event_type + "_IOS"].get(project_id=project_id, value=text, key=key,source=source)
elif event_type + "_IOS" in SUPPORTED_TYPES.keys():
rows = SUPPORTED_TYPES[event_type + "_IOS"].get(project_id=project_id, value=text, key=key, source=source)
elif event_type + "_MOBILE" in SUPPORTED_TYPES.keys():
rows = SUPPORTED_TYPES[event_type + "_MOBILE"].get(project_id=project_id, value=text, key=key, source=source)
elif event_type in sessions_metas.SUPPORTED_TYPES.keys():
return sessions_metas.search(text, event_type, project_id)
elif event_type.endswith("_IOS") \
and event_type[:-len("_IOS")] in sessions_metas.SUPPORTED_TYPES.keys():
return sessions_metas.search(text, event_type, project_id)
elif event_type.endswith("_MOBILE") \
and event_type[:-len("_MOBILE")] in sessions_metas.SUPPORTED_TYPES.keys():
return sessions_metas.search(text, event_type, project_id)
else:
return {"errors": ["unsupported event"]}

View file

@ -58,7 +58,7 @@ def get_crashes_by_session_id(session_id):
with pg_client.PostgresClient() as cur:
cur.execute(cur.mogrify(f"""
SELECT cr.*,uc.*, cr.timestamp - s.start_ts AS time
FROM {events.EventType.CRASH_IOS.table} AS cr
FROM {events.EventType.CRASH_MOBILE.table} AS cr
INNER JOIN public.crashes_ios AS uc USING (crash_ios_id)
INNER JOIN public.sessions AS s USING (session_id)
WHERE

View file

@ -9,8 +9,8 @@ from chalicelib.utils import sql_helper as sh
def filter_stages(stages: List[schemas.SessionSearchEventSchema2]):
ALLOW_TYPES = [schemas.EventType.click, schemas.EventType.input,
schemas.EventType.location, schemas.EventType.custom,
schemas.EventType.click_ios, schemas.EventType.input_ios,
schemas.EventType.view_ios, schemas.EventType.custom_ios, ]
schemas.EventType.click_mobile, schemas.EventType.input_mobile,
schemas.EventType.view_mobile, schemas.EventType.custom_mobile, ]
return [s for s in stages if s.type in ALLOW_TYPES and s.value is not None]

View file

@ -97,22 +97,22 @@ def __get_meta_constraint(project_id, data):
if any(item in [schemas.FilterType.user_browser] \
for item in filter_type):
constraints.append(f"sessions.user_browser = %({f['key']}_{i})s")
elif any(item in [schemas.FilterType.user_os, schemas.FilterType.user_os_ios] \
elif any(item in [schemas.FilterType.user_os, schemas.FilterType.user_os_mobile] \
for item in filter_type):
constraints.append(f"sessions.user_os = %({f['key']}_{i})s")
elif any(item in [schemas.FilterType.user_device, schemas.FilterType.user_device_ios] \
elif any(item in [schemas.FilterType.user_device, schemas.FilterType.user_device_mobile] \
for item in filter_type):
constraints.append(f"sessions.user_device = %({f['key']}_{i})s")
elif any(item in [schemas.FilterType.user_country, schemas.FilterType.user_country_ios] \
elif any(item in [schemas.FilterType.user_country, schemas.FilterType.user_country_mobile] \
for item in filter_type):
constraints.append(f"sessions.user_country = %({f['key']}_{i})s")
elif any(item in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios] \
elif any(item in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile] \
for item in filter_type):
constraints.append(f"sessions.user_id = %({f['key']}_{i})s")
elif any(item in [schemas.FilterType.user_anonymous_id, schemas.FilterType.user_anonymous_id_ios] \
elif any(item in [schemas.FilterType.user_anonymous_id, schemas.FilterType.user_anonymous_id_mobile] \
for item in filter_type):
constraints.append(f"sessions.user_anonymous_id = %({f['key']}_{i})s")
elif any(item in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_ios] \
elif any(item in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_mobile] \
for item in filter_type):
constraints.append(f"sessions.rev_id = %({f['key']}_{i})s")
return constraints

View file

@ -252,7 +252,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
f"{metadata.index_to_colname(meta_keys[f.source])} {op} %({f_k})s::text",
f.value, is_not=is_not, value_key=f_k))
elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
if is_any:
sessions_conditions.append('user_id IS NOT NULL')
elif is_undefined:
@ -263,7 +263,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
value_key=f_k))
elif f.type in [schemas.FilterType.user_anonymous_id,
schemas.FilterType.user_anonymous_id_ios]:
schemas.FilterType.user_anonymous_id_mobile]:
if is_any:
sessions_conditions.append('user_anonymous_id IS NOT NULL')
elif is_undefined:
@ -273,7 +273,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
sh.multi_conditions(f"user_anonymous_id {op} %({f_k})s::text", f.value, is_not=is_not,
value_key=f_k))
elif f.type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_ios]:
elif f.type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_mobile]:
if is_any:
sessions_conditions.append('rev_id IS NOT NULL')
elif is_undefined:
@ -621,7 +621,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# elif f["type"] == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
# event_table = JOURNEY_TYPES[event_type]["table"]
@ -710,7 +710,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# elif f["type"] == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
# event_table = JOURNEY_TYPES[event_type]["table"]
@ -796,7 +796,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# if f["type"] == "EVENT_TYPE" and JOURNEY_TYPES.get(f["value"]):
# event_table = JOURNEY_TYPES[f["value"]]["table"]
# event_column = JOURNEY_TYPES[f["value"]]["column"]
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
#
@ -861,7 +861,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# elif f["type"] == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
# event_table = JOURNEY_TYPES[event_type]["table"]
@ -930,7 +930,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# elif f["type"] == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
# event_table = JOURNEY_TYPES[event_type]["table"]
@ -990,7 +990,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# elif f["type"] == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query_chart.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
# event_table = JOURNEY_TYPES[event_type]["table"]
@ -1052,7 +1052,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# if f["type"] == "EVENT_TYPE" and JOURNEY_TYPES.get(f["value"]):
# event_table = JOURNEY_TYPES[f["value"]]["table"]
# event_column = JOURNEY_TYPES[f["value"]]["column"]
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
# pg_sub_query.append(f"length({event_column})>2")
@ -1086,7 +1086,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# for f in filters:
# if f["type"] == "PERIOD" and f["value"] in ["DAY", "WEEK"]:
# period = f["value"]
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query_chart.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
#
@ -1156,7 +1156,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection}
# elif f["type"] == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f["type"] in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# pg_sub_query.append(f"sessions.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
# event_table = JOURNEY_TYPES[event_type]["table"]

View file

@ -457,7 +457,7 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
sh.multi_conditions(f'ms.user_browser {op} %({f_k})s', f.value, is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.user_os, schemas.FilterType.user_os_ios]:
elif filter_type in [schemas.FilterType.user_os, schemas.FilterType.user_os_mobile]:
if is_any:
extra_constraints.append('s.user_os IS NOT NULL')
ss_constraints.append('ms.user_os IS NOT NULL')
@ -467,7 +467,7 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
ss_constraints.append(
sh.multi_conditions(f'ms.user_os {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_device, schemas.FilterType.user_device_ios]:
elif filter_type in [schemas.FilterType.user_device, schemas.FilterType.user_device_mobile]:
if is_any:
extra_constraints.append('s.user_device IS NOT NULL')
ss_constraints.append('ms.user_device IS NOT NULL')
@ -477,7 +477,7 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
ss_constraints.append(
sh.multi_conditions(f'ms.user_device {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_country, schemas.FilterType.user_country_ios]:
elif filter_type in [schemas.FilterType.user_country, schemas.FilterType.user_country_mobile]:
if is_any:
extra_constraints.append('s.user_country IS NOT NULL')
ss_constraints.append('ms.user_country IS NOT NULL')
@ -591,7 +591,7 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
sh.multi_conditions(
f"ms.{metadata.index_to_colname(meta_keys[f.source])} {op} %({f_k})s::text",
f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
elif filter_type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
if is_any:
extra_constraints.append('s.user_id IS NOT NULL')
ss_constraints.append('ms.user_id IS NOT NULL')
@ -606,7 +606,7 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
sh.multi_conditions(f"ms.user_id {op} %({f_k})s::text", f.value, is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.user_anonymous_id,
schemas.FilterType.user_anonymous_id_ios]:
schemas.FilterType.user_anonymous_id_mobile]:
if is_any:
extra_constraints.append('s.user_anonymous_id IS NOT NULL')
ss_constraints.append('ms.user_anonymous_id IS NOT NULL')
@ -620,7 +620,7 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
ss_constraints.append(
sh.multi_conditions(f"ms.user_anonymous_id {op} %({f_k})s::text", f.value, is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_ios]:
elif filter_type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_mobile]:
if is_any:
extra_constraints.append('s.rev_id IS NOT NULL')
ss_constraints.append('ms.rev_id IS NOT NULL')
@ -723,10 +723,10 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
sh.multi_conditions(f"main.{events.EventType.CLICK.column} {op} %({e_k})s", event.value,
value_key=e_k))
else:
event_from = event_from % f"{events.EventType.CLICK_IOS.table} AS main "
event_from = event_from % f"{events.EventType.CLICK_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.CLICK_IOS.column} {op} %({e_k})s", event.value,
sh.multi_conditions(f"main.{events.EventType.CLICK_MOBILE.column} {op} %({e_k})s", event.value,
value_key=e_k))
elif event_type == events.EventType.TAG.ui_type:
@ -747,10 +747,10 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
full_args = {**full_args, **sh.multi_values(event.source, value_key=f"custom{i}")}
else:
event_from = event_from % f"{events.EventType.INPUT_IOS.table} AS main "
event_from = event_from % f"{events.EventType.INPUT_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.INPUT_IOS.column} {op} %({e_k})s", event.value,
sh.multi_conditions(f"main.{events.EventType.INPUT_MOBILE.column} {op} %({e_k})s", event.value,
value_key=e_k))
@ -762,16 +762,16 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
sh.multi_conditions(f"main.{events.EventType.LOCATION.column} {op} %({e_k})s",
event.value, value_key=e_k))
else:
event_from = event_from % f"{events.EventType.VIEW_IOS.table} AS main "
event_from = event_from % f"{events.EventType.VIEW_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.VIEW_IOS.column} {op} %({e_k})s",
sh.multi_conditions(f"main.{events.EventType.VIEW_MOBILE.column} {op} %({e_k})s",
event.value, value_key=e_k))
elif event_type == events.EventType.SWIPE_IOS.ui_type and platform == "ios":
event_from = event_from % f"{events.EventType.SWIPE_IOS.table} AS main "
elif event_type == events.EventType.SWIPE_MOBILE.ui_type and platform == "ios":
event_from = event_from % f"{events.EventType.SWIPE_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.SWIPE_IOS.column} {op} %({e_k})s",
sh.multi_conditions(f"main.{events.EventType.SWIPE_MOBILE.column} {op} %({e_k})s",
event.value, value_key=e_k))
elif event_type == events.EventType.CUSTOM.ui_type:
event_from = event_from % f"{events.EventType.CUSTOM.table} AS main "
@ -809,43 +809,43 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status,
# ----- IOS
elif event_type == events.EventType.CLICK_IOS.ui_type:
event_from = event_from % f"{events.EventType.CLICK_IOS.table} AS main "
elif event_type == events.EventType.CLICK_MOBILE.ui_type:
event_from = event_from % f"{events.EventType.CLICK_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.CLICK_IOS.column} {op} %({e_k})s",
sh.multi_conditions(f"main.{events.EventType.CLICK_MOBILE.column} {op} %({e_k})s",
event.value, value_key=e_k))
elif event_type == events.EventType.INPUT_IOS.ui_type:
event_from = event_from % f"{events.EventType.INPUT_IOS.table} AS main "
elif event_type == events.EventType.INPUT_MOBILE.ui_type:
event_from = event_from % f"{events.EventType.INPUT_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.INPUT_IOS.column} {op} %({e_k})s",
sh.multi_conditions(f"main.{events.EventType.INPUT_MOBILE.column} {op} %({e_k})s",
event.value, value_key=e_k))
if event.source is not None and len(event.source) > 0:
event_where.append(sh.multi_conditions(f"main.value ILIKE %(custom{i})s", event.source,
value_key="custom{i}"))
full_args = {**full_args, **sh.multi_values(event.source, f"custom{i}")}
elif event_type == events.EventType.VIEW_IOS.ui_type:
event_from = event_from % f"{events.EventType.VIEW_IOS.table} AS main "
elif event_type == events.EventType.VIEW_MOBILE.ui_type:
event_from = event_from % f"{events.EventType.VIEW_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.VIEW_IOS.column} {op} %({e_k})s",
sh.multi_conditions(f"main.{events.EventType.VIEW_MOBILE.column} {op} %({e_k})s",
event.value, value_key=e_k))
elif event_type == events.EventType.CUSTOM_IOS.ui_type:
event_from = event_from % f"{events.EventType.CUSTOM_IOS.table} AS main "
elif event_type == events.EventType.CUSTOM_MOBILE.ui_type:
event_from = event_from % f"{events.EventType.CUSTOM_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.CUSTOM_IOS.column} {op} %({e_k})s",
sh.multi_conditions(f"main.{events.EventType.CUSTOM_MOBILE.column} {op} %({e_k})s",
event.value, value_key=e_k))
elif event_type == events.EventType.REQUEST_IOS.ui_type:
event_from = event_from % f"{events.EventType.REQUEST_IOS.table} AS main "
elif event_type == events.EventType.REQUEST_MOBILE.ui_type:
event_from = event_from % f"{events.EventType.REQUEST_MOBILE.table} AS main "
if not is_any:
event_where.append(
sh.multi_conditions(f"main.{events.EventType.REQUEST_IOS.column} {op} %({e_k})s",
sh.multi_conditions(f"main.{events.EventType.REQUEST_MOBILE.column} {op} %({e_k})s",
event.value, value_key=e_k))
elif event_type == events.EventType.CRASH_IOS.ui_type:
event_from = event_from % f"{events.EventType.CRASH_IOS.table} AS main INNER JOIN public.crashes_ios AS main1 USING(crash_id)"
elif event_type == events.EventType.CRASH_MOBILE.ui_type:
event_from = event_from % f"{events.EventType.CRASH_MOBILE.table} AS main INNER JOIN public.crashes_ios AS main1 USING(crash_id)"
if not is_any and event.value not in [None, "*", ""]:
event_where.append(
sh.multi_conditions(f"(main1.reason {op} %({e_k})s OR main1.name {op} %({e_k})s)",

View file

@ -43,25 +43,25 @@ SUPPORTED_TYPES = {
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.utm_source),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.utm_source)),
# IOS
schemas.FilterType.user_os_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_os_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_os_ios)),
schemas.FilterType.user_device_ios: SupportedFilter(
schemas.FilterType.user_os_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_os_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_os_mobile)),
schemas.FilterType.user_device_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(
typename=schemas.FilterType.user_device_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_device_ios)),
schemas.FilterType.user_country_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_country_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_country_ios)),
schemas.FilterType.user_id_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_id_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_id_ios)),
schemas.FilterType.user_anonymous_id_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_anonymous_id_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_anonymous_id_ios)),
schemas.FilterType.rev_id_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.rev_id_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.rev_id_ios)),
typename=schemas.FilterType.user_device_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_device_mobile)),
schemas.FilterType.user_country_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_country_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_country_mobile)),
schemas.FilterType.user_id_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_id_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_id_mobile)),
schemas.FilterType.user_anonymous_id_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_anonymous_id_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_anonymous_id_mobile)),
schemas.FilterType.rev_id_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.rev_id_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.rev_id_mobile)),
}

View file

@ -14,7 +14,7 @@ def __get_mob_keys(project_id, session_id):
]
def __get_ios_video_keys(project_id, session_id):
def __get_mobile_video_keys(project_id, session_id):
params = {
"sessionId": session_id,
"projectId": project_id
@ -54,9 +54,9 @@ def get_urls_depercated(session_id, check_existence: bool = True):
return results
def get_ios_videos(session_id, project_id, check_existence=False):
def get_mobile_videos(session_id, project_id, check_existence=False):
results = []
for k in __get_ios_video_keys(project_id=project_id, session_id=session_id):
for k in __get_mobile_video_keys(project_id=project_id, session_id=session_id):
if check_existence and not StorageClient.exists(bucket=config("IOS_VIDEO_BUCKET"), key=k):
continue
results.append(StorageClient.get_presigned_url_for_sharing(

View file

@ -1,5 +1,5 @@
import schemas
from chalicelib.core import events, metadata, events_ios, \
from chalicelib.core import events, metadata, events_mobile, \
sessions_mobs, issues, resources, assist, sessions_devtool, sessions_notes, canvas, user_testing
from chalicelib.utils import errors_helper
from chalicelib.utils import pg_client, helper
@ -48,12 +48,14 @@ def get_by_id2_pg(project_id, session_id, context: schemas.CurrentContext, full_
data = helper.dict_to_camel_case(data)
if full_data:
if data["platform"] == 'ios' or data["platform"] == 'android':
data['events'] = events_ios.get_by_sessionId(project_id=project_id, session_id=session_id)
data['events'] = events_mobile.get_by_sessionId(project_id=project_id, session_id=session_id)
for e in data['events']:
if e["type"].endswith("_IOS"):
e["type"] = e["type"][:-len("_IOS")]
data['crashes'] = events_ios.get_crashes_by_session_id(session_id=session_id)
data['userEvents'] = events_ios.get_customs_by_session_id(project_id=project_id,
elif e["type"].endswith("_MOBILE"):
e["type"] = e["type"][:-len("_MOBILE")]
data['crashes'] = events_mobile.get_crashes_by_session_id(session_id=session_id)
data['userEvents'] = events_mobile.get_customs_by_session_id(project_id=project_id,
session_id=session_id)
data['mobsUrl'] = []
else:
@ -123,7 +125,7 @@ def get_replay(project_id, session_id, context: schemas.CurrentContext, full_dat
if full_data:
if data["platform"] == 'ios' or data["platform"] == 'android':
data['mobsUrl'] = []
data['videoURL'] = sessions_mobs.get_ios_videos(session_id=session_id, project_id=project_id,
data['videoURL'] = sessions_mobs.get_mobile_videos(session_id=session_id, project_id=project_id,
check_existence=False)
else:
data['mobsUrl'] = sessions_mobs.get_urls_depercated(session_id=session_id, check_existence=False)
@ -166,12 +168,14 @@ def get_events(project_id, session_id):
s_data = helper.dict_to_camel_case(s_data)
data = {}
if s_data["platform"] == 'ios' or s_data["platform"] == 'android':
data['events'] = events_ios.get_by_sessionId(project_id=project_id, session_id=session_id)
data['events'] = events_mobile.get_by_sessionId(project_id=project_id, session_id=session_id)
for e in data['events']:
if e["type"].endswith("_IOS"):
e["type"] = e["type"][:-len("_IOS")]
data['crashes'] = events_ios.get_crashes_by_session_id(session_id=session_id)
data['userEvents'] = events_ios.get_customs_by_session_id(project_id=project_id,
elif e["type"].endswith("_MOBILE"):
e["type"] = e["type"][:-len("_MOBILE")]
data['crashes'] = events_mobile.get_crashes_by_session_id(session_id=session_id)
data['userEvents'] = events_mobile.get_customs_by_session_id(project_id=project_id,
session_id=session_id)
data['userTesting'] = []
else:

View file

@ -64,15 +64,15 @@ def get_stages_and_events(filter_d: schemas.CardSeriesFilterSchema, project_id)
first_stage_extra_constraints.append(
sh.multi_conditions(f's.user_browser {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_os, schemas.FilterType.user_os_ios]:
elif filter_type in [schemas.FilterType.user_os, schemas.FilterType.user_os_mobile]:
first_stage_extra_constraints.append(
sh.multi_conditions(f's.user_os {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_device, schemas.FilterType.user_device_ios]:
elif filter_type in [schemas.FilterType.user_device, schemas.FilterType.user_device_mobile]:
first_stage_extra_constraints.append(
sh.multi_conditions(f's.user_device {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_country, schemas.FilterType.user_country_ios]:
elif filter_type in [schemas.FilterType.user_country, schemas.FilterType.user_country_mobile]:
first_stage_extra_constraints.append(
sh.multi_conditions(f's.user_country {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type == schemas.FilterType.duration:
@ -97,16 +97,16 @@ def get_stages_and_events(filter_d: schemas.CardSeriesFilterSchema, project_id)
f's.{metadata.index_to_colname(meta_keys[f.source])} {op} %({f_k})s', f.value,
is_not=is_not, value_key=f_k))
# values[f_k] = helper.string_to_sql_like_with_op(f["value"][0], op)
elif filter_type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
elif filter_type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
first_stage_extra_constraints.append(
sh.multi_conditions(f's.user_id {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
# values[f_k] = helper.string_to_sql_like_with_op(f["value"][0], op)
elif filter_type in [schemas.FilterType.user_anonymous_id,
schemas.FilterType.user_anonymous_id_ios]:
schemas.FilterType.user_anonymous_id_mobile]:
first_stage_extra_constraints.append(
sh.multi_conditions(f's.user_anonymous_id {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
# values[f_k] = helper.string_to_sql_like_with_op(f["value"][0], op)
elif filter_type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_ios]:
elif filter_type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_mobile]:
first_stage_extra_constraints.append(
sh.multi_conditions(f's.rev_id {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
# values[f_k] = helper.string_to_sql_like_with_op(f["value"][0], op)
@ -142,18 +142,18 @@ def get_stages_and_events(filter_d: schemas.CardSeriesFilterSchema, project_id)
next_table = events.EventType.CUSTOM.table
next_col_name = events.EventType.CUSTOM.column
# IOS --------------
elif event_type == events.EventType.CLICK_IOS.ui_type:
next_table = events.EventType.CLICK_IOS.table
next_col_name = events.EventType.CLICK_IOS.column
elif event_type == events.EventType.INPUT_IOS.ui_type:
next_table = events.EventType.INPUT_IOS.table
next_col_name = events.EventType.INPUT_IOS.column
elif event_type == events.EventType.VIEW_IOS.ui_type:
next_table = events.EventType.VIEW_IOS.table
next_col_name = events.EventType.VIEW_IOS.column
elif event_type == events.EventType.CUSTOM_IOS.ui_type:
next_table = events.EventType.CUSTOM_IOS.table
next_col_name = events.EventType.CUSTOM_IOS.column
elif event_type == events.EventType.CLICK_MOBILE.ui_type:
next_table = events.EventType.CLICK_MOBILE.table
next_col_name = events.EventType.CLICK_MOBILE.column
elif event_type == events.EventType.INPUT_MOBILE.ui_type:
next_table = events.EventType.INPUT_MOBILE.table
next_col_name = events.EventType.INPUT_MOBILE.column
elif event_type == events.EventType.VIEW_MOBILE.ui_type:
next_table = events.EventType.VIEW_MOBILE.table
next_col_name = events.EventType.VIEW_MOBILE.column
elif event_type == events.EventType.CUSTOM_MOBILE.ui_type:
next_table = events.EventType.CUSTOM_MOBILE.table
next_col_name = events.EventType.CUSTOM_MOBILE.column
else:
logging.warning(f"=================UNDEFINED:{event_type}")
continue

View file

@ -24,12 +24,12 @@ def transform_old_filter_type(cls, values):
"USERANONYMOUSID": FilterType.user_anonymous_id.value,
"REFERRER": FilterType.referrer.value,
"REVID": FilterType.rev_id.value,
"USEROS_IOS": FilterType.user_os_ios.value,
"USERDEVICE_IOS": FilterType.user_device_ios.value,
"USERCOUNTRY_IOS": FilterType.user_country_ios.value,
"USERID_IOS": FilterType.user_id_ios.value,
"USERANONYMOUSID_IOS": FilterType.user_anonymous_id_ios.value,
"REVID_IOS": FilterType.rev_id_ios.value,
"USEROS_IOS": FilterType.user_os_mobile.value,
"USERDEVICE_IOS": FilterType.user_device_mobile.value,
"USERCOUNTRY_IOS": FilterType.user_country_mobile.value,
"USERID_IOS": FilterType.user_id_mobile.value,
"USERANONYMOUSID_IOS": FilterType.user_anonymous_id_mobile.value,
"REVID_IOS": FilterType.rev_id_mobile.value,
"DURATION": FilterType.duration.value,
"PLATFORM": FilterType.platform.value,
"METADATA": FilterType.metadata.value,
@ -48,12 +48,12 @@ def transform_old_filter_type(cls, values):
"GRAPHQL": EventType.graphql.value,
"STATEACTION": EventType.state_action.value,
"ERROR": EventType.error.value,
"CLICK_IOS": EventType.click_ios.value,
"INPUT_IOS": EventType.input_ios.value,
"VIEW_IOS": EventType.view_ios.value,
"CUSTOM_IOS": EventType.custom_ios.value,
"REQUEST_IOS": EventType.request_ios.value,
"ERROR_IOS": EventType.error_ios.value,
"CLICK_MOBILE": EventType.click_mobile.value,
"INPUT_MOBILE": EventType.input_mobile.value,
"VIEW_MOBILE": EventType.view_mobile.value,
"CUSTOM_MOBILE": EventType.custom_mobile.value,
"REQUEST_MOBILE": EventType.request_mobile.value,
"ERROR_MOBILE": EventType.error_mobile.value,
"DOM_COMPLETE": PerformanceEventType.location_dom_complete.value,
"LARGEST_CONTENTFUL_PAINT_TIME": PerformanceEventType.location_largest_contentful_paint_time.value,
"TTFB": PerformanceEventType.location_ttfb.value,
@ -471,13 +471,13 @@ class EventType(str, Enum):
state_action = "stateAction"
error = "error"
tag = "tag"
click_ios = "tapIos"
input_ios = "inputIos"
view_ios = "viewIos"
custom_ios = "customIos"
request_ios = "requestIos"
error_ios = "errorIos"
swipe_ios = "swipeIos"
click_mobile = "tapIos"
input_mobile = "inputIos"
view_mobile = "viewIos"
custom_mobile = "customIos"
request_mobile = "requestIos"
error_mobile = "errorIos"
swipe_mobile = "swipeIos"
class PerformanceEventType(str, Enum):
@ -502,12 +502,12 @@ class FilterType(str, Enum):
referrer = "referrer"
rev_id = "revId"
# IOS
user_os_ios = "userOsIos"
user_device_ios = "userDeviceIos"
user_country_ios = "userCountryIos"
user_id_ios = "userIdIos"
user_anonymous_id_ios = "userAnonymousIdIos"
rev_id_ios = "revIdIos"
user_os_mobile = "userOsIos"
user_device_mobile = "userDeviceIos"
user_country_mobile = "userCountryIos"
user_id_mobile = "userIdIos"
user_anonymous_id_mobile = "userAnonymousIdIos"
rev_id_mobile = "revIdIos"
#
duration = "duration"
platform = "platform"

View file

@ -220,7 +220,7 @@ def __search_errors(project_id, value, key=None, source=None):
return helper.list_to_camel_case(results)
def __search_errors_ios(project_id, value, key=None, source=None):
def __search_errors_mobile(project_id, value, key=None, source=None):
# TODO: define this when ios events are supported in CH
return []

View file

@ -858,14 +858,14 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
_multiple_conditions(f's.user_browser {op} %({f_k})s', f.value, is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.user_os, schemas.FilterType.user_os_ios]:
elif filter_type in [schemas.FilterType.user_os, schemas.FilterType.user_os_mobile]:
if is_any:
ch_sessions_sub_query.append('isNotNull(s.user_os)')
else:
ch_sessions_sub_query.append(
_multiple_conditions(f's.user_os {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_device, schemas.FilterType.user_device_ios]:
elif filter_type in [schemas.FilterType.user_device, schemas.FilterType.user_device_mobile]:
if is_any:
ch_sessions_sub_query.append('isNotNull(s.user_device)')
else:
@ -873,7 +873,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
_multiple_conditions(f's.user_device {op} %({f_k})s', f.value, is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.user_country, schemas.FilterType.user_country_ios]:
elif filter_type in [schemas.FilterType.user_country, schemas.FilterType.user_country_mobile]:
if is_any:
ch_sessions_sub_query.append('isNotNull(s.user_country)')
else:
@ -942,7 +942,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
f"s.{metadata.index_to_colname(meta_keys[f.source])} {op} toString(%({f_k})s)",
f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
elif filter_type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
if is_any:
ch_sessions_sub_query.append('isNotNull(s.user_id)')
elif is_undefined:
@ -952,7 +952,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
_multiple_conditions(f"s.user_id {op} toString(%({f_k})s)", f.value, is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.user_anonymous_id,
schemas.FilterType.user_anonymous_id_ios]:
schemas.FilterType.user_anonymous_id_mobile]:
if is_any:
ch_sessions_sub_query.append('isNotNull(s.user_anonymous_id)')
elif is_undefined:
@ -963,7 +963,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_ios]:
elif filter_type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_mobile]:
if is_any:
ch_sessions_sub_query.append('isNotNull(s.rev_id)')
elif is_undefined:

View file

@ -132,14 +132,14 @@ class EventType:
ERROR = Event(ui_type=schemas.EventType.error, table="events.errors",
column=None) # column=None because errors are searched by name or message
METADATA = Event(ui_type=schemas.FilterType.metadata, table="public.sessions", column=None)
# IOS
CLICK_IOS = Event(ui_type=schemas.EventType.click_ios, table="events_ios.taps", column="label")
INPUT_IOS = Event(ui_type=schemas.EventType.input_ios, table="events_ios.inputs", column="label")
VIEW_IOS = Event(ui_type=schemas.EventType.view_ios, table="events_ios.views", column="name")
SWIPE_IOS = Event(ui_type=schemas.EventType.swipe_ios, table="events_ios.swipes", column="label")
CUSTOM_IOS = Event(ui_type=schemas.EventType.custom_ios, table="events_common.customs", column="name")
REQUEST_IOS = Event(ui_type=schemas.EventType.request_ios, table="events_common.requests", column="path")
CRASH_IOS = Event(ui_type=schemas.EventType.error_ios, table="events_common.crashes",
# MOBILE
CLICK_MOBILE = Event(ui_type=schemas.EventType.click_mobile, table="events_ios.taps", column="label")
INPUT_MOBILE = Event(ui_type=schemas.EventType.input_mobile, table="events_ios.inputs", column="label")
VIEW_MOBILE = Event(ui_type=schemas.EventType.view_mobile, table="events_ios.views", column="name")
SWIPE_MOBILE = Event(ui_type=schemas.EventType.swipe_mobile, table="events_ios.swipes", column="label")
CUSTOM_MOBILE = Event(ui_type=schemas.EventType.custom_mobile, table="events_common.customs", column="name")
REQUEST_MOBILE = Event(ui_type=schemas.EventType.request_mobile, table="events_common.requests", column="path")
CRASH_MOBILE = Event(ui_type=schemas.EventType.error_mobile, table="events_common.crashes",
column=None) # column=None because errors are searched by name or message
@ -168,22 +168,22 @@ SUPPORTED_TYPES = {
EventType.METADATA.ui_type: SupportedFilter(get=autocomplete.__search_metadata,
query=None),
# IOS
EventType.CLICK_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.CLICK_IOS),
EventType.CLICK_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.CLICK_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.CLICK_IOS.ui_type)),
EventType.INPUT_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.INPUT_IOS),
typename=EventType.CLICK_MOBILE.ui_type)),
EventType.INPUT_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.INPUT_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.INPUT_IOS.ui_type)),
EventType.VIEW_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.VIEW_IOS),
typename=EventType.INPUT_MOBILE.ui_type)),
EventType.VIEW_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.VIEW_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.VIEW_IOS.ui_type)),
EventType.CUSTOM_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.CUSTOM_IOS),
typename=EventType.VIEW_MOBILE.ui_type)),
EventType.CUSTOM_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.CUSTOM_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.CUSTOM_IOS.ui_type)),
EventType.REQUEST_IOS.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.REQUEST_IOS),
typename=EventType.CUSTOM_MOBILE.ui_type)),
EventType.REQUEST_MOBILE.ui_type: SupportedFilter(get=autocomplete.__generic_autocomplete(EventType.REQUEST_MOBILE),
query=autocomplete.__generic_query(
typename=EventType.REQUEST_IOS.ui_type)),
EventType.CRASH_IOS.ui_type: SupportedFilter(get=autocomplete.__search_errors_ios,
typename=EventType.REQUEST_MOBILE.ui_type)),
EventType.CRASH_MOBILE.ui_type: SupportedFilter(get=autocomplete.__search_errors_mobile,
query=None),
}
@ -207,15 +207,15 @@ def search(text, event_type, project_id, source, key):
if event_type in SUPPORTED_TYPES.keys():
rows = SUPPORTED_TYPES[event_type].get(project_id=project_id, value=text, key=key, source=source)
# for IOS events autocomplete
# if event_type + "_IOS" in SUPPORTED_TYPES.keys():
# rows += SUPPORTED_TYPES[event_type + "_IOS"].get(project_id=project_id, value=text, key=key,source=source)
elif event_type + "_IOS" in SUPPORTED_TYPES.keys():
rows = SUPPORTED_TYPES[event_type + "_IOS"].get(project_id=project_id, value=text, key=key, source=source)
# for MOBILE events autocomplete
# if event_type + "_MOBILE" in SUPPORTED_TYPES.keys():
# rows += SUPPORTED_TYPES[event_type + "_MOBILE"].get(project_id=project_id, value=text, key=key,source=source)
elif event_type + "_MOBILE" in SUPPORTED_TYPES.keys():
rows = SUPPORTED_TYPES[event_type + "_MOBILE"].get(project_id=project_id, value=text, key=key, source=source)
elif event_type in sessions_metas.SUPPORTED_TYPES.keys():
return sessions_metas.search(text, event_type, project_id)
elif event_type.endswith("_IOS") \
and event_type[:-len("_IOS")] in sessions_metas.SUPPORTED_TYPES.keys():
elif event_type.endswith("_MOBILE") \
and event_type[:-len("_MOBILE")] in sessions_metas.SUPPORTED_TYPES.keys():
return sessions_metas.search(text, event_type, project_id)
else:
return {"errors": ["unsupported event"]}

View file

@ -264,7 +264,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
f"{metadata.index_to_colname(meta_keys[f.source])} {op} toString(%({f_k})s)",
f.value, is_not=is_not, value_key=f_k))
elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
if is_any:
sessions_conditions.append('isNotNull(user_id)')
elif is_undefined:
@ -275,7 +275,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
value_key=f_k))
elif f.type in [schemas.FilterType.user_anonymous_id,
schemas.FilterType.user_anonymous_id_ios]:
schemas.FilterType.user_anonymous_id_mobile]:
if is_any:
sessions_conditions.append('isNotNull(user_anonymous_id)')
elif is_undefined:
@ -285,7 +285,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
sh.multi_conditions(f"user_anonymous_id {op} toString(%({f_k})s)", f.value, is_not=is_not,
value_key=f_k))
elif f.type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_ios]:
elif f.type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_mobile]:
if is_any:
sessions_conditions.append('isNotNull(rev_id)')
elif is_undefined:
@ -683,7 +683,7 @@ ORDER BY event_number_in_session;"""
# elif f.type == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# meta_condition.append("sessions_metadata.user_id IS NOT NULL")
# meta_condition.append("not empty(sessions_metadata.user_id)")
@ -783,7 +783,7 @@ ORDER BY event_number_in_session;"""
# elif f.type == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# meta_condition.append("sessions_metadata.user_id IS NOT NULL")
# meta_condition.append("not empty(sessions_metadata.user_id)")
@ -890,7 +890,7 @@ ORDER BY event_number_in_session;"""
# if f.type == "EVENT_TYPE" and JOURNEY_TYPES.get(f["value"]):
# event_table = JOURNEY_TYPES[f["value"]]["table"]
# event_column = JOURNEY_TYPES[f["value"]]["column"]
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# meta_condition.append("sessions_metadata.user_id IS NOT NULL")
# meta_condition.append("not empty(sessions_metadata.user_id)")
@ -963,7 +963,7 @@ ORDER BY event_number_in_session;"""
# elif f.type == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# meta_condition.append("sessions_metadata.user_id IS NOT NULL")
# meta_condition.append("not empty(sessions_metadata.user_id)")
@ -1048,7 +1048,7 @@ ORDER BY event_number_in_session;"""
# elif f.type == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# meta_condition.append("user_id IS NOT NULL")
# meta_condition.append("not empty(sessions_metadata.user_id)")
@ -1117,7 +1117,7 @@ ORDER BY event_number_in_session;"""
# elif f.type == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# meta_condition.append("sessions_metadata.project_id = %(project_id)s")
# meta_condition.append("sessions_metadata.datetime >= toDateTime(%(startTimestamp)s/1000)")
@ -1181,7 +1181,7 @@ ORDER BY event_number_in_session;"""
# if f.type == "EVENT_TYPE" and JOURNEY_TYPES.get(f["value"]):
# event_table = JOURNEY_TYPES[f["value"]]["table"]
# event_column = JOURNEY_TYPES[f["value"]]["column"]
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# meta_condition.append("sessions_metadata.project_id = %(project_id)s")
# meta_condition.append("sessions_metadata.datetime >= toDateTime(%(startTimestamp)s/1000)")
@ -1220,7 +1220,7 @@ ORDER BY event_number_in_session;"""
# for f in filters:
# if f.type == "PERIOD" and f["value"] in ["DAY", "WEEK"]:
# period = f["value"]
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# extra_values["user_id"] = f["value"]
# period_function = PERIOD_TO_FUNCTION[period]
@ -1311,7 +1311,7 @@ ORDER BY event_number_in_session;"""
# elif f.type == "EVENT_VALUE":
# event_value = f["value"]
# default = False
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
# elif f.type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
# meta_condition.append(f"sessions_metadata.user_id = %(user_id)s")
# meta_condition.append("sessions_metadata.project_id = %(project_id)s")
# meta_condition.append("sessions_metadata.datetime >= toDateTime(%(startTimestamp)s/1000)")

View file

@ -522,7 +522,7 @@ def __get_event_type(event_type: Union[schemas.EventType, schemas.PerformanceEve
schemas.PerformanceEventType.location_avg_cpu_load: 'PERFORMANCE',
schemas.PerformanceEventType.location_avg_memory_usage: 'PERFORMANCE'
}
defs_ios = {
defs_mobile = {
schemas.EventType.click: "TAP",
schemas.EventType.input: "INPUT",
schemas.EventType.location: "VIEW",
@ -532,8 +532,8 @@ def __get_event_type(event_type: Union[schemas.EventType, schemas.PerformanceEve
schemas.PerformanceEventType.fetch_failed: "REQUEST",
schemas.EventType.error: "CRASH",
}
if platform == "ios" and event_type in defs_ios:
return defs_ios.get(event_type)
if platform == "ios" and event_type in defs_mobile:
return defs_mobile.get(event_type)
if event_type not in defs:
raise Exception(f"unsupported EventType:{event_type}")
return defs.get(event_type)
@ -605,7 +605,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu
ss_constraints.append(
_multiple_conditions(f'ms.user_browser {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_os, schemas.FilterType.user_os_ios]:
elif filter_type in [schemas.FilterType.user_os, schemas.FilterType.user_os_mobile]:
if is_any:
extra_constraints.append('isNotNull(s.user_os)')
ss_constraints.append('isNotNull(ms.user_os)')
@ -615,7 +615,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu
ss_constraints.append(
_multiple_conditions(f'ms.user_os {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_device, schemas.FilterType.user_device_ios]:
elif filter_type in [schemas.FilterType.user_device, schemas.FilterType.user_device_mobile]:
if is_any:
extra_constraints.append('isNotNull(s.user_device)')
ss_constraints.append('isNotNull(ms.user_device)')
@ -625,7 +625,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu
ss_constraints.append(
_multiple_conditions(f'ms.user_device {op} %({f_k})s', f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_country, schemas.FilterType.user_country_ios]:
elif filter_type in [schemas.FilterType.user_country, schemas.FilterType.user_country_mobile]:
if is_any:
extra_constraints.append('isNotNull(s.user_country)')
ss_constraints.append('isNotNull(ms.user_country)')
@ -739,7 +739,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu
_multiple_conditions(
f"ms.{metadata.index_to_colname(meta_keys[f.source])} {op} toString(%({f_k})s)",
f.value, is_not=is_not, value_key=f_k))
elif filter_type in [schemas.FilterType.user_id, schemas.FilterType.user_id_ios]:
elif filter_type in [schemas.FilterType.user_id, schemas.FilterType.user_id_mobile]:
if is_any:
extra_constraints.append('isNotNull(s.user_id)')
ss_constraints.append('isNotNull(ms.user_id)')
@ -754,7 +754,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu
_multiple_conditions(f"ms.user_id {op} toString(%({f_k})s)", f.value, is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.user_anonymous_id,
schemas.FilterType.user_anonymous_id_ios]:
schemas.FilterType.user_anonymous_id_mobile]:
if is_any:
extra_constraints.append('isNotNull(s.user_anonymous_id)')
ss_constraints.append('isNotNull(ms.user_anonymous_id)')
@ -768,7 +768,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu
ss_constraints.append(
_multiple_conditions(f"ms.user_anonymous_id {op} toString(%({f_k})s)", f.value, is_not=is_not,
value_key=f_k))
elif filter_type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_ios]:
elif filter_type in [schemas.FilterType.rev_id, schemas.FilterType.rev_id_mobile]:
if is_any:
extra_constraints.append('isNotNull(s.rev_id)')
ss_constraints.append('isNotNull(ms.rev_id)')
@ -896,7 +896,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu
value_key=e_k))
events_conditions[-1]["condition"] = event_where[-1]
else:
_column = events.EventType.CLICK_IOS.column
_column = events.EventType.CLICK_MOBILE.column
event_where.append(f"main.event_type='{__get_event_type(event_type, platform=platform)}'")
events_conditions.append({"type": event_where[-1]})
if not is_any:

View file

@ -47,26 +47,26 @@ SUPPORTED_TYPES = {
schemas.FilterType.utm_source: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.utm_source),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.utm_source)),
# IOS
schemas.FilterType.user_os_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_os_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_os_ios)),
schemas.FilterType.user_device_ios: SupportedFilter(
# MOBILE
schemas.FilterType.user_os_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_os_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_os_mobile)),
schemas.FilterType.user_device_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(
typename=schemas.FilterType.user_device_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_device_ios)),
schemas.FilterType.user_country_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_country_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_country_ios)),
schemas.FilterType.user_id_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_id_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_id_ios)),
schemas.FilterType.user_anonymous_id_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_anonymous_id_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_anonymous_id_ios)),
schemas.FilterType.rev_id_ios: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.rev_id_ios),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.rev_id_ios)),
typename=schemas.FilterType.user_device_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_device_mobile)),
schemas.FilterType.user_country_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_country_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_country_mobile)),
schemas.FilterType.user_id_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_id_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_id_mobile)),
schemas.FilterType.user_anonymous_id_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_anonymous_id_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.user_anonymous_id_mobile)),
schemas.FilterType.rev_id_mobile: SupportedFilter(
get=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.rev_id_mobile),
query=autocomplete.__generic_autocomplete_metas(typename=schemas.FilterType.rev_id_mobile)),
}