asyncio
and the asyncio.Queue
to decouple your existing client code from the communication overhead of sending data to Mindlytics. When you send events with this SDK you are simply pushing data into a queue. A background coroutine in the SDK will pop the queue and handle the actual communication with Mindlytics, handling errors, timeouts, rate limits, etc with zero impact to your main application.
end_conversation()
when a conversation is finished, or an end_session()
which will automatically end all open conversations associated with the session. This is required so that Mindlytics can perform post-conversation analysis.
asyncio
and uses an asynchronous queue to decouple your application from the actual communication with Mindlytics. When you interact with the SDK your data gets pushed into an asynchronous FIFO and the SDK returns control to your application immediately. In the background the SDK removes data from the queue and tries to send it to the Mindlytics service. The SDK handles errors, and any timeouts, retries or rate limits as it tries to get the data to the server. When your application exits there is a way to wait on the SDK to completely drain the queue so no data is lost.
MLSDK_API_KEY
and MLSDK_PROJECT_ID
which will be used unless you supply the value to the constructor.
Returns:
An instance of the Mindlytics client object. This is used primarily to create sessions, but has two other methods for identifying users and managing aliasing outside of normal sessions.
client
. If this id already exists, the given traits are merged with any existing traits. Any existing matching traits are over written. Mindlytics supports strings, booleans, and numbers as trait values.end_conversation()
. You can still call end_session()
and that will automatically end all open conversations. Here is an example:
id
is not passed, the session will be associated with a temporary anonymous user until the actual user is identified.
session.flush()
before destroying the session instance to make sure all asyncio tasks are cleaned up.
has_errors()
method can be used to check if there have been any errors communicating with the Mindlytics service. The get_errors()
method can be used to retrieve any errors. It returns a list of APIResponse
objects (pydantic data models):
client
. If this id already exists, the given traits are merged with any existing traits. Any existing matching traits are over written. Mindlytics supports strings, booleans, and numbers as trait values.session.end_session()
is called, any open conversations are also closed.
Arguments:
Installed kernelspec mindlytics in $HOME/Library/Jupyter/kernels/mindlytics
.
You should create a file named .env.examples
with some key environment variables that are required by the demos, something like this (with your real values of course):