diff --git a/api/chalicelib/core/errors/errors_details.py b/api/chalicelib/core/errors/errors_details.py index d2d3a16cb..0f17fc29b 100644 --- a/api/chalicelib/core/errors/errors_details.py +++ b/api/chalicelib/core/errors/errors_details.py @@ -1,5 +1,5 @@ from chalicelib.core.errors.modules import errors_helper -from chalicelib.utils import errors_helper + from chalicelib.utils import pg_client, helper from chalicelib.utils.TimeUTC import TimeUTC from chalicelib.utils.metrics_helper import get_step_size @@ -98,8 +98,7 @@ def get_details(project_id, error_id, user_id, **data): device_partition, country_partition, chart24, - chart30, - custom_tags + chart30 FROM (SELECT error_id, name, message, @@ -114,15 +113,8 @@ def get_details(project_id, error_id, user_id, **data): MIN(timestamp) AS first_occurrence FROM events.errors WHERE error_id = %(error_id)s) AS time_details ON (TRUE) - INNER JOIN (SELECT session_id AS last_session_id, - coalesce(custom_tags, '[]')::jsonb AS custom_tags + INNER JOIN (SELECT session_id AS last_session_id FROM events.errors - LEFT JOIN LATERAL ( - SELECT jsonb_agg(jsonb_build_object(errors_tags.key, errors_tags.value)) AS custom_tags - FROM errors_tags - WHERE errors_tags.error_id = %(error_id)s - AND errors_tags.session_id = errors.session_id - AND errors_tags.message_id = errors.message_id) AS errors_tags ON (TRUE) WHERE error_id = %(error_id)s ORDER BY errors.timestamp DESC LIMIT 1) AS last_session_details ON (TRUE) diff --git a/api/chalicelib/core/errors/modules/helper.py b/api/chalicelib/core/errors/modules/helper.py index af0c9e40b..d781ccf0b 100644 --- a/api/chalicelib/core/errors/modules/helper.py +++ b/api/chalicelib/core/errors/modules/helper.py @@ -1,6 +1,7 @@ from typing import Optional import schemas +from chalicelib.core.sourcemaps import sourcemaps def __get_basic_constraints(platform: Optional[schemas.PlatformType] = None, time_constraint: bool = True, @@ -42,3 +43,16 @@ def __get_basic_constraints_ch(platform=None, time_constraint=True, startTime_ar elif platform == schemas.PlatformType.DESKTOP: ch_sub_query.append("user_device_type = 'desktop'") return ch_sub_query + + +def format_first_stack_frame(error): + error["stack"] = sourcemaps.format_payload(error.pop("payload"), truncate_to_first=True) + for s in error["stack"]: + for c in s.get("context", []): + for sci, sc in enumerate(c): + if isinstance(sc, str) and len(sc) > 1000: + c[sci] = sc[:1000] + # convert bytes to string: + if isinstance(s["filename"], bytes): + s["filename"] = s["filename"].decode("utf-8") + return error diff --git a/api/chalicelib/core/sessions/sessions_replay.py b/api/chalicelib/core/sessions/sessions_replay.py index b4e9085d1..24e8a9478 100644 --- a/api/chalicelib/core/sessions/sessions_replay.py +++ b/api/chalicelib/core/sessions/sessions_replay.py @@ -2,7 +2,7 @@ import schemas from chalicelib.core import events, metadata, events_mobile, \ issues, assist, canvas, user_testing from . import sessions_mobs, sessions_devtool -from chalicelib.utils import errors_helper +from chalicelib.core.errors.modules import errors_helper from chalicelib.utils import pg_client, helper from chalicelib.core.modules import MOB_KEY, get_file_key diff --git a/api/chalicelib/utils/errors_helper.py b/api/chalicelib/utils/errors_helper.py deleted file mode 100644 index 6c0d697d6..000000000 --- a/api/chalicelib/utils/errors_helper.py +++ /dev/null @@ -1,14 +0,0 @@ -from chalicelib.core.sourcemaps import sourcemaps - - -def format_first_stack_frame(error): - error["stack"] = sourcemaps.format_payload(error.pop("payload"), truncate_to_first=True) - for s in error["stack"]: - for c in s.get("context", []): - for sci, sc in enumerate(c): - if isinstance(sc, str) and len(sc) > 1000: - c[sci] = sc[:1000] - # convert bytes to string: - if isinstance(s["filename"], bytes): - s["filename"] = s["filename"].decode("utf-8") - return error diff --git a/ee/api/.gitignore b/ee/api/.gitignore index 0bd67932c..ce25ba5be 100644 --- a/ee/api/.gitignore +++ b/ee/api/.gitignore @@ -235,7 +235,6 @@ Pipfile.lock /chalicelib/utils/dev.py /chalicelib/utils/email_handler.py /chalicelib/utils/email_helper.py -/chalicelib/utils/errors_helper.py /chalicelib/utils/event_filter_definition.py /chalicelib/utils/github_client_v3.py /chalicelib/utils/helper.py diff --git a/ee/api/chalicelib/core/errors/errors_details_exp.py b/ee/api/chalicelib/core/errors/errors_details_exp.py index bbf69f15f..95e45c9e6 100644 --- a/ee/api/chalicelib/core/errors/errors_details_exp.py +++ b/ee/api/chalicelib/core/errors/errors_details_exp.py @@ -107,16 +107,14 @@ def get_details(project_id, error_id, user_id, **data): 'UNDEFINED' AS user_os_version, NULL AS user_device_type, `$device` AS user_device, - `$country` AS user_country, - [] AS error_tags_keys, - [] AS error_tags_values + `$country` AS user_country FROM {MAIN_ERR_SESS_TABLE} AS errors WHERE {" AND ".join(ch_basic_query)} ) SELECT %(error_id)s AS error_id, name, message,users, first_occurrence,last_occurrence,last_session_id, sessions,browsers_partition,os_partition,device_partition, - country_partition,chart24,chart30,custom_tags + country_partition,chart24,chart30 FROM (SELECT error_id, name, message @@ -131,8 +129,7 @@ def get_details(project_id, error_id, user_id, **data): INNER JOIN (SELECT toUnixTimestamp(max(datetime)) * 1000 AS last_occurrence, toUnixTimestamp(min(datetime)) * 1000 AS first_occurrence FROM pre_processed) AS time_details ON TRUE - INNER JOIN (SELECT session_id AS last_session_id, - arrayMap((key, value)->(map(key, value)), error_tags_keys, error_tags_values) AS custom_tags + INNER JOIN (SELECT session_id AS last_session_id FROM pre_processed ORDER BY datetime DESC LIMIT 1) AS last_session_details ON TRUE diff --git a/ee/api/clean-dev.sh b/ee/api/clean-dev.sh index b24d6a3e9..2b69dd551 100755 --- a/ee/api/clean-dev.sh +++ b/ee/api/clean-dev.sh @@ -59,7 +59,6 @@ rm -rf ./chalicelib/utils/captcha.py rm -rf ./chalicelib/utils/dev.py rm -rf ./chalicelib/utils/email_handler.py rm -rf ./chalicelib/utils/email_helper.py -rm -rf ./chalicelib/utils/errors_helper.py rm -rf ./chalicelib/utils/event_filter_definition.py rm -rf ./chalicelib/utils/github_client_v3.py rm -rf ./chalicelib/utils/helper.py