Compare commits

..
8 Commits
Author SHA1 Message Date
Tim Glaser b923116a9e Release 1.0.10 2020-04-01 17:25:23 +01:00
Tim Glaser 1670901156 Merge branch 'master' of github.com:PostHog/posthog-python 2020-02-21 17:09:32 -08:00
Tim Glaser ab65f8f0f8 Add 'disabled' option for use in tests 2020-02-21 17:08:49 -08:00
Tim GlaserandGitHub 133e1a991c Merge pull request #1 from mariusandra/patch-1
Fix typo with "identify" code example
2020-02-18 18:19:25 -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
Marius AndraandGitHub 7a93a99541 Fix typo with "identify" code example 2020-02-18 22:10:02 +01:00
4 changed files with 41 additions and 14 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
+4 -2
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
@@ -115,4 +117,4 @@ As our open source project [PostHog](https://github.com/PostHog/posthog) shares
## Thank you
This library is largely based on the `analytics-python` package.
This library is largely based on the `analytics-python` package.
+34 -11
View File
@@ -6,18 +6,26 @@ from typing import Optional, Dict, Callable
__version__ = VERSION
"""Settings."""
api_key: str = None
host: str = None
on_error: Callable = None
debug: bool = False
send: bool = True
sync_mode:bool = False
api_key = None # type: str
host = None # type: str
on_error = None # type: Callable
debug = False # type: bool
send = True # type: bool
sync_mode = False # type: bool
disabled = False # type: bool
default_client = None
def capture(distinct_id: str, event: str, properties: Optional[Dict]=None, context: Optional[Dict]=None,
timestamp: Optional[str]=None, message_id: Optional[str]=None) -> None:
def capture(
distinct_id, # type: str,
event, # type: str,
properties=None, # type: Optional[Dict]
context=None, # type: Optional[Dict]
timestamp=None, # type: Optional[str]
message_id=None, # type: Optional[str]
):
# type: (...) -> None
"""
Capture allows you to capture anything a user does within your system, which you can later use in PostHog to find patterns in usage, work out which features to improve or where people are giving up.
@@ -36,8 +44,14 @@ def capture(distinct_id: str, event: str, properties: Optional[Dict]=None, conte
"""
_proxy('capture', distinct_id=distinct_id, event=event, properties=properties, context=context, timestamp=timestamp, message_id=message_id)
def identify(distinct_id: str, properties: Optional[Dict]=None, context: Optional[Dict]=None, timestamp: Optional[str]=None,
message_id=None) -> None:
def identify(
distinct_id, # type: str,
properties=None, # type: Optional[Dict]
context=None, # type: Optional[Dict]
timestamp=None, # type: Optional[str]
message_id=None, # type: Optional[str]
):
# type: (...) -> None
"""
Identify lets you add metadata on your users so you can more easily identify who they are in PostHog, and even do things like segment users by these properties.
@@ -60,7 +74,14 @@ def group(*args, **kwargs):
_proxy('group', *args, **kwargs)
def alias(previous_id: str, distinct_id: str, context: Optional[Dict]=None, timestamp: Optional[str]=None, message_id: Optional[str]=None) -> None:
def alias(
previous_id, # type: str,
distinct_id, # type: str,
context=None, # type: Optional[Dict]
timestamp=None, # type: Optional[str]
message_id=None, # type: Optional[str]
):
# type: (...) -> None
"""
To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call. This will allow you to answer questions like "Which marketing channels leads to users churning after a month?" or "What do users do on our website before signing up?"
@@ -109,6 +130,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,
+1 -1
View File
@@ -1 +1 @@
VERSION = '1.0.8'
VERSION = '1.0.10'