Skip to content

Commit c59947a

Browse files
authored
Remove Sentry (#2986)
1 parent 4f0a772 commit c59947a

File tree

14 files changed

+62
-658
lines changed

14 files changed

+62
-658
lines changed

.github/workflows/deploy-preview.yaml

-10
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,11 @@ jobs:
3535
- name: Sets env vars for production
3636
if: github.ref == 'refs/heads/main'
3737
run: |
38-
echo "SENTRY_ENVIRONMENT=production" >> $GITHUB_ENV
3938
echo "GITBOOK_ASSETS_PREFIX=https://static.gitbook.com" >> $GITHUB_ENV
40-
- name: Sets env vars for preview
41-
if: github.ref != 'refs/heads/main'
42-
run: |
43-
echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
4439
- name: Build Next.js with next-on-pages
4540
run: bun run turbo gitbook#build:cloudflare
4641
env:
47-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
4842
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: ${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
49-
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
50-
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
51-
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
52-
SENTRY_RELEASE: ${{ github.sha }}
5343
- id: deploy
5444
name: Deploy to Cloudflare
5545
uses: cloudflare/[email protected]

bun.lock

+18-475
Large diffs are not rendered by default.

packages/gitbook/.env.example

-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@
2323
## Caching
2424
# GITBOOK_OUTPUT_CACHE=true
2525

26-
### Sentry ###
27-
# SENTRY_DSN=xxx
28-
2926
### Silent logs
3027
# SILENT=true

packages/gitbook/.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ next-env.d.ts
2323
# visual tests
2424
screenshots/
2525

26-
# Sentry Config File
27-
.sentryclirc
28-
2926
/test-results/
3027
/playwright-report/
3128
/blob-report/

packages/gitbook/next.config.js

+42-76
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,49 @@
1-
const { withSentryConfig } = require('@sentry/nextjs');
2-
3-
module.exports = withSentryConfig(
4-
{
5-
env: {
6-
BUILD_VERSION: (process.env.GITHUB_SHA ?? '').slice(0, 7),
7-
SENTRY_RELEASE: process.env.SENTRY_RELEASE ?? '',
8-
SENTRY_DSN: process.env.SENTRY_DSN ?? '',
9-
SENTRY_ENVIRONMENT: process.env.SENTRY_ENVIRONMENT ?? 'development',
10-
GITBOOK_ASSETS_PREFIX: process.env.GITBOOK_ASSETS_PREFIX,
11-
GITBOOK_ICONS_URL: process.env.GITBOOK_ICONS_URL,
12-
GITBOOK_ICONS_TOKEN: process.env.GITBOOK_ICONS_TOKEN,
13-
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY,
14-
},
15-
16-
webpack(config, { dev, webpack }) {
17-
config.resolve.fallback = {
18-
...config.resolve.fallback,
1+
module.exports = {
2+
env: {
3+
BUILD_VERSION: (process.env.GITHUB_SHA ?? '').slice(0, 7),
4+
GITBOOK_ASSETS_PREFIX: process.env.GITBOOK_ASSETS_PREFIX,
5+
GITBOOK_ICONS_URL: process.env.GITBOOK_ICONS_URL,
6+
GITBOOK_ICONS_TOKEN: process.env.GITBOOK_ICONS_TOKEN,
7+
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY,
8+
},
199

20-
// Required for `swagger2openapi` to work:
21-
fs: false,
22-
path: false,
23-
http: false,
24-
};
10+
webpack(config) {
11+
config.resolve.fallback = {
12+
...config.resolve.fallback,
2513

26-
// Tree shake debug code for Sentry
27-
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/#tree-shaking-with-nextjs
28-
if (!dev) {
29-
config.plugins.push(
30-
new webpack.DefinePlugin({
31-
__SENTRY_DEBUG__: false,
32-
// We always init Sentry with enableTracing: false for now, so this is useless
33-
__SENTRY_TRACING__: false,
34-
__RRWEB_EXCLUDE_IFRAME__: true,
35-
__RRWEB_EXCLUDE_SHADOW_DOM__: true,
36-
__SENTRY_EXCLUDE_REPLAY_WORKER__: true,
37-
})
38-
);
39-
}
14+
// Required for `swagger2openapi` to work:
15+
fs: false,
16+
path: false,
17+
http: false,
18+
};
4019

41-
return config;
42-
},
20+
return config;
21+
},
4322

44-
async headers() {
45-
return [
46-
// Cache all static assets for 1 year
47-
{
48-
source: '/~gitbook/static/:path*',
49-
headers: [
50-
{
51-
key: 'Cache-Control',
52-
value: 'public, max-age=31536000, immutable',
53-
},
54-
],
55-
},
56-
];
57-
},
23+
async headers() {
24+
return [
25+
// Cache all static assets for 1 year
26+
{
27+
source: '/~gitbook/static/:path*',
28+
headers: [
29+
{
30+
key: 'Cache-Control',
31+
value: 'public, max-age=31536000, immutable',
32+
},
33+
],
34+
},
35+
];
36+
},
5837

59-
assetPrefix: process.env.GITBOOK_ASSETS_PREFIX,
60-
poweredByHeader: false,
38+
assetPrefix: process.env.GITBOOK_ASSETS_PREFIX,
39+
poweredByHeader: false,
6140

62-
images: {
63-
remotePatterns: [
64-
{
65-
protocol: 'https',
66-
hostname: '*.gitbook.io',
67-
},
68-
],
69-
},
41+
images: {
42+
remotePatterns: [
43+
{
44+
protocol: 'https',
45+
hostname: '*.gitbook.io',
46+
},
47+
],
7048
},
71-
{
72-
release: process.env.SENTRY_RELEASE,
73-
org: process.env.SENTRY_ORG,
74-
project: process.env.SENTRY_PROJECT,
75-
authToken: process.env.SENTRY_AUTH_TOKEN,
76-
77-
// Upload a larger set of source maps for prettier stack traces (increases build time)
78-
widenClientFileUpload: true,
79-
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
80-
tunnelRoute: '/~gitbook/monitoring',
81-
disableLogger: true,
82-
}
83-
);
49+
};

packages/gitbook/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"@radix-ui/react-checkbox": "^1.0.4",
3030
"@radix-ui/react-navigation-menu": "^1.2.3",
3131
"@radix-ui/react-popover": "^1.0.7",
32-
"@sentry/nextjs": "8.35.0",
3332
"@sindresorhus/fnv1a": "^3.1.0",
3433
"@tailwindcss/container-queries": "^0.1.1",
3534
"@tailwindcss/typography": "^0.5.16",

packages/gitbook/sentry.client.config.ts

-18
This file was deleted.

packages/gitbook/src/app/global-error.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
'use client';
22

3-
import { captureException } from '@sentry/nextjs';
43
import NextError from 'next/error';
5-
import { useEffect } from 'react';
6-
7-
export default function GlobalError({ error }: { error: Error }) {
8-
useEffect(() => {
9-
captureException(error);
10-
}, [error]);
114

5+
export default function GlobalError() {
126
return (
137
<html lang="en">
148
<body>

packages/gitbook/src/app/middleware/(site)/error.tsx

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
'use client';
22

3-
import { captureException, withScope } from '@sentry/nextjs';
4-
import React from 'react';
5-
63
import { Button } from '@/components/primitives/Button';
74
import { t, useLanguage } from '@/intl/client';
85
import { tcls } from '@/lib/tailwind';
@@ -11,18 +8,9 @@ export default function ErrorPage(props: {
118
error: Error & { digest?: string };
129
reset: () => void;
1310
}) {
14-
const { error, reset } = props;
11+
const { reset } = props;
1512
const language = useLanguage();
1613

17-
React.useEffect(() => {
18-
withScope((scope) => {
19-
if ('_componentStack' in error && error._componentStack) {
20-
scope.setExtra('componentStack', error._componentStack);
21-
}
22-
captureException(error);
23-
});
24-
}, [error]);
25-
2614
return (
2715
<div
2816
className={tcls(

packages/gitbook/src/components/Search/SearchResults.tsx

-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use client';
22

3-
import { captureException } from '@sentry/nextjs';
43
import { readStreamableValue } from 'ai/rsc';
54
import assertNever from 'assert-never';
65
import React from 'react';
@@ -132,12 +131,6 @@ export const SearchResults = React.forwardRef(function SearchResults(
132131
}
133132

134133
if (!results) {
135-
captureException(
136-
new Error(
137-
`corrupt-cache: ${global ? 'searchAllSiteContent' : 'searchSiteSpaceContent'} is ${results}`
138-
),
139-
{ extra: { results } }
140-
);
141134
setResultsState({ results: [], fetching: false });
142135
return;
143136
}

packages/gitbook/src/lib/cache/cache.ts

-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import hash from 'object-hash';
22

3-
import { captureException } from '../../sentry';
43
import { race, singletonMap } from '../async';
54
import { type TraceSpan, trace } from '../tracing';
65
import { assertIsNotV2 } from '../v2';
@@ -159,17 +158,11 @@ export function cache<Args extends any[], Result>(
159158
}
160159

161160
// Detect empty cache entries to avoid returning them.
162-
// Also log in Sentry to investigate what cache is returning empty entries.
163161
if (
164162
entry.data &&
165163
typeof entry.data === 'object' &&
166164
Object.keys(entry.data).length === 0
167165
) {
168-
captureException(
169-
new Error(
170-
`Cache entry ${key} from ${backendName} is an empty object`
171-
)
172-
);
173166
return null;
174167
}
175168

packages/gitbook/src/middleware.ts

-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { type ContentAPITokenPayload, CustomizationThemeMode, GitBookAPI } from '@gitbook/api';
2-
import { setContext, setTag } from '@sentry/nextjs';
32
import { getURLLookupAlternatives, normalizeURL } from '@v2/lib/data';
43
import assertNever from 'assert-never';
54
import jwt from 'jsonwebtoken';
@@ -96,14 +95,6 @@ export async function middleware(request: NextRequest) {
9695
const { url, mode } = getInputURL(request);
9796
const isServerAction = request.headers.has('Next-Action');
9897

99-
setTag('url', url.toString());
100-
setContext('request', {
101-
method: request.method,
102-
url: url.toString(),
103-
rawRequestURL: request.url,
104-
userAgent: userAgent(),
105-
});
106-
10798
// Redirect to normalize the URL
10899
const normalized = normalizeURL(url);
109100
if (normalized.toString() !== url.toString()) {
@@ -148,14 +139,6 @@ export async function middleware(request: NextRequest) {
148139
return writeCookies(NextResponse.redirect(normalizedVA.toString()), resolved.cookies);
149140
}
150141

151-
setTag('space', resolved.space);
152-
setContext('content', {
153-
space: resolved.space,
154-
changeRequest: resolved.changeRequest,
155-
revision: resolved.revision,
156-
...('site' in resolved ? { site: resolved.site, siteSpace: resolved.siteSpace } : {}),
157-
});
158-
159142
// Because of how Next will encode, we need to encode ourselves the pathname before rewriting to it.
160143
const rewritePathname = normalizePathname(encodePathname(resolved.pathname));
161144

packages/gitbook/src/sentry.ts

-20
This file was deleted.

turbo.json

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"ARGOS_*",
88
"GITHUB_*",
99
"GITBOOK_*",
10-
"SENTRY_*",
1110
"NEXT_SERVER_ACTIONS_ENCRYPTION_KEY"
1211
],
1312
"tasks": {

0 commit comments

Comments
 (0)