Skip to content

Commit

Permalink
fix: Handle product 404 links (#10742)
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome authored Jul 16, 2024
1 parent f366de4 commit 42a0e03
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/platform-redirect/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {notFound, redirect} from 'next/navigation';
import {redirect} from 'next/navigation';

import {DocPage} from 'sentry-docs/components/docPage';
import {PlatformIcon} from 'sentry-docs/components/platformIcon';
Expand Down Expand Up @@ -27,7 +27,8 @@ export default async function Page({
});

if (platformList.length === 0) {
return notFound();
// try to redirect the user to the page directly, might result in 404
return redirect(next);
}

const requestedPlatform = Array.isArray(platform) ? platform[0] : platform;
Expand Down
68 changes: 66 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type Redirect = {
};

/** Note: if you want to set redirects for developer docs, set them below in `DEVELOPER_DOCS_REDIRECTS` */
const SDK_DOCS_REDIRECTS: Redirect[] = [
const USER_DOCS_REDIRECTS: Redirect[] = [
{
from: '/platforms/javascript/guides/react/configuration/integrations/trycatch/',
to: '/platforms/javascript/configuration/integrations/browserapierrors/',
Expand Down Expand Up @@ -3302,6 +3302,70 @@ const SDK_DOCS_REDIRECTS: Redirect[] = [
from: '/account/quotas/spike-protection/',
to: '/pricing/quotas/spike-protection/',
},
{
from: '/_platforms/',
to: '/platforms',
},
{
from: '/accounts/require-2fa/',
to: '/organization/authentication/two-factor-authentication/',
},
{
from: '/platforms/go/guides/fiber/',
to: '/platforms/go/',
},
{
from: '/platforms/go/guides/fiber/user-feedback/configuration/',
to: '/platforms/go/user-feedback/',
},
{
from: '/platforms/javascript/guides/',
to: '/platforms/javascript/',
},
{
from: '/platforms/native/crashpad/',
to: '/platforms/native/guides/crashpad/',
},
{
from: '/platforms/python/legacy-sdk/integrations/pylons/',
to: '/platforms/python/legacy-sdk/integrations/#pylons',
},
{
from: '/concepts/data-management/event-grouping/grouping-breakdown/',
to: '/concepts/data-management/event-grouping/',
},
{
from: '/product/explore/session-replay/performance-overhead/',
to: '/product/explore/session-replay/web/performance-overhead/',
},
{
from: '/organization/integrations/project-mgmt/jira/',
to: '/organization/integrations/issue-tracking/jira/',
},
{
from: '/organization/integrations/source-code-/',
to: '/organization/integrations/source-code-mgmt/',
},
{
from: '/product/explore/session-replay/getting-started/',
to: '/product/explore/session-replay/',
},
{
from: '/product/explore/session-replay/replay-page-and-filters/',
to: '/product/explore/session-replay/web/replay-page-and-filters/',
},
{
from: '/platforms/nintendo-switch/',
to: '/platforms/unity/native-support/',
},
{
from: '/product/teams/roles/',
to: '/organization/membership/#team-level-roles',
},
{
from: '/enriching-error-data/additional-data/',
to: '/concepts/key-terms/enrich-data/',
},
];

const DEVELOPER_DOCS_REDIRECTS: Redirect[] = [
Expand Down Expand Up @@ -3512,7 +3576,7 @@ const DEVELOPER_DOCS_REDIRECTS: Redirect[] = [
];

const redirectMap = new Map(
(isDeveloperDocs ? DEVELOPER_DOCS_REDIRECTS : SDK_DOCS_REDIRECTS).map(r => [
(isDeveloperDocs ? DEVELOPER_DOCS_REDIRECTS : USER_DOCS_REDIRECTS).map(r => [
r.from as string,
r.to,
])
Expand Down

0 comments on commit 42a0e03

Please sign in to comment.