Skip to content

Commit 4cc04e2

Browse files
committed
fix(docs) fixes formatting, updates platformLink
1 parent 894c378 commit 4cc04e2

File tree

4 files changed

+76
-9
lines changed

4 files changed

+76
-9
lines changed

docs/platforms/javascript/common/configuration/integrations/openai.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ supported:
2323
- javascript.astro
2424
- javascript.bun
2525
- javascript.tanstackstart-react
26-
- javascript.cloudflare
2726
---
2827

2928
<Alert>

docs/platforms/javascript/common/configuration/integrations/vercelai.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ supported:
66
- javascript.aws-lambda
77
- javascript.azure-functions
88
- javascript.connect
9+
- javascript.deno
910
- javascript.express
1011
- javascript.fastify
1112
- javascript.gcp-functions
@@ -28,7 +29,8 @@ supported:
2829

2930
<Alert>
3031

31-
This integration only works in the Node.js, Cloudflare Workers, Vercel Edge Functions and Bun runtimes. Requires SDK version ``10.6.0` or higher.
32+
Requires SDK version `10.6.0` or higher for Node.js, Cloudflare Workers, Vercel Edge Functions and Bun.
33+
Requires SDK version `10.12.0` or higher for Deno.
3234

3335
</Alert>
3436

docs/platforms/javascript/common/tracing/instrumentation/ai-agents-module.mdx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,21 @@ As a prerequisite to setting up AI Agent Monitoring with JavaScript, you'll need
3434

3535
The JavaScript SDK supports automatic instrumentation for some AI libraries. We recommend adding their integrations to your Sentry configuration to automatically capture spans for AI agents.
3636

37-
- <PlatformLink to="/configuration/integrations/vercelai/">
38-
Vercel AI SDK
39-
</PlatformLink>
40-
- <PlatformLink to="/configuration/integrations/openai/">OpenAI</PlatformLink>
41-
- <PlatformLink to="/configuration/integrations/anthropic/">Anthropic</PlatformLink>
37+
<PlatformLink to="/configuration/integrations/vercelai/">
38+
- Vercel AI SDK
39+
</PlatformLink>
40+
<PlatformLink
41+
to="/configuration/integrations/openai/"
42+
notSupported={["javascript.deno", "javascript.cloudflare"]}
43+
>
44+
- OpenAI
45+
</PlatformLink>
46+
<PlatformLink
47+
to="/configuration/integrations/anthropic/"
48+
notSupported={["javascript.deno"]}
49+
>
50+
- Anthropic
51+
</PlatformLink>
4252

4353
## Manual Instrumentation
4454

src/components/platformLink.tsx

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,76 @@
1-
import {getCurrentPlatformOrGuide} from 'sentry-docs/docTree';
1+
import {getCurrentPlatformOrGuide, getPlatform} from 'sentry-docs/docTree';
22
import {serverContext} from 'sentry-docs/serverContext';
3+
import {Platform, PlatformGuide} from 'sentry-docs/types';
34

45
import {SmartLink} from './smartLink';
56

7+
function getPlatformsWithFallback(
8+
rootNode: any,
9+
platformOrGuide: Platform | PlatformGuide
10+
) {
11+
const result = [platformOrGuide.key];
12+
let curPlatform: Platform | PlatformGuide | undefined = platformOrGuide;
13+
while (curPlatform?.fallbackPlatform) {
14+
result.push(curPlatform.fallbackPlatform);
15+
curPlatform = getPlatform(rootNode, curPlatform.fallbackPlatform);
16+
}
17+
return result;
18+
}
19+
20+
const isSupported = (
21+
platformKey: string,
22+
supported: string[],
23+
notSupported: string[]
24+
): boolean | null => {
25+
if (supported.length && supported.find(p => p === platformKey)) {
26+
return true;
27+
}
28+
if (notSupported.length && notSupported.find(p => p === platformKey)) {
29+
return false;
30+
}
31+
return null;
32+
};
33+
634
type Props = {
735
children: React.ReactNode;
36+
notSupported?: string[];
37+
supported?: string[];
838
to?: string;
939
};
1040

11-
export function PlatformLink({children, to}: Props) {
41+
export function PlatformLink({children, to, supported = [], notSupported = []}: Props) {
1242
if (!to) {
1343
return children;
1444
}
1545

1646
const {rootNode, path} = serverContext();
1747
const currentPlatformOrGuide = getCurrentPlatformOrGuide(rootNode, path);
48+
49+
// Check platform support if we have a current platform and support constraints
50+
if (currentPlatformOrGuide && (supported.length > 0 || notSupported.length > 0)) {
51+
const platformsToSearch = getPlatformsWithFallback(rootNode, currentPlatformOrGuide);
52+
53+
let result: boolean | null = null;
54+
// eslint-disable-next-line no-cond-assign
55+
for (let platformKey: string, i = 0; (platformKey = platformsToSearch[i]); i++) {
56+
if (!platformKey) {
57+
continue;
58+
}
59+
result = isSupported(platformKey, supported, notSupported);
60+
if (result === false) {
61+
// Platform is not supported, hide completely
62+
return null;
63+
}
64+
if (result === true) {
65+
break;
66+
}
67+
}
68+
if (result === null && supported.length) {
69+
// No supported platform found, hide completely
70+
return null;
71+
}
72+
}
73+
1874
let href: string;
1975
if (currentPlatformOrGuide) {
2076
href = currentPlatformOrGuide.url + to.slice(1);

0 commit comments

Comments
 (0)