evc-sdk
v0.0.6
Published
Evc nodejs/edge sdk
Downloads
403
Readme
EVC SDK
A TypeScript client for interacting with the Devi Mailing EVC API. This SDK provides a simple interface for managing contacts, events, and user groups.
Installation
npm install evc-sdk
# or
yarn add evc-sdk
Quick Start
import { createEVCApiClient } from "evc-sdk";
const client = createEVCApiClient({
baseUrl: "https://your-api-base-url.com",
apiKey: "your-api-key",
product: "your-product-name",
});
// Example: Create or update a contact
const contact = await client.upsertContact({...});
Features
- Contact management (create, update, retrieve)
- Event tracking
- User group management
- Type-safe API with TypeScript support
- Automatic error handling
API Reference
Creating a Client
const client = createEVCApiClient({
baseUrl: string;
apiKey: string;
product: string;
});
Methods
Contact Management
upsertContact()
Create or update a contact.
const contact = await client.upsertContact({...});
getContact()
Retrieve a contact by user ID.
const contact = await client.getContact("user123");
Event Tracking
addEvent()
Track a new event.
const event = await client.addEvent(...);
Group Management
manageUserGroup()
Add or remove a user from a group.
const result = await client.manageUserGroup({
userId: "user123",
addGroupName: "premium_users", // Add to group
deleteGroupName: "trial_users", // Remove from group
});
Error Handling
The SDK includes built-in error handling that throws custom errors with detailed messages. All API calls are wrapped in try-catch blocks and will throw appropriate errors if something goes wrong.
try {
const contact = await client.getContact("invalid-user");
} catch (error) {
console.error("Error fetching contact:", error.message);
}
Best Practices
- Always store your API key securely and never expose it in client-side code
- Handle errors appropriately in your application
- Use TypeScript to get the most out of the SDK's type safety features
- Keep track of event names and properties for consistent analytics
Support
Internal package not intended for external use. For questions or support, please reach [email protected]