Add sentry

This commit is contained in:
Jade Ellis
2024-08-25 02:42:16 +01:00
parent 13844eea85
commit f39d357a32
6 changed files with 1406 additions and 21 deletions
+2
View File
@@ -12,3 +12,5 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-* vite.config.ts.timestamp-*
output output
Notes-1.0.0.tgz Notes-1.0.0.tgz
# Sentry Config File
.sentryclirc
+1
View File
@@ -74,6 +74,7 @@
"@lezer/highlight": "^1.2.0", "@lezer/highlight": "^1.2.0",
"@octokit/types": "^13.5.0", "@octokit/types": "^13.5.0",
"@resvg/resvg-js": "^2.6.2", "@resvg/resvg-js": "^2.6.2",
"@sentry/sveltekit": "^8.26.0",
"@steeze-ui/svelte-icon": "^1.5.0", "@steeze-ui/svelte-icon": "^1.5.0",
"@tabler/icons-svelte": "^3.11.0", "@tabler/icons-svelte": "^3.11.0",
"@tusbar/cache-control": "^1.0.2", "@tusbar/cache-control": "^1.0.2",
+21
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();
+10 -2
View File
@@ -1,5 +1,12 @@
import {sequence} from '@sveltejs/kit/hooks';
import * as Sentry from '@sentry/sveltekit';
import type { Handle } from "@sveltejs/kit"; import type { Handle } from "@sveltejs/kit";
Sentry.init({
dsn: "https://d006c73cc53783930a1521a68ae1c312@o4507835405369344.ingest.de.sentry.io/4507835410481232",
tracesSampleRate: 1
})
const securityHeaders = { const securityHeaders = {
'X-Content-Type-Options': 'nosniff', 'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '0', '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); const response = await resolve(event);
Object.entries(securityHeaders).forEach( Object.entries(securityHeaders).forEach(
([header, value]) => { ([header, value]) => {
@@ -27,4 +34,5 @@ export const handle: Handle = async ({ event, resolve }) => {
response.headers.delete("x-sveltekit-page") response.headers.delete("x-sveltekit-page")
return response; return response;
} })
export const handleError = Sentry.handleErrorWithSentry();
+10 -5
View File
@@ -1,3 +1,4 @@
import { sentrySvelteKit } from "@sentry/sveltekit";
import { sveltekit } from "@sveltejs/kit/vite"; import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig, type PluginOption } from "vite"; import { defineConfig, type PluginOption } from "vite";
import { ViteImageOptimizer } from "vite-plugin-image-optimizer"; import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
@@ -60,9 +61,9 @@ function relativeResolver({ include, exclude, rootdir: rootDirCfg }: Options = {
// if (!isThumbHash(file)) return // if (!isThumbHash(file)) return
// Your local include path must either starts with `./` or `../` // Your local include path must either starts with `./` or `../`
// if (file.startsWith('./') || file.startsWith('../')) { // if (file.startsWith('./') || file.startsWith('../')) {
// console.log(file, 'from', origin, 'to', resolve(dirname(origin as string), file)) // console.log(file, 'from', origin, 'to', resolve(dirname(origin as string), file))
// Return an absolute include path // Return an absolute include path
return relative(rootDir, resolve(dirname(origin as string), decodeURIComponent(file))); return relative(rootDir, resolve(dirname(origin as string), decodeURIComponent(file)));
// } // }
return null; // Continue to the next plugins! return null; // Continue to the next plugins!
}, },
@@ -107,6 +108,12 @@ export default defineConfig({
} }
}, },
plugins: [ plugins: [
sentrySvelteKit({
sourceMapsUploadOptions: {
org: "jade-ellis",
project: "jade-website-sveltekit"
}
}),
// relativeResolver({include: [/node_modules\/Notes/]}), // relativeResolver({include: [/node_modules\/Notes/]}),
// blurhash_transform(), // blurhash_transform(),
typeAsJsonSchemaPlugin(), typeAsJsonSchemaPlugin(),
@@ -135,7 +142,6 @@ export default defineConfig({
// mdsvex_transform(), // mdsvex_transform(),
sveltekit(), sveltekit(),
dynamicImport({ dynamicImport({
filter(id) { filter(id) {
if (id.includes('node_modules/Notes')) { if (id.includes('node_modules/Notes')) {
return true return true
@@ -153,7 +159,6 @@ export default defineConfig({
// emitFile: true, // emitFile: true,
// filename: "stats.html", // filename: "stats.html",
// }) as PluginOption // }) as PluginOption
], ],
build: { build: {
assetsInlineLimit: 0, assetsInlineLimit: 0,
+1358 -10
View File
File diff suppressed because it is too large Load Diff