feat: SDK auth/client config factories (bearerToken, browserSession, createSentryClient)#78
Draft
betegon wants to merge 1 commit into
Draft
feat: SDK auth/client config factories (bearerToken, browserSession, createSentryClient)#78betegon wants to merge 1 commit into
betegon wants to merge 1 commit into
Conversation
…createSentryClient)
Configure the client once instead of threading baseUrl + auth into every call.
`bearerToken({ token })` returns a typed config (default baseUrl https://sentry.io) for
`client.setConfig(...)` (global) or `createSentryClient(...)` (isolated, for servers/tests).
`browserSession()` (in ./browser) is the blessed name for the existing cookie+CSRF browser
config; `createBrowserSdkConfig` stays as an alias.
Re-exports the client (`client`, `createClient`, `createSentryClient`, `createConfig`, `Config`)
from the public entry so consumers configure it without reaching into generated internals.
Pure builders, no side effects, no `mode` enum. Additive and opt-in; existing per-call config
still works. First of three PRs (auth factories -> region routing -> query accuracy) toward one
SDK for the CLI, MCP, and frontend.
Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Jul 10, 2026
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.
What
First of three small, additive PRs making
@sentry/apia one-line-to-configure client for the CLI, MCP, and frontend, instead of threadingbaseUrl+ auth into every call.This PR adds the auth/init factories and exposes the client from the public entry. No region routing yet (PR2), no query-accuracy helper (PR3).
Changes
lib/auth-config.ts(new):bearerToken({ token, baseUrl?, fetch?, headers?, throwOnError? })— a pure factory returning a typed config. DefaultsbaseUrltohttps://sentry.io. Standalone (local types, no generated imports), same pattern aslib/sentry-pagination.ts.lib/browser-client.ts: addbrowserSession()as the blessed name for the existing cookie+CSRFcreateBrowserSdkConfig(kept as an alias).build.mjs: copyauth-config.tsinto the build and re-export from the public entry:bearerToken,client,createClient,createClient as createSentryClient,createConfig, and theConfigtype. (client/createClientwere not exported before, despite the browser docstring assumingimport { client }.)README.md: lead with configure-once usage; document the isolated-client and browser paths. Retires "pass baseUrl to each call."Design
bearerToken,browserSession); host/routing are options, not separate factories. Noconfigure, noinit, nomodeenum, no "SaaS."client.setConfig(...)(global singleton) for the CLI;createSentryClient(...)(isolated instance) for servers like MCP and for tests, so a multi-token server never shares global mutable auth state.Usage
Test plan
bun test: 97 pass / 0 fail (8 new intest/auth-config.test.ts).bun run build: green;bun run typecheck: clean.bearerToken-> sentry.io +Bearerheader;createSentryClient/createClient/client.setConfigresolve;browserSession()->baseUrl: ''; isolated client instantiates.Not in scope (follow-ups)
resolveRegionUrloption + per-request region routing (default = sentry.io proxy).queryWithAccuracy(progressive sampling), + backend follow-up to addsamplingto the spec.