Skip to content

Commit ba38f6f

Browse files
committed
feat: use json
1 parent 0680374 commit ba38f6f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

posthog/exception_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# 💖open source (under MIT License)
66
# We want to keep payloads as similar to Sentry as possible for easy interoperability
77

8+
import json
89
import linecache
910
import os
1011
import re
@@ -931,7 +932,7 @@ def _serialize_variable_value(value, max_length=1024):
931932
elif isinstance(value, str):
932933
result = repr(value)
933934
else:
934-
result = repr(value)
935+
result = json.dumps(value)
935936

936937
# Truncate if too long
937938
if len(result) > max_length:

posthog/test/test_exception_capture.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def process_data():
7878
assert b"'my_string': \"'hello world'\"" in output
7979
assert b"'my_number': '42'" in output
8080
assert b"'my_bool': 'True'" in output
81-
assert b"'my_dict': \"{'name': 'test', 'value': 123}\"" in output
82-
assert b"'my_obj': '<__main__.UnserializableObject object at " in output
81+
assert b'"my_dict": "{\\"name\\": \\"test\\", \\"value\\": 123}"' in output
82+
assert b'"my_obj": "<UnserializableObject>"' in output
8383
assert b"'my_password': '***'" in output
8484
assert b"'__should_be_ignored':" not in output
8585

0 commit comments

Comments
 (0)