mirror of
https://github.com/hanzoai/insights-python.git
synced 2026-10-30 18:33:17 +00:00
- Rename main class Posthog -> Insights (Posthog kept as alias) - Rename PosthogContextMiddleware -> InsightsContextMiddleware (alias kept) - Rename PostHogTracingProcessor -> InsightsTracingProcessor (alias kept) - Add `insights/` re-export package so `from insights import Insights` works - Update all imports from `posthog` to `hanzo_insights` across source and tests - Update docstrings, comments, error messages, user agent string - Update README, example.py, .env.example, Makefile, LLM.md - Django middleware now supports INSIGHTS_MW_* settings (POSTHOG_MW_* still works) - Django middleware accepts X-INSIGHTS-* headers (X-POSTHOG-* still works) - Keep protocol-level values ($lib, ingestion URLs, sentinel strings) for server compat - Keep posthog_* parameter names in AI wrappers for API compat - All 681 tests pass
33 lines
815 B
Python
33 lines
815 B
Python
import unittest
|
|
|
|
from hanzo_insights import Insights
|
|
|
|
|
|
class TestModule(unittest.TestCase):
|
|
client = None
|
|
|
|
def _assert_enqueue_result(self, result):
|
|
self.assertEqual(type(result[0]), str)
|
|
|
|
def failed(self):
|
|
self.failed = True
|
|
|
|
def setUp(self):
|
|
self.failed = False
|
|
self.client = Insights(
|
|
"testsecret", host="http://localhost:8000", on_error=self.failed
|
|
)
|
|
|
|
def test_track(self):
|
|
res = self.client.capture("python module event", distinct_id="distinct_id")
|
|
self._assert_enqueue_result(res)
|
|
self.client.flush()
|
|
|
|
def test_alias(self):
|
|
res = self.client.alias("previousId", "distinct_id")
|
|
self._assert_enqueue_result(res)
|
|
self.client.flush()
|
|
|
|
def test_flush(self):
|
|
self.client.flush()
|