Repository navigation
feat(sentry): Show Sentry issue links as cards for viewers who can open them - #3367
Conversation
…en them Link cards for Sentry issues and their events, on sentry.io and on customer domains, by numeric id or short id. The viewer's own Sentry OAuth token checks access. Junior's org read token reads the card, cached per issue. Core adds viewerEgress to ObjectLinkContext. It uses only the viewer's own stored OAuth token, never a plugin grant or an environment token, and never asks the viewer to connect. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: BYK <[email protected]> # Conflicts: # packages/junior-dashboard/src/mock-reporting/fixtures.ts
BYK
left a comment
There was a problem hiding this comment.
The @sentry/api package or the SDK of the sentry package on npm may become handy for Sentry API related stuff
Co-Authored-By: BYK <[email protected]>
|
249 screenshot changes — 0 changed · 249 added · 0 removed |
|
Re The plan: this PR keeps its one zod-checked fetch. From the charts PR on, Sentry cards use |
Co-Authored-By: BYK <[email protected]>
Read the org's links.regionUrl from sentry.io, cached per org for a day, and send the viewer access check and the card read to that host. A region URL that is not a Sentry API host fails the card. Co-Authored-By: BYK <[email protected]>
Co-Authored-By: BYK <[email protected]> # Conflicts: # packages/docs/src/content/docs/extend/build-a-plugin.md
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 60bb2ee. Configure here.
A refused org read can change soon, such as after a new org read token, so it no longer hides issue cards for a day.
## Problem Each link type checks the viewer inside `resolve`. Nothing makes a new plugin do that check, so a plugin that forgets it shows cards to viewers who cannot open the object. See the review on #3349. ## Fix - `PluginObjectLinkDefinition` now requires `canView(ctx, url): Promise<boolean>`. Plugin registration rejects a link type without it. - Core calls `canView` before `resolve`, for each card read and again on each Attach. `resolve` runs only when `canView` returns true. - Core link types: - Conversation: `canViewConversationLink` reads the viewer's Conversation access. - Person and `mailto:`: true, because every signed-in viewer sees the People pages. - `web_page`: true, because Junior fetches the page without credentials. - Slack message: true for now. Its card read checks channel access inside the viewer's Slack workspace, and that check shares the Slack installation with the read. - `junior-github` account links: true, because a GitHub profile is public. - `junior-google`: `canView` runs the existing viewer rule. Drive and Calendar metadata are read through `ctx.cache` for 10 seconds, so `canView` and `resolve` share one read. The Drive access queries check `trashed = false` again, so a trashed file never shows. - The plugin docs describe the contract. `canView` can take the separate `viewerCanSeeIssue` check from #3367. On #3367's head `2aec5973f`, that check needs the region origin and is not exported, so the Sentry link type adds this hook in its own module, as Stella posted in [#3367](#3367 (comment)): ```ts canView: async (ctx, url) => { const link = parseSentryIssueLink(url); const origin = link && (await sentryRegionOrigin(ctx, link.org)); return origin ? viewerCanSeeIssue(ctx, origin, link) : false; }, ``` The PR that merges second adds it. ## Tests - `object-attach.test.ts`: the test link types check access only in `canView`, and `resolve` always returns data. A participant without access gets no card from `/api/objects` and a 404 on Attach. This fails when core does not call `canView`. - `junior-google` link tests: every case goes through `canView` and then `resolve`. A Doc and a Calendar event each make one metadata read for both calls. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Ab4ab1661aa9222ed540303a34bce2d99 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Ab4ab1661aa9222ed540303a34bce2d99) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ab4ab1661aa9222ed540303a34bce2d99/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
# Conflicts: # packages/docs/src/content/docs/extend/build-a-plugin.md # packages/junior/src/api/objects/resolve.ts
… links (#3381) ## Problem A message with several links in one sentence turned into a row of chips. Each chip had an icon, a border, a background, a status suffix (" · Running") and a trailing ↗, and lines broke badly (a lone "." on its own line). A URL repeated in a message showed its card twice. ## Fix - **Inline links** in prose and summaries are plain links with the object title, such as "Pin the release train to payments 4.2 (#91)". No icon, border, background, status, or ↗. Status shows only in the hover card and in block cards. A message link shows its channel (`#proj-release`), and long titles stop at 80 characters. - **People** keep the avatar and name chip, without the ↗. - **A URL alone on its line** shows the block card, whatever its type. A video or image page shows only its thumbnail. - **A URL repeated in one message** gets one card, also across code fences. - **Hover cards** open after 350 ms. Base UI's default is 600 ms. - To tell a video or image page from an article, web page cards now save `facts.media` from the oEmbed `type` (`video` or `photo`), or from Open Graph `og:type` `video.*` or `og:video`. A page that already has a cached card gets the field when its cache entry expires (1 h by default). The Sentry issue link from the screenshot that started this (`JUNIOR-3ZK · Unresolved`) comes from #3367. It goes through the same inline path, so it renders as a plain titled link once #3367 lands. ## Screenshots (1440 wide, mock release reply) | | Before | After | |---|---|---| | Dark |  |  | | Light |  |  | <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A3327eedcd48b4d0139d324d264a639d1 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A3327eedcd48b4d0139d324d264a639d1) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A3327eedcd48b4d0139d324d264a639d1/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
…Sentry issues (#3373) A Sentry issue card now draws its events per hour for the last day as a sparkline. Stacked on #3367. After #3367 merges, this moves onto `main`. **Contract:** Ticket (`task`) facts take an optional `trend`: a `label` and 2 to 60 nonnegative `points`, oldest first. The full card draws the shape under the summary. It has no exact values or axes, and it doesn't use the image proxy: the series is plain numbers in the facts, well under the 4 KiB limit. A shared `Sparkline` in `components/charts/` draws it as inline SVG in the accent color. **Sentry:** the issue details API already returns `stats["24h"]`, which holds hourly `[timestamp, count]` pairs. The card maps them to `points`. It sends no trend when there are fewer than two points or a negative count, so a bad series never drops the whole card. | | Dark | Light | |---|---|---| | Before |  |  | | After |  |  | **Tests** - `tests/integration/api/sentry-issue-links.test.ts`: the allowed viewer's card has the trend. Without the facts schema change, the cards are rejected and the tests fail. - Dashboard e2e: the hover card shows the "Events, last 24 hours" sparkline. This fails without the change. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Ab784a61e6351b98fecdafda6e0e72301 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Ab784a61e6351b98fecdafda6e0e72301) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ab784a61e6351b98fecdafda6e0e72301/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
…nks (#3397) The Sentry issue link expectation from #3367 and #3373 is out of date. It looks for a chip named "JUNIOR-3ZK · Unresolved". Since #3381, a bare link in a sentence renders as a plain titled link, "TypeError: cart.total is undefined (JUNIOR-3ZK)". The PRs landed close together, so the expectation still describes the old chip. The new rendering is intended, so only the expectation changes: a titled link, with the issue state shown in the hover card. No app code changes. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Ab784a61e6351b98fecdafda6e0e72301 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Ab784a61e6351b98fecdafda6e0e72301) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ab784a61e6351b98fecdafda6e0e72301/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
## Problem After #3381, a person link in running text is still a pill: border, fill and a person icon. That chip is the one item in a paragraph that doesn't look like text. A Slack `<@U…>` mention shows no photo at all. ## Fix - A person in running text now renders like a GitHub mention: a round photo about 1em high at the text baseline, then `@Name` as a plain link. There's no border, fill, padding box or icon. The hover card and its delay stay. - When the person is the viewer, the mention gets a subtle `dashboard-accent` highlight that works in both themes, plus `data-self-mention`. - A person with no photo shows only the name. A photo that fails to load is dropped. - Person object links and Slack mention tokens both use the same `PersonMention`, in `display-text/people.tsx`. - In mock mode, Morgan Lee has an initials photo so the screenshots show it. - The Sentry issue e2e from #3367 still expected the `JUNIOR-3ZK · Unresolved` chip that #3381 removed. It now expects the titled link. ## Screenshots (1440) David's release paragraph. The mock viewer is Morgan Lee, so this message also mentions the viewer. | | Before | After | | --- | --- | --- | | Light |  |  | | Dark |  |  | <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A3327eedcd48b4d0139d324d264a639d1 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A3327eedcd48b4d0139d324d264a639d1) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A3327eedcd48b4d0139d324d264a639d1/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
…3408) People share Sentry Explore links in threads to show a trend, such as a latency spike after a deploy. Today such a link shows as a plain URL, so readers must open Sentry to see what it shows. This PR makes links to Explore traces, logs, and metrics resolve to chart cards. It follows the issue cards (#3367, #3373) as part of the work to give Sentry links cards. **`chart` object type.** A new native type (label "Chart", icon "graph"). Its facts are a display (line, bar, or area), the y-axis, the range, and 1 to 5 series of 2 to 120 points. Slack cards and the model's text show the range as a field. On the dashboard, the range is the chart caption. **Dashboard chart.** The issue trend Sparkline now draws one or more series as lines, areas, or stacked bars. A legend names the series when there is more than one. The issue trend looks the same as before. The card meta line drops a label that repeats the type. **Access and data.** A chart query covers the projects that its reader may see. Junior's org read token could see more than the viewer can, so the viewer's own Sentry token runs the query: - `canView` runs the `events-timeseries` query through `viewerEgress`. - The result is cached per viewer and URL for one minute. `resolve` builds the card from that entry. - Junior's org read token only finds the org's region host. It reads no chart data. - A viewer with no Sentry connection, or a Sentry 400, 401, 403, or 404, gets no card. - Points are downsampled and rounded to three significant digits, so five series fit the 4 KiB facts limit. The `viewerEgress` doc now covers data that depends on who reads it. **`@sentry/api`.** Sentry API calls for link cards use `@sentry/api`, pinned at 2.3.0, instead of hand-built requests. This covers the region lookup, the issue card reads, and the chart query. Each call goes through one Junior egress, so the host picks the token. Only the root client is used. It keeps no response cache, so one viewer's data never serves another. `@sentry/[email protected]` is the only new `minimumReleaseAgeExclude` entry, because Sentry publishes it. Its dependencies `p-limit` 7.3.3 and `http-cache-semantics` 4.2.0 pass the release age policy. Nothing breaks. Issue cards keep their behavior. No new OAuth scopes, credential paths, or migrations. ### Screenshots Desktop at 1440, rendered from the dashboard mock. | | Dark | Light | | --- | --- | --- | | Chart card |  |  | | Hover card |  |  | <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Ab784a61e6351b98fecdafda6e0e72301 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Ab784a61e6351b98fecdafda6e0e72301) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ab784a61e6351b98fecdafda6e0e72301/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>

Sentry issue links in a Conversation show as bare URLs, so people must open Sentry to see what an issue is. They now show as a chip and a hover card, for viewers who can open the issue in Sentry.
Links:
sentry.io/organizations/<org>/issues/<id>/and<org>.sentry.io/issues/<id>/, by numeric id or short id (JUNIOR-3ZK), plus/events/<id|latest|recommended|oldest>/under an issue (shows the issue card). Other Sentry pages get no card.Access: the link type's
canView(#3376) asks Sentry, with the viewer's own OAuth token on the org's region host, whether the viewer can open the issue. Core calls it before each card read and again on Attach. Then Junior's org read token reads the card, cached per issue for 60 seconds. A viewer who has not connected Sentry, or whom Sentry denies, gets no card and no fields.Core:
ObjectLinkContext.viewerEgress, available tocanViewandresolve. It is egress with the viewer as the credential subject anduserOAuthOnly: it uses only that viewer's stored OAuth token. It skips plugin grants, never falls back to an environment token, and never asks the viewer to connect. No new OAuth scopes, credential stores, or migrations. If this path breaks, the exposure is one viewer's own Sentry token used for a read that the same viewer can already make.Card: reuses Ticket (
task) with display type "Sentry issue": title, culprit, state, assignee, priority, project, level and substatus labels, event and user counts. No event data, tags, or stack frames.via @BYK.
--
View Session [Sentry]