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
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
8 changed files with 21 additions and 9 deletions

6
packages/website/.env Normal file
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"

View file

@ -3,8 +3,9 @@ node_modules
/build
/.svelte-kit
/package
.env
.env.*
.env.sentry-build-plugin
.env.local
.env.*.local
!.env.example
.vercel
.output

View file

@ -56,11 +56,9 @@ const cspDirectives = {
// remove report-to & report-uri if you do not want to use Sentry reporting
'report-to': ["'csp-endpoint'"],
'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;

View file

@ -22,6 +22,7 @@
"@types/node": "^20.16.1",
"@types/polka": "^0.5.7",
"@types/sharedworker": "^0.0.115",
"dotenv": "^16.4.5",
"esbuild": "^0.23.1",
"github-slugger": "^2.0.0",
"glob": "^10.4.5",

View file

@ -1,7 +1,8 @@
import { init as initSentry, handleErrorWithSentry, makeBrowserOfflineTransport, makeFetchTransport } from '@sentry/sveltekit';
initSentry({
dsn: 'https://d006c73cc53783930a1521a68ae1c312@o4507835405369344.ingest.de.sentry.io/4507835410481232',
dsn: import.meta.env.SENTRY_DSN,
environment: import.meta.env.MODE,
tracesSampleRate: 1.0,
// This sets the sample rate to be 10%. You may want this to be 100% while

View file

@ -4,7 +4,8 @@ import type { Handle } from "@sveltejs/kit";
import { randomBytes } from 'crypto';
initSentry({
dsn: "https://d006c73cc53783930a1521a68ae1c312@o4507835405369344.ingest.de.sentry.io/4507835410481232",
dsn: import.meta.env.SENTRY_DSN,
environment: import.meta.env.MODE,
tracesSampleRate: 1
})
@ -20,7 +21,7 @@ const securityHeaders = {
'Cross-Origin-Opener-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) => {

View file

@ -1,8 +1,9 @@
import "dotenv/config";
import { mdsvex } from "mdsvex";
import mdsvexConfig from "./mdsvex.config.js";
import adapter from "@sveltejs/adapter-node";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import htmlMinifierAdaptor from "sveltekit-html-minifier";
// import htmlMinifierAdaptor from "sveltekit-html-minifier";
import cspDirectives from "./csp.js";
/** @type {import('@sveltejs/kit').Config} */

3
pnpm-lock.yaml generated
View file

@ -216,6 +216,9 @@ importers:
'@types/sharedworker':
specifier: ^0.0.115
version: 0.0.115
dotenv:
specifier: ^16.4.5
version: 16.4.5
esbuild:
specifier: ^0.23.1
version: 0.23.1