feat: added client functions using openapi specs#164
Closed
MathurAditya724 wants to merge 4 commits intomainfrom
Closed
feat: added client functions using openapi specs#164MathurAditya724 wants to merge 4 commits intomainfrom
MathurAditya724 wants to merge 4 commits intomainfrom
Conversation
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊❌ Patch coverage is 37.31%. Project has 3659 uncovered lines. Files with missing lines (40)
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.