# sentry-browser-sdk

Adopt this skill: https://proskills.md/skills/sdk-setup/getsentry-sentry-for-ai-skills-legacy-sentry-browser-sdk

Page: https://proskills.md/skills/sdk-setup/getsentry-sentry-for-ai-skills-legacy-sentry-browser-sdk
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: skills-legacy/sentry-browser-sdk/SKILL.md
size: 8070
upstream: https://github.com/getsentry/sentry-for-ai/blob/main/skills-legacy/sentry-browser-sdk/SKILL.md

````text
---
name: sentry-browser-sdk
description: Full Sentry SDK setup for browser JavaScript. Use when asked to "add Sentry to a website", "install @sentry/browser", or configure error monitoring, tracing, session replay, or logging for vanilla JavaScript, jQuery, static sites, or WordPress.
license: Apache-2.0
category: sdk-setup
parent: sentry-sdk-setup
disable-model-invocation: true
---

> [All Skills](../../SKILL_TREE.md) > [SDK Setup](../sentry-sdk-setup/SKILL.md) > Browser SDK

# Sentry Browser SDK

Opinionated wizard that scans your project and guides you through complete Sentry setup for browser JavaScript — vanilla JS, jQuery, static sites, WordPress, and any JS project without a framework-specific SDK.

## Invoke This Skill When

- User asks to "add Sentry to a website" or set up Sentry for plain JavaScript
- User wants to install `@sentry/browser` or configure the Loader Script
- User has a WordPress, Shopify, Squarespace, or static HTML site
- User wants error monitoring, tracing, session replay, or logging without a framework
- No framework-specific SDK applies

