From 2c22ada761c39f694f4a7540e7d35342dc5af633 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 18 Sep 2026 11:15:28 +0200 Subject: [PATCH] refactor(js): use browser-only/server-only directly in getPlatformHints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the current-platform runtime check in getPlatformHints with direct `isBrowserOnly` / `isServerOnly` category checks. The "Only available on: Client/Server" hint is only informative on dual-runtime (meta-framework) platforms; on a single-runtime platform the option's runtime is already implied, so we suppress it there. Note: this also surfaces the hint on `desktop` platforms (electron), which carry neither `browser-only` nor `server-only` — electron runs both a browser (renderer) and a Node (main) runtime, so the runtime note is appropriate there. Previously it was suppressed on electron because it lacked an explicit `browser`/`server` tag. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/categories.ts | 10 ++++++++++ src/components/sdkOption.tsx | 17 ++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/categories.ts b/src/categories.ts index ab2f5964c6446..1a09398173a09 100644 --- a/src/categories.ts +++ b/src/categories.ts @@ -20,3 +20,13 @@ export function hasServerCategory(categories?: PlatformCategory[] | null): boole export function hasBrowserCategory(categories?: PlatformCategory[] | null): boolean { return !!categories?.includes('browser'); } + +/** Whether the platform/guide runs exclusively in the browser (no server side). */ +export function isBrowserOnly(categories?: PlatformCategory[] | null): boolean { + return !!categories?.includes('browser-only'); +} + +/** Whether the platform/guide runs exclusively on a server (no browser side). */ +export function isServerOnly(categories?: PlatformCategory[] | null): boolean { + return !!categories?.includes('server-only'); +} diff --git a/src/components/sdkOption.tsx b/src/components/sdkOption.tsx index 1b8a405b10dec..c2aa88a748a95 100644 --- a/src/components/sdkOption.tsx +++ b/src/components/sdkOption.tsx @@ -1,4 +1,9 @@ -import {hasBrowserCategory, hasServerCategory} from 'sentry-docs/categories'; +import { + hasBrowserCategory, + hasServerCategory, + isBrowserOnly, + isServerOnly, +} from 'sentry-docs/categories'; import {getCurrentPlatformOrGuide} from 'sentry-docs/docTree'; import {serverContext} from 'sentry-docs/serverContext'; import {PlatformCategory} from 'sentry-docs/types'; @@ -96,12 +101,14 @@ export function getPlatformHints(categorySupported: PlatformCategory[]) { const supportedServerLikeOnly = !hasBrowserCategory(categorySupported) && hasServerCategory(categorySupported); + // Only surface the runtime hint when it adds information. On a single-runtime + // platform the option's runtime is already implied (a browser-only platform + // needs no "client only" note, a server-only one no "server only" note), so + // we show it on dual-runtime platforms (meta-frameworks) instead. const showBrowserOnly = - hasCategorySupported && supportedBrowserOnly && hasServerCategory(currentCategories); + hasCategorySupported && supportedBrowserOnly && !isBrowserOnly(currentCategories); const showServerLikeOnly = - hasCategorySupported && - supportedServerLikeOnly && - hasBrowserCategory(currentCategories); + hasCategorySupported && supportedServerLikeOnly && !isServerOnly(currentCategories); return {showBrowserOnly, showServerLikeOnly}; }