Nest Engineering Docs
Event Logging

Data model

Persisted event shape and metadata envelope for Event Logging

V1 writes one row per accepted request to NestEventLog.

Schema reference

  • Spanner migration: db/liquibase/changelogs/spanner/nest/118_create_nest_event_log_table.sql
  • Repository implementation: services/events/core/repository.py

Column mapping

ColumnSourceNotes
event_idservice-generatedCurrent implementation uses a UUID string.
event_namerequest.event_nameTrimmed during normalization.
event_typerequest.event_typeTrimmed during normalization. Stored as NULL when omitted.
actor_idrequest.actor_idTrimmed during normalization. Stored as NULL when omitted.
event_tsrequest.event_ts or service timeAlways normalized to UTC.
valuenot populated in v1Stored as NULL.
metadatanormalized caller metadata plus _eventLogStored as Spanner JSON.
ingested_atSpanner commit timestampGenerated by the table schema, not by the service.

_eventLog metadata envelope

Caller metadata is preserved, but the service always reserves _eventLog for its own bookkeeping. That envelope currently contains:

  • forwardToStatsig
  • optional idempotencyKey
  • optional caller object with the platform caller identity: actorId, principalEmail, and principalId

Example persisted metadata:

{
  "provider": "password",
  "details": {
    "plan": "pro",
    "seats": 3
  },
  "_eventLog": {
    "forwardToStatsig": true,
    "idempotencyKey": "dedupe-1",
    "caller": {
      "actorId": "checkout@nestveterinary.com",
      "principalEmail": "checkout@nestveterinary.com",
      "principalId": "principal-123"
    }
  }
}

Metadata constraints

  • Top-level keys are capped at 256 by protobuf validation.
  • Canonical serialized JSON is capped at 64 KiB during normalization.
  • Nested objects and arrays are allowed.
  • _eventLog is reserved and rejected if a caller tries to send it.
  • _eventLog.caller is service-managed auth metadata and is distinct from the row-level actor_id column sourced from the request.

Statsig mapping note

The Spanner row keeps nested metadata as JSON. The Statsig adapter is stricter: when forwarding, nested objects and arrays are stringified into deterministic JSON so they can fit Statsig's flatter metadata model.

Last updated on

On this page