diff --git a/api/chalicelib/core/sessions.py b/api/chalicelib/core/sessions.py index d230e8810..b9a64cdc5 100644 --- a/api/chalicelib/core/sessions.py +++ b/api/chalicelib/core/sessions.py @@ -814,12 +814,6 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status, event_where.append( 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_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_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 " if not is_any: @@ -855,7 +849,7 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status, event_where.append(sh.multi_conditions(f"main1.source = %({s_k})s", event.source, value_key=s_k)) - # ----- IOS + # ----- Mobile 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: @@ -897,6 +891,13 @@ def search_query_parts(data: schemas.SessionsSearchPayloadSchema, error_status, event_where.append( sh.multi_conditions(f"(main1.reason {op} %({e_k})s OR main1.name {op} %({e_k})s)", event.value, value_key=e_k)) + elif event_type == events.EventType.SWIPE_MOBILE.ui_type and platform != "web": + 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_MOBILE.column} {op} %({e_k})s", + event.value, value_key=e_k)) + elif event_type == schemas.PerformanceEventType.fetch_failed: event_from = event_from % f"{events.EventType.REQUEST.table} AS main " if not is_any: diff --git a/api/routers/core.py b/api/routers/core.py index 40bf26520..7c5a90456 100644 --- a/api/routers/core.py +++ b/api/routers/core.py @@ -19,6 +19,7 @@ from routers.base import get_routers public_app, app, app_apikey = get_routers() +@app.get('/{projectId}/autocomplete', tags=["events"]) @app.get('/{projectId}/events/search', tags=["events"]) def events_search(projectId: int, q: str, type: Union[schemas.FilterType, schemas.EventType, diff --git a/api/schemas/schemas.py b/api/schemas/schemas.py index f074f10be..766cc833b 100644 --- a/api/schemas/schemas.py +++ b/api/schemas/schemas.py @@ -471,13 +471,13 @@ class EventType(str, Enum): state_action = "stateAction" error = "error" tag = "tag" - click_mobile = "tapIos" - input_mobile = "inputIos" - view_mobile = "viewIos" - custom_mobile = "customIos" - request_mobile = "requestIos" - error_mobile = "errorIos" - swipe_mobile = "swipeIos" + click_mobile = "click_mobile" + input_mobile = "input_mobile" + view_mobile = "view_mobile" + custom_mobile = "custom_mobile" + request_mobile = "request_mobile" + error_mobile = "error_mobile" + swipe_mobile = "swipe_mobile" class PerformanceEventType(str, Enum): diff --git a/ee/api/chalicelib/core/sessions_exp.py b/ee/api/chalicelib/core/sessions_exp.py index da9b3bdc8..575476c95 100644 --- a/ee/api/chalicelib/core/sessions_exp.py +++ b/ee/api/chalicelib/core/sessions_exp.py @@ -567,7 +567,7 @@ 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_mobile: + if platform != "web" 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}") @@ -968,7 +968,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu value_key=f"custom{i}")) full_args = {**full_args, **_multiple_values(event.source, value_key=f"custom{i}")} else: - _column = events.EventType.INPUT_IOS.column + _column = events.EventType.INPUT_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: @@ -1001,7 +1001,7 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu event.value, value_key=e_k)) events_conditions[-1]["condition"] = event_where[-1] else: - _column = events.EventType.VIEW_IOS.column + _column = events.EventType.VIEW_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: @@ -1093,6 +1093,114 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu events_conditions[-1]["condition"] = " AND ".join(events_conditions[-1]["condition"]) + # ----- Mobile + elif event_type == events.EventType.CLICK_MOBILE.ui_type: + _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: + if is_not: + event_where.append(_multiple_conditions(f"sub.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions_not.append( + {"type": f"sub.event_type='{__get_event_type(event_type, platform=platform)}'"}) + events_conditions_not[-1]["condition"] = event_where[-1] + else: + event_where.append(_multiple_conditions(f"main.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions[-1]["condition"] = event_where[-1] + elif event_type == events.EventType.INPUT_MOBILE.ui_type: + _column = events.EventType.INPUT_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: + if is_not: + event_where.append(_multiple_conditions(f"sub.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions_not.append( + {"type": f"sub.event_type='{__get_event_type(event_type, platform=platform)}'"}) + events_conditions_not[-1]["condition"] = event_where[-1] + else: + event_where.append(_multiple_conditions(f"main.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions[-1]["condition"] = event_where[-1] + elif event_type == events.EventType.VIEW_MOBILE.ui_type: + _column = events.EventType.VIEW_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: + if is_not: + event_where.append(_multiple_conditions(f"sub.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions_not.append( + {"type": f"sub.event_type='{__get_event_type(event_type, platform=platform)}'"}) + events_conditions_not[-1]["condition"] = event_where[-1] + else: + event_where.append(_multiple_conditions(f"main.{_column} {op} %({e_k})s", + event.value, value_key=e_k)) + events_conditions[-1]["condition"] = event_where[-1] + elif event_type == events.EventType.CUSTOM_MOBILE.ui_type: + _column = events.EventType.CUSTOM_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: + if is_not: + event_where.append(_multiple_conditions(f"sub.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions_not.append( + {"type": f"sub.event_type='{__get_event_type(event_type, platform=platform)}'"}) + events_conditions_not[-1]["condition"] = event_where[-1] + else: + event_where.append(_multiple_conditions(f"main.{_column} {op} %({e_k})s", + event.value, value_key=e_k)) + events_conditions[-1]["condition"] = event_where[-1] + elif event_type == events.EventType.REQUEST_MOBILE.ui_type: + event_from = event_from % f"{MAIN_EVENTS_TABLE} AS main " + _column = 'url_path' + 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: + if is_not: + event_where.append(_multiple_conditions(f"sub.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions_not.append( + {"type": f"sub.event_type='{__get_event_type(event_type, platform=platform)}'"}) + events_conditions_not[-1]["condition"] = event_where[-1] + else: + event_where.append(_multiple_conditions(f"main.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions[-1]["condition"] = event_where[-1] + elif event_type == events.EventType.CRASH_MOBILE.ui_type: + _column = events.EventType.CRASH_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: + if is_not: + event_where.append(_multiple_conditions(f"sub.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions_not.append( + {"type": f"sub.event_type='{__get_event_type(event_type, platform=platform)}'"}) + events_conditions_not[-1]["condition"] = event_where[-1] + else: + event_where.append(_multiple_conditions(f"main.{_column} {op} %({e_k})s", + event.value, value_key=e_k)) + events_conditions[-1]["condition"] = event_where[-1] + elif event_type == events.EventType.SWIPE_MOBILE.ui_type and platform != "web": + _column = events.EventType.SWIPE_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: + if is_not: + event_where.append(_multiple_conditions(f"sub.{_column} {op} %({e_k})s", event.value, + value_key=e_k)) + events_conditions_not.append( + {"type": f"sub.event_type='{__get_event_type(event_type, platform=platform)}'"}) + events_conditions_not[-1]["condition"] = event_where[-1] + else: + event_where.append(_multiple_conditions(f"main.{_column} {op} %({e_k})s", + event.value, value_key=e_k)) + events_conditions[-1]["condition"] = event_where[-1] + elif event_type == schemas.PerformanceEventType.fetch_failed: event_from = event_from % f"{MAIN_EVENTS_TABLE} AS main " _column = 'url_path'