Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab65f8f0f8 | ||
|
|
34e92615c2 | ||
|
|
cf09644d4f | ||
|
|
0cfce57d0e | ||
|
|
e9862cf671 | ||
|
|
0ce011a36d |
@@ -1,5 +1,7 @@
|
||||
Copyright (c) 2020 PostHog (part of Hiberly Inc)
|
||||
|
||||
Copyright (c) 2013 Segment Inc. friends@segment.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
|
||||
@@ -53,7 +53,7 @@ An `identify` call requires
|
||||
|
||||
For example:
|
||||
```python
|
||||
posthog.capture('distinct id', {
|
||||
posthog.identify('distinct id', {
|
||||
'email': 'dwayne@gmail.com',
|
||||
'name': 'Dwayne Johnson'
|
||||
})
|
||||
@@ -69,6 +69,8 @@ In a purely back-end implementation, this means whenever an anonymous user does
|
||||
|
||||
The same concept applies for when a user logs in.
|
||||
|
||||
If you're using PostHog in the front-end and back-end, doing the `identify` call in the frontend will be enough.
|
||||
|
||||
An `alias` call requires
|
||||
- `previous distinct id` the unique ID of the user before
|
||||
- `distinct id` the current unique id
|
||||
|
||||
@@ -12,6 +12,7 @@ on_error: Callable = None
|
||||
debug: bool = False
|
||||
send: bool = True
|
||||
sync_mode:bool = False
|
||||
disabled: bool = False
|
||||
|
||||
default_client = None
|
||||
|
||||
@@ -109,6 +110,8 @@ def shutdown():
|
||||
def _proxy(method, *args, **kwargs):
|
||||
"""Create an analytics client if one doesn't exist and send to it."""
|
||||
global default_client
|
||||
if disabled:
|
||||
return None
|
||||
if not default_client:
|
||||
default_client = Client(api_key, host=host, debug=debug,
|
||||
on_error=on_error, send=send,
|
||||
|
||||
+4
-2
@@ -218,8 +218,10 @@ class Client(object):
|
||||
timestamp = guess_timezone(timestamp)
|
||||
msg['timestamp'] = timestamp.isoformat()
|
||||
msg['messageId'] = stringify_id(message_id)
|
||||
msg['library'] = 'posthog-python'
|
||||
msg['library_version'] = VERSION
|
||||
if not msg.get('properties'):
|
||||
msg['properties'] = {}
|
||||
msg['properties']['$lib'] = 'posthog-python'
|
||||
msg['properties']['$lib_version'] = VERSION
|
||||
|
||||
msg['distinct_id'] = stringify_id(msg.get('distinct_id', None))
|
||||
|
||||
|
||||
@@ -63,10 +63,8 @@ class TestClient(unittest.TestCase):
|
||||
self.assertEqual(msg['properties'], {'property': 'value'})
|
||||
self.assertEqual(msg['context']['ip'], '192.168.0.1')
|
||||
self.assertEqual(msg['event'], 'python test event')
|
||||
self.assertEqual(msg['context']['library'], {
|
||||
'name': 'analytics-python',
|
||||
'version': VERSION
|
||||
})
|
||||
self.assertEqual(msg['properties']['$lib'], 'posthog-python')
|
||||
self.assertEqual(msg['properties']['$lib_version'], VERSION)
|
||||
self.assertEqual(msg['messageId'], 'messageId')
|
||||
self.assertEqual(msg['distinct_id'], 'distinct_id')
|
||||
self.assertEqual(msg['type'], 'track')
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
VERSION = '1.0.6'
|
||||
VERSION = '1.0.9'
|
||||
|
||||
Reference in New Issue
Block a user