From 5affddcda6de2fcc7cb7bb019e3dc0ff3d118aa6 Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Fri, 12 Sep 2025 10:45:28 -0700 Subject: [PATCH 1/3] fixing JS framework formatting for redirect pages --- app/platform-redirect/page.tsx | 120 ++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 18 deletions(-) diff --git a/app/platform-redirect/page.tsx b/app/platform-redirect/page.tsx index 3cfd54088e637..70c72376b69c9 100644 --- a/app/platform-redirect/page.tsx +++ b/app/platform-redirect/page.tsx @@ -39,12 +39,31 @@ export default async function Page(props: { // get rid of irrelevant platforms for the `next` path const platformList = extractPlatforms(rootNode).filter(platform_ => { - const node = nodeForPath(rootNode, [ + // First check the main platform path + let node = nodeForPath(rootNode, [ 'platforms', platform_.key, ...pathname.split('/').filter(Boolean), ]); + // If not found, check if it's a guide (like dart/guides/flutter) + if (!node && platform_.guides) { + for (const guide of platform_.guides) { + node = nodeForPath(rootNode, [ + 'platforms', + platform_.key, + 'guides', + guide.name, + ...pathname.split('/').filter(Boolean), + ]); + if (node) { + // Update the platform URL to point to the guide + platform_.url = guide.url; + break; + } + } + } + // extract title and description for displaying it on page if (node && title === defaultTitle && pathname.length > 0) { title = node.frontmatter.title ?? title; @@ -54,18 +73,78 @@ export default async function Page(props: { return !!node; }); - if (platformList.length === 0) { + // For JavaScript platforms, also include individual frameworks that support the content + const expandedPlatformList = [...platformList]; + + // Find JavaScript platform and add its supported frameworks + // Check both the filtered platformList and all platforms to find JavaScript + const javascriptPlatform = platformList.find(p => p.key === 'javascript') || + extractPlatforms(rootNode).find(p => p.key === 'javascript'); + + if (javascriptPlatform && ( + pathname.startsWith('/session-replay/') || + pathname.startsWith('/tracing/') || + pathname.startsWith('/profiling/') || + pathname.startsWith('/logs/') + )) { + // Get the JavaScript page to check which frameworks are supported + const jsPageNode = nodeForPath(rootNode, [ + 'platforms', + 'javascript', + ...pathname.split('/').filter(Boolean), + ]); + + if (jsPageNode && jsPageNode.frontmatter.notSupported) { + const notSupported = jsPageNode.frontmatter.notSupported; + + // Remove JavaScript from the main list temporarily + const otherPlatforms = expandedPlatformList.filter(p => p.key !== 'javascript'); + + // Add supported JavaScript frameworks as separate entries + const jsFrameworks = []; + javascriptPlatform.guides?.forEach(guide => { + const guideKey = `javascript.${guide.name}`; + if (!notSupported.includes(guideKey)) { + jsFrameworks.push({ + key: guideKey, + name: guide.name, + type: 'platform' as const, + url: javascriptPlatform.url, + title: guide.title, + caseStyle: guide.caseStyle, + sdk: guide.sdk, + fallbackPlatform: guide.fallbackPlatform, + language: guide.language, + categories: guide.categories, + keywords: guide.keywords, + guides: [], + integrations: [], + icon: `javascript-${guide.name}`, + }); + } + }); + + // Rebuild the list with JavaScript and its frameworks at the end + expandedPlatformList.length = 0; // Clear the array + expandedPlatformList.push(...otherPlatforms); // Add other platforms first + expandedPlatformList.push(javascriptPlatform); // Add JavaScript platform + expandedPlatformList.push(...jsFrameworks); // Add JavaScript frameworks last + } + } + + if (expandedPlatformList.length === 0) { // try to redirect the user to the page directly, might result in 404 return redirect(next); } const requestedPlatform = Array.isArray(platform) ? platform[0] : platform; if (requestedPlatform) { - const isValidPlatform = platformList.some( + const validPlatform = expandedPlatformList.find( p => p.key === requestedPlatform?.toLowerCase() ); - if (isValidPlatform) { - return redirect(`/platforms/${requestedPlatform}${pathname}`); + if (validPlatform) { + // Use the platform's URL (which may have been updated to point to a guide) + return redirect(`${validPlatform.url}${pathname}`); } } @@ -82,19 +161,24 @@ export default async function Page(props: { {platformInfo} ); From 3fe281a304136ba8f614bede71f184093c0c11e1 Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Fri, 12 Sep 2025 10:53:43 -0700 Subject: [PATCH 2/3] fixing bugs --- app/platform-redirect/page.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/platform-redirect/page.tsx b/app/platform-redirect/page.tsx index 70c72376b69c9..d4d0d8d7d97e4 100644 --- a/app/platform-redirect/page.tsx +++ b/app/platform-redirect/page.tsx @@ -57,8 +57,10 @@ export default async function Page(props: { ...pathname.split('/').filter(Boolean), ]); if (node) { - // Update the platform URL to point to the guide - platform_.url = guide.url; + // Create a copy of the platform with the guide URL to avoid mutating the original + const platformCopy = {...platform_, url: guide.url}; + // Update the platform reference to use the copy + Object.assign(platform_, platformCopy); break; } } @@ -77,9 +79,8 @@ export default async function Page(props: { const expandedPlatformList = [...platformList]; // Find JavaScript platform and add its supported frameworks - // Check both the filtered platformList and all platforms to find JavaScript - const javascriptPlatform = platformList.find(p => p.key === 'javascript') || - extractPlatforms(rootNode).find(p => p.key === 'javascript'); + // Only use JavaScript platform if it's already in the filtered list (has relevant content) + const javascriptPlatform = platformList.find(p => p.key === 'javascript'); if (javascriptPlatform && ( pathname.startsWith('/session-replay/') || @@ -101,7 +102,7 @@ export default async function Page(props: { const otherPlatforms = expandedPlatformList.filter(p => p.key !== 'javascript'); // Add supported JavaScript frameworks as separate entries - const jsFrameworks = []; + const jsFrameworks: typeof platformList = []; javascriptPlatform.guides?.forEach(guide => { const guideKey = `javascript.${guide.name}`; if (!notSupported.includes(guideKey)) { From d39eb3a5b56e12ae0c4a2ba0cfee8d37efd5c15b Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Fri, 12 Sep 2025 17:54:36 +0000 Subject: [PATCH 3/3] [getsentry/action-github-commit] Auto commit --- app/platform-redirect/page.tsx | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/platform-redirect/page.tsx b/app/platform-redirect/page.tsx index d4d0d8d7d97e4..88e23b44e1084 100644 --- a/app/platform-redirect/page.tsx +++ b/app/platform-redirect/page.tsx @@ -77,30 +77,31 @@ export default async function Page(props: { // For JavaScript platforms, also include individual frameworks that support the content const expandedPlatformList = [...platformList]; - + // Find JavaScript platform and add its supported frameworks // Only use JavaScript platform if it's already in the filtered list (has relevant content) const javascriptPlatform = platformList.find(p => p.key === 'javascript'); - - if (javascriptPlatform && ( - pathname.startsWith('/session-replay/') || - pathname.startsWith('/tracing/') || - pathname.startsWith('/profiling/') || - pathname.startsWith('/logs/') - )) { + + if ( + javascriptPlatform && + (pathname.startsWith('/session-replay/') || + pathname.startsWith('/tracing/') || + pathname.startsWith('/profiling/') || + pathname.startsWith('/logs/')) + ) { // Get the JavaScript page to check which frameworks are supported const jsPageNode = nodeForPath(rootNode, [ 'platforms', 'javascript', ...pathname.split('/').filter(Boolean), ]); - + if (jsPageNode && jsPageNode.frontmatter.notSupported) { const notSupported = jsPageNode.frontmatter.notSupported; - + // Remove JavaScript from the main list temporarily const otherPlatforms = expandedPlatformList.filter(p => p.key !== 'javascript'); - + // Add supported JavaScript frameworks as separate entries const jsFrameworks: typeof platformList = []; javascriptPlatform.guides?.forEach(guide => { @@ -124,7 +125,7 @@ export default async function Page(props: { }); } }); - + // Rebuild the list with JavaScript and its frameworks at the end expandedPlatformList.length = 0; // Clear the array expandedPlatformList.push(...otherPlatforms); // Add other platforms first @@ -165,7 +166,7 @@ export default async function Page(props: { {expandedPlatformList.map(p => { // Check if this is a JavaScript framework (has javascript. prefix) const isJSFramework = p.key.startsWith('javascript.'); - + return (