Skip to content

Commit

Permalink
add sentry for both client and server (using placeholder dsn for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
toshok committed Feb 12, 2025
1 parent fc89c55 commit 0463dd8
Show file tree
Hide file tree
Showing 8 changed files with 1,195 additions and 21 deletions.
9 changes: 6 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TOGETHER_API_KEY=
#Get your Hyperbolics API Key at https://app.hyperbolic.xyz/settings
#baseURL="https://api.hyperbolic.xyz/v1/chat/completions"
HYPERBOLIC_API_KEY=
HYPERBOLIC_API_BASE_URL=
HYPERBOLIC_API_BASE_URL=

# Get your Mistral API Key by following these instructions -
# https://console.mistral.ai/api-keys/
Expand All @@ -78,7 +78,7 @@ LMSTUDIO_API_BASE_URL=
# You only need this environment variable set if you want to use xAI models
XAI_API_KEY=

# Get your Perplexity API Key here -
# Get your Perplexity API Key here -
# https://www.perplexity.ai/settings/api
# You only need this environment variable set if you want to use Perplexity models
PERPLEXITY_API_KEY=
Expand All @@ -98,9 +98,12 @@ AWS_BEDROCK_CONFIG=
VITE_LOG_LEVEL=debug

# Example Context Values for qwen2.5-coder:32b
#
#
# DEFAULT_NUM_CTX=32768 # Consumes 36GB of VRAM
# DEFAULT_NUM_CTX=24576 # Consumes 32GB of VRAM
# DEFAULT_NUM_CTX=12288 # Consumes 26GB of VRAM
# DEFAULT_NUM_CTX=6144 # Consumes 24GB of VRAM
DEFAULT_NUM_CTX=

# If you're using Sentry for error tracking, include your Sentry Auth token here to upload sourcemaps
SENTRY_AUTH_TOKEN=
5 changes: 5 additions & 0 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as Sentry from '@sentry/remix';
import { RemixBrowser } from '@remix-run/react';
import { startTransition } from 'react';
import { hydrateRoot } from 'react-dom/client';

Sentry.init({
dsn: 'client-dsn-goes-here',
});

startTransition(() => {
hydrateRoot(document.getElementById('root')!, <RemixBrowser />);
});
3 changes: 3 additions & 0 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Sentry from '@sentry/remix';
import type { AppLoadContext, EntryContext } from '@remix-run/cloudflare';
import { RemixServer } from '@remix-run/react';
import { isbot } from 'isbot';
Expand All @@ -6,6 +7,8 @@ import { renderHeadToString } from 'remix-island';
import { Head } from './root';
import { themeStore } from '~/lib/stores/theme';

export const handleError = Sentry.sentryHandleError;

export default async function handleRequest(
request: Request,
responseStatusCode: number,
Expand Down
10 changes: 9 additions & 1 deletion app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { captureRemixErrorBoundaryError } from '@sentry/remix';
import { useStore } from '@nanostores/react';
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 { themeStore } from './lib/stores/theme';
import { stripIndents } from './utils/stripIndent';
Expand Down Expand Up @@ -80,6 +81,13 @@ export function Layout({ children }: { children: React.ReactNode }) {

import { logStore } from './lib/stores/logs';

export const ErrorBoundary = () => {
const error = useRouteError();
captureRemixErrorBoundaryError(error);

return <div>Something went wrong</div>;
};

export default function App() {
const theme = useStore(themeStore);

Expand Down
10 changes: 10 additions & 0 deletions functions/_middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Sentry from '@sentry/cloudflare';

export const onRequest = [
// Make sure Sentry is the first middleware
Sentry.sentryPagesPlugin((_context) => ({
dsn: 'server-dsn-goes-here',
})),

// if we ever add more middleware, add them below:
];
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"node": ">=18.18.0"
},
"dependencies": {
"@ai-sdk/amazon-bedrock": "1.0.6",
"@ai-sdk/anthropic": "^0.0.39",
"@ai-sdk/cohere": "^1.0.3",
"@ai-sdk/google": "^0.0.52",
"@ai-sdk/mistral": "^0.0.43",
"@ai-sdk/openai": "^0.0.66",
"@anthropic-ai/sdk": "^0.33.1",
"@ai-sdk/amazon-bedrock": "1.0.6",
"@codemirror/autocomplete": "^6.18.3",
"@codemirror/commands": "^6.7.1",
"@codemirror/lang-cpp": "^6.0.2",
Expand Down Expand Up @@ -69,6 +69,9 @@
"@remix-run/cloudflare": "^2.15.0",
"@remix-run/cloudflare-pages": "^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",
"@unocss/reset": "^0.61.9",
"@webcontainer/api": "1.5.1-internal.8",
Expand Down
Loading

0 comments on commit 0463dd8

Please sign in to comment.