Registry / http-networking / mixpanel-py-async

mixpanel-py-async

JSON →
library0.3.0pypypi✓ verified 83d ago

A Python library designed for asynchronously sending event data to Mixpanel, offering an `AsyncBufferedConsumer` for efficient batching and transmission. It streamlines event tracking in asynchronous applications. Currently at version 0.3.0, it receives updates as needed.

pip install mixpanel-py-async
INSTALL
IMPORT
SIG · MIXPANEL-PY-ASYNC
M
mixpanel-py-async
http-networkingpythonv0.3.0
Install
4.5s avg
Import
Disk
33MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 34.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.5s · import 0.000s · 34MB
33MB installed
● package 33MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AsyncBufferedConsumer
from mixpanel_async import AsyncBufferedConsumer
from mixpanel_async import MixpanelAsync
async_buffered_consumer
from mixpanel_async import async_buffered_consumer

This example demonstrates how to initialize `MixpanelAsync`, track an event, update user profile properties, and increment a user property. It highlights the importance of calling `flush()` and `close()` to ensure all buffered events are sent and resources are properly cleaned up before application exit.

import asyncio import os from mixpanel_async import MixpanelAsync async def main(): # Retrieve Mixpanel project token from environment variables # For a real application, ensure MIXPANEL_PROJECT_TOKEN is set project_token = os.environ.get("MIXPANEL_PROJECT_TOKEN", "YOUR_MIXPANEL_PROJECT_TOKEN") if project_token == "YOUR_MIXPANEL_PROJECT_TOKEN": print("Warning: MIXPANEL_PROJECT_TOKEN environment variable not set. Using a placeholder.") # Initialize Mixpanel with the project token. AsyncBufferedConsumer is used by default. mixpanel = MixpanelAsync(project_token) try: user_id = "test_user_123" # Track an event await mixpanel.track(user_id, "Product Viewed", {"product_id": "SKU456", "category": "Electronics"}) # Update user profile properties await mixpanel.people_set(user_id, {"$first_name": "Async", "$last_name": "User", "Plan": "Free"}) # Increment a user property await mixpanel.people_increment(user_id, {"Views": 1}) print(f"Tracking data for user {user_id}...") finally: # Crucial: flush any remaining buffered events before the application exits await mixpanel.flush() # Close the consumer's HTTP session and clean up resources await mixpanel.close() print("Mixpanel events flushed and consumer closed.") if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
breakingThe `AsyncBufferedConsumer` constructor no longer accepts arbitrary `*args` or `**kwargs`. All parameters must be explicitly defined arguments.
fix
Review your `AsyncBufferedConsumer` initialization. Remove any `*args` or `**kwargs` that were previously passed and ensure only named, supported parameters are used. New parameters like `import_url`, `request_timeout`, etc., are now directly supported.
affects: >=0.3.0
breakingThe `flush` argument for the `AsyncBufferedConsumer.flush` method was renamed from `async` to `async_` to avoid conflicts with Python 3.7's `async` keyword.
fix
If you were explicitly passing `async=True` to `flush`, change it to `async_=True`.
affects: >=0.2.0
gotchaEvents tracked with `MixpanelAsync` are buffered by default. If the application exits before the buffer is full or the flush interval passes, events might be lost.
fix
Always call `await mixpanel.flush()` to send any remaining events in the buffer, and `await mixpanel.close()` to clean up resources, before your application terminates. This should typically be done in a `finally` block or a shutdown hook.
affects: all
Upgrade
Version history
0.3.0latest on PyPI · released Feb 18, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
2
Resources
mixpanel-py-async — pip install mixpanel-py-async · libregistry