Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4c4df83
Changes from background agent bc-35f9d74e-0d62-4250-a112-37ced1f68837
cursoragent Sep 10, 2025
3829d6d
Refactor platform selector and doc tree key generation
cursoragent Sep 10, 2025
ff37338
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 10, 2025
e90acbd
Refactor: Stabilize platform selector search value updates
cursoragent Sep 10, 2025
49f03e8
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 10, 2025
b358c46
Refactor PlatformSelector to use startTransition for search
cursoragent Sep 11, 2025
49b42e3
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 11, 2025
8637559
Fix: PlatformSelector key collision and add unique key to default guide
cursoragent Sep 11, 2025
c8d7092
Refactor: Remove unnecessary startTransition from PlatformSelector
cursoragent Sep 11, 2025
fc3723e
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 11, 2025
87ed033
Refactor JavaScript platform redirect and improve stored platform han…
cursoragent Sep 11, 2025
b824aad
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 11, 2025
ae3fc1d
Refactor: Improve platform selector search and virtual guide stability
cursoragent Sep 11, 2025
8240cd4
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 11, 2025
77605b3
Refactor: Update JS platform key and remove unused handler
cursoragent Sep 11, 2025
d829e32
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 11, 2025
ee1c1d7
Refactor platform selector logic for clarity and correctness
cursoragent Sep 11, 2025
fab73dd
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 11, 2025
7ea14fa
Add debounced search to platform selector
cursoragent Sep 12, 2025
e241867
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 12, 2025
4bbb823
Refactor PlatformSelector and add browser guide for JS
cursoragent Sep 12, 2025
ba28fc5
[getsentry/action-github-commit] Auto commit
getsantry[bot] Sep 12, 2025
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
33 changes: 33 additions & 0 deletions docs/platforms/javascript/guides/browser/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Browser JavaScript
description: Learn how to set up Sentry's Browser JavaScript SDK to automatically report errors and exceptions in your application.
sidebar_order: 1
---

<Alert level="info">
If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page.
</Alert>

Sentry captures data by using an SDK within your application's runtime.

<PlatformContent includePath="getting-started-install" />

## Configure

Configuration should happen as early as possible in your application's lifecycle.

<PlatformContent includePath="getting-started-config" />

## Verify

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

<PlatformContent includePath="getting-started-verify" />

## Next Steps

For complete details on DSN configuration, additional options, and type information, see our TypeScript docs.

Alert us to which features you'd like us to expand upon:

<GuideGrid platform="javascript" />
48 changes: 29 additions & 19 deletions src/components/platformSelector/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
'use client';
import {
Fragment,
Ref,
startTransition,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import {Fragment, Ref, useEffect, useMemo, useRef, useState} from 'react';
import {Combobox, ComboboxItem, ComboboxList, ComboboxProvider} from '@ariakit/react';
import {CaretRightIcon, CaretSortIcon, MagnifyingGlassIcon} from '@radix-ui/react-icons';
import * as RadixSelect from '@radix-ui/react-select';
Expand Down Expand Up @@ -95,12 +87,21 @@ export function PlatformSelector({

const router = useRouter();
const onPlatformChange = (platformKey: string) => {
const platform_ = platformsAndGuides.find(
platform => platform.key === platformKey.replace('-redirect', '')
);
if (platform_) {
localStorage.setItem('active-platform', platform_.key);
router.push(platform_.url);
const cleanKey = platformKey.replace('-redirect', '');
let targetPlatform = platformsAndGuides.find(platform => platform.key === cleanKey);

// Special handling for JavaScript: when platform "javascript" is selected,
// redirect to the real browser guide "javascript.browser" instead
if (cleanKey === 'javascript' && targetPlatform?.type === 'platform') {
const browserGuide = platformsAndGuides.find(p => p.key === 'javascript.browser');
if (browserGuide) {
targetPlatform = browserGuide;
}
}

if (targetPlatform) {
localStorage.setItem('active-platform', targetPlatform.key);
router.push(targetPlatform.url);
}
};

Expand All @@ -114,9 +115,18 @@ export function PlatformSelector({
}, [open]);

const [storedPlatformKey, setStoredPlatformKey] = useState<string | null>(null);
const storedPlatform = platformsAndGuides.find(
let storedPlatform = platformsAndGuides.find(
platform => platform.key === storedPlatformKey
);

// Handle stored JavaScript platform: redirect to browser guide
if (storedPlatformKey === 'javascript' && storedPlatform?.type === 'platform') {
const browserGuide = platformsAndGuides.find(p => p.key === 'javascript.browser');
if (browserGuide) {
storedPlatform = browserGuide;
}
}

useEffect(() => {
if (currentPlatformKey) {
localStorage.setItem('active-platform', currentPlatformKey);
Expand All @@ -142,7 +152,7 @@ export function PlatformSelector({
<div>
<RadixSelect.Root
defaultValue={currentPlatformKey}
value={showStoredPlatform ? storedPlatformKey : undefined}
value={showStoredPlatform ? storedPlatform?.key : undefined}
onValueChange={onPlatformChange}
open={open}
onOpenChange={setOpen}
Expand All @@ -151,7 +161,7 @@ export function PlatformSelector({
open={open}
setOpen={setOpen}
includesBaseElement={false}
setValue={v => startTransition(() => setSearchValue(v))}
setValue={setSearchValue}
>
<RadixSelect.Trigger aria-label="Platform" className={styles.select}>
<RadixSelect.Value placeholder="Choose your SDK" />
Expand Down Expand Up @@ -242,7 +252,7 @@ export function PlatformSelector({
</RadixSelect.Content>
</ComboboxProvider>
</RadixSelect.Root>
{showStoredPlatform && (
{showStoredPlatform && storedPlatform && (
<div className="mt-3">
<SidebarLink
href={storedPlatform.url}
Expand Down
11 changes: 2 additions & 9 deletions src/docTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,19 +372,12 @@ function extractGuides(platformNode: DocNode): PlatformGuide[] {
return [];
}

// If a `platformTitle` is defined, we add a virtual guide
const defaultGuide = platformNode.frontmatter.platformTitle
? {
...nodeToGuide(platformNode.slug, platformNode),
key: platformNode.slug,
}
: undefined;

// No virtual guide needed - we now have a real browser guide
const childGuides = guidesNode.children
.filter(({path}) => !isVersioned(path))
.map(n => nodeToGuide(platformNode.slug, n));

return defaultGuide ? [defaultGuide, ...childGuides] : childGuides;
return childGuides;
}

const extractIntegrations = (p: DocNode): PlatformIntegration[] => {
Expand Down
Loading