CDPClient
The CDPClient class is the primary interface for interacting with the OpenCDP. It handles authentication, connection management, and optional dual-writing to Customer.io.
Initialization
from cdp_client.client import CDPClient
from cdp_client.models import CDPConfig
config = CDPConfig(cdp_api_key="your_api_key")
client = CDPClient(config)
Parameters
config(CDPConfig): A configuration object containing the API key and other settings.
Methods
identify
Identifies a user and sets their specific traits.
await client.identify(user_id: str, traits: Dict[str, Any])
track
Tracks a custom event with associated properties.
await client.track(user_id: str, event_name: str, properties: Dict[str, Any])
register_device
Registers a device token for push notifications.
await client.register_device(
user_id: str,
device_id: str,
platform: str,
token: str,
attributes: Optional[Dict[str, Any]] = None
)
Read more about register_device
send_email
Sends a transactional email.
await client.send_email(payload: EmailPayload)
send_push
Sends a transactional push notification.
await client.send_push(payload: PushPayload)
send_sms
Sends a transactional SMS.
await client.send_sms(payload: SmsPayload)
close
Closes the underlying HTTP client. This should be called before your application shuts down.
await client.close()