Skip to main content
This guide walks through migrating from the @honeyhive/logger package to @honeyhive/api-client.

What changes for you

@honeyhive/logger targets HoneyHive v1 and is being replaced by @honeyhive/api-client, the typed v2 SDK. The two are not drop-in compatible, but you get a lot more in return:
  • Full typed access to the v2 API. Beyond logging events, you can manage datasets, datapoints, experiments, metrics, and event search from the same client.
  • One Client instance, not per-call config. Set your API key once via HH_API_KEY instead of passing apiKey (and project) on every call.
  • Project scope is automatic. v2 API keys are scoped to a single project, so the SDK no longer needs a project parameter. If you write to multiple projects, construct one Client per key.
  • Errors surface instead of being swallowed. Failed calls throw typed errors you can catch, rather than logging to console.error and returning undefined.
Logger’s three functions (start, log, update) map onto two namespaces on the new client: client.sessions and client.events.

Install and import

Old:
New:

Configuration

See the full ClientConfig reference for every option. The most common settings and mechanism for setting them are below.

TLS / certificate verification

Logger exposed a per-call verify flag (Node-only). The new SDK is isomorphic - it runs in Node and the browser - and TLS verification isn’t something you can flip from JavaScript in the browser, so the SDK doesn’t expose a flag. In Node, if you genuinely need to disable verification (for example, to talk to an internal HoneyHive deployment with a self-signed cert), use the standard Node environment variables: prefer NODE_EXTRA_CA_CERTS=/path/to/ca.pem to register the internal CA, or NODE_TLS_REJECT_UNAUTHORIZED=0 as a last resort. Do not disable verification against the public HoneyHive endpoint. In the browser, certificate trust is browser-managed - trust the cert at the OS or browser level.

Retry behavior changed

Logger had built-in retry (3 attempts, exponential backoff with jitter, retrying on 5xx / 408 / 429 / network errors). The new SDK does not retry. If you relied on logger’s retry behavior in production, you’ll need to add it yourself - wrap calls in a small retry helper or use a library like p-retry.

Function-by-function migration

start(...)client.sessions.create(...)

See the sessions namespace for the full method reference. Before:
After:
The new SDK returns the full CreateSessionResponse (which includes both session_id and a separate event_id - see Updating a session below) and throws on failure rather than swallowing the error. See Error handling below.

log(...)client.events.create(...)

See the events namespace for the full method reference. Before:
After:
If you log many events back-to-back, take a look at client.events.createBatch({ events: [...] }) - it submits them in a single request.

update(...)client.events.update(...)

Before:
After:
Same renames as above: durationMsduration, userPropertiesuser_properties.

Updating a session

This is a meaningful behavior change. In v1, the legacy server treated session_id and event_id interchangeably for updates, so logger’s update({ eventId }) would accept either. In v2 it does not - passing a session_id to events.update returns a 400 Bad Request with the message no event with event_id - <id> found. A session is itself an event with event_type: 'session'. client.sessions.create returns both identifiers:
  • session_id - the session correlation ID. Use this as the session_id on child events to associate them with the session.
  • event_id - the row ID of the session-typed event itself. Use this when you want to update the session row.
events.update only merges nine specific fields: metadata, feedback, metrics, outputs, config, user_properties, duration, end_time, children_ids. Other fields are accepted by the server but silently ignored.

End-to-end example

A complete flow - start a session, log a model event, update it with the response - looks like this:
The @honeyhive/api-client README has the same example with more commentary.

Error handling

Logger swallowed errors by default - when a call failed, it logged to console.error and returned null (set verbose: true to make it throw instead). The new SDK throws on failure:
  • ApiError - the server returned a non-2xx response. Carries .status, .response, .error, and a .parseError() helper that returns a typed ErrorResponse when the body matches.
  • NetworkError - the request never made it to the server (DNS, connection reset, TLS failure, etc.). Carries .error with the underlying cause.
Both extend HoneyHiveError, so a single catch (err) { if (err instanceof HoneyHiveError) ... } handles both:
If you previously relied on logger’s silent-failure behavior (your code expected null on failure and kept going), you’ll need to add a try/catch to preserve that behavior - or, better, decide whether failing loud is what you actually want.

What else you get

Migrating opens up a much larger API surface. None of these have a logger equivalent: For worked examples see the @honeyhive/api-client README. For the full reference, see the API SDK reference site.