---
title: "Watch what your app decides"
description: "Subscribe to network, access and action events, assert on them in a test, and print them while you debug a refused call."
section: "guides"
status: "Building for 0.3"
spec: "observe"
canonical: "https://mainsdk.dev/docs/guides/watch-what-your-app-decides"
updated: "2026-10-28"
---

# Watch what your app decides

> Subscribe to network, access and action events, assert on them in a test, and print them while you debug a refused call.

Status: Building for 0.3 · Canonical: https://mainsdk.dev/docs/guides/watch-what-your-app-decides · Updated: 2026-10-28

You will watch the decisions your app makes (which hosts it may call, who may do what), check them in a test, and print them while you debug. It takes about 10 minutes.

## You need

- A MainSDK app with a `main.yaml`, run from the repository (nothing here is published to npm).
- A `network.allow` list with at least one host.

## Steps

1. Subscribe to the network decisions. The callback runs off the request path and can't change a call.

```ts title="lib/watch.ts"
import { observe } from "mainsdk";

export const stop = observe("mainsdk:network.decision", (e) => {
  console.log(e.data.host, e.data.decision);
});
```

2. Assert on events in a test. `createTestApp()` records them as they happen, so no flush is needed.

```ts title="test/network.test.ts"
const app = createTestApp();
await app.access.check({
  subject: { id: "u1", roles: [] },
  action: "orders.write",
  resource: { type: "orders" },
});
assert.equal(app.events("mainsdk:access.decision")[0]?.data.decision, "deny");
```

3. Print while you debug. In development, set `MAINSDK_DEBUG=mainsdk:access.*` and run the app. Each matching event prints one line with its channel, decision and reasons.

## What you get

Every event is redacted before an observer sees it and holds no request body, prompt or secret. Read [the channels reference](https://mainsdk.dev/docs/reference/channels) for each payload, and [`observe`](https://mainsdk.dev/docs/interfaces/observe) for the calls.
