Python
Installation
To install the ConnectFramework Python SDK, use the following command:
pip install connectframeworkUsage
Before using any functions, initialize the SDK with your API key.
Initializing the SDK
from connectframework import ConnectFramework
# Initialize the SDK with your API key
ConnectFramework.initialize(api_key="your_api_key_here")User Authentication
Logging in with a Unique ID and Email
Logs in the user using a unique ID and an email. If unique_id is None, a new one is generated automatically. Returns true if email was accepted and an OTP code was sent to the email.
ConnectFramework.login(unique_id=None, email="[email protected]")Submitting an OTP Code
If the login process requires an OTP (One-Time Password), this function submits the OTP code for verification.
def otp_callback(success: bool):
    if success:
        print("OTP verified successfully, user logged in.")
    else:
        print("OTP verification failed.")
ConnectFramework.submit_otp(email="[email protected]", otp_code="123456", callback=otp_callback)Logging Out
Logs out the user entirely.
ConnectFramework.logout()Checking if User is Connected
Returns True if the user is logged in and running the Connect.ai desktop client.
is_connected = ConnectFramework.is_connected()
print(f"User is connected: {is_connected}")Analytics Tracking
Logging an Event
Logs an analytics event with a category and action.
ConnectFramework.log_event(category="user_action", action="button_click")Logging an Event with Additional Data
Logs an analytics event with a category, action, label, and numerical value.
ConnectFramework.log_event_with_details(
    category="user_action",
    action="purchase",
    label="premium_upgrade",
    value=29.99
)Summary
initialize(api_key: str)
Initializes the SDK with an API key.
`login(unique_id: str
None, email: str, callback: Callable[[bool], None])`
submit_otp(email: str, otp_code: str, callback: Callable[[bool], None])
Submits an OTP code for verification.
logout()
Logs out the user.
is_connected() -> bool
Returns True if the user is logged in and running the Connect.ai client.
log_event(category: str, action: str)
Logs an analytics event with a category and action.
log_event_with_details(category: str, action: str, label: str, value: float)
Logs an analytics event with additional details.
For more details, refer to the official API documentation.
Last updated
