Skip to content

feat: added client functions using openapi specs#164

Closed
MathurAditya724 wants to merge 4 commits intomainfrom
fix/88
Closed

feat: added client functions using openapi specs#164
MathurAditya724 wants to merge 4 commits intomainfrom
fix/88

Conversation

@MathurAditya724
Copy link
Member

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (issue) Replace --org/--project flags with /ID syntax by BYK in #161
  • Added client functions using openapi specs by MathurAditya724 in #164

Bug Fixes 🐛

  • Added nullable in substatus's zod validation by MathurAditya724 in #157

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

Codecov Results 📊

❌ Patch coverage is 37.31%. Project has 3659 uncovered lines.
❌ Project coverage is 56.66%. Comparing base (base) to head (head).

Files with missing lines (40)
File Patch % Lines
sdk.gen.ts 20.74% ⚠️ 879 Missing
human.ts 31.87% ⚠️ 682 Missing
resolve-target.ts 10.74% ⚠️ 291 Missing
api-client.ts 58.22% ⚠️ 249 Missing
oauth.ts 25.10% ⚠️ 194 Missing
serverSentEvents.gen.ts 0.62% ⚠️ 160 Missing
upgrade.ts 39.76% ⚠️ 153 Missing
resolver.ts 3.23% ⚠️ 120 Missing
pathSerializer.gen.ts 11.72% ⚠️ 113 Missing
errors.ts 5.94% ⚠️ 95 Missing
params.gen.ts 10.00% ⚠️ 90 Missing
migration.ts 47.44% ⚠️ 82 Missing
queryKeySerializer.gen.ts 6.33% ⚠️ 74 Missing
client.gen.ts 72.30% ⚠️ 59 Missing
utils.gen.ts 78.95% ⚠️ 48 Missing
api.ts 89.80% ⚠️ 47 Missing
seer.ts 50.55% ⚠️ 45 Missing
bodySerializer.gen.ts 23.08% ⚠️ 40 Missing
utils.gen.ts 67.37% ⚠️ 31 Missing
seer.ts 79.87% ⚠️ 30 Missing
client-setup.ts 82.01% ⚠️ 25 Missing
preload.ts 39.02% ⚠️ 25 Missing
utils.ts 87.43% ⚠️ 24 Missing
version-check.ts 76.00% ⚠️ 18 Missing
detector.ts 87.79% ⚠️ 16 Missing
schema.ts 64.10% ⚠️ 14 Missing
auth.gen.ts 53.33% ⚠️ 7 Missing
auth.ts 94.78% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
arg-parsing.ts 93.41% ⚠️ 6 Missing
upgrade.ts 93.83% ⚠️ 5 Missing
index.ts 95.06% ⚠️ 4 Missing
colors.ts 91.84% ⚠️ 4 Missing
telemetry.ts 97.20% ⚠️ 4 Missing
env-file.ts 97.17% ⚠️ 3 Missing
sentry-urls.ts 88.00% ⚠️ 3 Missing
alias.ts 98.56% ⚠️ 2 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
java.ts 97.22% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    69.20%    56.66%   -12.54%
==========================================
  Files           57        70       +13
  Lines         6565      8442     +1877
  Branches         0         0         —
==========================================
+ Hits          4543      4783      +240
- Misses        2022      3659     +1637
- Partials         0         0         —

Generated by Codecov Action

MathurAditya724 added a commit that referenced this pull request Feb 13, 2026
## Summary

Migrates the Sentry API client from hand-rolled `ky` HTTP calls with
Zod-validated responses to the
[`@sentry/api`](https://www.npmjs.com/package/@sentry/api) SDK package.
This gives us type-safe API calls generated from the OpenAPI spec, while
keeping raw requests for internal/undocumented endpoints.

This supersedes #164, which generated the client in-repo using
`@hey-api/openapi-ts`. Using the published `@sentry/api` package instead
avoids maintaining ~20k lines of generated code in the repo.

## What changed

### New: `src/lib/sentry-client.ts`
Request configuration layer for `@sentry/api` SDK functions. Provides:
- **Authenticated fetch** with Bearer token injection
- **Automatic retry** on transient errors (408, 429, 5xx) with
exponential backoff
- **401 token refresh** — force-refreshes OAuth token and retries once
- **Request timeout** via AbortController (30s)
- Per-region config via `getSdkConfig(regionUrl)`

### Rewritten: `src/lib/api-client.ts`
All API functions now use `@sentry/api` SDK functions where possible:

| Function | SDK function used |
|----------|------------------|
| `listOrganizationsInRegion` | `listYourOrganizations` |
| `getOrganization` | `retrieveAnOrganization` |
| `listProjects` | `listAnOrganization_sProjects` |
| `getProject` | `retrieveAProject` |
| `getProjectKeys` | `listAProject_sClientKeys` |
| `getIssueByShortId` | `resolveAShortId` |
| `getLatestEvent` | `retrieveAnIssueEvent` |
| `getEvent` | `retrieveAnEventForAProject` |
| `triggerRootCauseAnalysis` | `startSeerIssueFix` |
| `getAutofixState` | `retrieveSeerIssueFixState` |
| `listLogs` / `getLog` | `queryExploreEventsInTableFormat` |

Functions that use raw requests (no SDK equivalent):
- `getUserRegions` — `/users/me/regions/` (internal endpoint)
- `getCurrentUser` — `/users/me/` (internal endpoint)
- `findProjectByDsnKey` — `/projects/?query=dsn:...` (internal query
param)
- `listIssues` — SDK missing `limit`/`sort` params
- `getIssue` / `updateIssueStatus` — legacy `/issues/{id}/` endpoint (no
org slug needed)
- `getDetailedTrace` — `/organizations/{org}/trace/{traceId}/` (internal
endpoint)
- `triggerSolutionPlanning` — SDK doesn't support `run_id` + `step` body

### Refactored: `src/types/sentry.ts`
- SDK-backed types now derive from `@sentry/api` response types using
`Partial<SdkType> & RequiredCore`
- Keeps Zod schemas only for internal endpoints not covered by the SDK
(Region, User, Logs)
- Event entry types (exceptions, breadcrumbs, request, etc.) remain as
plain TypeScript interfaces

### Removed
- `ky` dependency (replaced by `@sentry/api` + native fetch)
- Most Zod schemas for SDK-covered types (Organization, Project, Issue,
Event, ProjectKey, etc.)
- `SentryOrganizationSchema` and other schema exports from
`types/index.ts`

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant