Registry / crm-productivity / mparticle

mparticle

JSON →
library0.16.1pypypi✓ verified 84d ago

Python client for the mParticle customer data platform. Currently version 0.16.1. SDK supports event tracking, user management, and consent state. Maintenance cadence is irregular with occasional feature releases.

pip install mparticle
INSTALL
IMPORT
SIG · MPARTICLE
M
mparticle
crm-productivitypythonv0.16.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Batch
from mparticle import Batch
MParticle
from mparticle import MParticle
Event
from mparticle import Event
UserIdentities
from mparticle.models import UserIdentities
from mparticle import UserIdentities
UserIdentities is a model in the separate models module, not directly in mparticle top-level

Initialize mParticle client with API credentials and log a custom event.

from mparticle import MParticle from mparticle import Event from mparticle.models import UserIdentities api_key = os.environ.get('MPARTICLE_API_KEY', '') api_secret = os.environ.get('MPARTICLE_API_SECRET', '') mp = MParticle(api_key, api_secret) # Track a simple event event = Event('Test Event', 'navigation') mp.log_event(event) # Track with user identity user_ids = UserIdentities(customer_id='user123') mp.log_event(event, user_identities=user_ids)
Debug
Known issues
deprecatedThe SDK uses v2 of the mParticle Events API, but some endpoints may be removed in future versions.
fix
Watch for API version updates in the official changelog.
affects: >=0.10.0,<0.17.0
breakingUserIdentities moved from top-level to mparticle.models in v0.11.0.
fix
Import from mparticle.models instead of mparticle.
affects: >=0.11.0
gotchaBatch uploads require setting the batch endpoint correctly; default config may not batch as expected.
fix
Use mp.upload() with a Batch object to send batched events.
affects: all
deprecatedPython 3.5 minimum since v0.13.0; Python 2.7 support dropped.
fix
Use Python 3.5+.
affects: >=0.13.0
Errors
Common errors & fixes
AttributeError: module 'mparticle' has no attribute 'UserIdentities'
UserIdentities is in the models submodule, not top-level.
fix
Use 'from mparticle.models import UserIdentities' instead.
mparticle.exceptions.MParticleError: 401 Unauthorized
Invalid API key or secret.
fix
Verify your mParticle API credentials and ensure environment variables are set correctly.
TypeError: log_event() missing 1 required positional argument: 'event'
Passing event object as keyword argument incorrectly.
fix
Call 'mp.log_event(event)' with the event as a positional argument.
Upgrade
Version history
0.16.1latest on PyPI · released Jun 20, 2023
Audit
Dependencies
requestsrequiredHTTP client for API calls
sixrequiredPython 2/3 compatibility
python-dateutilrequiredDate/time parsing
Agent activity
33 hits · last 30 days
node
30
OpenAI (training)
1
Resources
mparticle — pip install mparticle · libregistry