From 16cd471d59094da338b0b3a956ace135b2c43ea8 Mon Sep 17 00:00:00 2001 From: ashirgaokar Date: Tue, 13 Feb 2024 06:05:44 +0000 Subject: [PATCH] Added missing realtime event methods for related products and related conten models. --- algoliasearch/insights_client.py | 92 ++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/algoliasearch/insights_client.py b/algoliasearch/insights_client.py index 672d5dc7c..708ac1eda 100644 --- a/algoliasearch/insights_client.py +++ b/algoliasearch/insights_client.py @@ -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, + )