-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update alias docs #82
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,8 +199,8 @@ def group_identify( | |
|
||
|
||
def alias( | ||
previous_id, # type: str, | ||
distinct_id, # type: str, | ||
distinct_id, # type: str | ||
previous_id, # type: str | ||
context=None, # type: Optional[Dict] | ||
timestamp=None, # type: Optional[datetime.datetime] | ||
uuid=None, # type: Optional[str] | ||
|
@@ -214,18 +214,25 @@ def alias( | |
The same concept applies for when a user logs in. | ||
|
||
An `alias` call requires | ||
- `previous distinct id` the unique ID of the user before | ||
- `distinct id` the current unique id | ||
- `distinct id` the current unique id of the user (normally the id in your database) | ||
- `alias distinct id` the alias id you want to attach to the user, such as the anonymous session id or another ID like their email | ||
|
||
|
||
For example: | ||
```python | ||
posthog.alias('anonymous session id', 'distinct id') | ||
posthog.alias('distinct id', 'anonymous session id') | ||
``` | ||
|
||
or | ||
|
||
```python | ||
posthog.alias('distinct id', '[email protected]') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks like a bad example. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People use aliasing is several ways, not just for anonymous session ids. E.g. if you want to be able to identify users by their email as well as their distinct ID. But I guess we don't need this example in the library doc and instead can just have it in the posthog.com docs |
||
``` | ||
""" | ||
_proxy( | ||
"alias", | ||
previous_id=previous_id, | ||
distinct_id=distinct_id, | ||
previous_id=previous_id, | ||
context=context, | ||
timestamp=timestamp, | ||
uuid=uuid, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,21 +241,21 @@ def group_identify(self, group_type=None, group_key=None, properties=None, conte | |
|
||
return self._enqueue(msg) | ||
|
||
def alias(self, previous_id=None, distinct_id=None, context=None, timestamp=None, uuid=None): | ||
def alias(self, distinct_id=None, previous_id=None, context=None, timestamp=None, uuid=None): | ||
context = context or {} | ||
|
||
require("previous_id", previous_id, ID_TYPES) | ||
require("distinct_id", distinct_id, ID_TYPES) | ||
|
||
msg = { | ||
"properties": { | ||
"distinct_id": previous_id, | ||
"alias": distinct_id, | ||
"distinct_id": distinct_id, | ||
"alias": previous_id, | ||
}, | ||
"timestamp": timestamp, | ||
"context": context, | ||
"event": "$create_alias", | ||
"distinct_id": previous_id, | ||
"distinct_id": distinct_id, | ||
Comment on lines
-252
to
+258
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we swapping the order here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In our docs we tell people to use the ordering posthog.alias(distinct_id, alias). However, the parameter names are the wrong way round for this so I've updated the parameter names. Even in the current version we're actually sending it the right way (but in a fairly hacky way where we send the distinct_id as the alias because the user actually gives the alias in place of the distinct_id). I've put in a regression test to confirm that it doesn't change user functionality (apart from named args, as the named args actually refer to the opposite thing) |
||
} | ||
|
||
return self._enqueue(msg) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not clear to me what alias_id restrictions are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we are removing the alias restrictions with the new updates of persons on events enabling person merging?