Skip to content

Commit

Permalink
Merge pull request #6 from interakt/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
amarjaiswal007 authored Nov 4, 2020
2 parents cfbb46e + 3b98eee commit 36281e3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ install:
python3 setup.py sdist bdist_wheel
pip3 install -e .

.PHONY: release install
uninstall:
pip3 uninstall interakt-track-python

.PHONY: release install uninstall


18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ track.on_error = on_error

# APIs
## User
The `identify` lets you tie a user to their actions and record traits about them. It includes a unique **User ID** or **Phone Number and Country Code** any optional traits you know about them.
The track `user` call lets you tie a user to their actions and record traits about them. It includes a unique **User ID** or **Phone Number and Country Code** any optional traits you know about them.

Example `user` call:
```
track.user(
userId="<user_id in your db>",
user_id="<user_id in your db>",
traits={
"name": "John Doe",
"email": "john@email.com",
Expand All @@ -58,15 +58,15 @@ track.user(
#### The `user` call has the following fields:
|Field|Data type|Description|
|--|--|--|
|userId|str or int|The ID for the user in your database.|
|countryCode|str|country code for the phone_number (default value is "+91")|
|phoneNumber|str|phone_number without country_code (eg: "9876598765")|
|user_id|str or int|The ID for the user in your database.|
|country_code|str|country code for the phone_number (default value is "+91")|
|phone_number|str|phone_number without country_code (eg: "9876598765")|
|traits|dict|A dict of traits you know about the user. Things like: `email`, `name` or `age`|

**NOTE:** Atleast one of these two is required for user identification :

- **userId**, OR
- **phoneNumber** with **countryCode**
- **user_id**, OR
- **phone_number** with **country_code**



Expand All @@ -76,7 +76,7 @@ track.user(
Example `event` call:
```
track.event(
userId="<user id in your db>",
user_id="<user id in your db>",
event="Product Added",
traits={"price": 200}
)
Expand All @@ -85,6 +85,6 @@ track.event(

|Field|Data type|Description|
|--|--|--|
|userId|str or int|The ID for the user in your database.|
|user_id|str or int|The ID for the user in your database.|
|event|str|Name of the event you want to track, For eg: "Product Added".|
|traits|dict|dictionary of properties for the event. If the event was **Product Added**, it might have properties like `price` or `product_name`.|
4 changes: 2 additions & 2 deletions track/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
max_queue_size = 10000


def identify(user_id=None, country_code='+91', phone_number=None, traits={}):
def user(user_id=None, country_code='+91', phone_number=None, traits={}):
"""Send an identify call for customer"""
return _proxy('identify', user_id=user_id, country_code=country_code,
return _proxy('user', user_id=user_id, country_code=country_code,
phone_number=phone_number, traits=traits)


Expand Down
4 changes: 2 additions & 2 deletions track/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, write_key=None, host=None, debug=False,
)
self.consumer.start()

def identify(self, user_id=None, country_code='+91', phone_number=None, traits={}):
def user(self, user_id=None, country_code='+91', phone_number=None, traits={}):
"""Tie a user to their actions and record traits about them."""
if not user_id and not phone_number:
raise AssertionError("Either user_id or phone_number is required")
Expand All @@ -60,7 +60,7 @@ def identify(self, user_id=None, country_code='+91', phone_number=None, traits={
'phoneNumber': phone_number,
'traits': traits
}
return self.__queue_request(path=ApiPaths.Identify.value, body=body)
return self.__queue_request(path=ApiPaths.User.value, body=body)

def event(self, user_id=None, event=None, traits={}):
"""To record user events"""
Expand Down
2 changes: 1 addition & 1 deletion track/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@


class ApiPaths(enum.Enum):
Identify = '/v1/public/track/users/'
User = '/v1/public/track/users/'
Event = '/v1/public/track/events/'
2 changes: 1 addition & 1 deletion track/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.0.2'
VERSION = '1.0.3'

0 comments on commit 36281e3

Please sign in to comment.