posthoganalytics 7.0.0__tar.gz → 7.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {posthoganalytics-7.0.0/posthoganalytics.egg-info → posthoganalytics-7.0.1}/PKG-INFO +1 -1
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/client.py +3 -2
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/exception_utils.py +22 -11
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_exception_capture.py +75 -1
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/version.py +1 -1
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1/posthoganalytics.egg-info}/PKG-INFO +1 -1
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/LICENSE +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/MANIFEST.in +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/README.md +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/__init__.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/__init__.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/anthropic/__init__.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/anthropic/anthropic.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/anthropic/anthropic_async.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/anthropic/anthropic_converter.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/anthropic/anthropic_providers.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/gemini/__init__.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/gemini/gemini.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/gemini/gemini_converter.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/langchain/__init__.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/langchain/callbacks.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/openai/__init__.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/openai/openai.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/openai/openai_async.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/openai/openai_converter.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/openai/openai_providers.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/sanitization.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/types.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/utils.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/args.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/consumer.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/contexts.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/exception_capture.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/feature_flags.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/integrations/__init__.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/integrations/django.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/poller.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/py.typed +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/request.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/__init__.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_before_send.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_client.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_consumer.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_contexts.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_feature_flag.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_feature_flag_result.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_feature_flags.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_module.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_request.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_size_limited_dict.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_types.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_utils.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/types.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/utils.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics.egg-info/SOURCES.txt +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics.egg-info/dependency_links.txt +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics.egg-info/requires.txt +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics.egg-info/top_level.txt +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/pyproject.toml +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/setup.cfg +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/setup.py +0 -0
- {posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/setup_analytics.py +0 -0
|
@@ -295,8 +295,9 @@ class Client(object):
|
|
|
295
295
|
# to call flush().
|
|
296
296
|
if send:
|
|
297
297
|
atexit.register(self.join)
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
|
|
299
|
+
self.consumers = []
|
|
300
|
+
for _ in range(thread):
|
|
300
301
|
consumer = Consumer(
|
|
301
302
|
self.queue,
|
|
302
303
|
self.api_key,
|
|
@@ -969,19 +969,30 @@ def _serialize_variable_value(value, limiter, max_length=1024):
|
|
|
969
969
|
return result
|
|
970
970
|
except Exception:
|
|
971
971
|
try:
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
972
|
+
result = repr(value)
|
|
973
|
+
if len(result) > max_length:
|
|
974
|
+
result = result[: max_length - 3] + "..."
|
|
975
|
+
|
|
976
|
+
result_size = len(result)
|
|
977
|
+
if not limiter.can_add(result_size):
|
|
975
978
|
return None
|
|
976
|
-
limiter.add(
|
|
977
|
-
return
|
|
979
|
+
limiter.add(result_size)
|
|
980
|
+
return result
|
|
978
981
|
except Exception:
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
982
|
+
try:
|
|
983
|
+
fallback = f"<{type(value).__name__}>"
|
|
984
|
+
fallback_size = len(fallback)
|
|
985
|
+
if not limiter.can_add(fallback_size):
|
|
986
|
+
return None
|
|
987
|
+
limiter.add(fallback_size)
|
|
988
|
+
return fallback
|
|
989
|
+
except Exception:
|
|
990
|
+
fallback = "<unserializable object>"
|
|
991
|
+
fallback_size = len(fallback)
|
|
992
|
+
if not limiter.can_add(fallback_size):
|
|
993
|
+
return None
|
|
994
|
+
limiter.add(fallback_size)
|
|
995
|
+
return fallback
|
|
985
996
|
|
|
986
997
|
|
|
987
998
|
def _is_simple_type(value):
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_exception_capture.py
RENAMED
|
@@ -96,7 +96,7 @@ def test_code_variables_capture(tmpdir):
|
|
|
96
96
|
assert b"'my_number': 42" in output
|
|
97
97
|
assert b"'my_bool': 'True'" in output
|
|
98
98
|
assert b'"my_dict": "{\\"name\\": \\"test\\", \\"value\\": 123}"' in output
|
|
99
|
-
assert b
|
|
99
|
+
assert b"<__main__.UnserializableObject object at" in output
|
|
100
100
|
assert b"'my_password': '$$_posthog_redacted_based_on_masking_rules_$$'" in output
|
|
101
101
|
assert b"'__should_be_ignored':" not in output
|
|
102
102
|
|
|
@@ -332,3 +332,77 @@ def test_code_variables_enabled_then_disabled_in_context(tmpdir):
|
|
|
332
332
|
assert '"code_variables":' not in output
|
|
333
333
|
assert "'my_var'" not in output
|
|
334
334
|
assert "'important_value'" not in output
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def test_code_variables_repr_fallback(tmpdir):
|
|
338
|
+
app = tmpdir.join("app.py")
|
|
339
|
+
app.write(
|
|
340
|
+
dedent(
|
|
341
|
+
"""
|
|
342
|
+
import os
|
|
343
|
+
import re
|
|
344
|
+
from datetime import datetime, timedelta
|
|
345
|
+
from decimal import Decimal
|
|
346
|
+
from fractions import Fraction
|
|
347
|
+
from posthoganalytics import Posthog
|
|
348
|
+
|
|
349
|
+
class CustomReprClass:
|
|
350
|
+
def __repr__(self):
|
|
351
|
+
return '<CustomReprClass: custom representation>'
|
|
352
|
+
|
|
353
|
+
posthog = Posthog(
|
|
354
|
+
'phc_x',
|
|
355
|
+
host='https://eu.i.posthog.com',
|
|
356
|
+
debug=True,
|
|
357
|
+
enable_exception_autocapture=True,
|
|
358
|
+
capture_exception_code_variables=True,
|
|
359
|
+
project_root=os.path.dirname(os.path.abspath(__file__))
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
def trigger_error():
|
|
363
|
+
my_regex = re.compile(r'\\d+')
|
|
364
|
+
my_datetime = datetime(2024, 1, 15, 10, 30, 45)
|
|
365
|
+
my_timedelta = timedelta(days=5, hours=3)
|
|
366
|
+
my_decimal = Decimal('123.456')
|
|
367
|
+
my_fraction = Fraction(3, 4)
|
|
368
|
+
my_set = {1, 2, 3}
|
|
369
|
+
my_frozenset = frozenset([4, 5, 6])
|
|
370
|
+
my_bytes = b'hello bytes'
|
|
371
|
+
my_bytearray = bytearray(b'mutable bytes')
|
|
372
|
+
my_memoryview = memoryview(b'memory view')
|
|
373
|
+
my_complex = complex(3, 4)
|
|
374
|
+
my_range = range(10)
|
|
375
|
+
my_custom = CustomReprClass()
|
|
376
|
+
my_lambda = lambda x: x * 2
|
|
377
|
+
my_function = trigger_error
|
|
378
|
+
|
|
379
|
+
1/0
|
|
380
|
+
|
|
381
|
+
trigger_error()
|
|
382
|
+
"""
|
|
383
|
+
)
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
with pytest.raises(subprocess.CalledProcessError) as excinfo:
|
|
387
|
+
subprocess.check_output([sys.executable, str(app)], stderr=subprocess.STDOUT)
|
|
388
|
+
|
|
389
|
+
output = excinfo.value.output.decode("utf-8")
|
|
390
|
+
|
|
391
|
+
assert "ZeroDivisionError" in output
|
|
392
|
+
assert "code_variables" in output
|
|
393
|
+
|
|
394
|
+
assert "re.compile(" in output and "\\\\d+" in output
|
|
395
|
+
assert "datetime.datetime(2024, 1, 15, 10, 30, 45)" in output
|
|
396
|
+
assert "datetime.timedelta(days=5, seconds=10800)" in output
|
|
397
|
+
assert "Decimal('123.456')" in output
|
|
398
|
+
assert "Fraction(3, 4)" in output
|
|
399
|
+
assert "{1, 2, 3}" in output
|
|
400
|
+
assert "frozenset({4, 5, 6})" in output
|
|
401
|
+
assert "b'hello bytes'" in output
|
|
402
|
+
assert "bytearray(b'mutable bytes')" in output
|
|
403
|
+
assert "<memory at" in output
|
|
404
|
+
assert "(3+4j)" in output
|
|
405
|
+
assert "range(0, 10)" in output
|
|
406
|
+
assert "<CustomReprClass: custom representation>" in output
|
|
407
|
+
assert "<lambda>" in output
|
|
408
|
+
assert "<function trigger_error at" in output
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/anthropic/anthropic.py
RENAMED
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/anthropic/anthropic_async.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/gemini/gemini_converter.py
RENAMED
|
File without changes
|
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/langchain/callbacks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/openai/openai_async.py
RENAMED
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/openai/openai_converter.py
RENAMED
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/ai/openai/openai_providers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_feature_flag.py
RENAMED
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_feature_flag_result.py
RENAMED
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_feature_flags.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics/test/test_size_limited_dict.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-7.0.0 → posthoganalytics-7.0.1}/posthoganalytics.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|