Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const client = new IterableClient({
apiKey: 'your-api-key'
});

const user = await client.getUserByEmail('user@example.com');
const user = await client.getUserByEmail({ email: 'user@example.com' });

// Track event
await client.trackEvent({
Expand Down Expand Up @@ -57,13 +57,15 @@ const client = new IterableClient({

### Environment Variables

```bash
ITERABLE_API_KEY=your-api-key # Required
ITERABLE_DEBUG=true # Enable basic debug logging
ITERABLE_DEBUG_VERBOSE=true # Enable full body logging (includes PII)
LOG_LEVEL=info # Log level
LOG_FILE=./logs/iterable.log # Log to file
```
| Variable | Description | Default |
|----------|-------------|---------|
| `ITERABLE_API_KEY` | API key (required when using `createIterableConfig()`) | — |
| `ITERABLE_BASE_URL` | API base URL | `https://api.iterable.com` |
| `ITERABLE_DEBUG` | Log HTTP requests/responses (headers redacted) to stderr | `false` |
| `ITERABLE_DEBUG_VERBOSE` | Include response bodies in debug output (may contain PII) | `false` |
| `LOG_LEVEL` | Log level (`error`, `warn`, `info`, `debug`, etc.) | `debug` when `ITERABLE_DEBUG` is set, otherwise `info` |
| `LOG_FILE` | Write logs to a file | — |
| `LOG_STDERR` | Write logs to stderr | `true` |

## Development

Expand Down
9 changes: 6 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ export const config = createEnv({
LOG_LEVEL: z
.enum(["error", "warn", "info", "http", "verbose", "debug", "silly"])
.default(
!process.env.NODE_ENV || process.env.NODE_ENV === "production"
? "info"
: "debug"
process.env.ITERABLE_DEBUG === "true" ||
process.env.ITERABLE_DEBUG_VERBOSE === "true"
? "debug"
: !process.env.NODE_ENV || process.env.NODE_ENV === "production"
? "info"
: "debug"
),
LOG_JSON: z.coerce.boolean().default(process.env.NODE_ENV === "production"),
LOG_FILE: z.string().optional(),
Expand Down
Loading