# RevMax SDK Examples

Quick examples to get you started with the RevMax SDK.

## Prerequisites

1. Build the SDK first:
   ```bash
   cd /path/to/backend/sdk
   npm install
   npm run build
   ```

2. Set your API key:
   ```bash
   export REVMAX_API_KEY=revx_pk_your_api_key_here
   export REVMAX_API_URL=http://localhost:3005/v1/sdk  # or production URL
   ```

## Examples

### 01 - Quick Start
The simplest example - connect and track one event.
```bash
node examples/01-quick-start.js
```

### 02 - Single Event with Costs
Track an event with detailed usage cost breakdown (LLM tokens).
```bash
node examples/02-single-event-with-costs.js
```

### 03 - Multiple Single Events
Send 3 events one at a time (sequential API calls).
```bash
node examples/03-multiple-single-events.js
```

### 04 - Batch Events
Send 5 events in a single API call for better performance.
```bash
node examples/04-batch-events.js
```

### 05 - Customer Management
Create, list, get, and update customers.
```bash
node examples/05-customer-management.js
```

### 06 - Full Workflow
Complete end-to-end example with customer creation and event tracking.
```bash
node examples/06-full-workflow.js
```

## Signal Names (Examples)

These are example signal shortNames you might use:

| Signal | Description |
|--------|-------------|
| `qbr_generated` | Quarterly Business Review generated |
| `success_plan_created` | Success plan created for customer |
| `customer_research_report` | Customer research report generated |
| `hours_saved` | Hours saved (can have quantity > 1) |
| `customer_retained` | Customer retention event |
| `api_call` | Generic API call |

## Usage Cost Tracking

Track LLM/API costs in event metadata:

```javascript
await client.trackEvent({
  customerExternalId: 'cust-123',
  agentId: 'agent-uuid',
  signalName: 'task_completed',
  quantity: 1,
  metadata: {
    usageCost: [
      { serviceName: 'Anthropic Claude Sonnet Input', units: 15000, unitType: 'token' },
      { serviceName: 'Anthropic Claude Sonnet Output', units: 3000, unitType: 'token' },
    ]
  }
});
```

## Need Help?

- [Full Documentation](../README.md)
- [API Reference](https://docs.userevmax.com)
