Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
17 changes: 12 additions & 5 deletions src/components/sdkOption.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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};
}
Loading