2.0.5 • Published 3 months ago

cdp-node v2.0.5

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

@codematic/cdp-node

A Node.js client library for Codematic's Customer Data Platform (CDP) with optional Customer.io integration.

Installation

npm install @codematic.io/cdp-node
# or
yarn add @codematic.io/cdp-node

Features

  • Send customer identification and event data to Codematic CDP
  • Optional dual-write capability to Customer.io
  • TypeScript support
  • Simple error handling and logging

Usage

import { CDPClient } from '@codematic.io/cdp-node';

const client = new CDPClient({
  cdpApiKey: 'your-cdp-api-key'
});

// Identify a user
await client.identify('user123', {
  email: 'user@example.com',
  name: 'John Doe',
  plan: 'premium'
});

// Track an event
await client.track('user123', 'purchase_completed', {
  amount: 99.99,
  item_id: 'prod-123'
});

// Update user properties
await client.update('user123', {
  last_login: new Date(),
  login_count: 42
});

Dual-write to Customer.io

const client = new CDPClient({
  cdpApiKey: 'your-cdp-api-key',
  sendToCustomerIo: true,
  customerIo: {
    siteId: 'your-customer-io-site-id',
    apiKey: 'your-customer-io-api-key',
    region: 'us' // or 'eu' for EU data centers
  }
});

// Now all identify, track, and update calls will send data to both platforms

Constructor options

interface CDPConfig {
  // Required CDP configuration
  cdpApiKey: string;
  cdpEndpoint?: string; // Optional custom endpoint

  // Optional Customer.io configuration
  sendToCustomerIo?: boolean;
  customerIo?: {
    siteId: string;
    apiKey: string;
    region?: 'us' | 'eu';
  };

  // Logging options
  debug?: boolean;
  cdpLogger?: Logger; // Custom logger. will default to console.log
}
2.0.5

3 months ago

2.0.3

3 months ago

2.0.2

3 months ago

2.0.1

3 months ago

2.0.0

3 months ago

1.0.0

3 months ago