Repository navigation
feat(events)!: Let event automations run for any resource - #2407
sentry-junior[bot] wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
An event automation trigger can now leave out the identifier and the resource type. It then runs for every resource of its namespace that its filters match, such as any Sentry metric alert for one project. Each plugin declares in `anyResourceEvents` which events can run this way, and the filter an event needs. GitHub issue, pull request, and release events need `repo`. Linear issues need `teamKey`. Sentry and Vercel events and GitHub deployments need no filter. Slack channel messages keep their identifier. - Match `identifier = event.identifier or identifier is null` and load lazy filters for rows with no identifier. - Count each event key once in the run limit, so many copies of one event do not block the automation. - Give guidance by namespace and event, and reject plugins whose resource types disagree. - Run the shared trigger check for the dashboard list instead of a SQL copy. - Allow a null identifier for event rows. Refs #2362 Co-Authored-By: David Cramer <david@sentry.io>
Sentry Evalsjunior-behavioral
Base commit junior-guardian
Base commit junior-integration
Base commit |
34c5056 to
2a7aca0
Compare
|
What's the co figuration look like now? Like field name = value. What are the fields for a few scenarios? |
|
A trigger is now Any new PR in one repo, opened by someone with write access { "namespace": "github", "events": ["pull_request.opened"],
"match": { "repo": "getsentry/junior", "openerRole": ["admin", "maintain", "write"] } }
Any PR I co-authored, in two repos, not drafts { "namespace": "github", "events": ["pull_request.opened", "pull_request.ready_for_review"],
"match": { "repo": ["getsentry/junior", "getsentry/junior-prod"], "authors": "dcramer", "isDraft": false } }Any failed GitHub deployment to production, in any repo (no filter required) { "namespace": "github", "events": ["deployment.failed", "deployment.error"],
"match": { "environment": "production" } }Any critical Sentry metric alert that covers the javascript project (no filter required; one install is one org) { "namespace": "sentry", "events": ["metric_alert.critical"],
"match": { "projects": "javascript" } }Any new high-priority Sentry issue in two projects { "namespace": "sentry", "events": ["issue.created"],
"match": { "projects": ["junior", "sentry"], "priority": "high" } }Any new Linear issue in one team ( { "namespace": "linear", "events": ["issue.created"], "match": { "teamKey": "ENG" } }Any production Vercel deploy of one project (no filter required) { "namespace": "vercel", "events": ["deployment.succeeded", "deployment.error"],
"match": { "projectId": "prj_abc123", "target": "production" } }Still exact-resource (unchanged): one PR, or a Slack channel, which always needs its identifier: { "namespace": "github", "resourceType": "pull_request", "identifier": "getsentry/junior#2407",
"events": ["pull_request.merged"] }Filter fields per namespace:
Every selected event must set each filter field. For example, |
Each plugin now declares every event type once in `events`, with its
reach ("all", { anyOf: [filters] }, or "resource") and optional
guidance. Registration fails when an event has no declaration. This
replaces `anyResourceEvents`, where `{}` meant "run for every resource",
and per-resource-type `guidance`.
- Pass known event data (repo) to neededMatchKeys, so a broad trigger
for one repo loads no lazy PR data for other repos.
- Runtime gate: identifier column and trigger must agree, bad rows are
logged and skipped, and rejected rows log a warning.
- updateEventAutomation keeps the saved identifier and resource type
when they are left out; only an explicit null removes them.
- Match fields declare `case`, and core saves filter values in it.
- The catalog, searchEventTypes, and the dashboard API give reach once
per namespace, and filters are merged once per catalog build.
- Docs say that a required filter is not access control.
Refs #2362
Co-Authored-By: David Cramer <david@sentry.io>
|
9 screenshot changes — 7 changed · 2 added · 0 removed Review screenshots in Frameshift |
Check the namespace reach of the event catalog with a shorter assertion, so the file-length check passes.
Slice B of item 7 in #2362 (event-first triggers). Refs #2362.
An event automation trigger can now leave out
identifierandresourceType. It then runs for every resource of its namespace that its filters match. Two examples: "any Sentrymetric_alert.criticalwhereprojectsincludes javascript", and "anypull_request.openedwhererepois getsentry/junior". Saved triggers that have an identifier work as before. Watches do not change. This PR does not convert saved rows (slice C) or drop the column (slice D).Event reach
Each source now declares every event type once, in
events, with its Event reach (defined inTERMINOLOGY.md) and optional guidance:"all": a trigger with no identifier can run for every resource, with no filter.{ anyOf }: a trigger with no identifier must set at least one of these filters."resource": the trigger needs an identifier.Registration fails when an event type has no declaration, or when an
anyOffilter is not set on that event. Writing less now grants less. The name still fits after slice D removes identifiers.deployment.*all. Status facts only, no reaction, no lookups.release.published,issue.*,pull_request.*{ anyOf: ["repo"] }. Text from repos that can be private; comments and reviews add a reaction.issue.created,metric_alert.*all. One install is one org.deployment.*all. Status facts only.issue.created{ anyOf: ["teamKey", "issueIdentifier"] }.message.postedresource.workspace_snapshot.*,timer.firedresource.How it stays safe and correct
neededMatchKeystakes the eventdatathe plugin already knows. GitHub passesrepofor pull request and check suite webhooks. Core skips a row with no identifier whose filters on that data fail, so a trigger for one repo loads no PR facts for other repos.identifier = event.identifier or identifier is null, and event type (record->'trigger'->'events' @> [type]). In JS, a saved identifier must equal the row column, and a row with no identifier must have a trigger that the current catalog accepts. Rows that do not parse are logged and skipped (safeParse), so one bad row cannot break ingest for a namespace. Gate rejections logevent_automation.gate.rejectedwith the automation id and reason.updateEventAutomationkeeps the savedidentifierandresourceTypewhen they are left out. Only an explicitnullremoves them.case: "lower" | "upper". Core saves filter values in that case (create, update, dashboard, and Watches), sorepo: "getsentry/Junior"matches. GitHubrepo,commitSha,environment, Sentryprojects, and VercelcommitShaare lower; LinearteamKeyandissueIdentifierare upper.searchEventTypesoutput (namespaces[].reach), and in the dashboard event catalog API (one entry per namespace withdisplayName,events,anyResourceFields,resourceTypes). Core merges the filters of every resource type once when it builds the catalog.data. The dispatch key removes the extra copies, and the run limit counts a key once.eventTriggerProblems, the same check as the tools and the editor. The editor shows the service display name, says which filter an event needs with the filter description, and asks for a "Trigger name" instead of a "Resource name" when there is no identifier.Breaking changes
PluginEvents.anyResourceEventsandPluginEventType.guidanceare removed.PluginEvents.eventsis required and must declare every supported event withreachand optionalguidance.sourceEventGuidanceandanyResourceEventSchemaare removed;eventReachSchema,pluginEventDeclarationSchema, andnormalizeEventMatchare added. Match fields acceptcase.eventTriggerProblems/describeEventTrigger/eventTriggerChoices:EventTriggerSourceis now{ resourceTypes, events, anyResourceFields }.EventPublisher.neededMatchKeysaccepts optionaldata.identifierandresourceTypecan benullin event automation results.searchEventTypesdrops per-resource-typeanyResourceEventsand addsnamespaces./api/automations/event-catalogreturns one entry per namespace instead of one per resource type.Rollback
After any automation with no identifier is saved, the previous release cannot read it: its schema requires
identifier, and those rows fail to parse. Before rolling back, pause or delete rows wherekind = 'event' and identifier is null.Next (slice C)
channelneeds achannelIdfilter before slice D.projects; slice C keeps their identifiers.getEventCatalog()call; it merges filters once per build.via David Cramer.
--
View Session [Sentry]