mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-22 08:38:13 +02:00
chore: fix phantom user creation in posthog
This commit is contained in:
parent
a67c984e1a
commit
c554256db1
2 changed files with 36 additions and 1 deletions
34
api/tests/test_posthog_client.py
Normal file
34
api/tests/test_posthog_client.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from api.services import posthog_client
|
||||
|
||||
|
||||
class FakePostHog:
|
||||
def __init__(self):
|
||||
self.group_identify_calls = []
|
||||
|
||||
def group_identify(self, *args, **kwargs):
|
||||
self.group_identify_calls.append((args, kwargs))
|
||||
|
||||
|
||||
def test_group_identify_uses_stable_server_distinct_id(monkeypatch):
|
||||
fake_posthog = FakePostHog()
|
||||
monkeypatch.setattr(posthog_client, "get_posthog", lambda: fake_posthog)
|
||||
|
||||
posthog_client.group_identify("organization", "42", {})
|
||||
|
||||
_, kwargs = fake_posthog.group_identify_calls[0]
|
||||
assert kwargs["distinct_id"] == "server-group-identify"
|
||||
|
||||
|
||||
def test_group_identify_preserves_real_distinct_id(monkeypatch):
|
||||
fake_posthog = FakePostHog()
|
||||
monkeypatch.setattr(posthog_client, "get_posthog", lambda: fake_posthog)
|
||||
|
||||
posthog_client.group_identify(
|
||||
"organization",
|
||||
"42",
|
||||
{},
|
||||
distinct_id="stack-user-1",
|
||||
)
|
||||
|
||||
_, kwargs = fake_posthog.group_identify_calls[0]
|
||||
assert kwargs["distinct_id"] == "stack-user-1"
|
||||
Loading…
Add table
Add a link
Reference in a new issue