Compare commits

..
6 Commits
Author SHA1 Message Date
Tim Glaser ab65f8f0f8 Add 'disabled' option for use in tests 2020-02-21 17:08:49 -08:00
Tim Glaser 34e92615c2 License 2020-02-18 17:15:29 -08:00
Tim Glaser cf09644d4f Clarify alias call frontend vs backend 2020-02-18 17:13:58 -08:00
Tim Glaser 0cfce57d0e Fix error in documentation 2020-02-18 17:12:14 -08:00
Tim Glaser e9862cf671 Fix properties undefined error 2020-02-18 15:44:56 -08:00
Tim Glaser 0ce011a36d Correctly send in properties 2020-02-17 19:20:57 -08:00
6 changed files with 15 additions and 8 deletions
+2
View File
@@ -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
+3 -1
View File
@@ -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
+3
View File
@@ -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
View File
@@ -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))
+2 -4
View File
@@ -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
View File
@@ -1 +1 @@
VERSION = '1.0.6'
VERSION = '1.0.9'