Factor out Sentry URLs and set Sentry environment

This commit is contained in:
Jade Ellis
2024-08-27 18:51:11 +01:00
parent 687733bf7d
commit 8fbab1f87c
8 changed files with 21 additions and 9 deletions
+6
View File
@@ -0,0 +1,6 @@
# This is committed to git
# DO NOT STORE SECRETS IN THIS FILE
# use .env.local for secrets
SENTRY_DSN = "https://d006c73cc53783930a1521a68ae1c312@o4507835405369344.ingest.de.sentry.io/4507835410481232"
SENTRY_REPORT_URL = "https://o4507835405369344.ingest.de.sentry.io/api/4507835410481232/security/?sentry_key=d006c73cc53783930a1521a68ae1c312"
+3 -2
View File
@@ -3,8 +3,9 @@ node_modules
/build /build
/.svelte-kit /.svelte-kit
/package /package
.env .env.sentry-build-plugin
.env.* .env.local
.env.*.local
!.env.example !.env.example
.vercel .vercel
.output .output
+1 -3
View File
@@ -56,11 +56,9 @@ const cspDirectives = {
// remove report-to & report-uri if you do not want to use Sentry reporting // remove report-to & report-uri if you do not want to use Sentry reporting
'report-to': ["'csp-endpoint'"], 'report-to': ["'csp-endpoint'"],
'report-uri': [ 'report-uri': [
'https://o4507835405369344.ingest.de.sentry.io/api/4507835410481232/security/?sentry_key=d006c73cc53783930a1521a68ae1c312', process.env.SENTRY_REPORT_URL,
], ],
}; };
// Report-To: {"group":"csp-endpoint","max_age":10886400,"endpoints":[{"url":"https://o4507835405369344.ingest.de.sentry.io/api/4507835410481232/security/?sentry_key=d006c73cc53783930a1521a68ae1c312"}],"include_subdomains":true}
export default cspDirectives; export default cspDirectives;
+1
View File
@@ -22,6 +22,7 @@
"@types/node": "^20.16.1", "@types/node": "^20.16.1",
"@types/polka": "^0.5.7", "@types/polka": "^0.5.7",
"@types/sharedworker": "^0.0.115", "@types/sharedworker": "^0.0.115",
"dotenv": "^16.4.5",
"esbuild": "^0.23.1", "esbuild": "^0.23.1",
"github-slugger": "^2.0.0", "github-slugger": "^2.0.0",
"glob": "^10.4.5", "glob": "^10.4.5",
+2 -1
View File
@@ -1,7 +1,8 @@
import { init as initSentry, handleErrorWithSentry, makeBrowserOfflineTransport, makeFetchTransport } from '@sentry/sveltekit'; import { init as initSentry, handleErrorWithSentry, makeBrowserOfflineTransport, makeFetchTransport } from '@sentry/sveltekit';
initSentry({ initSentry({
dsn: 'https://d006c73cc53783930a1521a68ae1c312@o4507835405369344.ingest.de.sentry.io/4507835410481232', dsn: import.meta.env.SENTRY_DSN,
environment: import.meta.env.MODE,
tracesSampleRate: 1.0, tracesSampleRate: 1.0,
// This sets the sample rate to be 10%. You may want this to be 100% while // This sets the sample rate to be 10%. You may want this to be 100% while
+3 -2
View File
@@ -4,7 +4,8 @@ import type { Handle } from "@sveltejs/kit";
import { randomBytes } from 'crypto'; import { randomBytes } from 'crypto';
initSentry({ initSentry({
dsn: "https://d006c73cc53783930a1521a68ae1c312@o4507835405369344.ingest.de.sentry.io/4507835410481232", dsn: import.meta.env.SENTRY_DSN,
environment: import.meta.env.MODE,
tracesSampleRate: 1 tracesSampleRate: 1
}) })
@@ -20,7 +21,7 @@ const securityHeaders = {
'Cross-Origin-Opener-Policy': 'same-origin', 'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Resource-Policy': 'same-origin', 'Cross-Origin-Resource-Policy': 'same-origin',
'Report-To': '{"group":"csp-endpoint","max_age":10886400,"endpoints":[{"url":"https://o4507835405369344.ingest.de.sentry.io/api/4507835410481232/security/?sentry_key=d006c73cc53783930a1521a68ae1c312"}],"include_subdomains":true}', 'Report-To': '{"group":"csp-endpoint","max_age":10886400,"endpoints":[{"url":"' + import.meta.env.SENTRY_REPORT_URL + '"}],"include_subdomains":true}',
} }
export const handle: Handle = async (input) => { export const handle: Handle = async (input) => {
+2 -1
View File
@@ -1,8 +1,9 @@
import "dotenv/config";
import { mdsvex } from "mdsvex"; import { mdsvex } from "mdsvex";
import mdsvexConfig from "./mdsvex.config.js"; import mdsvexConfig from "./mdsvex.config.js";
import adapter from "@sveltejs/adapter-node"; import adapter from "@sveltejs/adapter-node";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import htmlMinifierAdaptor from "sveltekit-html-minifier"; // import htmlMinifierAdaptor from "sveltekit-html-minifier";
import cspDirectives from "./csp.js"; import cspDirectives from "./csp.js";
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
+3
View File
@@ -216,6 +216,9 @@ importers:
'@types/sharedworker': '@types/sharedworker':
specifier: ^0.0.115 specifier: ^0.0.115
version: 0.0.115 version: 0.0.115
dotenv:
specifier: ^16.4.5
version: 16.4.5
esbuild: esbuild:
specifier: ^0.23.1 specifier: ^0.23.1
version: 0.23.1 version: 0.23.1