Skip to content

Add pyproject.toml packaging and optional event properties - #2

Draft
donaldng wants to merge 1 commit into
mainfrom
cursor/feat-packaging-and-set-event-properties-f2c8
Draft

donaldng wants to merge 1 commit into
mainfrom
cursor/feat-packaging-and-set-event-properties-f2c8

Conversation

@donaldng

@donaldng donaldng commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

This PR adds two independent enhancements to the mida-python SDK:

  1. Optional event properties: Added properties parameter to set_event() to support event metadata (e.g., revenue tracking)
  2. Modern Python packaging: Added pyproject.toml for standards-compliant packaging and distribution

Why

Event Properties: Server-side SDKs should support event properties for tracking additional context like revenue, quantity, product IDs, etc. This matches the capabilities of the Node.js and PHP SDKs.

Packaging: The repository had no packaging configuration, requiring users to manually copy mida.py and install dependencies. A proper pyproject.toml enables:

  • pip install . from the repository
  • Future PyPI distribution with pip install mida-python
  • Proper dependency management
  • Standard Python packaging workflows

Changes

Event Properties

  • set_event(event_name, distinct_id, properties=None) now accepts an optional properties dict
  • When provided, properties are serialized to JSON and sent as a properties field (matching Node.js/PHP SDK wire format)
  • Fully backwards compatible (old code without properties continues to work)
  • Added test in tests/test_set_event.py that verifies both with and without properties

Packaging

  • Added pyproject.toml with:
    • setuptools>=61 build backend
    • Package name: mida-python (placeholder, see notes below)
    • Version: 0.1.0 (placeholder, see notes below)
    • requests dependency declared
    • Proper metadata (description, license, URLs, keywords)
    • py-modules = ["mida"] to package the single-file module
  • Updated README install instructions to show pip install . workflow
  • Added .gitignore for Python build artifacts
  • Successfully builds both wheel and source distributions

Risk

Low risk - Both changes are backwards compatible:

  • Code not using properties parameter continues to work unchanged
  • The packaging doesn't change how the module is used (just how it's installed)

Merge Conflicts

⚠️ Expected conflicts with PR #1 (feature flag cache fix):

  • README.md: Both PRs modify the "Methods" section and the usage example. This PR updates installation instructions and set_event documentation while PR Fix feature flag cache to be keyed per user #1 updates is_feature_enabled documentation. Manual merge will combine both changes.
  • .gitignore: Both PRs add identical .gitignore files (no actual conflict, just duplicate adds)

These conflicts are expected and resolvable. The patches are functionally independent.

Important Notes

🚨 Placeholders for Donald to confirm before publishing:

  1. Package name: Currently set to mida-python in pyproject.toml

    • PyPI availability was not checked
    • May need to be changed if the name is taken or if a different name is preferred
  2. Version: Currently set to 0.1.0

    • Should be confirmed or adjusted based on versioning strategy
  3. License format warning: The build shows a deprecation warning about license = { text = "MIT" }

    • Consider updating to license = "MIT" (requires setuptools>=77.0.0 or later)
    • Current format works but will be unsupported by 2027-Feb-18

How to Verify

Test event properties:

python3 tests/test_set_event.py

Tests verify:

  • Events without properties send the original payload
  • Events with properties include a JSON-stringified properties field

Build the package:

pip install build
python3 -m build

Should successfully create:

  • dist/mida_python-0.1.0.tar.gz (source distribution)
  • dist/mida_python-0.1.0-py3-none-any.whl (wheel)

Install and test locally:

pip install dist/mida_python-0.1.0-py3-none-any.whl
python3 -c "from mida import Mida; m = Mida('test'); print('Import works!')"
Open in Web Open in Cursor 

Co-authored-by: Donald Ng <donaldngg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants