Add sentry

This commit is contained in:
Jade Ellis 2024-08-25 02:42:16 +01:00
parent 13844eea85
commit f39d357a32
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
6 changed files with 1406 additions and 21 deletions

View file

@ -11,4 +11,6 @@ node_modules
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
output
Notes-1.0.0.tgz
Notes-1.0.0.tgz
# Sentry Config File
.sentryclirc

View file

@ -74,6 +74,7 @@
"@lezer/highlight": "^1.2.0",
"@octokit/types": "^13.5.0",
"@resvg/resvg-js": "^2.6.2",
"@sentry/sveltekit": "^8.26.0",
"@steeze-ui/svelte-icon": "^1.5.0",
"@tabler/icons-svelte": "^3.11.0",
"@tusbar/cache-control": "^1.0.2",

View file

@ -0,0 +1,21 @@
import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
import * as Sentry from '@sentry/sveltekit';
Sentry.init({
dsn: 'https://d006c73cc53783930a1521a68ae1c312@o4507835405369344.ingest.de.sentry.io/4507835410481232',
tracesSampleRate: 1.0,
// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.1,
// If the entire session is not sampled, use the below sample rate to sample
// sessions when an error occurs.
replaysOnErrorSampleRate: 1.0,
// If you don't want to use Session Replay, just remove the line below:
integrations: [replayIntegration()],
});
// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry();

View file

@ -1,5 +1,12 @@
import {sequence} from '@sveltejs/kit/hooks';
import * as Sentry from '@sentry/sveltekit';
import type { Handle } from "@sveltejs/kit";
Sentry.init({
dsn: "https://d006c73cc53783930a1521a68ae1c312@o4507835405369344.ingest.de.sentry.io/4507835410481232",
tracesSampleRate: 1
})
const securityHeaders = {
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '0',
@ -14,7 +21,7 @@ const securityHeaders = {
}
export const handle: Handle = async ({ event, resolve }) => {
export const handle: Handle = sequence(Sentry.sentryHandle(), async ({ event, resolve }) => {
const response = await resolve(event);
Object.entries(securityHeaders).forEach(
([header, value]) => {
@ -27,4 +34,5 @@ export const handle: Handle = async ({ event, resolve }) => {
response.headers.delete("x-sveltekit-page")
return response;
}
})
export const handleError = Sentry.handleErrorWithSentry();

View file

@ -1,3 +1,4 @@
import { sentrySvelteKit } from "@sentry/sveltekit";
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig, type PluginOption } from "vite";
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
@ -49,20 +50,20 @@ function relativeResolver({ include, exclude, rootdir: rootDirCfg }: Options = {
}
if (opt.isEntry) return
if (!filter(origin)) {
// console.log(origin, "not filter")
return null
}
console.log("relatively resolving")
console.log(relative(rootDir, resolve(dirname(origin as string), decodeURIComponent(file))))
// if (!isThumbHash(file)) return
// Your local include path must either starts with `./` or `../`
// if (file.startsWith('./') || file.startsWith('../')) {
// console.log(file, 'from', origin, 'to', resolve(dirname(origin as string), file))
// Return an absolute include path
return relative(rootDir, resolve(dirname(origin as string), decodeURIComponent(file)));
// console.log(file, 'from', origin, 'to', resolve(dirname(origin as string), file))
// Return an absolute include path
return relative(rootDir, resolve(dirname(origin as string), decodeURIComponent(file)));
// }
return null; // Continue to the next plugins!
},
@ -107,6 +108,12 @@ export default defineConfig({
}
},
plugins: [
sentrySvelteKit({
sourceMapsUploadOptions: {
org: "jade-ellis",
project: "jade-website-sveltekit"
}
}),
// relativeResolver({include: [/node_modules\/Notes/]}),
// blurhash_transform(),
typeAsJsonSchemaPlugin(),
@ -135,7 +142,6 @@ export default defineConfig({
// mdsvex_transform(),
sveltekit(),
dynamicImport({
filter(id) {
if (id.includes('node_modules/Notes')) {
return true
@ -153,7 +159,6 @@ export default defineConfig({
// emitFile: true,
// filename: "stats.html",
// }) as PluginOption
],
build: {
assetsInlineLimit: 0,
@ -170,4 +175,4 @@ export default defineConfig({
/* ... */
],
},
});
});

1368
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff