diff --git a/src/categories.ts b/src/categories.ts index ab2f5964c6446b..1a09398173a09e 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 1b8a405b10dec0..c2aa88a748a950 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}; }