> **Note:** SDK versions and APIs below reflect `@sentry/browser` ≥10.0.0.
> Always verify against [docs.sentry.io/platforms/javascript/](https://docs.sentry.io/platforms/javascript/) before implementing.

---

## Phase 1: Detect

**CRITICAL — Check for frameworks first.** Framework-specific SDKs provide significantly better coverage and must be recommended before proceeding with `@sentry/browser`.

### Step 1A: Framework Detection (Redirect If Found)

```bash
# Check for React
cat package.json 2>/dev/null | grep -E '"react"'

# Check for Next.js
cat package.json 2>/dev/null | grep '"next"'

# Check for Vue
cat package.json 2>/dev/null | grep '"vue"'

# Check for Angular
cat package.json 2>/dev/null | grep '"@angular/core"'

# Check for Svelte / SvelteKit
cat package.json 2>/dev/null | grep -E '"svelte"|"@sveltejs/kit"'

# Check for Remix
cat package.json 2>/dev/null | grep -E '"@remix-run/react"|"@remix-run/node"'

# Check for Nuxt
cat package.json 2>/dev/null | grep '"nuxt"'

# Check for Astro
cat package.json 2>/dev/null | grep '"astro"'

# Check for Ember
cat package.json 2>/dev/null | grep '"ember-source"'

# Check for Node.js server frameworks (wrong SDK entirely)
cat package.json 2>/dev/null | grep -E '"express"|"fastify"|"@nestjs/core"|"koa"'
```

**If a framework is detected, stop and redirect:**

| Framework detected | Redirect to |
|-------------------|-------------|
| `next` | Load `sentry-nextjs-sdk` skill — **do not proceed here** |
| `react` (without Next.js) | Load `sentry-react-sdk` skill — **do not proceed here** |
| `vue` | Suggest `@sentry/vue` — see [docs.sentry.io/platforms/javascript/guides/vue/](https://docs.sentry.io/platforms/javascript/guides/vue/) |
| `@angular/core` | Suggest `@sentry/angular` — see [docs.sentry.io/platforms/javascript/guides/angular/](https://docs.sentry.io/platforms/javascript/guides/angular/) |
| `@sveltejs/kit` | Load `sentry-svelte-sdk` skill — **do not proceed here** |
| `svelte` (SPA, no kit) | Suggest `@sentry/svelte` — see [docs.sentry.io/platforms/javascript/guides/svelte/](https://docs.sentry.io/platforms/javascript/guides/svelte/) |
| `@remix-run` | Suggest `@sentry/remix` — see [docs.sentry.io/platforms/javascript/guides/remix/](https://docs.sentry.io/platforms/javascript/guides/remix/) |
| `nuxt` | Suggest `@sentry/nuxt` — see [docs.sentry.io/platforms/javascript/guides/nuxt/](https://docs.sentry.io/platforms/javascript/guides/nuxt/) |
| `astro` | Suggest `@sentry/astro` — see [docs.sentry.io/platforms/javascript/guides/astro/](https://docs.sentry.io/platforms/javascript/guides/astro/) |
| `ember-source` | Suggest `@sentry/ember` — see [docs.sentry.io/platforms/javascript/guides/ember/](https://docs.sentry.io/platforms/javascript/guides/ember/) |
| `express` / `fastify` / `@nestjs/core` | This is a Node.js server — load `sentry-node-sdk` or `sentry-nestjs-sdk` skill |

> **Why redirect matters:** Framework SDKs add router-aware transactions, error boundaries, component tracking, and often SSR coverage. Using `@sentry/browser` directly in a React or Next.js app loses all of that.

Only continue with `@sentry/browser` if **no framework is detected**.

### Step 1B: Installation Method Detection

```bash
# Check if there's a package.json at all (bundler environment)
ls package.json 2>/dev/null

# Check package manager
ls package-lock.json yarn.lock pnpm-lock.yaml bun.lockb 2>/dev/null

# Check build tool
ls vite.config.ts vite.config.js webpack.config.js rollup.config.js esbuild.config.js 2>/dev/null
cat package.json 2>/dev/null | grep -E '"vite"|"webpack"|"rollup"|"esbuild"'

# Check for CMS or static site indicators
ls wp-config.php wp-content/ 2>/dev/null   # WordPress
ls _config.yml _config.yaml 2>/dev/null    # Jekyll
ls config.toml 2>/dev/null                 # Hugo
ls .eleventy.js 2>/dev/null                # Eleventy

# Check for existing Sentry
cat package.json 2>/dev/null | grep '"@sentry/'
grep -r "sentry-cdn.com\|js.sentry-cdn.com" . --include="*.html" -l 2>/dev/null | head -3
```

**What to determine:**

| Question | Impact |
|----------|--------|
| `package.json` exists + bundler? | → **Path A: npm install** |
| WordPress, Shopify, static HTML, no npm? | → **Path B: Loader Script** |
| Script tags only, no Loader Script access? | → **Path C: CDN bundle** |
| Already has `@sentry/browser`? | Skip install, go straight to feature config |
| Build tool is Vite / webpack / Rollup / esbuild? | Source maps plugin to configure |

---

## Phase 2: Recommend

Present a recommendation based on what you found. Lead with a concrete proposal, don't ask open-ended questions.

**Recommended (core coverage):**
- ✅ **Error Monitoring** — always; captures unhandled errors and promise rejections
- ✅ **Tracing** — recommended for any interactive site; tracks page load and user interactions
- ✅ **Session Replay** — recommended for user-facing apps; records sessions around errors

**Optional (enhanced observability):**
- ⚡ **User Feedback** — capture reports directly from users after errors
- ⚡ **Logging** — structured logs via `Sentry.logger.*`; requires npm or CDN logs bundle (not available via Loader Script)
- ⚡ **Profiling** — JS Self-Profiling API; beta, Chromium-only, requires `Document-Policy: js-profiling` response header

**Feature recommendation logic:**

| Feature | Recommend when... |
|---------|------------------|
| Error Monitoring | **Always** — non-negotiable baseline |
| Tracing | **Always** for interactive pages — page load + navigation spans are high-value |
| Session Replay | User-facing app, support flows, or checkout pages |
| User Feedback | Support-focused app; want in-app bug reports with screenshots |
| Logging | Structured log search or log-to-trace correlation needed; **npm path only** |
| Profiling | Performance-critical, Chromium-only app; `Document-Policy: js-profiling` header required |

**Installation path recommendation:**

| Scenario | Recommended path |
|----------|-----------------|
| Project has `package.json` + bundler | **Path A (npm)** — full features, source maps, tree-shaking |
| WordPress, Shopify, Squarespace, static HTML | **Path B (Loader Script)** — zero build tooling, always up to date |
| Static HTML without Loader Script access | **Path C (CDN bundle)** — manual `<script>` tag |

Propose: *"I recommend setting up Error Monitoring + Tracing + Session Replay using Path A (npm). Want me to also add Logging or User Feedback?"*

---

## Phase 3: Guide

### Path A: npm / yarn / pnpm (Recommended — Bundler Projects)

#### Install

```bash
npm install @sentry/browser --save
# or
yarn add @sentry/browser
# or
pnpm add @sentry/browser
```

#### Create `src/instrument.ts`

Sentry must initialize **before any other code runs**. Put `Sentry.init()` in a dedicated sidecar file:

```typescript
import * as Sentry from "@sentry/browser";

Sentry.init({
  dsn: import.meta.env.VITE_SENTRY_DSN, // Adjust pe
````

## File: README.md
upstream: https://github.com/getsentry/sentry-for-ai/blob/main/README.md

````text
# Sentry for AI

> [!IMPORTANT]
> **This is a skill *source* repository — not something you install directly.** The
> skills here are built from this source into a portable
> [Agent Plugin](https://github.com/getsentry/agent-plugin) and installable
> client-specific plugins for
> [Google Antigravity](https://github.com/getsentry/plugin-antigravity),
> [Claude Code](https://github.com/getsentry/plugin-claude),
> [GitHub Copilot](https://github.com/getsentry/plugin-copilot),
> [Cursor](https://github.com/getsentry/plugin-cursor),
> [Codex](https://github.com/getsentry/plugin-codex), and
> [Grok](https://github.com/getsentry/plugin-grok) — install one of those, not this
> repo. They’re also served over HTTP at [skills.sentry.dev](https://skills.sentry.dev)
> for agents to fetch directly.
> In the future we may also publish the skills as a generic, standalone skills
> repository.

Your AI coding assistant already knows how to write code.
This plugin teaches it Sentry — how to set it up, how to find and fix production issues,
and how to get the most out of every feature.

Whether you’re adding Sentry to a new project, debugging a spike in errors, or
configuring alerts, just ask.
The plugin gives your assistant the context it needs to do it right.

Supports the [**Agent Plugins standard**](https://agent-plugins.org/),
[**Google Antigravity**](https://github.com/getsentry/plugin-antigravity),
[**Claude Code**](https://github.com/getsentry/plugin-claude),
[**GitHub Copilot**](https://github.com/getsentry/plugin-copilot),
[**Cursor**](https://github.com/getsentry/plugin-cursor),
[**Codex**](https://github.com/getsentry/plugin-codex), and
[**Grok**](https://github.com/getsentry/plugin-grok).

## What You Can Do

**Set up Sentry in any project** — SDK setup wizards that detect your stack, recommend
the right features, and walk through the full installation.
No copy-pasting from docs.

```
Add Sentry to my Next.js app
Set up Sentry in my Rails project
Add error monitoring to my iOS app
```

**Find and fix production issues** — Query your Sentry environment, triage errors, and
fix them in place.

```
What are the top errors in the last 24 hours?
Which issues are affecting the most users?
Fix the recent Sentry errors
```

**Review code with Sentry context** — Automatically resolve bugs that Sentry or Seer
flag in pull request comments.

```
Review PR #118 and fix the Sentry comments
```

**Configure monitoring** — Set up alerts, instrument AI/LLM calls, connect OpenTelemetry
pipelines.

```
Create a Slack alert for new high-priority issues
Monitor my OpenAI calls with Sentry
Set up OTel Collector with Sentry exporter
```

## Distribution

This repository is the single source of truth for all skills, but it is not itself an
installable plugin.
Each assistant needs the plugin in a slightly different shape, so the
per-agent plugins are **built** from it by the build scripts under
`src/plugins/<agent>/build.sh`. CI runs these on every push and deploys each result to
its own **distribution repository**, whose root is exactly that agent’s plugin:

| Agent | Distribution repository |
| --- | --- |
| Agent Plugins 1.0.0 | [`getsentry/agent-plugin`](https://github.com/getsentry/agent-plugin) |
| Google Antigravity | [`getsentry/plugin-antigravity`](https://github.com/getsentry/plugin-antigravity) |
| Claude Code | [`getsentry/plugin-claude`](https://github.com/getsentry/plugin-claude) |
| GitHub Copilot CLI / VS Code | [`getsentry/plugin-copilot`](https://github.com/getsentry/plugin-copilot) |
| Cursor | [`getsentry/plugin-cursor`](https://github.com/getsentry/plugin-cursor) |
| Codex | [`getsentry/plugin-codex`](https://github.com/getsentry/plugin-codex) |
| Grok | [`getsentry/plugin-grok`](https://github.com/getsentry/plugin-grok) |

These repositories are generated; do not edit them.
Each one’s README has the install instructions for that agent.

The skill library is also browsable at [skills.sentry.dev](https://skills.sentry.dev)
and available through the [`skills.sh`](https://www.skills.sh/getsentry/sentry-for-ai)
installer.

### Build it yourself

Each `src/plugins/<agent>/build.sh` takes an output directory and writes that agent’s
plugin into it (the Codex build moves the plugin under `plugins/sentry/` and swaps the
skill tree’s `disable-model-invocation` flags for Codex’s `agents/openai.yaml` policy):

```bash
git clone https://github.com/getsentry/sentry-for-ai.git
cd sentry-for-ai
src/plugins/agent-plugin/build.sh /tmp/sentry-agent-plugin
```

To build any target locally, run `src/plugins/<agent>/build.sh <output-dir>`
(`agent-plugin`, `antigravity`, `claude`, `copilot`, `cursor`, `codex`, or `grok`).

## Skills

### Core

| Skill | What it does |
| --- | --- |
| `sentry-get-started` | Guided entry point — orients to your current Sentry setup and routes to the right skill |
| `sentry-instrument` | Add Sentry to a project, or wire up any signal — error monitoring, tracing, logging, metrics, profiling, session replay, user feedback, cron check-ins, and AI/LLM monitoring. Detects your platform and pulls the code from the reference library. |
| `sentry-debug-issue` | Find a Sentry issue, pull full context, optionally run Seer root-cause / autofix, apply the fix, and resolve it |

### Feature Setup

| Skill | What it does |
| --- | --- |
| `sentry-otel-exporter-setup` | Configure OTel Collector with the Sentry exporter for multi-project routing |
| `sentry-create-alert` | Create alerts via the Sentry workflow engine API |
| `sentry-snapshots-cocoa` | Set up Sentry Snapshots for Apple/Cocoa projects |

### Reference Library

`sentry-instrument` doesn’t hard-code platform steps — it pulls them from a shared
library that the build hydrates into the skill:

- **`src/references/sdks/<platform>/`** — per-platform install and per-signal code, one
  directory per supported platform.
- **`src/references/concepts/`** — per-signal strategy: errors, tracing, logging,
  metrics, profiling, session replay, user feedback, crons, uptime, releases, data
  scrubbing, and choosing-a-signal.

> Superseded per-SDK “wizard” skills are frozen under `skills-legacy/`, excluded from
> the plugin build.

## Prerequisites

The plugin configures the [Sentry MCP server](https://mcp.sentry.dev) automatically on
install. No extra setup needed.

Some skills require the [GitHub CLI](https://cli.github.com/):

```bash
brew install gh    # macOS
gh auth login
```

## Contributing

Skills follow the [Agent Skills specification](https://agentskills.io).
Each skill is a directory with a `SKILL.md` file containing YAML frontmatter and
markdown instructions.
A skill can declare the shared references it needs in a `references.yml` manifest; the
build hydrates the matching files from the shared library at `references/` into the
skill so the shipped copy is self-contained.

## License

MIT
````
