Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Send event json errors #847

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data_diff/diff_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def diff_tables(self, table1: TableSegment, table2: TableSegment, info_tree: Inf
def _diff_tables_wrapper(self, table1: TableSegment, table2: TableSegment, info_tree: InfoTree) -> DiffResult:
if is_tracking_enabled():
options = attrs.asdict(self, recurse=False)
# not a useful event attribute
options.pop("_ignored_columns_lock")
options["differ_name"] = type(self).__name__
event_json = create_start_event_json(options)
run_as_daemon(send_event_json, event_json)
Expand Down
17 changes: 17 additions & 0 deletions data_diff/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,27 @@ def create_email_signup_event_json(email: str) -> Dict[str, Any]:
}


def convert_sets_to_lists(obj):
"""
Recursively convert sets in the given object to lists.
"""
if isinstance(obj, set):
return list(obj)
elif isinstance(obj, dict):
return {k: convert_sets_to_lists(v) for k, v in obj.items()}
elif isinstance(obj, list):
return [convert_sets_to_lists(elem) for elem in obj]
else:
return obj


def send_event_json(event_json) -> None:
if not g_tracking_enabled:
raise RuntimeError("Won't send; tracking is disabled!")

# Convert sets to lists in event_json
event_json = convert_sets_to_lists(event_json)

headers = {
"Content-Type": "application/json",
"Authorization": "Basic MkhndE00SGNxOUJtZWlDcU5ZaHo3Tzl0a2pNOg==",
Expand Down