Compare commits

...

11 Commits

Author SHA1 Message Date
Greg Bergé de2d468677 Fix build 2025-01-09 10:03:57 +01:00
Greg Bergé 7f50ad68bb Remove import 2025-01-09 09:49:51 +01:00
Greg Bergé 3a759b14a4 Fix lockfile 2025-01-09 09:46:55 +01:00
Greg Bergé b5e2e3fa8d Setup Sentry with Cloudflare 2025-01-09 09:40:47 +01:00
Greg Bergé fec48ce708 Import Sentry in middleware 2025-01-09 09:21:52 +01:00
Greg Bergé 0784bf5df7 Update wrangler 2025-01-09 08:49:48 +01:00
Greg Bergé f8f485ae25 Add log 2025-01-09 08:48:44 +01:00
Greg Bergé 3491bdc522 Import Sentry in middleware 2025-01-08 17:14:16 +01:00
Greg Bergé 2cda8d4cad Add more logs 2025-01-08 16:51:07 +01:00
Greg Bergé 3fcbe46262 Introduce error on purpose 2025-01-08 16:34:30 +01:00
Greg Bergé 884ee7073f Simplify Sentry setup, add logs 2025-01-08 16:34:27 +01:00
10 changed files with 22 additions and 108 deletions
-42
View File
@@ -94,48 +94,6 @@ jobs:
Latest commit: [${{ steps.deploy.outputs.deployment-url }}](${{ steps.deploy.outputs.deployment-url }})
PR: [${{ steps.deploy.outputs.deployment-alias-url }}](${{ steps.deploy.outputs.deployment-alias-url }})
edit-mode: replace
visual-testing:
runs-on: ubuntu-latest
name: Visual Testing
needs: deploy
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: ./.github/composite/setup-bun
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Setup Playwright
uses: ./.github/actions/setup-playwright
- name: Run Playwright tests
run: bun e2e
env:
BASE_URL: ${{needs.deploy.outputs.deployment_url}}
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-test-results
path: packages/gitbook/test-results/
retention-days: 3
pagespeed-testing:
runs-on: ubuntu-latest
name: PageSpeed Testing
needs: deploy
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: ./.github/composite/setup-bun
- name: Install dependencies
run: bun install --frozen-lockfile
env:
PUPPETEER_SKIP_DOWNLOAD: 1
- name: Run pagespeed tests
run: bun ./packages/gitbook/tests/pagespeed-testing.ts $DEPLOYMENT_URL
env:
DEPLOYMENT_URL: ${{needs.deploy.outputs.deployment_url}}
PAGESPEED_API_KEY: ${{ secrets.PAGESPEED_API_KEY }}
format:
runs-on: ubuntu-latest
name: Format
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -21,7 +21,7 @@
},
"devDependencies": {
"typescript": "^5.5.3",
"wrangler": "3.82.0"
"wrangler": "^3.100.0"
},
"scripts": {
"generate": "wrangler types --experimental-include-runtime",
+1
View File
@@ -25,6 +25,7 @@
"@gitbook/react-openapi": "workspace:*",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-popover": "^1.0.7",
"@sentry/cloudflare": "8.35.0",
"@sentry/nextjs": "8.35.0",
"@sindresorhus/fnv1a": "^3.1.0",
"@tailwindcss/container-queries": "^0.1.1",
+1 -9
View File
@@ -1,18 +1,10 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/nextjs';
const dsn = process.env.SENTRY_DSN;
if (dsn) {
Sentry.init({
dsn,
release: process.env.SENTRY_RELEASE,
// Disable tracing as it creates additional requests in an env where subrequests are limited.
tracesSampleRate: 0,
// Disable transactions as it creates additional requests in an env where subrequests are limited.
// https://docs.sentry.io/platforms/node/configuration/filtering/#using--3
beforeSendTransaction: () => {
return null;
},
});
}
-18
View File
@@ -1,18 +0,0 @@
import { init } from '@sentry/nextjs';
const dsn = process.env.SENTRY_DSN;
if (dsn) {
init({
dsn,
release: process.env.SENTRY_RELEASE,
// Disable tracing as it creates additional requests in an env where subrequests are limited.
tracesSampleRate: 0,
// Disable transactions as it creates additional requests in an env where subrequests are limited.
// https://docs.sentry.io/platforms/node/configuration/filtering/#using--3
beforeSendTransaction: () => {
return null;
},
});
}
-18
View File
@@ -1,18 +0,0 @@
import { init } from '@sentry/nextjs';
const dsn = process.env.SENTRY_DSN;
if (dsn) {
init({
dsn,
release: process.env.SENTRY_RELEASE,
// Disable tracing as it creates additional requests in an env where subrequests are limited.
tracesSampleRate: 0,
// Disable transactions as it creates additional requests in an env where subrequests are limited.
// https://docs.sentry.io/platforms/node/configuration/filtering/#using--3
beforeSendTransaction: () => {
return null;
},
});
}
+18 -6
View File
@@ -1,13 +1,10 @@
// @ts-ignore
import nextOnPagesHandler from '@cloudflare/next-on-pages/fetch-handler';
import { withSentry } from '@sentry/cloudflare';
import { withMiddlewareHeadersStorage } from './lib/middleware';
/**
* We use a custom entrypoint until we can move to opennext (https://github.com/opennextjs/opennextjs-cloudflare/issues/92).
* There is a bug in next-on-pages where headers can't be set on the response in the middleware for RSC requests (https://github.com/cloudflare/next-on-pages/issues/897).
*/
export default {
const exportedHandler = {
async fetch(request, env, ctx) {
const response = await withMiddlewareHeadersStorage(() =>
nextOnPagesHandler.fetch(request, env, ctx),
@@ -15,4 +12,19 @@ export default {
return response;
},
} as ExportedHandler<{ ASSETS: Fetcher }>;
} satisfies ExportedHandler<{ ASSETS: Fetcher }>;
/**
* We use a custom entrypoint until we can move to opennext (https://github.com/opennextjs/opennextjs-cloudflare/issues/92).
* There is a bug in next-on-pages where headers can't be set on the response in the middleware for RSC requests (https://github.com/cloudflare/next-on-pages/issues/897).
*/
export default withSentry(
(env) => ({
dsn: env.SENTRY_DSN,
release: env.SENTRY_RELEASE,
environment: env.SENTRY_ENVIRONMENT,
tracesSampleRate: 0,
}),
// @ts-ignore
exportedHandler,
);
@@ -30,7 +30,7 @@ export function HeaderMobileMenu(props: Partial<React.ButtonHTMLAttributes<HTMLB
}
};
const windowRef = useRef(typeof window === 'undefined' ? null : window);
const windowRef = useRef(window);
useScrollListener(() => {
if (window.scrollY >= scrollDistance) {
setHasScrolled(true);
-13
View File
@@ -1,13 +0,0 @@
import * as Sentry from '@sentry/nextjs';
import { Instrumentation } from 'next';
export async function register() {
await import('../sentry.edge.config');
}
export const onRequestError: Instrumentation.onRequestError = async (...args) => {
Sentry.captureRequestError(...args);
// There is an issue on Cloudflare that requires us to flush the events manually.
// https://github.com/getsentry/sentry-javascript/issues/14931#issuecomment-2577640023
await Sentry.flush();
};