diff --git a/src/components/sdkOption.tsx b/src/components/sdkOption.tsx index 69a1999144e6e..c877764af3b76 100644 --- a/src/components/sdkOption.tsx +++ b/src/components/sdkOption.tsx @@ -2,8 +2,6 @@ import {getCurrentPlatformOrGuide} from 'sentry-docs/docTree'; import {serverContext} from 'sentry-docs/serverContext'; import {PlatformCategory} from 'sentry-docs/types'; -import {PlatformCategorySection} from './platformCategorySection'; -import {PlatformSection} from './platformSection'; import {SdkDefinition, SdkDefinitionTable} from './sdkDefinition'; type Props = { @@ -28,6 +26,21 @@ export function SdkOption({ categorySupported = [], }: Props) { const {showBrowserOnly, showServerLikeOnly} = getPlatformHints(categorySupported); + const {rootNode, path} = serverContext(); + const currentPlatformOrGuide = getCurrentPlatformOrGuide(rootNode, path); + const shouldShowEnvVar = () => { + if (!currentPlatformOrGuide) return false; + + const isServerPlatform = + currentPlatformOrGuide.categories?.includes('server') || + currentPlatformOrGuide.categories?.includes('serverless'); + + const isExcludedPlatform = + currentPlatformOrGuide.key === 'javascript.nextjs' || + currentPlatformOrGuide.key === 'javascript.sveltekit'; + + return isServerPlatform && !isExcludedPlatform; + }; return ( @@ -39,11 +52,10 @@ export function SdkOption({ {defaultValue && ( )} - - - {envVar && } - - + + {shouldShowEnvVar() && envVar && ( + + )} {showBrowserOnly && } {showServerLikeOnly && }