Skip to content
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

Added realtime event methods for related products/content models. #564

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions algoliasearch/insights_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,95 @@ def viewed_filters(self, event_name, index_name, filters, request_options=None):
},
request_options,
)

def add_to_cart_object_ids(
self,
event_name,
index_name,
object_ids,
request_options=None,
):
# type: (str, str, List[str], Optional[Union[dict, RequestOptions]]) -> dict # noqa: E501

return self._insights_client.send_event(
{
"eventType": "conversion",
"eventSubtype": "addToCart",
"eventName": event_name,
"index": index_name,
"userToken": self._user_token,
"objectIds": object_ids,
},
request_options,
)

def add_to_cart_object_ids_after_search(
self,
event_name,
index_name,
object_ids,
positions,
query_id,
request_options=None,
):
# type: (str, str, List[str], List[int], str, Optional[Union[dict, RequestOptions]]) -> dict # noqa: E501

return self._insights_client.send_event(
{
"eventType": "conversion",
"eventSubtype": "addToCart",
"eventName": event_name,
"index": index_name,
"userToken": self._user_token,
"objectIds": object_ids,
"positions": positions,
"queryId": query_id,
},
request_options,
)

def purchased_object_ids(
self,
event_name,
index_name,
object_ids,
request_options=None,
):
# type: (str, str, List[str], Optional[Union[dict, RequestOptions]]) -> dict # noqa: E501

return self._insights_client.send_event(
{
"eventType": "conversion",
"eventSubtype": "purchase",
"eventName": event_name,
"index": index_name,
"userToken": self._user_token,
"objectIds": object_ids,
},
request_options,
)

def purchased_object_ids_after_search(
self,
event_name,
index_name,
object_ids,
positions,
query_id,
request_options=None,
):
# type: (str, str, List[str], List[int], str, Optional[Union[dict, RequestOptions]]) -> dict # noqa: E501

return self._insights_client.send_event(
{
"eventType": "conversion",
"eventSubtype": "purchase",
"eventName": event_name,
"index": index_name,
"userToken": self._user_token,
"objectIds": object_ids,
"positions": positions,
"queryId": query_id,
},
request_options,
)