# Save views and where you were

App Monitoring remembers your environment, time range and order per project, and saves issue searches as views you can share.

Replace _project-id_ with the project's id and _view-id_ with a view's id.

## Prerequisites

- `errors:ListIssues` on the project: to have your choices remembered, and to save, change or
  delete your own views.
- To share a view with the organization, or to change or delete a shared view (yours or someone
  else's): `errors:ManageSharedIssueViews` on the project. These changes are recorded in the
  audit log.

## Where you were

The **Environment** and **Time range** above the **Issues**, **Transactions** and **Releases** tabs,
and the issue list's order, are remembered for you and the project, with your account rather than
in the browser: they hold across tabs, after a reload, on your next visit and on another computer.
**Profiles** takes the remembered environment and keeps its own, shorter window.

- What you choose in the bar is remembered; what a link you open says is shown but not
  remembered, so a colleague's link does not change your own choice.
- The page's address always carries the environment and range, so a copied link shows the same
  list.
- **Reset** beside the bar forgets them: every environment, the last 14 days and the
  **Needs attention** order.
- On a phone the bar is one **Filters** button; its number counts the choices that differ from
  the defaults, and the order and the view are in it too.

**Console**
1. Open the project.
2. Choose an **Environment** and a **Time range** above the list.
3. To forget them, choose **Reset**.

**CLI**
```sh
dcloud errors views get-scope project-id
dcloud errors views set-scope project-id --environment production --range 7d
dcloud errors views reset-scope project-id
```

**API**
```http
PUT /errors/api/projects/project-id/scope
{ "environment": "production", "range": "7d" }
```

Fields you leave out keep their value; `null` forgets one. The answer is `200` with
`environment`, `range`, `sort` and `defaultViewId`.

## Save a view

A view is a name for a search and an order, and, if you choose, an environment and a time range.
Your views are yours alone; a shared view is listed for everyone who can see the project's issues.

**Console**
1. On the **Issues** tab, search and order the list the way you want it.
2. Open the views menu (it shows **Unresolved** until you choose a view) and choose
   **Save this list as a view…**.
3. Enter a **Name**. Leave **Open in** _environment_, _range_ on to save them with the view, or
   turn it off to keep whatever the bar shows.
4. (Optional) Choose **Share with the organization**.
5. Choose **Save view**.

To open a view, choose it in the views menu. To have the list open with it, open it and choose
**Open with** _view_ in the menu; **Open with Unresolved** goes back to the built-in list. To delete
it, open it and choose **Delete** _view_.

**CLI**
```sh
dcloud errors views create project-id --name "Production errors" --query "is:unresolved level:error" --sort attention --environment production --range 7d
dcloud errors views list project-id
dcloud errors issues list project-id --view view-id
```

**API**
```http
POST /errors/api/projects/project-id/views
{ "name": "Production errors", "query": "is:unresolved level:error", "sort": "attention",
  "environment": "production", "range": "7d", "shared": false }
```

The answer is `201` with the view. Pass its `id` as `view` to the issue list; what the request
names itself wins over the view.

`403` when `shared` is `true` without `errors:ManageSharedIssueViews`. `409` "At most 50 views per
person and project".

## Related

- [Find and triage issues](triage-issues.md)
- `errors.views.create` · `dcloud errors views list`
