Python SDK
Python ব্যাকএন্ডের জন্য একটি সার্ভার ক্লায়েন্ট, স্ট্যান্ডার্ড লাইব্রেরির বাইরে কিছুই ছাড়া। প্রতিটি কল ব্যবহারকারীর নাম দেয়, কারণ একটি প্রসেস অনেককে সেবা দেয়।
যেখানে প্রকাশিত
prodantix-sdk on PyPI. Requires Python 3.9 or newer.
ইনস্টল
pip install prodantix-sdkপ্রতিটি কল ব্যবহারকারীর নাম দেয়
ব্রাউজার ক্লায়েন্ট মনে রাখতে পারে কে এটি ব্যবহার করছে; সার্ভার পারে না। তাই ক্যাপচার, আইডেন্টিফাই, গ্রুপ এবং ইনবক্স পড়ার প্রথম আর্গুমেন্ট হলো ডিসটিংক্ট আইডি। ব্রাউজার ও মোবাইল ক্লায়েন্ট থেকে এটিই একমাত্র গঠনগত পার্থক্য।
import os
from prodantix import Client
client = Client(
api_key=os.environ["PRODANTIX_PUBLIC_KEY"],
host="https://eu.api.prodantix.com",
)
client.capture("user-123", "order.completed", properties={"total": 42, "currency": "XAF"})
client.identify("user-123", set_props={"plan": "pro"})
client.group("user-123", "company", "acme", properties={"seats": 10})
for message in client.get_inbox("user-123"):
...
client.mark_message_read("user-123", "message-id")দূরবর্তী ও স্থানীয় ফ্ল্যাগ
দূরবর্তী যাচাই সার্ভারকে জিজ্ঞাসা করে এবং সেটিই চূড়ান্ত। স্থানীয় যাচাই নিয়মের একটি ক্যাশ করা স্ন্যাপশট প্রসেসের ভিতরেই মূল্যায়ন করে, প্রতি কলে রাউন্ড ট্রিপ ছাড়াই, যা একটি হট পাথের প্রয়োজন।
# Remote: asks the server, and is the authoritative answer.
if client.is_feature_enabled("user-123", "new-checkout"):
...
# Local: evaluated in process from a cached snapshot, no round trip per call.
if client.is_feature_enabled_local("user-123", "new-checkout", properties={"plan": "pro"}):
...
every_flag = client.get_all_flags("user-123")
# Every per-flag read records one $feature_flag_called exposure.
variant = client.get_variant("user-123", "new-checkout")
if variant and variant["key"] == "treatment":
...
# A flag targeting a cohort reads the user's memberships from the store;
# pass cohorts=[...] to skip the lookup.
if client.is_feature_enabled_local("user-123", "members", cohorts=["<cohort id>"]):
...
# With stream_flags=True the client holds a Socket.IO subscription and refetches
# the snapshot when a flag changes, instead of waiting for the 30s poll.
client = Client(api_key=os.environ["PRODANTIX_PUBLIC_KEY"], host="https://eu.api.prodantix.com", stream_flags=True)ডেলিভারি ও শাটডাউন
ইভেন্টগুলি একটি থ্রেড-নিরাপদ সারিতে যায়, আর একটি ব্যাকগ্রাউন্ড ফ্লাশার সেগুলি ব্যাচে পাঠায়, সংখ্যা বা টাইমার যেটি আগে আসে সেই অনুযায়ী। ক্লায়েন্টটিকে কনটেক্সট ম্যানেজার হিসেবে ব্যবহার করুন, ব্লক শেষ হলে শেষ ব্যাচটি পাঠিয়ে দেওয়া হয়।
with Client(api_key=..., host=...) as client:
client.capture("user-123", "page.viewed")
# the final batch is flushed here
# Without the context manager, flush and stop the background flusher yourself.
client.shutdown()| Argument | Default | Purpose |
|---|---|---|
| api_key | required | Public project key (pdx_pub_…) |
| host | required | Ingest base URL |
| flags_host | host | Base URL for the flags and inbox endpoints |
| flush_at | 20 | Queue size that triggers an immediate flush |
| flush_interval_s | 10.0 | Background flush cadence; 0 or less disables the timer |
| max_queue_size | 1000 | Cap; the oldest events are dropped on overflow |
| max_retries | 3 | Delivery retry attempts |
| request_timeout_s | 10.0 | Per-request timeout |
| default_properties | None | A dict or a callable merged into every event |
| on_error | no-op | Called with any capture or background error |
| stream_flags | False | Hold a Socket.IO subscription to flag changes and refetch the snapshot on push |
| socket_factory | stdlib client | Builds the websocket the flag stream uses; the test seam |