Skip to content

Frontend logging

Errors in your users' browsers and phones are hard to see. With ObjectsGrid frontend logging, your app sends its errors, slow requests and user events in batches, and you search them later, by session, user, app version or message.

Each logged event is stored as a LogEvent: the message, severity and details of the event, and where it happened (app, session, device, network, page).

Send a batch

Collect events in your app and send them together with POST /log, up to 1000 at a time, for example every 30 seconds, when 100 have gathered, or when the user leaves the page.

The fields that are the same for every event of the batch, such as the app, session and device, go once in sourceInfo. ObjectsGrid copies them into each event; an event's own value replaces the shared one.

curl -X POST https://apis.objectsgrid.com/log \
  -H 'Content-Type: application/json' \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -H "Authorization: Bearer $TOKEN" \
  -d @batch.json
batch.json
{
  "sourceInfo": {
    "schemaVersion": "1.0.0",
    "app": {"name": "northpeak-shop", "version": "4.2.0"},
    "environment": "production",
    "platform": "web",
    "baseUrl": "https://shop.northpeak.example",
    "sentAt": "2026-11-13T09:31:00Z",
    "session": {"sessionId": "s-8f2a91"},
    "client": {"locale": "de-DE", "timezone": "Europe/Berlin"},
    "device": {"type": "desktop", "osName": "macOS"},
    "web": {"browserName": "Firefox", "browserVersion": "145.0", "pageUrl": "https://shop.northpeak.example/checkout"}
  },
  "logEvents": [
    {
      "timestamp": "2026-11-13T09:30:12Z",
      "severity": "info",
      "eventType": "page.load",
      "message": "Checkout loaded",
      "performance": {"ttfb": 120, "lcp": 850}
    },
    {
      "timestamp": "2026-11-13T09:30:41Z",
      "severity": "error",
      "eventType": "error",
      "message": "Payment form failed to load",
      "stackTrace": "TypeError: card is undefined\n    at mountPaymentForm (checkout.js:212:9)",
      "http": {"method": "GET", "status": 503, "urlTemplate": "/payments/form", "durationMs": 3012}
    }
  ]
}
  • 201 Created, with no body, means every event was stored.
  • All or nothing: if one event isn't valid, nothing is stored, and the error's reasons name it by position, such as /logEvents/1/message.
  • Rarely, some events can't be stored after the batch was accepted. The answer is then 207 with {"errors": [{"index": 1, "error": {...}}]}; the other events were stored.
  • The body may be up to 10 MB, and each event up to 1 MB.
  • Each event counts as one request against your monthly spending cap.

Every event needs schemaVersion, app, environment, platform, sentAt, session, timestamp, severity and message, either itself or through sourceInfo. All fields are in the LogEvent reference.

Which account sends the logs?

Visitors who aren't signed in can send logs with your public service account's token. Allow it to create LogEvent, and nothing else on logs, in your ABAC policy:

allow if {
    input.action == "create"
    input.objectType == "LogEvent"
}

Search your logs

Log events are searchable within seconds. List them with GET /log and a where, for example every error of one session, newest first:

curl -G https://apis.objectsgrid.com/log \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode 'where={"session": {"sessionId": "s-8f2a91"}, "severity": "error"}' \
  --data-urlencode 'orderBy={"timestamp": "desc"}' \
  -d first=50

To see which errors happen most, group them: groupBy={"by": ["message"], "where": {"severity": "error"}, "_count": true, "orderBy": {"_count": {"_all": "desc"}}}.

Read one event with GET /log/{id}. Log events can't be changed or deleted.

GraphQL

The GraphQL API writes a batch with createLogEvents, which returns the number of events stored:

mutation {
  createLogEvents(
    sourceInfo: {
      schemaVersion: "1.0.0"
      app: { name: "northpeak-shop", version: "4.2.0" }
      environment: "production"
      platform: "web"
      sentAt: "2026-11-13T09:31:00Z"
      session: { sessionId: "s-8f2a91" }
    }
    logEvents: [
      { timestamp: "2026-11-13T09:30:41Z", severity: "error", message: "Payment form failed to load" }
    ]
  )
}

and searches with logEvents, which takes the same where and orderBy as the REST API, typed:

{
  logEvents(where: {session: {sessionId: {equals: "s-8f2a91"}}}, orderBy: [{timestamp: desc}], first: 50) {
    items { timestamp severity message }
    pageInfo { endCursor hasNextPage }
  }
}

Good practice

  • Don't log personal data, such as email addresses, names or full card numbers, in messages or context. Use ids, such as the user's account id in auth.userId.
  • Send batches rather than single events: fewer requests, lower cost.
  • Send the last batch when the page is hidden (visibilitychange) with fetch(..., {keepalive: true}), so it isn't lost when the user leaves.