Developers

Instrument once. Keep the contract.

Every event states its schema, consent and idempotency key before MetricMark accepts it.

instrumentation.ts
const event = await metricmark.enqueue(outbox, {
  type: "stackdeck.chat.turn.completed",
  schemaVersion: 1,
  idempotencyKey: `stackdeck:chat:turn:${turn.id}`,
  classification: "internal",
  purposes: ["product_analytics"],
  consent: {
    class_key: "product_analytics",
    state: "granted",
    recorded_at: consent.updatedAt,
    source_ref: "stackdeck.cookie-consent.v1",
    version: 1,
  },
  payload: turn.labels,
});

Server events

Write to your outbox first.

The Node.js SDK queues the event in your product's own transaction and sends it after commit.

producer.ts
const event = await metricmark.enqueue(outbox, {
  type: "stackdeck.chat.turn.completed",
  schemaVersion: 1,
  idempotencyKey: `stackdeck:chat:turn:${turn.id}`,
  classification: "internal",
  purposes: ["product_analytics"],
  consent: {
    class_key: "product_analytics",
    state: "granted",
    recorded_at: consent.updatedAt,
    source_ref: "stackdeck.cookie-consent.v1",
    version: 1,
  },
  payload: turn.labels,
});
  1. 01
    Register the source

    Register it in MetricMark's Settings and copy the key once.

  2. 02
    Use a registered schema

    Send only event types MetricMark has registered, each with its consent class.

  3. 03
    Commit atomically

    Write the product record and the event to one transactional outbox.

  4. 04
    Deliver idempotently

    Send to POST /v2/events, and a repeat gets the original receipt.

Consent evidence

Missing consent never gets in.

Ingest compares each event's consent with its schema's class and stores nothing it refuses.

Ingest response
POST /v2/events  →  422

{
  "code": "consent_missing",
  "message": "Events of class 'product_analytics' need consent evidence",
  "paths": ["consent"]
}

Delivery model

At least once, with duplicates removed.

MetricMark does not promise exactly once, so it makes retries safe instead.

Product transactionOutbox row committed

The event cannot get lost between your change and its delivery.

MetricMark ingestSignature, schema and consent checked

The receipt and an outbox row commit in one PostgreSQL transaction.

Pub/Sub and writerStored once

A writer takes each event from Pub/Sub and drops duplicates.

Envelope v2

Context that analytics usually guesses later.

Scope

Tenant, workspace, project, environment, source and installation

Identity

Optional actor and subject with an explicit type and namespace

Governance

Classification, purposes and consent evidence

Causality

Occurrence and send time, correlation, causation and idempotency

SDK context

SDK name and version, session, trace, locale, time zone and coarse country

Payload

A property set checked against the registered schema

Ready to connect

Start with one governed event.

Create a StackDeck account to register a source, or review the security controls first.