Use cases and places
How Sypnia measures each use case of your app in production, and checks with real clicks that people move through your app the way its navigation map says.
This page is for anyone who builds with use cases: a map of what people can do in your app, kept in Sypnia Cases or written as code with Sypnorm. It works with the open-source engine and with Sypnia Cloud. Without a map, nothing here changes how the rest of Sypnia works.
A use case in a trace
When a request or a job serves a use case, its span carries two attributes:
| Attribute | What it holds | Example |
|---|---|---|
sypnia.case | The case id, as it is on the map | place-order |
sypnia.case.outcome | How the case ended: the name of one of its outcomes or failures | OrderPlaced, OutOfStock |
You rarely set them yourself:
- Sypnorm sets both on every use case it runs: each run is a span
usecase <case id>carryingsypnia.case, and the outcome (errorwhen the run threw) is set on that same span, withsetSpanAttributes()of@sypnia/telemetry0.4.0 or later, or with the OpenTelemetry API when one is registered. With an older@sypnia/telemetry, whosespan()takes its attributes when it starts, the ending is recorded as a second, short spanusecase <case id> → <Outcome>with both attributes. - Sypnia Run sets both on the cases it runs: routes, scheduled jobs and listeners (how Run runs use cases).
- Any other code sets them on the span that serves the case, with
setSpanAttributes()of@sypnia/telemetry(from version 0.4.0; in Next.js from@sypnia/telemetry/next/server). It finds the request’s span for you, and the outcome can be set after the work ended (Node SDK):
import { setSpanAttributes } from '@sypnia/telemetry/node';
setSpanAttributes({ 'sypnia.case': 'place-order' });
// … the work of the case …
setSpanAttributes({ 'sypnia.case.outcome': 'OrderPlaced' });With OpenTelemetry, the same with its API:
import { trace } from '@opentelemetry/api';
const span = trace.getActiveSpan();
span?.setAttribute('sypnia.case', 'place-order');
// … the work of the case …
span?.setAttribute('sypnia.case.outcome', 'OrderPlaced');A trace belongs to the case of its first span that carries one. Calls made inside that work, to Sypnia AI, Files, Mail or your own services, are spans of the same trace, so the case shows everything it did. Both attributes are in the semantic conventions.
What each case shows
| Figure | What it counts |
|---|---|
| Runs | How many times the case ran in the range, and the trend |
| Outcomes | How many runs ended in each outcome and each failure, by name |
| Errors | Runs that threw, answered 500 or above, or ended without any outcome the case declares |
| Duration | p50 and p95 of the span that carries the case |
| Problems | The problems whose failures happened inside the case |
A declared failure is not an error. When the bread is sold out, OutOfStock is the case doing its job: it is counted under outcomes, with the message people saw. An error is something the case did not plan for. So a problem reads «3 people could not finish Place an order: the card form never loaded», and the case’s page shows it next to the 41 runs that ended in OrderPlaced.
A case that starts only when several events have arrived (on_all in Cases) has a window to wait for them. When the window closes before they all arrive, the case does not run, and its page shows the wait as WindowExpired, with the events that did arrive. It is counted under outcomes, not as an error.
Places: where people are
Inside an app, every use case has a place: a screen, a tab, a dialog or a menu, on the app’s navigation map. In Cases this is the case’s where, and each place has one parent, so the way to get there is always known: «Shop › Checkout».
The browser SDK reads places from your pages. The element that shows a place carries its id:
<main data-sypnia-place="shop.checkout">
…
<dialog open data-sypnia-place="shop.checkout.change-address">…</dialog>
</main>Every page_view and click, rage and dead clicks included, then carries place (from version 0.4.0 of the browser SDK): the id of the innermost place around it. A dialog open over the checkout is its own place. Pieces generated by Sypnia Design and the components of @sypnia/ui set the attribute for you from the case’s where. A place id is a name from your code: it is never the page’s content, and masking does not change it.
The navigation check
From those events Sypnia knows how people move: a click in one place, then the next place they see. With the project linked to a Cases map, it compares those moves with the navigation tree:
| What Sypnia finds | What it means | What to do |
|---|---|---|
| A move along the tree | People get there the way the map says | Nothing |
| A move the tree does not have | A shortcut or a link nobody put on the map | Add it to the map as a shortcut, or remove the link |
| A place nobody reached in 30 days | A screen people cannot find, or no longer need | Check the way to it, or remove it from the map |
| A route with no place | A screen that is not on the map | Give it a place, or find out why it exists |
It does the same for use cases:
| What Sypnia finds | What it means |
|---|---|
| An outcome the case does not declare | A gap in the map: something happens that no one agreed on. Cases proposes a change to the case, with what people saw |
| A case on the map that never ran in 30 days | It is not built, not reachable, or not used |
| A case id that is not on the map | Code that does something no case describes |
The comparison happens where the map lives: Sypnia Cases reads these figures from Sypnia and shows them on each case and each place (Cases and Telemetry). A self-hosted Cases engine reads them from your own engine with an API token.
Reading the figures
- In the app, each use case and each place has its page, linked from the traces and problems that belong to it.
- The API gives the same figures:
GET /v1/cases,GET /v1/places, and thecasefilter onGET /v1/traces.
How Sypnia uses it
Sypnia measures its own products this way. Every product of the suite has its map of cases, and their spans and places arrive in Sypnia Telemetry, the pilot: Telemetry, the pilot.