> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/ai/session-logging.md).

# Session logging

Enable **`logs: true`** when constructing `DNotifier` to send AI session telemetry to the DNotifier dashboard — session start, completion, and token usage for each `sendAI` call.

## What gets logged

When logging is enabled and you call `sendAI`:

| Event            | When                                                                                |
| ---------------- | ----------------------------------------------------------------------------------- |
| Session start    | Before the AI request is sent                                                       |
| Session complete | After the HTTP response returns (or WS AI reply for WebSocket)                      |
| Token usage      | Extracted from response when available                                              |
| Model            | From `sendAI` / agent `model` when set; otherwise project default (`current_model`) |

View sessions in the dashboard under **Logs** — see [Dashboard overview](https://github.com/smartguy6666/dnotifier-sdk/tree/main/docs/ai/getting-started/dashboard-overview.md).

{% hint style="success" %}
Session logging works with **`transport: "http"`** and requires no extra API calls beyond `sendAI`.
{% endhint %}

## Enable logging

Pass `logs: true` at construction time (not per `sendAI` call):

```js
const notifier = new DNotifier({
  appId: process.env.DNOTIFIER_APP_ID,
  secret: process.env.DNOTIFIER_SECRET,
  transport: "http",
  userId: "user-123",
  logs: true,
  onConnected: () => {},
  onMessage: () => {},
  onDisconnected: () => {},
});
```

## Logging vs AI history

| Feature      | `logs: true`               | `saveHistory` on `sendAI`        |
| ------------ | -------------------------- | -------------------------------- |
| **Purpose**  | Ops dashboard, token audit | User-facing conversation storage |
| **API**      | Automatic on `sendAI`      | `fetchAIHistory` to read         |
| **Audience** | Developers / support leads | End-user chat UI                 |

Use both in production: history for the product, logs for operations.

{% hint style="info" %}
Full comparison of **`logs`**, **`saveHistory`**, and **`observability`**: [Observability overview](/product-docs/observability/observability.md) · [FAQ](/product-docs/observability/faq.md)
{% endhint %}

## Workflow observability

AI calls **inside workflows** use a separate mechanism — workflow **observability** (`observability: true` on `Workflow`). See [Workflow observability](https://github.com/smartguy6666/dnotifier-sdk/tree/main/docs/ai/workflows/observability.md).

## Language guides

| Language                | Guide                                                                                 |
| ----------------------- | ------------------------------------------------------------------------------------- |
| JavaScript / TypeScript | [javascript-typescript.md](/product-docs/ai/session-logging/javascript-typescript.md) |
| Dart / Flutter          | [dart-flutter.md](/product-docs/ai/session-logging/dart-flutter.md)                   |

## Next steps

* [**Dashboard overview**](https://github.com/smartguy6666/dnotifier-sdk/tree/main/docs/ai/getting-started/dashboard-overview.md) — Where logs appear
* [**AI sessions**](/product-docs/ai/sessions.md) — `sessionId` continuation
