# Issues

Exceptions your apps log, and errors sent by [Sentry SDKs](https://tailcove.dev/docs/sending-logs/sentry), are grouped into **issues**: one issue per kind of error, with a count, when it was first and last seen, and a stack trace. An issue is **open**, **resolved** or **ignored**.

## History after the lines expire

Raw log lines are kept for your plan's retention (7 days on Free, 14 on Pro, 30 on Business). An issue keeps more than
that. Every day it happens, Tailcove keeps how many times it happened and how many different users it hit, and it keeps
your [deploys](https://tailcove.dev/docs/deploy-checks) as long:

| Plan     | Lines kept | Issue history |
| -------- | ---------- | ------------- |
| Free     | 7 days     | 90 days       |
| Pro      | 14 days    | 365 days      |
| Business | 30 days    | 730 days      |

So on Monday you can still answer the two questions that matter: did this start after Friday's deploy, and how many
people hit it. On the issue's page, switch the **Occurrences** chart from **14 days** to the longer range. Each bar is a
day, each deploy is a thin line you can click to open its report, and the header says how many users were affected over
the range. Days whose lines have expired are shaded and the chart says how long your plan keeps lines, so an old stretch
doesn't look like "nothing happened". The 14-day view shades those hours too.

These counts are a few numbers per issue per day, so they don't count toward your data and the storage cost doesn't grow
with your traffic. The release and environment filters only narrow the 14-day view, because the history isn't split by
release.

### Users affected

A user is counted when the line names one: a top-level `user_id` in the context, or `user.id`. Errors from a
[Sentry SDK](https://tailcove.dev/docs/sending-logs/sentry) carry the event's `user.id` when **Keep the user id on events** is ticked in the source's Sentry settings. The id can be a
string or a whole number. We only keep a hash of it, never the id itself, and a user who hits the issue on three days
counts once over the range. When none of an issue's lines name a user, the chart says "users not known" rather than 0.

```json
{
    "message": "Payment failed",
    "context": {
        "user_id": "usr_482",
        "exception": { "class": "CardDeclined" }
    }
}
```

## From the stack trace to the code

Each frame of your own code on an issue's page has **View on GitHub** (or your host's name) and **Open in VS Code**: the first opens the file at that line in your repository, at the commit of the last deploy before the occurrence; the second opens it on your computer. Minified browser frames show the original file and the code around it once you upload source maps. Set it up under the source's **Settings, Code links**; see [Code links and source maps](https://tailcove.dev/docs/code-links).

## Working an issue

- **Resolve** it when it is fixed. If the error then happens again, the issue **reopens by itself** and your alerts for the source are told ("Issue regressed"). Only an occurrence _after_ you resolved it counts: a batch of older lines that reaches Tailcove late never reopens it.
- **Ignore** it when it is noise: forever, **for a day**, or **until it has happened N more times**. An ignored issue does not page anyone. A limited ignore ends by itself: the issue reopens the next time it happens after the day, or when its count reaches the number, and your alerts are told ("Issue is back").
- **Reopen** brings back a resolved or ignored issue by hand.
- **Assign** it to a team member who can open the source. The list filters by _Assigned to me_ and _Unassigned_.
- **Comment** on it. The activity list also records every status change, assignment, regression and incident, with who did it.
- **Select several** on the list to resolve, reopen, ignore or assign them to yourself at once.

## Open an incident for an issue

On a source's issue list, **Incident rule** opens an [incident](https://tailcove.dev/docs/incidents) when:

- an issue happens **N times within M minutes**, and/or
- a **new** issue (first seen in the last 15 minutes) has an occurrence at level critical, alert or emergency.

Only open issues count. A flood that goes on is one incident, not one a minute: the rule fires again for an issue only after its incident is closed and a whole window has passed. A new critical issue fires once. A run opens at most five incidents, so a bad deploy that creates a hundred issues pages a handful at a time. Choose an escalation policy to page through, or leave it to tell the whole team once.

## Likely cause: the commit that broke it

When an error first shows up right after a deploy, the question is which change did it. An issue's page answers that
under **Likely cause**:

1. It finds the deploy the error first appeared after (the source's latest deploy with a commit SHA, within 7 days
   before the first sighting) and the deploy before that one.
2. It asks GitHub what changed between the two.
3. A commit that changed the file the error was raised in is a suspect. One whose change covers the very line (give
   or take 3 lines) is listed first and marked.

When no commit in the deploy touched that file, the page lists the deploy's newest commits instead, with a link to
compare the two deploys on GitHub. When it can't say, it says what's missing, never a guess.

It needs three things: deploys recorded with their commit (`tailcove deploy`, or the
[deploys API](https://tailcove.dev/docs/api/deploys) from CI), the source's GitHub repository (below), and
[GitHub connected](https://tailcove.dev/docs/notifications/github) by you or by whoever set the repository. Minified browser errors are
placed through their [source maps](https://tailcove.dev/docs/code-links) first. The answer is kept for 6 hours per deploy pair, so the
page asks GitHub once.

## Create a Linear or Jira ticket

Teams that track work in Linear or Jira connect it once in **Settings, Issue trackers** (owners and admins):

- **Linear**: a personal API key and the team's key (`ENG`). Tickets open as that key's account.
- **Jira Cloud**: your `https://<name>.atlassian.net` address, an Atlassian account's email and API token, the project
  key and the issue type (`Task` by default). Jira Server and Data Center aren't supported.

The credentials are checked against Linear or Jira when you save them, stored encrypted, and never shown again.

Then every issue's page has **Create Linear issue** or **Create Jira issue** under **Tickets**. The ticket carries the
error, how often and since when it happens, where it was raised and a link back, as plain text with the title in
quotes so it can't mention anyone. An issue opens one ticket per tracker; the page links to it from then on.

## Create a GitHub issue

With [GitHub connected](https://tailcove.dev/docs/notifications/github), an issue's page lets you pick a repository and **Create GitHub issue**. The two stay linked: resolving here closes it on GitHub, and closing it on GitHub resolves it here. Without a connection, an alert on the source with its own **GitHub** channel (a repository and a token) is used instead, and nothing is linked. The GitHub issue carries the title, the counts and a link back; the title is written in code quotes so an exception message cannot mention a user. One GitHub issue is created per Tailcove issue.

## A repository for the source

On the source's **Issues** tab, **GitHub repository** sets the repository its issues open GitHub issues in;
each issue's page then offers it first. Switch on **Open a GitHub issue for every new issue** and a new
issue opens its linked GitHub issue by itself, shortly after it is first seen, written as opened
automatically by Tailcove. This needs [GitHub connected](https://tailcove.dev/docs/notifications/github). At most 10 are opened
this way per source per hour, so a release that breaks everything does not flood the repository; the rest
can still be created by hand. One that GitHub refuses is not retried.
