Skip to content

Openpanel-dev/python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenPanel Python SDK

The OpenPanel Python SDK allows you to track user behavior in your Python applications. This guide provides instructions for installing and using the Python SDK in your project.

Installation

⚠️ This package is not yet published. So you cannot install it with pip

You can install the OpenPanel Python SDK using pip:

pip install openpanel

Usage

Initialization

First, import the SDK and initialize it with your client ID:

from openpanel import OpenPanel

op = OpenPanel(client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET")

Options

When initializing the SDK, you can provide several options:

  • client_id (required): Your OpenPanel client ID.
  • client_secret (optional): Your OpenPanel client secret.
  • api_url (optional): Custom API URL if you're not using the default OpenPanel API.
  • filter (optional): A function to filter events before sending.
  • disabled (optional): Set to True to disable event sending.

Tracking Events

To track an event:

op.track("button_clicked", {"button_id": "submit_form"})

Identifying Users

To identify a user:

op.identify("user123", {
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "customAttribute": "value"
})

Setting Global Properties

To set properties that will be sent with every event:

op.set_global_properties({
    "app_version": "1.0.2",
    "environment": "production"
})

Creating Aliases

To create an alias for a user:

op.alias("user123", "john_doe")

Incrementing Properties

To increment a numeric property on a user profile:

op.increment("user123", "login_count", 1)

Decrementing Properties

To decrement a numeric property on a user profile:

op.decrement("user123", "credits", 5)

Clearing User Data

To clear the current user's data:

op.clear()

Advanced Usage

Custom Event Filtering

You can set up custom event filtering:

def my_filter(payload):
    # Your custom filtering logic here
    return True  # or False to filter out the event

op = OpenPanel(client_id="YOUR_CLIENT_ID", filter=my_filter)

Disabling Tracking

You can temporarily disable tracking:

op = OpenPanel(client_id="YOUR_CLIENT_ID", disabled=True)

Thread Safety

The OpenPanel SDK is designed to be thread-safe. You can call its methods from any thread without additional synchronization.

Support

For any issues or feature requests, please file an issue on our GitHub repository.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages