> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zixflow.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API Reference

> Node.js SDK method reference for @zixflow/analytics-node.

### new Analytics(settings)

Create an analytics instance.

| Key                  | Type     | Required | Default                   | Description              |
| -------------------- | -------- | -------- | ------------------------- | ------------------------ |
| `writeKey`           | `string` | Yes      | —                         | Your Zixflow write key   |
| `host`               | `string` | No       | `https://cdp.zixflow.com` | API base URL             |
| `path`               | `string` | No       | `/v1/batch`               | Batch path               |
| `maxEventsInBatch`   | `number` | No       | `15`                      | Batch size threshold     |
| `flushInterval`      | `number` | No       | `10000`                   | Auto-flush interval (ms) |
| `maxRetries`         | `number` | No       | `3`                       | Retry attempts           |
| `httpRequestTimeout` | `number` | No       | `10000`                   | Request timeout (ms)     |

**Returns:** `Analytics`

***

### analytics.identify(params, callback?)

Identify a user. Returns `void`.

**Params:** `userId?`, `anonymousId?`, `traits?`, `context?`, `timestamp?`, `integrations?`, `messageId?`

At least one of `userId` or `anonymousId` is required.

***

### analytics.track(params, callback?)

Track an event. Returns `void`.

**Params:** `event` (required), plus identity fields, `properties?`, `context?`, `timestamp?`, `integrations?`, `messageId?`

***

### analytics.page(params, callback?)

Track a page view. Returns `void`.

**Params:** identity fields, `category?`, `name?`, `properties?`, `context?`, `timestamp?`, `integrations?`, `messageId?`

***

### analytics.screen(params, callback?)

Track a screen view. Same shape as `page()`. Returns `void`.

***

### analytics.group(params, callback?)

Associate a user with a group. Returns `void`.

**Params:** `groupId` (required), identity fields, `traits?`, `context?`, `timestamp?`, `integrations?`, `messageId?`

***

### analytics.alias(params, callback?)

Merge identities. Returns `void`.

**Params:** `userId` (required), `previousId` (required), `context?`, `timestamp?`, `integrations?`, `messageId?`

***

### analytics.closeAndFlush(options?)

Flush queued events and stop accepting new ones. Returns `Promise<void>`.

**Options:** `timeout?` (ms). Default timeout is approximately `flushInterval * 1.25`.

***

### analytics.register(...plugins) / analytics.deregister(...names)

Register or remove plugins. Both return `Promise<void>`.

***

### analytics.on(event, listener)

Subscribe to emitter events such as `error`, `http_request`, and `drained`.
