Skip to main content

Official Python SDK for Ripples.sh — server-side event tracking

Project description

Ripples Python SDK

Server-side Python SDK for Ripples.sh analytics.

Install

pip install ripples

Set your secret key:

RIPPLES_SECRET_KEY=priv_your_secret_key

Usage

from ripples import Ripples

ripples = Ripples()

ripples.revenue(49.99, "user_123")
ripples.signup("user_123", email="jane@example.com")
ripples.track("created a budget", "user_123", area="budgets")
ripples.identify("user_123", email="jane@example.com")

That's it. Events are batched and sent automatically when the process exits.

Track product usage

Call track() when a user does something meaningful. Ripples auto-detects activation (first occurrence per user), computes adoption rates, and correlates with retention and payment.

ripples.track("created a budget", "user_123", area="budgets")
ripples.track("shared a list", "user_123", area="sharing", via="link")
ripples.track("exported report", "user_123", area="reports", format="csv")

Use area to group actions into product areas. Use activated=True to mark the specific moment a user activates:

ripples.track("added transaction", "user_123", area="transactions", activated=True)

Track revenue

ripples.revenue(49.99, "user_123")

Any extra keyword argument becomes a custom property:

ripples.revenue(49.99, "user_123",
    email="jane@example.com",
    currency="EUR",
    transaction_id="txn_abc123",
    plan="annual",
    coupon="WELCOME20",
)

Refunds are negative revenue:

ripples.revenue(-29.99, "user_123", transaction_id="txn_abc123")

Track signups

ripples.signup("user_123",
    email="jane@example.com",
    name="Jane Smith",
    referral="twitter",
    plan="free",
)

Identify users

Update user traits at any time:

ripples.identify("user_123",
    email="jane@example.com",
    name="Jane Smith",
    company="Acme Inc",
    role="admin",
)

Error handling

from ripples import RipplesError

try:
    ripples.revenue(49.99, "user_123")
except RipplesError as e:
    print(e)

By default, errors during flush are swallowed so your app is never disrupted. Use on_error to log them:

ripples = Ripples(on_error=lambda e: print(f"Ripples error: {e}"))

Configuration

ripples = Ripples(
    "priv_explicit_key",
    base_url="https://your-domain.com/api",
    timeout=10,
    max_queue_size=50,
)

Or via environment variables:

RIPPLES_SECRET_KEY=priv_your_secret_key
RIPPLES_URL=https://your-domain.com/api

Flush manually

Events are flushed automatically at exit. For long-running processes or CLI scripts, call flush() explicitly:

ripples.flush()

Custom HTTP client

Subclass and override _post():

class MyRipples(Ripples):
    def _post(self, path, data):
        # your custom implementation
        pass

Requirements

  • Python 3.9+
  • requests

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ripples-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ripples-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file ripples-0.1.0.tar.gz.

File metadata

  • Download URL: ripples-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ripples-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57618eaaa956449d6d91acd02172759f643048b5812f130d53563676483674d2
MD5 35bd30219a36c07ac5a7864953859639
BLAKE2b-256 bf644e46b42e98be53b6caca0164e729ae4c2e9622f63530e67cf3334cf10c03

See more details on using hashes here.

File details

Details for the file ripples-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ripples-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ripples-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1850a153ab2207163bf25f2e7e70dc6a00a26a512b61b3cba6d8314820eac12
MD5 7e2e8c6807d54d81a4f2302a85a26ad3
BLAKE2b-256 bba06358571a313eb08f3584cd3c39c19736fbde5e09682d3747a20c9f741950

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page