---
url: https://rustrak.dev/usage/alerts/
---

# Alerts

An alert tells your team when something happens in a project: a new issue, a regression, a user's feedback. It has two parts:

- **Channels** say where to send: Slack, email, a webhook or a custom webhook. They are shared by every project and live in **Settings → Integrations**.
- **Alerts** say when to send and to which channels. Each project has its own, under **Alerts** in its sidebar.

## Add a channel

Go to **Settings → Integrations**, pick a provider and fill in its form. Each channel's **⋯** menu has **Test**, which sends a sample alert, so you can check it before any alert uses it.

### Slack

Two ways to connect:

- **Incoming webhook**: create one in Slack ([Incoming Webhooks](https://api.slack.com/messaging/webhooks)) and paste its `https://hooks.slack.com/...` URL. Messages go to the channel the webhook was made for.
- **Bot token**: paste a token starting with `xoxb-`. Each alert then names the Slack channel to post in (`#alerts` or an ID like `C1234567890`), so one bot serves many channels.

### Email

Give the SMTP host, port, username, password and sender address. Port `465` uses TLS from the start; any other port uses STARTTLS. Recipients are chosen on each alert, not on the channel. For Gmail, use an [app password](https://support.google.com/accounts/answer/185833).

The server can also take SMTP defaults from the environment: `SMTP_HOST`, `SMTP_PORT` (default `587`), `SMTP_USERNAME`, `SMTP_PASSWORD` and `SMTP_FROM`.

### Webhook

Rustrak POSTs a JSON payload to your URL. The URL is optional on the channel: leave it blank and each alert supplies its own. Add a secret to sign requests.

```json
{
  "alert_id": "1-550e8400-1706140800000",
  "alert_type": "new_issue",
  "triggered_at": "2026-01-25T12:00:00.000Z",
  "project": { "id": 1, "name": "Storefront", "slug": "storefront" },
  "issue": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "short_id": "STOREFRONT-42",
    "title": "TypeError: Cannot read properties of undefined (reading 'price')",
    "level": "error",
    "first_seen": "2026-01-25T11:55:00Z",
    "last_seen": "2026-01-25T12:00:00Z",
    "event_count": 5
  },
  "issue_url": "https://rustrak.example.com/projects/1/issues/550e8400-e29b-41d4-a716-446655440000",
  "actor": "Rustrak"
}
```

`alert_type` is `new_issue`, `regression` or `new_feedback`. `issue.level` can be absent.

Every request carries these headers:

| Header | Value |
|---|---|
| `Content-Type` | `application/json` |
| `X-Rustrak-Timestamp` | Unix time in seconds |
| `X-Rustrak-Request-ID` | The `alert_id` |
| `X-Rustrak-Signature` | `sha256=<hex>`, only when the channel has a secret |

The signature is an HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the secret. Verify it against the body exactly as received:

```javascript
const crypto = require('crypto');

function verify(rawBody, timestamp, signature, secret) {
  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(`${timestamp}.${rawBody}`)
    .digest('hex');
  return signature.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}
```

Reject requests whose timestamp is too old. That bounds how long a captured request stays usable but does not stop a repeat inside the window, so also skip any `X-Rustrak-Request-ID` you have already processed on that endpoint. Every rule and channel that reports the same event sends the same ID, so keep a separate record per channel.

### Custom webhook

POSTs a JSON body you write yourself, for an endpoint that expects its own shape: a chat bot, a ticketing system. Write the body under **Message body**: **Start from** loads a known shape (Slack-compatible, Mattermost, Discord, Teams, WeCom, DingTalk, Feishu), **Insert field** adds an alert value at the cursor, and the preview below shows what will be sent.

```json
{
  "text": "Rustrak: {{ issue.title }} ({{ issue.short_id }})\n{{ issue_url }}"
}
```

Values are escaped for wherever you put them, and the body must render to valid JSON, which is checked when you save. The fields, rules and examples are on [Message body template](https://rustrak.dev/usage/alerts/message-body-template/). It signs requests the same way as the webhook.

A delivery counts as sent when the endpoint answers 2xx with a readable body; the body is never read for meaning. A 2xx whose body is over 64 KiB, cut off or not UTF-8 counts as failed. Some services answer `200` while refusing the message, so press **Test** after setting one up: it shows exactly what the endpoint answered. A WeCom or DingTalk bot with a custom keyword refuses any message without that keyword, so put the keyword in the body's fixed text.

### Mattermost

Mattermost takes alerts through a custom webhook:

1. In Mattermost, open **Integrations → Incoming Webhooks → Add Incoming Webhook**, choose the channel and copy the URL.
2. In Rustrak, add a **Custom webhook** with that URL and **Start from** *Mattermost*, then save it.
3. Press **Test** in its **⋯** menu and check the message arrives.

To post somewhere other than the webhook's channel, add `"channel": "town-square"` (the channel's name, not its display name) to the body. This only works when the webhook is not locked to its channel, and only for public channels or private ones the webhook's creator belongs to. Mattermost also honours `"username"` and `"icon_url"` when its admin allows integrations to override them. Mattermost does not render Slack Block Kit, so a body copied from a Slack app needs `text` or `attachments` instead.

A Mattermost server on your own network is a private address, which alerts refuse by default: set [`RUSTRAK_ALERTS_ALLOW_PRIVATE_NETWORKS=on`](https://rustrak.dev/configuration/environment/).

### Extra headers

Webhook and custom webhook channels can send extra headers, such as an `Authorization` your endpoint asks for. Up to 20; each name once, whatever its case. `Content-Type`, `Content-Length`, `Host`, `Transfer-Encoding` and anything starting with `X-Rustrak-` are reserved.

## Create an alert

Open a project, go to **Alerts** and click **New alert**:

| Field | What it does |
|---|---|
| **When** | **New issue**, **Regression** (a resolved issue comes back) or **New feedback** |
| **Environments** | Only events from these. **All** by default |
| **Level** | Only events at this level or higher. An event with no level counts as `error` |
| **After this many events** | New issues only: wait until the issue has this many events, then alert once |
| **Notify** | One or more channels. Email asks for recipients, a Slack bot for a channel, and a webhook can take its own URL here |
| **At most** | How often this alert can notify about the same issue: every time, every 5 minutes, once an hour, once a day, or any number of minutes |

The summary on the right reads the alert back in a sentence before you save. **Send a test** sends a sample through the chosen channels.

After this many events: `10` together with **production** keeps a one-off error on someone's laptop from paging anyone.

## Manage alerts

Each alert has its own page with what it does in one sentence, an **Active** switch to pause it without deleting it, **Edit** and **Delete**. The **Deliveries** tab lists every alert sent, with the reason when one failed or was skipped.
