---
title: "nuxt-backend/monitoring"
description: "Every export of nuxt-backend/monitoring, with its signature and where it is defined."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/monitoring"
---
# nuxt-backend/monitoring

Version: nuxt-backend 0.6.x · Tab: Reference · Kind: reference · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

**Experimental**

Error reports and cron check-ins from the backend's own actions, sent to
the monitoring service the deployment's DSN names. They are posted
straight to its ingest endpoint with `fetch`: no SDK runs in the backend.
Without `MONITORING_DSN` on the deployment every call is a no-op that
resolves `false`. Reports name the environment `BACKEND_ENVIRONMENT`
says (`env push` derives it from the deployment's kind), so they sit
beside the app's own.

Only actions (and HTTP actions) can post: a query or a mutation cannot
fetch. Their failures are reported where they are called from: the
browser and the Nuxt server report them with the function's name and the
error's catalog code. A mutation job checks in by scheduling an action
that calls [checkIn](#checkin) as it succeeds, so a failed run shows as a
missed check-in.

The `authed`, `workspace`, `admin` and `withRole` actions of `createFunctions`
report what their handlers throw already, with its code and stack; an
action cannot read its own name, so those reports carry no
`backend.function` tag (the caller's report of the same failure does).
The functions here are for the app's own actions and jobs.

Experimental: the cron check-ins follow the monitoring service's cron
monitors, whose options may still move, so this entry's shape may change
in a minor release. The tags a report carries (`MONITORING_TAGS`) are
stable, as are the health routes.

## Interfaces

### ReportErrorOptions

Defined in: [src/convex/integrations/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts)

**Experimental**

What a report says about where an error happened.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="function">
        
      </a>
      
       <code>
        function?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The function it happened in, <code>
        digest:send
      </code>
      
      , or the route, <code>
        imports webhook
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts" rel="nofollow">
        src/convex/integrations/monitoring.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="tags">
        
      </a>
      
       <code>
        tags?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       More tags to search the report by.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts" rel="nofollow">
        src/convex/integrations/monitoring.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CheckInOptions

Defined in: [src/convex/integrations/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts)

**Experimental**

A check-in's status, and what keeps its monitor in step with the code.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="status">
        
      </a>
      
       <code>
        status?
      </code>
    </td>
    
    <td>
      <a href="#checkinstatus">
        <code>
          CheckInStatus
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Default <code>
        ok
      </code>
      
      . <code>
        in_progress
      </code>
      
       when a long job starts, then <code>
        ok
      </code>
      
       or <code>
        error
      </code>
      
       when it ends.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts" rel="nofollow">
        src/convex/integrations/monitoring.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="schedule">
        
      </a>
      
       <code>
        schedule?
      </code>
    </td>
    
    <td>
      <a href="#backendcronschedule">
        <code>
          BackendCronSchedule
        </code>
      </a>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The job's schedule, <code>
        every
      </code>
      
       an interval or on a <code>
        cron
      </code>
      
       expression. Given, the first check-in creates the monitor, and every later one keeps its schedule in step with the code.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts" rel="nofollow">
        src/convex/integrations/monitoring.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="durationms">
        
      </a>
      
       <code>
        durationMs?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How long the run took, in milliseconds.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts" rel="nofollow">
        src/convex/integrations/monitoring.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Type Aliases

### CronInterval

```ts
type CronInterval = Parameters<Crons["interval"]>[1];
```

Defined in: [src/convex/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts)

**Experimental**

How often an interval check-in runs: exactly one of `seconds`, `minutes` or `hours`.

---

### BackendCronSchedule

```ts
type BackendCronSchedule = 
  | {
  every: CronInterval;
  cron?: never;
}
  | {
  cron: string;
  every?: never;
};
```

Defined in: [src/convex/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts)

**Experimental**

When a monitored job runs, as its monitor expects it: `every` an
interval, or on a `cron` expression (five fields, UTC).

---

### CheckInStatus

```ts
type CheckInStatus = "ok" | "error" | "in_progress";
```

Defined in: [src/convex/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts)

**Experimental**

What a check-in says: `in_progress` when a job starts, `ok` or `error` when it ends.

## Variables

### MONITORING_TAGS

```ts
const MONITORING_TAGS: {
  function: "backend.function";
  code: "backend.code";
  reason: "backend.reason";
  source: "backend.source";
};
```

Defined in: [src/convex/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts)

**Experimental**

The tags an event about a backend call carries. Brand-neutral, so a search
in the monitoring service reads the same whichever side reported it: the
browser, the Nuxt server or the backend itself.

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default value
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="property-function">
        
      </a>
      
       <code>
        function
      </code>
    </td>
    
    <td>
      <code>
        "backend.function"
      </code>
    </td>
    
    <td>
      <code>
        'backend.function'
      </code>
    </td>
    
    <td>
      The function the call ran, <code>
        billing:checkout
      </code>
      
      , or the webhook it came in on, <code>
        billing webhook
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts" rel="nofollow">
        src/convex/monitoring.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-code">
        
      </a>
      
       <code>
        code
      </code>
    </td>
    
    <td>
      <code>
        "backend.code"
      </code>
    </td>
    
    <td>
      <code>
        'backend.code'
      </code>
    </td>
    
    <td>
      Its catalog code (<code>
        unavailable
      </code>
      
      ), or <code>
        none
      </code>
      
       for a crash or an app's own error.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts" rel="nofollow">
        src/convex/monitoring.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-reason">
        
      </a>
      
       <code>
        reason
      </code>
    </td>
    
    <td>
      <code>
        "backend.reason"
      </code>
    </td>
    
    <td>
      <code>
        'backend.reason'
      </code>
    </td>
    
    <td>
      An <code>
        unavailable
      </code>
      
       refusal's <code>
        service
      </code>
      
       and <code>
        reason
      </code>
      
      , as <code>
        billing/provider_refused
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts" rel="nofollow">
        src/convex/monitoring.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-source">
        
      </a>
      
       <code>
        source
      </code>
    </td>
    
    <td>
      <code>
        "backend.source"
      </code>
    </td>
    
    <td>
      <code>
        'backend.source'
      </code>
    </td>
    
    <td>
      Where it was reported from: <code>
        browser
      </code>
      
      , <code>
        server
      </code>
      
       or <code>
        backend
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts" rel="nofollow">
        src/convex/monitoring.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Functions

### reportError()

```ts
function reportError(error, options?): Promise<boolean>;
```

Defined in: [src/convex/integrations/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts)

**Experimental**

Report an error to the monitoring service, from an action. A refusal from
the error catalog (anything but `unavailable`) is the app working as
designed and is not reported. Resolves with whether a report was sent;
never rejects, so a report cannot fail the action it reports on. A report
carries the error's name, message and stack, the function and the tags:
never the call's arguments, or who made it.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        error
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#reporterroroptions">
        <code>
          ReportErrorOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`Promise`<`boolean`>

#### Example

```ts [backend/digest.ts]
import { reportError } from 'nuxt-backend/monitoring'

export const send = internalAction({
  args: {},
  handler: async (ctx) => {
    try {
      await deliverDigests(ctx)
    }
    catch (error) {
      await reportError(error, { function: 'digest:send' })
      throw error
    }
  },
})
```

---

### checkIn()

```ts
function checkIn(job, options?): Promise<boolean>;
```

Defined in: [src/convex/integrations/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts)

**Experimental**

Check a scheduled job in to its monitor, from an action: the job named
`send weekly digest` checks in to `send-weekly-digest`. A monitor that
expects a check-in and gets none reports the job missed, which is how a
failed run shows. Resolves with whether the check-in was sent; never
rejects.

Only a deployment whose `BACKEND_ENVIRONMENT` is set, and is neither
`development` nor `preview`, checks in: `env push --prod` sets
`production`. A dev deployment that sleeps with a laptop, or a preview
deleted with its branch, would otherwise read as a missed run.

A job that runs as a mutation cannot fetch: it schedules an action that
checks in, as its last step, so a run that throws takes the check-in with
it.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        job
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#checkinoptions">
        <code>
          CheckInOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`Promise`<`boolean`>

#### Examples

```ts [backend/digest.ts]
import { checkIn } from 'nuxt-backend/monitoring'

export const send = internalAction({
  args: {},
  handler: async (ctx) => {
    await deliverDigests(ctx)
    await checkIn('send weekly digest', { schedule: { cron: '15 8 * * 1' } })
  },
})
```

```ts [backend/digest.ts]
// A mutation job: its last step schedules the check-in, in its own transaction.
export const prune = internalMutation({
  args: {},
  handler: async (ctx) => {
    await pruneOldDrafts(ctx)
    await ctx.scheduler.runAfter(0, internal.digest.pruneCheckIn, {})
  },
})

export const pruneCheckIn = internalAction({
  args: {},
  handler: async () => {
    await checkIn('prune drafts', { schedule: { every: { hours: 1 } } })
  },
})
```

---

### reportingErrors()

```ts
function reportingErrors<Ctx, Args, Result>(handler, options?): (ctx, ...args) => Promise<Result>;
```

Defined in: [src/convex/integrations/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts)

**Experimental**

An action handler that reports what it throws ([reportError](#reporterror)), then
rethrows it: the caller still sees the failure.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-ctx">
        
      </a>
      
       <code>
        Ctx
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-args">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        unknown
      </code>
      
      <span>
        
      </span>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-result">
        
      </a>
      
       <code>
        Result
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        handler
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , ...<code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Result
      </code>
      
      >
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#reporterroroptions">
        <code>
          ReportErrorOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

(`ctx`, ...`args`) => `Promise`<`Result`>

#### Example

```ts [backend/imports.ts]
import { reportingErrors } from 'nuxt-backend/monitoring'

export const run = internalAction({
  args: { url: v.string() },
  handler: reportingErrors(async (ctx, { url }) => importFrom(url), { function: 'imports:run' }),
})
```

---

### checkingIn()

```ts
function checkingIn<Ctx, Args, Result>(
   job, 
   schedule, 
   handler
): (ctx, ...args) => Promise<Result>;
```

Defined in: [src/convex/integrations/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/monitoring.ts)

**Experimental**

An action handler that checks its job in each time it runs: `ok` with how
long the run took, or `error` (with the error reported, then rethrown)
when it throws. Wrap the action a cron of `backend/crons.ts` calls, and
pass the cron's schedule: the first check-in creates the monitor. A job
that never runs, or runs late, is the monitor's missed check-in.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-ctx-1">
        
      </a>
      
       <code>
        Ctx
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-args-1">
        
      </a>
      
       <code>
        Args
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        unknown
      </code>
      
      <span>
        
      </span>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-result-1">
        
      </a>
      
       <code>
        Result
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        job
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        schedule
      </code>
    </td>
    
    <td>
      <a href="#backendcronschedule">
        <code>
          BackendCronSchedule
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        handler
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , ...<code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Result
      </code>
      
      >
    </td>
  </tr>
</tbody>
</table>

#### Returns

(`ctx`, ...`args`) => `Promise`<`Result`>

#### Example

```ts [backend/digest.ts]
import { checkingIn } from 'nuxt-backend/monitoring'

export const send = internalAction({
  args: {},
  handler: checkingIn('send weekly digest', { cron: '15 8 * * 1' }, async (ctx) => {
    await deliverDigests(ctx)
  }),
})
```

---

### isReportable()

```ts
function isReportable(error): boolean;
```

Defined in: [src/convex/monitoring.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/monitoring.ts)

**Experimental**

Whether a failure is worth a report: a crash or an app's own error (no
catalog code), or a service that cannot serve the call (`unavailable`).
Every other catalog code is a refusal, the app working as designed:
nobody signed in, a role it lacks, an argument it refuses, credits that
ran out.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        error
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`boolean`


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
