apx-sentry 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- apx_sentry/__init__.py +5 -0
- apx_sentry/access.py +144 -0
- apx_sentry/cli.py +43 -0
- apx_sentry/observe.py +126 -0
- apx_sentry/plugin.py +69 -0
- apx_sentry/settings.py +41 -0
- apx_sentry/tools.py +44 -0
- apx_sentry-0.1.0.dist-info/METADATA +83 -0
- apx_sentry-0.1.0.dist-info/RECORD +13 -0
- apx_sentry-0.1.0.dist-info/WHEEL +5 -0
- apx_sentry-0.1.0.dist-info/entry_points.txt +2 -0
- apx_sentry-0.1.0.dist-info/licenses/LICENSE +201 -0
- apx_sentry-0.1.0.dist-info/top_level.txt +1 -0
apx_sentry/__init__.py
ADDED
apx_sentry/access.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""A Sentry organization: membership with its organization role, and team membership with its team role."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from action_platform.core.service_access import (
|
|
8
|
+
AccessError,
|
|
9
|
+
AccessProvider,
|
|
10
|
+
Grant,
|
|
11
|
+
Http,
|
|
12
|
+
Op,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SentryProvider(AccessProvider):
|
|
17
|
+
"""Accounts are member emails. An added member gets Sentry's invitation email and counts as granted while it is pending."""
|
|
18
|
+
|
|
19
|
+
name = "sentry"
|
|
20
|
+
levels = {
|
|
21
|
+
"org": ("member", "billing", "admin", "manager", "owner"),
|
|
22
|
+
"team": ("contributor", "admin"),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
org: str,
|
|
28
|
+
token: str,
|
|
29
|
+
url: str = "https://sentry.io",
|
|
30
|
+
http: Optional[Http] = None,
|
|
31
|
+
) -> None:
|
|
32
|
+
self.org = org
|
|
33
|
+
self.http = http or Http("sentry", url, {"authorization": f"Bearer {token}"})
|
|
34
|
+
self.ids: dict[str, str] = {}
|
|
35
|
+
|
|
36
|
+
def rank(self, grant: Grant) -> int:
|
|
37
|
+
if grant.resource == "org":
|
|
38
|
+
return {
|
|
39
|
+
"member": 0,
|
|
40
|
+
"billing": 0,
|
|
41
|
+
"admin": 1,
|
|
42
|
+
"manager": 2,
|
|
43
|
+
"owner": 3,
|
|
44
|
+
}.get(grant.level, -1)
|
|
45
|
+
|
|
46
|
+
return super().rank(grant)
|
|
47
|
+
|
|
48
|
+
def read(self) -> list[Grant]:
|
|
49
|
+
grants: list[Grant] = []
|
|
50
|
+
self.ids = {}
|
|
51
|
+
|
|
52
|
+
for m in self.http.pages(f"api/0/organizations/{self.org}/members/"):
|
|
53
|
+
email = (m.get("email") or "").lower()
|
|
54
|
+
|
|
55
|
+
if not email:
|
|
56
|
+
continue
|
|
57
|
+
|
|
58
|
+
self.ids[email] = str(m["id"])
|
|
59
|
+
grants.append(
|
|
60
|
+
Grant(
|
|
61
|
+
"sentry",
|
|
62
|
+
email,
|
|
63
|
+
"org",
|
|
64
|
+
m.get("orgRole") or m.get("role") or "member",
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
for team in self.http.pages(f"api/0/organizations/{self.org}/teams/"):
|
|
69
|
+
slug = team["slug"]
|
|
70
|
+
|
|
71
|
+
for m in self.http.pages(f"api/0/teams/{self.org}/{slug}/members/"):
|
|
72
|
+
email = (m.get("email") or "").lower()
|
|
73
|
+
|
|
74
|
+
if email:
|
|
75
|
+
level = m.get("teamRole") or "contributor"
|
|
76
|
+
grants.append(Grant("sentry", email, f"team/{slug}", level))
|
|
77
|
+
|
|
78
|
+
return self.strongest(grants)
|
|
79
|
+
|
|
80
|
+
def apply(self, op: Op) -> None:
|
|
81
|
+
g, base = op.grant, f"api/0/organizations/{self.org}/members"
|
|
82
|
+
kind, _, team = g.resource.partition("/")
|
|
83
|
+
|
|
84
|
+
if kind == "org" and op.action == "add":
|
|
85
|
+
created = self.http.call(
|
|
86
|
+
"POST",
|
|
87
|
+
f"{base}/",
|
|
88
|
+
{"email": g.account, "orgRole": g.level, "teamRoles": []},
|
|
89
|
+
)
|
|
90
|
+
self.ids[g.account.lower()] = str((created or {}).get("id", ""))
|
|
91
|
+
return
|
|
92
|
+
|
|
93
|
+
member = self._id(g.account)
|
|
94
|
+
|
|
95
|
+
if kind == "org" and op.action == "change":
|
|
96
|
+
self.http.call("PUT", f"{base}/{member}/", {"orgRole": g.level})
|
|
97
|
+
elif kind == "org":
|
|
98
|
+
self.http.call("DELETE", f"{base}/{member}/")
|
|
99
|
+
elif kind == "team" and op.action == "remove":
|
|
100
|
+
self.http.call("DELETE", f"{base}/{member}/teams/{team}/")
|
|
101
|
+
elif kind == "team":
|
|
102
|
+
if op.action == "add":
|
|
103
|
+
self.http.call("POST", f"{base}/{member}/teams/{team}/")
|
|
104
|
+
|
|
105
|
+
if op.action == "change" or g.level != "contributor":
|
|
106
|
+
self.http.call(
|
|
107
|
+
"PUT", f"{base}/{member}/teams/{team}/", {"teamRole": g.level}
|
|
108
|
+
)
|
|
109
|
+
else:
|
|
110
|
+
raise AccessError(f"sentry: cannot apply {g.resource}")
|
|
111
|
+
|
|
112
|
+
def guard(self, ops: list[Op], live: list[Grant]) -> dict[Op, str]:
|
|
113
|
+
owners = {
|
|
114
|
+
g.account.lower()
|
|
115
|
+
for g in live
|
|
116
|
+
if g.resource == "org" and g.level == "owner"
|
|
117
|
+
}
|
|
118
|
+
losing = {
|
|
119
|
+
op.grant.account.lower()
|
|
120
|
+
for op in ops
|
|
121
|
+
if op.grant.resource == "org"
|
|
122
|
+
and op.grant.account.lower() in owners
|
|
123
|
+
and (op.action == "remove" or op.grant.level != "owner")
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if owners and losing >= owners:
|
|
127
|
+
return {
|
|
128
|
+
op: f"sentry: {op.grant.account} is the last owner of {self.org}"
|
|
129
|
+
for op in ops
|
|
130
|
+
if op.grant.resource == "org" and op.grant.account.lower() in losing
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {}
|
|
134
|
+
|
|
135
|
+
def _id(self, email: str) -> str:
|
|
136
|
+
if email.lower() not in self.ids:
|
|
137
|
+
self.read()
|
|
138
|
+
|
|
139
|
+
found = self.ids.get(email.lower())
|
|
140
|
+
|
|
141
|
+
if not found:
|
|
142
|
+
raise AccessError(f"sentry: {email} is not a member of {self.org}")
|
|
143
|
+
|
|
144
|
+
return found
|
apx_sentry/cli.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""`action-platform sentry …` — the same reads as the tools, from a terminal."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from apx_sentry.observe import Issue
|
|
10
|
+
from apx_sentry.settings import connect
|
|
11
|
+
|
|
12
|
+
app = typer.Typer(
|
|
13
|
+
help="Sentry: issues of a release, errors since a moment.", no_args_is_help=True
|
|
14
|
+
)
|
|
15
|
+
options: Any | None = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def show(issues: list[Issue]) -> None:
|
|
19
|
+
for i in issues:
|
|
20
|
+
typer.echo(
|
|
21
|
+
f"{i.short_id}\t{i.count} events\t{i.users} users\t{i.last_seen}\t{i.title}\t{i.culprit or '-'}\t{i.permalink or '-'}"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@app.command("release-issues")
|
|
26
|
+
def release_issues(
|
|
27
|
+
project: str,
|
|
28
|
+
release: str,
|
|
29
|
+
period: str = typer.Option("30d", help="How far back to look"),
|
|
30
|
+
limit: int = typer.Option(25),
|
|
31
|
+
) -> None:
|
|
32
|
+
"""Issues first seen in a release of a project."""
|
|
33
|
+
show(connect(options).release_issues(project, release, period, limit))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@app.command("latest-errors")
|
|
37
|
+
def latest_errors(
|
|
38
|
+
project: str,
|
|
39
|
+
since: str = typer.Argument(..., help="ISO 8601 time, e.g. 2026-11-24T14:30:00Z"),
|
|
40
|
+
limit: int = typer.Option(25),
|
|
41
|
+
) -> None:
|
|
42
|
+
"""Unresolved issues of a project with events since a moment."""
|
|
43
|
+
show(connect(options).latest_errors(project, since, limit))
|
apx_sentry/observe.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""Read-only looks at a Sentry organization's issues: what a release introduced and what broke since a moment."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
from typing import Any, Optional
|
|
7
|
+
|
|
8
|
+
from action_platform.core.exception import ActionPlatformError
|
|
9
|
+
from action_platform.core.service_access import Http
|
|
10
|
+
from pydantic import BaseModel
|
|
11
|
+
|
|
12
|
+
MAX = 100
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Issue(BaseModel):
|
|
16
|
+
id: str
|
|
17
|
+
short_id: str
|
|
18
|
+
title: str
|
|
19
|
+
culprit: Optional[str] = None
|
|
20
|
+
level: Optional[str] = None
|
|
21
|
+
status: Optional[str] = None
|
|
22
|
+
count: int
|
|
23
|
+
users: int
|
|
24
|
+
first_seen: Optional[str] = None
|
|
25
|
+
last_seen: Optional[str] = None
|
|
26
|
+
permalink: Optional[str] = None
|
|
27
|
+
project: str
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Sentry:
|
|
31
|
+
def __init__(self, org: str, http: Http) -> None:
|
|
32
|
+
self.org = org
|
|
33
|
+
self.http = http
|
|
34
|
+
|
|
35
|
+
def project_id(self, project: str) -> str:
|
|
36
|
+
found = self.http.call("GET", f"api/0/projects/{self.org}/{project}/")
|
|
37
|
+
|
|
38
|
+
if not isinstance(found, dict) or not found.get("id"):
|
|
39
|
+
raise ActionPlatformError(f"sentry: no project {project!r} in {self.org}")
|
|
40
|
+
|
|
41
|
+
return str(found["id"])
|
|
42
|
+
|
|
43
|
+
def release_issues(
|
|
44
|
+
self, project: str, release: str, period: str = "30d", limit: int = 25
|
|
45
|
+
) -> list[Issue]:
|
|
46
|
+
"""Issues whose first event came in `release`, newest first."""
|
|
47
|
+
return self._issues(
|
|
48
|
+
{
|
|
49
|
+
"project": self.project_id(project),
|
|
50
|
+
"query": f"firstRelease:{_quote(release)}",
|
|
51
|
+
"statsPeriod": period,
|
|
52
|
+
"sort": "new",
|
|
53
|
+
"limit": _limit(limit),
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
def latest_errors(
|
|
58
|
+
self, project: str, since: str, limit: int = 25, until: Optional[str] = None
|
|
59
|
+
) -> list[Issue]:
|
|
60
|
+
"""Unresolved issues with events between `since` and `until` (now), the most recently seen first."""
|
|
61
|
+
start = _moment(since)
|
|
62
|
+
end = _moment(until) if until else _now()
|
|
63
|
+
|
|
64
|
+
return self._issues(
|
|
65
|
+
{
|
|
66
|
+
"project": self.project_id(project),
|
|
67
|
+
"query": "is:unresolved",
|
|
68
|
+
"start": start,
|
|
69
|
+
"end": end,
|
|
70
|
+
"sort": "date",
|
|
71
|
+
"limit": _limit(limit),
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def _issues(self, query: dict[str, Any]) -> list[Issue]:
|
|
76
|
+
rows = self.http.call(
|
|
77
|
+
"GET", f"api/0/organizations/{self.org}/issues/", query=query
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
if not isinstance(rows, list):
|
|
81
|
+
raise ActionPlatformError("sentry: the issues listing is not a list")
|
|
82
|
+
|
|
83
|
+
return [_issue(r) for r in rows]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _issue(row: dict[str, Any]) -> Issue:
|
|
87
|
+
return Issue(
|
|
88
|
+
id=str(row["id"]),
|
|
89
|
+
short_id=str(row.get("shortId") or row["id"]),
|
|
90
|
+
title=row.get("title") or "",
|
|
91
|
+
culprit=row.get("culprit"),
|
|
92
|
+
level=row.get("level"),
|
|
93
|
+
status=row.get("status"),
|
|
94
|
+
count=int(row.get("count") or 0),
|
|
95
|
+
users=int(row.get("userCount") or 0),
|
|
96
|
+
first_seen=row.get("firstSeen"),
|
|
97
|
+
last_seen=row.get("lastSeen"),
|
|
98
|
+
permalink=row.get("permalink"),
|
|
99
|
+
project=(row.get("project") or {}).get("slug", ""),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _quote(value: str) -> str:
|
|
104
|
+
return '"' + value.replace("\\", "\\\\").replace('"', '\\"') + '"'
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _limit(limit: int) -> int:
|
|
108
|
+
return max(1, min(limit, MAX))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _now() -> str:
|
|
112
|
+
return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _moment(value: str) -> str:
|
|
116
|
+
try:
|
|
117
|
+
parsed = datetime.fromisoformat(value.strip())
|
|
118
|
+
except ValueError as e:
|
|
119
|
+
raise ActionPlatformError(
|
|
120
|
+
f"sentry: {value!r} is not an ISO 8601 time, e.g. 2026-11-24T14:30:00Z"
|
|
121
|
+
) from e
|
|
122
|
+
|
|
123
|
+
if parsed.tzinfo is not None:
|
|
124
|
+
parsed = parsed.astimezone(timezone.utc)
|
|
125
|
+
|
|
126
|
+
return parsed.strftime("%Y-%m-%dT%H:%M:%S")
|
apx_sentry/plugin.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""The plugin: access on a Sentry organization, `sentry_*` tools and `action-platform sentry` commands."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from action_platform.abc import Option, Plugin, Surface
|
|
8
|
+
from action_platform.core.service_access import AccessError, AccessProvider
|
|
9
|
+
|
|
10
|
+
from apx_sentry import cli
|
|
11
|
+
from apx_sentry.access import SentryProvider
|
|
12
|
+
from apx_sentry.settings import URL
|
|
13
|
+
from apx_sentry.tools import register_tools
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SentryPlugin(Plugin):
|
|
17
|
+
slug = "sentry"
|
|
18
|
+
name = "Sentry"
|
|
19
|
+
description = (
|
|
20
|
+
"Manage who belongs to a Sentry organization and its teams; "
|
|
21
|
+
"read a release's new issues and the errors after a deploy"
|
|
22
|
+
)
|
|
23
|
+
min_core = "0.33"
|
|
24
|
+
needs = [
|
|
25
|
+
"env: AP_SENTRY_ORG, AP_SENTRY_TOKEN, AP_SENTRY_URL on a machine (the plugin's options on the platform)",
|
|
26
|
+
"net: sentry.io, or the self-hosted Sentry's url",
|
|
27
|
+
]
|
|
28
|
+
options = [
|
|
29
|
+
Option(
|
|
30
|
+
"org",
|
|
31
|
+
"Organization slug",
|
|
32
|
+
"text",
|
|
33
|
+
help="The organization's slug in Sentry, as in sentry.io/organizations/<slug>/. Access is off while it is empty.",
|
|
34
|
+
),
|
|
35
|
+
Option(
|
|
36
|
+
"token",
|
|
37
|
+
"Token",
|
|
38
|
+
"secret",
|
|
39
|
+
help="A personal or internal integration token. To read access: member:read, team:read, org:read. To change it: member:admin, team:write, org:read. For the issue tools: project:read, event:read.",
|
|
40
|
+
required=True,
|
|
41
|
+
),
|
|
42
|
+
Option(
|
|
43
|
+
"url",
|
|
44
|
+
"Sentry URL",
|
|
45
|
+
"url",
|
|
46
|
+
help=f"Only for a self-hosted Sentry. Empty means {URL}.",
|
|
47
|
+
),
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
def register(self, surface: Surface) -> None:
|
|
51
|
+
if surface.mcp is not None:
|
|
52
|
+
register_tools(surface.mcp, surface.options)
|
|
53
|
+
|
|
54
|
+
if surface.cli is not None:
|
|
55
|
+
cli.options = surface.options
|
|
56
|
+
surface.cli.add_typer(cli.app, name="sentry")
|
|
57
|
+
|
|
58
|
+
def access(self, options: Any) -> Optional[AccessProvider]:
|
|
59
|
+
org = options.get("org")
|
|
60
|
+
|
|
61
|
+
if not org:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
token = options.get("token")
|
|
65
|
+
|
|
66
|
+
if not token:
|
|
67
|
+
raise AccessError("sentry: set the plugin's token option to read access")
|
|
68
|
+
|
|
69
|
+
return SentryProvider(str(org), str(token), options.get("url") or URL)
|
apx_sentry/settings.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Where a setting comes from, in order: the process environment (`AP_SENTRY_<KEY>`), then the plugin's options on this machine."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import Any, Optional
|
|
7
|
+
|
|
8
|
+
from action_platform.core.service_access import AccessError, Http
|
|
9
|
+
from action_platform.plugins.options import FileOptions
|
|
10
|
+
|
|
11
|
+
from apx_sentry.observe import Sentry
|
|
12
|
+
|
|
13
|
+
SLUG = "sentry"
|
|
14
|
+
URL = "https://sentry.io"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def setting(key: str, options: Any = None) -> Optional[str]:
|
|
18
|
+
found = os.environ.get(f"AP_{SLUG}_{key}".upper())
|
|
19
|
+
|
|
20
|
+
if not found:
|
|
21
|
+
found = (options or FileOptions(SLUG)).get(key)
|
|
22
|
+
|
|
23
|
+
return str(found) if found else None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def credentials(options: Any = None) -> tuple[str, str, str]:
|
|
27
|
+
"""The organization slug, the token and the base url, or an `AccessError` naming what is missing."""
|
|
28
|
+
org, token = setting("org", options), setting("token", options)
|
|
29
|
+
missing = [k for k, v in (("org", org), ("token", token)) if not v]
|
|
30
|
+
|
|
31
|
+
if missing:
|
|
32
|
+
names = ", ".join(f"AP_SENTRY_{k.upper()}" for k in missing)
|
|
33
|
+
raise AccessError(f"sentry: set {names} (or the plugin's options)")
|
|
34
|
+
|
|
35
|
+
return str(org), str(token), setting("url", options) or URL
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def connect(options: Any = None) -> Sentry:
|
|
39
|
+
org, token, url = credentials(options)
|
|
40
|
+
|
|
41
|
+
return Sentry(org, Http("sentry", url, {"authorization": f"Bearer {token}"}))
|
apx_sentry/tools.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""`sentry_*` MCP tools: read-only looks at issues. Access is changed through the core's `access_*` tools."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Any
|
|
6
|
+
|
|
7
|
+
from action_platform.mcp.annotations import READ_ONLY
|
|
8
|
+
from pydantic import Field
|
|
9
|
+
|
|
10
|
+
from apx_sentry.observe import Issue
|
|
11
|
+
from apx_sentry.settings import connect
|
|
12
|
+
|
|
13
|
+
Project = Annotated[str, Field(description="The project's slug in Sentry")]
|
|
14
|
+
Limit = Annotated[int, Field(description="How many issues, at most 100")]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def register_tools(mcp: Any, options: Any) -> None:
|
|
18
|
+
@mcp.tool(annotations=READ_ONLY)
|
|
19
|
+
def release_issues(
|
|
20
|
+
project: Project,
|
|
21
|
+
release: Annotated[
|
|
22
|
+
str, Field(description="The release version as Sentry has it")
|
|
23
|
+
],
|
|
24
|
+
period: Annotated[
|
|
25
|
+
str, Field(description="How far back to look, as 14d, 30d or 90d")
|
|
26
|
+
] = "30d",
|
|
27
|
+
limit: Limit = 25,
|
|
28
|
+
) -> list[Issue]:
|
|
29
|
+
"""Issues first seen in a release of a project, newest first, each with its title, culprit, event and user counts, first and last seen, and link."""
|
|
30
|
+
return connect(options).release_issues(project, release, period, limit)
|
|
31
|
+
|
|
32
|
+
@mcp.tool(annotations=READ_ONLY)
|
|
33
|
+
def latest_errors(
|
|
34
|
+
project: Project,
|
|
35
|
+
since: Annotated[
|
|
36
|
+
str,
|
|
37
|
+
Field(
|
|
38
|
+
description="ISO 8601 time to look from, such as the deploy's: 2026-11-24T14:30:00Z"
|
|
39
|
+
),
|
|
40
|
+
],
|
|
41
|
+
limit: Limit = 25,
|
|
42
|
+
) -> list[Issue]:
|
|
43
|
+
"""Unresolved issues of a project with events since a moment, the most recently seen first — what broke after a deploy."""
|
|
44
|
+
return connect(options).latest_errors(project, since, limit)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apx-sentry
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
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.
|
|
5
|
+
Author-email: Action Platform <cloud@actionplatform.io>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: action-platform>=0.33
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
13
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
14
|
+
Requires-Dist: action-platform[mcp]; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# apx-sentry
|
|
18
|
+
|
|
19
|
+
[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.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
action-platform plugin install sentry
|
|
23
|
+
export AP_SENTRY_ORG=… AP_SENTRY_TOKEN=… # or Plugins → Sentry → Configure on the platform
|
|
24
|
+
action-platform sentry release-issues web web@1.4.0
|
|
25
|
+
action-platform sentry latest-errors web 2026-11-24T14:30:00Z
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Access
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
| Resource | Levels, lowest first |
|
|
33
|
+
|---|---|
|
|
34
|
+
| `org` | `member`, `billing`, `admin`, `manager`, `owner` |
|
|
35
|
+
| `team/<slug>` | `contributor`, `admin` |
|
|
36
|
+
|
|
37
|
+
- A member's organization role comes from `orgRole`; a team member's role from `teamRole` (a team member without one is a `contributor`).
|
|
38
|
+
- Adding a member sends Sentry's invitation email; the member counts as granted while the invitation is pending.
|
|
39
|
+
- The last owner of the organization is never removed or demoted.
|
|
40
|
+
- Reads follow Sentry's `Link: rel="next"` paging through every page of members, teams and team members.
|
|
41
|
+
- Changes are dry runs until the core's tools are told to apply.
|
|
42
|
+
|
|
43
|
+
## Tools
|
|
44
|
+
|
|
45
|
+
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`.
|
|
46
|
+
|
|
47
|
+
| Tool | Does |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `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. |
|
|
50
|
+
| `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. |
|
|
51
|
+
|
|
52
|
+
`project` is the project's slug; `limit` is at most 100. A `since` with an offset is converted to UTC.
|
|
53
|
+
|
|
54
|
+
## Options
|
|
55
|
+
|
|
56
|
+
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.
|
|
57
|
+
|
|
58
|
+
| Option | |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `org` | Organization slug. Access is off while it is empty. |
|
|
61
|
+
| `token` | Secret. A personal or internal integration token. |
|
|
62
|
+
| `url` | Only for a self-hosted Sentry; empty means `https://sentry.io`. |
|
|
63
|
+
|
|
64
|
+
### Token scopes
|
|
65
|
+
|
|
66
|
+
| For | Scopes |
|
|
67
|
+
|---|---|
|
|
68
|
+
| Reading access | `member:read`, `team:read`, `org:read` |
|
|
69
|
+
| Changing access | `member:admin`, `team:write`, `org:read` |
|
|
70
|
+
| The issue tools | `project:read`, `event:read` |
|
|
71
|
+
|
|
72
|
+
## Develop
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install -e ".[dev]"
|
|
76
|
+
ruff check . && ruff format --check . && pytest -q
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
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:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
AP_SENTRY_LIVE=1 AP_SENTRY_ORG=… AP_SENTRY_TOKEN=… AP_SENTRY_PROJECT=<slug> AP_SENTRY_RELEASE=<version> pytest tests/live
|
|
83
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
apx_sentry/__init__.py,sha256=cH4_541b7Vh-7kKr3j6T9vxadA3AQRh9gHOhhKEbAPY,180
|
|
2
|
+
apx_sentry/access.py,sha256=taCPUZgCPqBr-9dXpCkXXnQwjBR7p9vG32fluocMDjE,4564
|
|
3
|
+
apx_sentry/cli.py,sha256=USZAqLFGw4Ch8b5o816-6NAcgjfM75M7yTq1feBEGlI,1262
|
|
4
|
+
apx_sentry/observe.py,sha256=gLpdWGpNfBLyvPPp_1nGOwM5xR06oaK9WmStubG4y3Q,3797
|
|
5
|
+
apx_sentry/plugin.py,sha256=NXLSQ2Rh_D6llc0Yaf9k2W4YqyhiAfYqXzMY7uCSkSI,2300
|
|
6
|
+
apx_sentry/settings.py,sha256=mc8Dt4xxFa9uALwZocMh6HAx816Afbv9tmuzkYF9UDQ,1360
|
|
7
|
+
apx_sentry/tools.py,sha256=LGX1XydgY46l3dM_HkwEc9KMrh6mivWD03vqcJJnJiI,1685
|
|
8
|
+
apx_sentry-0.1.0.dist-info/licenses/LICENSE,sha256=WcDWtpGI54c3iNg7UddKYdRlt9oUzbMjUzdgKqsE8SI,11263
|
|
9
|
+
apx_sentry-0.1.0.dist-info/METADATA,sha256=kBG0AOU_M5FH4C-sVCH5OUGGGEIC3tQS1C0iJ1-0WKI,3925
|
|
10
|
+
apx_sentry-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
11
|
+
apx_sentry-0.1.0.dist-info/entry_points.txt,sha256=yLoJR54hIdGuPPWPsZiLhNvQI-p0seJGQoGN-0fcoIU,59
|
|
12
|
+
apx_sentry-0.1.0.dist-info/top_level.txt,sha256=A10lAkwMgmhXax2Gqij7-SSFoUdldj_bsduNdARwMU8,11
|
|
13
|
+
apx_sentry-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may accept a fee in exchange for,
|
|
167
|
+
acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf
|
|
170
|
+
and on Your sole responsibility, not on behalf of any other
|
|
171
|
+
Contributor, and only if You agree to indemnify, defend, and hold
|
|
172
|
+
each Contributor harmless for any liability incurred by, or claims
|
|
173
|
+
asserted against, such Contributor by reason of your accepting any
|
|
174
|
+
such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same page as the copyright notice for easier identification within
|
|
187
|
+
the file itself.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Fernando Celmer
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
apx_sentry
|