Hosted preview

See what your server did for each user

Some events happen on your server: a payment is captured, an email is sent, a job fails. The Node SDK sends them to Sequential with a server key. Sequential puts them on the same person as the browser events. When it can prove that the browser session is theirs, it also puts them in that session. An error from your server opens a case at once.

Anyone can create an account. The hosted preview gives 5,000 sessions a month and takes no payment.

01Backend SDK

Three steps

  1. Create a server key

    Open Settings › Keys. Under "Server keys", give the key a label in "Make a server key", then press "Make key". Sequential shows the key once. Store it in your secret manager. It is not the write key. Never put it in a web page.

  2. Install the SDK

    The package is @usesequential/node. It has no dependencies, it needs Node 18 or later, and it works with CommonJS and ES modules. Types are included. Licence: MIT.

  3. Send events with the user id

    Call track() with the event name and your user id. To join the browser session too, pass the request. The browser SDK writes a small first-party cookie, and contextFromRequest() reads it.

Shell

npm install @usesequential/node
An Express route. Koa (pass ctx.req), Fastify (request.raw) and Next.js route handlers work too. In Hono, pass c.req.raw.

import { SequentialServer, contextFromRequest } from '@usesequential/node';

const sequential = new SequentialServer({ secretKey: process.env.SEQUENTIAL_SERVER_KEY });

app.post('/api/checkout', async (req, res) => {
  // ... your code
  sequential.track({ event: 'payment_captured', userId: req.user.id, context: contextFromRequest(req) });
  res.sendStatus(204);
});

02

One person, one timeline

The user id decides the person. The context adds the session. If Sequential can prove that the context belongs to that user, the event goes into that browser session. It shows next to the replay. If it cannot, Sequential keeps the event on the user, leaves the session out and counts it as "context dropped". So a forged cookie cannot put an event into another person’s session.

With no user id, the context alone decides: the event goes on that person and that session. When the person signs in later, the event shows on the user.

On the person's page in People, the "Backend activity, last 30 days" strip lists the events your server sent, newest first. Each row has the event name and the time. A row that has a session links to its replay. Your coding agent sees the same list in get_user_journey, as names and times.

03

Server errors become cases

Call captureError(err) in your error handler, or captureHttpError() for a 5xx answer. Sequential stores the error type, the message and the first 20 lines of the stack.

  • At once. An error from your server opens a case at its first occurrence.
  • Marked. A case with server occurrences has no page. In Problems › Cases and on the case, "your server" shows in place of the page.
  • Counted honestly. An error with no browser session counts in people and occurrences, never in sessions.
  • Joined. A server error and a browser error with no page, of the same type and message, are one case.
  • For your agent. list_errors gives each group its source: browser, server or both. Cases carry the same sources.

04

An SDK that does not get in the way

  • track() never throws. It returns true or false.
  • Events go out in batches: every 100 events or every second.
  • A failed batch is tried again up to 3 times, with backoff.
  • When Sequential answers 429 or 503 with Retry-After, the SDK waits that long. It keeps the batch for up to 5 minutes. These waits do not count as tries.
  • A retried batch is stored once. But it can be stored twice if the first try is before Monday 00:00 UTC and the retry after.
  • Each drop has a reason in stats and in onError. The reasons are: invalid event, no identity, queue full, too large, refused, retries used up.
  • The timer never keeps your process alive. In serverless code, call await flush() before you return.
  • disabled: true sends nothing, for tests and local runs.

05

What server events count as

Server events do not count as page views, sessions or people, signed in or anonymous. Plans count sessions, and a server event never starts one. So server events do not add to your billed usage.

Sequential stores no browser, device, IP address, country or URL for a server event. A server event never identifies a person.

Funnels, flows and event search count server events, so "paid" can be a step after "clicked Pay".

06

Server keys

  • Stored as a hash. Sequential keeps the SHA-256 and the last 4 characters. The list shows the label, the last 4 and when each key was last used.
  • Revoke any time. Servers that send with a revoked key are refused within seconds. To rotate a key, create a new key, deploy it, then revoke the old one.
  • Owners and admins. They create and revoke keys. With two-factor on, creating a key asks for a code. Members see the list.
  • Not for browsers. A request that carries an Origin header is refused. The server key also does not work on the browser route.

07

Good to know

  • Node only. There is no SDK for other server languages yet.
  • No identify from the server. Link ids in the browser.
  • The cookie is an analytics cookie. List __sq_ctx with your analytics cookies. It is first party and lasts 30 minutes. The browser SDK sets it only while it records. Opt-out clears it. For a signed-in person, it can carry your user id.
  • Across sites or from an app. The cookie stays on your domain. From another site or a native app, send the x-sequential-context header.
  • Right after sign-in. In about the first minute after your page identifies a person, a server event stays on the user. It may not join the session yet.
  • Several tabs. Each tab has its own session, and the cookie is shared. So a server event goes into the session of the tab that wrote the cookie last.
  • Limits. 50 requests a second for each key. 500 events and 1 MB for each request. Your project’s event rate limit applies too.
  • Trial projects. A trial project cannot have server keys. Claim the project first.
  • Releases and changes. A server key cannot record them. From a deploy step, the Sequential CLI records them with a project access token.
  • Personal data. Error messages are stored as sent. Keep personal data out of them.

08

Questions engineers ask

Do server events cost extra?

No. Plans count sessions, and a server event never starts a session. A project that is over its limit can still refuse them.

We already send errors to an error tracker. Why send them here too?

Here the error is on the person. When a browser request caused it, the error is also in the session, next to the replay. A case counts the people it hit.

Can someone fake the cookie?

They can put a session id in it. With your user id on the event, Sequential keeps the session only when the context belongs to that user. Without a user id, the event is marked unverified and counted.

Start free in the hosted preview.

The hosted preview gives you 5,000 sessions a month and keeps 7 days of data by default. It takes no payment.