Metadata-Version: 2.4
Name: apx-sentry
Version: 0.1.0
Summary: Sentry for Action Platform: organization and team access, and read-only tools for a release's new issues and the errors after a deploy.
Author-email: Action Platform <cloud@actionplatform.io>
License-Expression: Apache-2.0
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: action-platform>=0.33
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: action-platform[mcp]; extra == "dev"
Dynamic: license-file

# apx-sentry

[Sentry](https://sentry.io) for [Action Platform](https://github.com/actionplatform/action-platform): the access provider the core's access engine drives, and two read-only tools over issues. `apx-` is the prefix every Action Platform extension carries.

```bash
action-platform plugin install sentry
export AP_SENTRY_ORG=… AP_SENTRY_TOKEN=…     # or Plugins → Sentry → Configure on the platform
action-platform sentry release-issues web web@1.4.0
action-platform sentry latest-errors web 2026-11-24T14:30:00Z
```

## Access

With `org` set, the core's access tools (`access_audit`, `access_who`, `access_sync`, `access_grant`, `access_revoke`, `access_offboard`) read and change Sentry next to the other services. Accounts are member emails.

| Resource | Levels, lowest first |
|---|---|
| `org` | `member`, `billing`, `admin`, `manager`, `owner` |
| `team/<slug>` | `contributor`, `admin` |

- A member's organization role comes from `orgRole`; a team member's role from `teamRole` (a team member without one is a `contributor`).
- Adding a member sends Sentry's invitation email; the member counts as granted while the invitation is pending.
- The last owner of the organization is never removed or demoted.
- Reads follow Sentry's `Link: rel="next"` paging through every page of members, teams and team members.
- Changes are dry runs until the core's tools are told to apply.

## Tools

Read-only. MCP tools are `sentry_<name>`; each is also `action-platform sentry <name>` with dashes. Both return, per issue: `id`, `short_id`, `title`, `culprit`, `level`, `status`, `count` (events), `users`, `first_seen`, `last_seen`, `permalink`, `project`.

| Tool | Does |
|---|---|
| `sentry_release_issues(project, release, period="30d", limit=25)` | Issues first seen in a release of a project, newest first (`firstRelease:"<release>"` on the organization's issues, sorted by first seen). `period` is how far back Sentry looks. |
| `sentry_latest_errors(project, since, limit=25)` | Unresolved issues of a project with events from `since` (ISO 8601, e.g. the deploy's time) until now, most recently seen first. |

`project` is the project's slug; `limit` is at most 100. A `since` with an offset is converted to UTC.

## Options

An organization fills them in under Plugins → Sentry → Configure; on a machine the tools read `AP_SENTRY_<KEY>` first, then the plugin's options file. Access reads the options only.

| Option | |
|---|---|
| `org` | Organization slug. Access is off while it is empty. |
| `token` | Secret. A personal or internal integration token. |
| `url` | Only for a self-hosted Sentry; empty means `https://sentry.io`. |

### Token scopes

| For | Scopes |
|---|---|
| Reading access | `member:read`, `team:read`, `org:read` |
| Changing access | `member:admin`, `team:write`, `org:read` |
| The issue tools | `project:read`, `event:read` |

## Develop

```bash
pip install -e ".[dev]"
ruff check . && ruff format --check . && pytest -q
```

Tests run without a network against `tests/fake.py`, which answers only the routes and fields Sentry's [API reference](https://docs.sentry.io/api/) documents. `tests/live/` reads a real Sentry and changes nothing:

```bash
AP_SENTRY_LIVE=1 AP_SENTRY_ORG=… AP_SENTRY_TOKEN=… AP_SENTRY_PROJECT=<slug> AP_SENTRY_RELEASE=<version> pytest tests/live
```
