veridia / sdk
PHP SDK for Veridia
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/veridia/sdk
Requires
- php: >=8.2
- aws/aws-sdk-php: ^3.0
- guzzlehttp/guzzle: ^7.0
- psr/log: ^3.0
Requires (Dev)
- pestphp/pest: ^3.8
README
Official PHP SDK for integrating with the Veridia Platform. It provides an easy way to identify users, send tracking events, retrieve user segments, and manage batching with retries and timeouts — all from your backend.
🚀 Installation
composer require veridia/sdk
📦 Usage
<?php use Veridia\Client; $client = new Client([ 'credentials' => [ 'access_key_id' => 'your-access-key-id', 'secret_access_key' => 'your-secret-access-key', ] ]);
🧠 API Reference
identify($identifierType, $identifierId, $attributes)
Identify a user and update their profile attributes. Provided attributes must match the Profile Attributes schema defined in your Veridia dashboard.
$client->identify('userId', '123', [ 'email' => 'user@example.com', 'country' => 'US', 'plan' => 'premium', ]);
| Parameter | Type | Description |
|---|---|---|
identifierType |
`"userId" | "email"` |
identifierId |
string |
Unique identifier value. |
attributes |
array |
Arbitrary user attributes. |
track($identifierType, $identifierId, $eventType, $eventId, $eventTime, $properties, $tenantId = null)
Track an event performed by a user. Provided attributes must match the event attributes schema defined in your Veridia dashboard.
$client->track('userId', '123', 'purchase', 'evt-001', gmdate('c'), [ 'productId' => 'A-1', 'price' => 49.99, ]);
| Parameter | Type | Description |
|---|---|---|
identifierType |
string |
How the user is identified. |
identifierId |
string |
Unique user identifier. |
eventType |
string |
Logical name of the event. |
eventId |
string |
Unique event ID for idempotency. |
eventTime |
string |
ISO timestamp string. |
properties |
array |
Optional event properties. |
tenantId |
?string |
Internal tenant identifier. |
getUserSegments($identifierType, $identifierId, $noSegmentsOnError = true)
Fetches the list of segments the specified user currently belongs to.
If the API call fails and noSegmentsOnError is set to false, it will throw an error.
Otherwise, it will return an empty array.
$segments = $client->getUserSegments('userId', '123');
| Parameter | Type | Default | Description |
|---|---|---|---|
identifierType |
string |
— | Type of user identifier (userId or email). |
identifierId |
string |
— | Unique user ID or email. |
noSegmentsOnError |
bool |
true |
If true, returns [] instead of throwing an error. |
Returns:
string[] — Array of segment identifiers.
flush()
Immediately sends all queued identify and track data. Automatically called when buffers reach their configured limits or after the flush interval (checked on the next call).
$client->flush();
close()
Flushes any remaining buffered data and closes the client gracefully. Call this before application exit in workers or serverless environments.
$client->close();
⚙️ Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
credentials |
array |
— | Veridia API access credentials. |
endpoint |
string |
https://api.veridia.io/v1/ |
API base URL. |
region |
string |
default |
API region. |
auto_flush |
bool |
true |
Whether to automatically flush buffered data. |
max_buffer_size |
int |
500 |
Max number of items before auto-flush. |
max_buffer_timeout |
int |
5000 |
Max time (ms) before auto-flush. |
retries |
int |
3 |
Retry attempts on transient network errors. |
delay |
int |
500 |
Base delay (ms) for exponential backoff. |
timeout |
int |
5 |
Timeout (sec) for batch flush requests. |
logger |
Psr\Log\LoggerInterface |
— | PSR Logger implementation. |