Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c92cc9f
1
nitedani Nov 27, 2025
0e40b15
Refactor code structure for improved readability and maintainability
nitedani Nov 27, 2025
bf74ae8
fix: update server path in photon config and add server entry plugin …
nitedani Dec 14, 2025
86f4a68
refactor: remove redundant comments regarding Sentry instrumentation …
nitedani Dec 14, 2025
1ce4aa7
refactor: update Sentry configuration and improve plugin integration
nitedani Dec 15, 2025
e2778b5
Merge remote-tracking branch 'origin/main' into nitedani/vike-react-s…
brillout Dec 17, 2025
108bd39
align tsconfig.json
brillout Dec 17, 2025
7f34286
feat: enhance Sentry integration with new configuration options and u…
nitedani Dec 17, 2025
8324d9c
minor
nitedani Dec 17, 2025
540635c
add function config support and separate sentryVite config
nitedani Dec 17, 2025
0252b6d
run format
nitedani Dec 18, 2025
a66a60c
docs: update README.md
nitedani Dec 18, 2025
dd221bc
minor
nitedani Dec 18, 2025
63937e0
feat: add hook wrapper for instrumentation with Sentry
nitedani Jan 6, 2026
b3ad69c
docs: update README.md to include Vike hooks instrumentation with onH…
nitedani Jan 6, 2026
2243d24
chore: update vike dependency to version 0.4.252 across all packages
nitedani Jan 13, 2026
6e1c6f5
refactor
nitedani Jan 13, 2026
d81d704
minor
nitedani Jan 13, 2026
016ddd5
refactor
nitedani Jan 13, 2026
58c6361
feat: integrate Sentry with adaptive sampling and error tracking
nitedani Jan 15, 2026
91e7427
Merge remote-tracking branch 'origin/main' into nitedani/vike-react-s…
brillout Jan 20, 2026
6faabfa
use 0.4.252-commit-3c0065c
brillout Jan 20, 2026
1c61729
minor
brillout Jan 20, 2026
9a95e3f
update ts usage
brillout Jan 20, 2026
e6b18de
refactor: remove unused Sentry client settings and update error handling
nitedani Feb 10, 2026
9843681
format
nitedani Feb 10, 2026
af3454d
feat: add assertWarning function for improved error handling and logging
nitedani Feb 10, 2026
11d0f2f
docs: update README with additional Sentry options and configuration …
nitedani Feb 10, 2026
557d0c5
minor
nitedani Feb 10, 2026
3029508
minor
nitedani Feb 10, 2026
8b755c7
add warning in readme
nitedani Feb 10, 2026
39f76ea
example readme
nitedani Feb 10, 2026
f210e5f
feat: add Sentry test scripts for development and production environm…
nitedani Feb 10, 2026
6b6cc33
remove ai file
nitedani Feb 10, 2026
7c86728
Merge remote-tracking branch 'origin/main' into nitedani/vike-react-s…
brillout Feb 11, 2026
cfc8e34
revert outdated changes
brillout Feb 11, 2026
91a74a0
align vike version
brillout Feb 11, 2026
e533853
require vike version
brillout Feb 11, 2026
df8401b
polish readme
brillout Feb 11, 2026
b9e6f86
readme: update toc
brillout Feb 11, 2026
8165b7a
further polish readme
brillout Feb 11, 2026
b135a26
align tsconfig.json
brillout Feb 11, 2026
076933e
remove react peer dep
brillout Feb 11, 2026
45f55cd
rm universal-middlewares
brillout Feb 11, 2026
be6255c
update lock file
brillout Feb 11, 2026
abad0ab
make @brillout/vite-plugin-server-entry direct dep
brillout Feb 11, 2026
993a1d2
re-add react peer dep
brillout Feb 11, 2026
8a60edc
use local vike-react version
brillout Feb 11, 2026
c011702
minor refactor
brillout Feb 11, 2026
93d4c83
fix assert() bug
brillout Feb 11, 2026
a321408
minor refactor
brillout Feb 11, 2026
745aefb
polish
brillout Feb 11, 2026
d6c97ab
polish
brillout Feb 11, 2026
bd0d142
don't use original error
brillout Feb 11, 2026
d1f12db
minor refactor
brillout Feb 11, 2026
753b3bb
minor refactor
brillout Feb 11, 2026
0fcf7f9
improve readme intro
brillout Feb 11, 2026
b1ff613
remove plugin export
brillout Feb 11, 2026
84b81f6
Make `+sentry` config async with `getGlobalContext()` (#212)
Copilot Feb 11, 2026
4cc9a09
revert readme
brillout Feb 11, 2026
9a42cf6
update readme
brillout Feb 11, 2026
7a4d228
readme: polish
brillout Feb 11, 2026
d2b0c01
Merge remote-tracking branch 'origin/main' into nitedani/vike-react-s…
brillout Feb 11, 2026
f0d0112
remove warning
brillout Feb 11, 2026
948bb41
Merge remote-tracking branch 'origin/main' into nitedani/vike-react-s…
brillout Feb 11, 2026
f36d197
remove markErrorAsCaptured utility and its usage in onHookCall functions
nitedani Feb 12, 2026
133e1df
Apply suggestion from @brillout
brillout Feb 12, 2026
753f81c
Apply suggestions from code review
brillout Feb 12, 2026
9345ecf
polish readme
brillout Feb 12, 2026
c4fa49b
readme: minor
brillout Feb 12, 2026
636d7f2
[AI] Remove trailing commas in code blocks
brillout Feb 12, 2026
572fc2e
readme: improve
brillout Feb 12, 2026
3c330b9
readme: minor
brillout Feb 12, 2026
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
7 changes: 7 additions & 0 deletions examples/sentry/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Required: Your Sentry DSN (public, safe to expose to the browser)
PUBLIC_ENV__SENTRY_DSN=your-dsn-url

# Required for source map upload: Sentry Auth Token
# Create at https://sentry.io/settings/account/api/auth-tokens/
# Required scopes: project:read, project:releases, project:write
SENTRY_AUTH_TOKEN=sntryu_xxxxx
8 changes: 8 additions & 0 deletions examples/sentry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist/
node_modules/
.DS_Store
*.log
.env
.env.local
.env.production

2 changes: 2 additions & 0 deletions examples/sentry/.test-dev.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { testRun } from './.testRun'
testRun('pnpm run dev')
2 changes: 2 additions & 0 deletions examples/sentry/.test-prod.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { testRun } from './.testRun'
testRun('pnpm run prod')
94 changes: 94 additions & 0 deletions examples/sentry/.testRun.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
export { testRun }

import { test, expect, run, fetchHtml, page, getServerUrl, autoRetry } from '@brillout/test-e2e'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const TEST_DSN = 'https://8de66fe8dda3a86d986df8ee3aa09f72@o4510438936412161.ingest.de.sentry.io/4510438941655120'

function setupEnv() {
const envPath = path.join(__dirname, '.env')
const examplePath = path.join(__dirname, '.env.example')
let content = fs.readFileSync(examplePath, 'utf-8')
content = content.replace('your-dsn-url', TEST_DSN)
fs.writeFileSync(envPath, content)
}

function testRun(cmd: 'pnpm run dev' | 'pnpm run prod') {
setupEnv()
run(cmd, {
// We intentionally throw errors to test Sentry error reporting
tolerateError: ({ logText }) =>
logText.includes('This is a test error sent to Sentry!') ||
logText.includes('This is an async error sent to Sentry!') ||
logText.includes('[sentry-vite-plugin]'),
})

test('page content is rendered to HTML', async () => {
const html = await fetchHtml('/')
expect(html).toContain('<h1>Vike + React + Sentry Example</h1>')
})

test('page is rendered to the DOM and interactive', async () => {
await page.goto(getServerUrl() + '/')
expect(await page.textContent('h1')).toBe('Vike + React + Sentry Example')
await testCounter()
})

test('sync error is sent to Sentry', async () => {
await page.goto(getServerUrl() + '/')
await testSentryRequest('Throw Sync Error', 'This is a test error sent to Sentry!')
})

test('async error is sent to Sentry', async () => {
await page.goto(getServerUrl() + '/')
await testSentryRequest('Throw Async Error', 'This is an async error sent to Sentry!')
})
}

async function testCounter() {
// autoRetry() in case page isn't hydrated yet
await autoRetry(
async () => {
const heading = page.locator('h2', { hasText: 'Counter' })
expect(await heading.textContent()).toBe('Counter: 0')
},
{ timeout: 5 * 1000 },
)
await autoRetry(
async () => {
const btn = page.locator('button', { hasText: 'Increment' })
await btn.click()
const heading = page.locator('h2', { hasText: 'Counter' })
expect(await heading.textContent()).toBe('Counter: 1')
},
{ timeout: 5 * 1000 },
)
}

async function testSentryRequest(buttonText: string, expectedMessage: string) {
const sentryBodies: string[] = []

// Listen for Sentry envelope requests
const listener = (req: { url: () => string; method: () => string; postData: () => string | null }) => {
if (req.url().includes('sentry.io') && req.method() === 'POST') {
sentryBodies.push(req.postData() || '')
}
}
page.on('request', listener)

const btn = page.locator('button', { hasText: buttonText })
await btn.click()

await autoRetry(
async () => {
const match = sentryBodies.find((body) => body.includes(expectedMessage))
expect(match).toBeTruthy()
},
{ timeout: 10 * 1000 },
)

page.removeListener('request', listener)
}
64 changes: 64 additions & 0 deletions examples/sentry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Vike + React + Sentry Example

This example demonstrates how to integrate Sentry error tracking with a Vike + React application using [`vike-react-sentry`](https://github.com/vikejs/vike-react/tree/main/packages/vike-react-sentry).

## Features

- Client-side error tracking
- Server-side error tracking
- Performance monitoring and tracing
- Source map uploads for production debugging

## Setup

1. Install dependencies:

```bash
pnpm install
```

2. Copy `.env.example` to `.env` and fill in your Sentry DSN:

```bash
cp .env.example .env
```

3. Run development server:

```bash
pnpm dev
```

4. Build for production (source maps are uploaded when `SENTRY_AUTH_TOKEN` is set):

```bash
pnpm build
pnpm prod
```

## Configuration

The Sentry DSN and auth token are configured via environment variables in `.env`:

```bash
PUBLIC_ENV__SENTRY_DSN=https://xxxxx@xxxxx.ingest.sentry.io/xxxxx
SENTRY_AUTH_TOKEN=sntryu_xxxxx
```

You can optionally customize Sentry SDK options in `pages/+config.ts`:

```ts
export default {
sentry: {
tracesSampleRate: 1.0,
debug: true,
}
}
```

See the [`vike-react-sentry` README](https://github.com/vikejs/vike-react/tree/main/packages/vike-react-sentry) for all available options.

## Learn More

- [Vike Documentation](https://vike.dev)
- [Sentry Documentation](https://docs.sentry.io)
26 changes: 26 additions & 0 deletions examples/sentry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"scripts": {
"dev": "vike dev",
"build": "vike build",
"prod": "vike build && node ./dist/server/index.mjs"
},
"dependencies": {
"@photonjs/hono": "^0.1.7",
"@sentry/react": "^10.22.0",
"@sentry/node": "^10.22.0",
"@sentry/vite-plugin": "^4.6.0",
"@types/react": "^19.1.13",
"@types/react-dom": "^19.1.9",
"@vitejs/plugin-react": "^5.0.3",
"hono": "^4.7.14",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"typescript": "^5.9.2",
"vike": "^0.4.253",
"vike-photon": "^0.1.20",
"vike-react": "0.6.10",
"vike-react-sentry": "0.1.0",
"vite": "^7.1.7"
},
"type": "module"
}
15 changes: 15 additions & 0 deletions examples/sentry/pages/+config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export { config }

import type { Config } from 'vike/types'
import vikeReact from 'vike-react/config'
import vikePhoton from 'vike-photon/config'
import vikeReactSentry from 'vike-react-sentry/config'

const config = {
title: 'Vike + React + Sentry Example',
extends: [vikeReact, vikePhoton, vikeReactSentry],
// Photon configuration
photon: {
server: '../server/index.ts',
},
} satisfies Config
76 changes: 76 additions & 0 deletions examples/sentry/pages/index/+Page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
export { Page }

import { useState } from 'react'

function Page() {
const [count, setCount] = useState(0)

const throwError = () => {
throw new Error('This is a test error sent to Sentry!')
}

const throwAsyncError = async () => {
await new Promise((resolve) => setTimeout(resolve, 100))
throw new Error('This is an async error sent to Sentry!')
}

return (
<div style={{ padding: '20px', fontFamily: 'system-ui' }}>
<h1>Vike + React + Sentry Example</h1>

<p>This example demonstrates Sentry error tracking integration with Vike.</p>

<div style={{ marginTop: '20px' }}>
<h2>Counter: {count}</h2>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>

<div style={{ marginTop: '20px' }}>
<h2>Test Error Tracking</h2>
<p>Click these buttons to send test errors to Sentry:</p>

<div style={{ display: 'flex', gap: '10px', marginTop: '10px' }}>
<button
onClick={throwError}
style={{
padding: '10px',
backgroundColor: '#ff4444',
color: 'white',
border: 'none',
borderRadius: '4px',
cursor: 'pointer',
}}
>
Throw Sync Error
</button>

<button
onClick={throwAsyncError}
style={{
padding: '10px',
backgroundColor: '#ff8844',
color: 'white',
border: 'none',
borderRadius: '4px',
cursor: 'pointer',
}}
>
Throw Async Error
</button>
</div>
</div>

<div style={{ marginTop: '40px', padding: '15px', backgroundColor: '#f0f0f0', borderRadius: '4px' }}>
<h3>Configuration</h3>
<p>
Edit <code>pages/+config.ts</code> to configure your Sentry DSN and options.
</p>
<ul>
<li>Client-side errors are automatically captured</li>
<li>Server-side errors are automatically captured</li>
<li>Distributed tracing connects server and client errors</li>
</ul>
</div>
</div>
)
}
13 changes: 13 additions & 0 deletions examples/sentry/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Hono } from 'hono'
import { apply, serve } from '@photonjs/hono'

function startServer() {
const app = new Hono()

// Apply Vike and Vike extensions middleware
apply(app)

return serve(app)
}

export default startServer()
19 changes: 19 additions & 0 deletions examples/sentry/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"strict": true,
"module": "ES2020",
"moduleResolution": "bundler",
"target": "ES2020",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["vite/client"],
"jsx": "react-jsx",
"skipLibCheck": true,
"esModuleInterop": true
},
"include": [
"**/*",
// Include .test* files
// https://github.com/microsoft/TypeScript/issues/49555
"**/.*"
]
}
7 changes: 7 additions & 0 deletions examples/sentry/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import vike from 'vike/plugin'

export default defineConfig({
plugins: [react(), vike()],
})
2 changes: 1 addition & 1 deletion packages/vike-react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@tanstack/react-query": ">=5.0.0",
"react": ">=18.0.0",
"react-streaming": ">=0.4.6",
"vike": ">=0.4.242",
"vike": ">=0.4.252",
"vike-react": ">=0.6.8"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/vike-react-sentry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/dist/
5 changes: 5 additions & 0 deletions packages/vike-react-sentry/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 0.1.0

Initial release.
Loading