mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
[PRO-974] add sentry for both client and server (#20)
Basically ran through the remix + cloudflare setup docs.
This commit is contained in:
parent
38d389a42e
commit
e4a57bf59e
@ -108,3 +108,6 @@ DEFAULT_NUM_CTX=
|
|||||||
# set these to enable opentelemetry
|
# set these to enable opentelemetry
|
||||||
HONEYCOMB_API_KEY=
|
HONEYCOMB_API_KEY=
|
||||||
HONEYCOMB_DATASET=
|
HONEYCOMB_DATASET=
|
||||||
|
|
||||||
|
# If you're using Sentry for error tracking, include your Sentry Auth token here to upload sourcemaps
|
||||||
|
SENTRY_AUTH_TOKEN=
|
||||||
|
|||||||
7
.github/actions/setup-and-build/action.yaml
vendored
7
.github/actions/setup-and-build/action.yaml
vendored
@ -9,6 +9,11 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: '20.15.1'
|
default: '20.15.1'
|
||||||
|
sentry-auth-token:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ''
|
||||||
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
@ -30,3 +35,5 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
pnpm install
|
pnpm install
|
||||||
pnpm run build
|
pnpm run build
|
||||||
|
env:
|
||||||
|
SENTRY_AUTH_TOKEN: ${{ inputs.sentry-auth-token }}
|
||||||
|
|||||||
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -10,7 +10,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: CI/CD (and deploy on main)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -18,6 +18,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Setup and Build
|
- name: Setup and Build
|
||||||
uses: ./.github/actions/setup-and-build
|
uses: ./.github/actions/setup-and-build
|
||||||
|
with:
|
||||||
|
sentry-auth-token: ${{ github.ref == 'refs/heads/main' && secrets.SENTRY_AUTH_TOKEN || '' }}
|
||||||
|
|
||||||
- name: Run type check
|
- name: Run type check
|
||||||
run: pnpm run typecheck
|
run: pnpm run typecheck
|
||||||
|
|||||||
@ -1,7 +1,17 @@
|
|||||||
|
import * as Sentry from '@sentry/remix';
|
||||||
import { RemixBrowser } from '@remix-run/react';
|
import { RemixBrowser } from '@remix-run/react';
|
||||||
import { startTransition } from 'react';
|
import { startTransition } from 'react';
|
||||||
import { hydrateRoot } from 'react-dom/client';
|
import { hydrateRoot } from 'react-dom/client';
|
||||||
|
|
||||||
|
Sentry.init({
|
||||||
|
dsn: 'https://5465638ce4f73a256d861820b3a4dad4@o437061.ingest.us.sentry.io/4508853437399040',
|
||||||
|
integrations: [Sentry.replayIntegration()],
|
||||||
|
|
||||||
|
// Session Replay
|
||||||
|
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
|
||||||
|
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
|
||||||
|
});
|
||||||
|
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
hydrateRoot(document.getElementById('root')!, <RemixBrowser />);
|
hydrateRoot(document.getElementById('root')!, <RemixBrowser />);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import * as Sentry from '@sentry/remix';
|
||||||
import type { AppLoadContext, EntryContext } from '@remix-run/cloudflare';
|
import type { AppLoadContext, EntryContext } from '@remix-run/cloudflare';
|
||||||
import { RemixServer } from '@remix-run/react';
|
import { RemixServer } from '@remix-run/react';
|
||||||
import { isbot } from 'isbot';
|
import { isbot } from 'isbot';
|
||||||
@ -6,6 +7,8 @@ import { renderHeadToString } from 'remix-island';
|
|||||||
import { Head } from './root';
|
import { Head } from './root';
|
||||||
import { themeStore } from '~/lib/stores/theme';
|
import { themeStore } from '~/lib/stores/theme';
|
||||||
|
|
||||||
|
export const handleError = Sentry.sentryHandleError;
|
||||||
|
|
||||||
export default async function handleRequest(
|
export default async function handleRequest(
|
||||||
request: Request,
|
request: Request,
|
||||||
responseStatusCode: number,
|
responseStatusCode: number,
|
||||||
|
|||||||
10
app/root.tsx
10
app/root.tsx
@ -1,6 +1,7 @@
|
|||||||
|
import { captureRemixErrorBoundaryError } from '@sentry/remix';
|
||||||
import { useStore } from '@nanostores/react';
|
import { useStore } from '@nanostores/react';
|
||||||
import type { LinksFunction } from '@remix-run/cloudflare';
|
import type { LinksFunction } from '@remix-run/cloudflare';
|
||||||
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react';
|
import { Links, Meta, Outlet, Scripts, ScrollRestoration, useRouteError } from '@remix-run/react';
|
||||||
import tailwindReset from '@unocss/reset/tailwind-compat.css?url';
|
import tailwindReset from '@unocss/reset/tailwind-compat.css?url';
|
||||||
import { themeStore } from './lib/stores/theme';
|
import { themeStore } from './lib/stores/theme';
|
||||||
import { stripIndents } from './utils/stripIndent';
|
import { stripIndents } from './utils/stripIndent';
|
||||||
@ -80,6 +81,13 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
|||||||
|
|
||||||
import { logStore } from './lib/stores/logs';
|
import { logStore } from './lib/stores/logs';
|
||||||
|
|
||||||
|
export const ErrorBoundary = () => {
|
||||||
|
const error = useRouteError();
|
||||||
|
captureRemixErrorBoundaryError(error);
|
||||||
|
|
||||||
|
return <div>Something went wrong</div>;
|
||||||
|
};
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const theme = useStore(themeStore);
|
const theme = useStore(themeStore);
|
||||||
|
|
||||||
|
|||||||
10
functions/_middleware.ts
Normal file
10
functions/_middleware.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import * as Sentry from '@sentry/cloudflare';
|
||||||
|
|
||||||
|
export const onRequest = [
|
||||||
|
// Make sure Sentry is the first middleware
|
||||||
|
Sentry.sentryPagesPlugin((_context) => ({
|
||||||
|
dsn: 'https://5465638ce4f73a256d861820b3a4dad4@o437061.ingest.us.sentry.io/4508853437399040',
|
||||||
|
})),
|
||||||
|
|
||||||
|
// if we ever add more middleware, add them below:
|
||||||
|
];
|
||||||
@ -78,6 +78,9 @@
|
|||||||
"@remix-run/cloudflare": "^2.15.0",
|
"@remix-run/cloudflare": "^2.15.0",
|
||||||
"@remix-run/cloudflare-pages": "^2.15.0",
|
"@remix-run/cloudflare-pages": "^2.15.0",
|
||||||
"@remix-run/react": "^2.15.0",
|
"@remix-run/react": "^2.15.0",
|
||||||
|
"@sentry/cloudflare": "^8.55.0",
|
||||||
|
"@sentry/remix": "^8",
|
||||||
|
"@sentry/vite-plugin": "^3.1.2",
|
||||||
"@uiw/codemirror-theme-vscode": "^4.23.6",
|
"@uiw/codemirror-theme-vscode": "^4.23.6",
|
||||||
"@unocss/reset": "^0.61.9",
|
"@unocss/reset": "^0.61.9",
|
||||||
"@webcontainer/api": "1.5.1-internal.8",
|
"@webcontainer/api": "1.5.1-internal.8",
|
||||||
|
|||||||
1167
pnpm-lock.yaml
1167
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@ import UnoCSS from 'unocss/vite';
|
|||||||
import { defineConfig, type ViteDevServer } from 'vite';
|
import { defineConfig, type ViteDevServer } from 'vite';
|
||||||
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
||||||
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
|
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
|
||||||
|
import { sentryVitePlugin } from '@sentry/vite-plugin';
|
||||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||||
import * as dotenv from 'dotenv';
|
import * as dotenv from 'dotenv';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
@ -49,6 +50,13 @@ export default defineConfig((config) => {
|
|||||||
tsconfigPaths(),
|
tsconfigPaths(),
|
||||||
chrome129IssuePlugin(),
|
chrome129IssuePlugin(),
|
||||||
config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
|
config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
|
||||||
|
config.mode === 'production' &&
|
||||||
|
process.env.SENTRY_AUTH_TOKEN &&
|
||||||
|
sentryVitePlugin({
|
||||||
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||||
|
org: 'replay',
|
||||||
|
project: 'nut',
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
envPrefix: ["VITE_","OPENAI_LIKE_API_BASE_URL", "OLLAMA_API_BASE_URL", "LMSTUDIO_API_BASE_URL","TOGETHER_API_BASE_URL"],
|
envPrefix: ["VITE_","OPENAI_LIKE_API_BASE_URL", "OLLAMA_API_BASE_URL", "LMSTUDIO_API_BASE_URL","TOGETHER_API_BASE_URL"],
|
||||||
css: {
|
css: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user