Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: sentry frontend

Andras Bacsai3d20433ad1c3
diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts
index ffd3ddb056..b7b3ba55a6 100644
--- a/apps/api/src/routes/api/v1/handlers.ts
+++ b/apps/api/src/routes/api/v1/handlers.ts
@@ -13,6 +13,7 @@ import {
prisma,
uniqueName,
version,
+ sentryDSN,
} from "../../../lib/common";
import { scheduler } from "../../../lib/scheduler";
import type { FastifyReply, FastifyRequest } from "fastify";
@@ -398,7 +399,8 @@ export async function getCurrentUser(
}
const pendingInvitations = await prisma.teamInvitation.findMany({ where: { uid: request.user.userId } })
return {
- settings: await prisma.setting.findFirst(),
+ settings: await prisma.setting.findUnique({ where: { id: "0" } }),
+ sentryDSN,
pendingInvitations,
token,
...request.user,
diff --git a/apps/ui/package.json b/apps/ui/package.json
index 1cadeffd82..d40dba2a0c 100644
--- a/apps/ui/package.json
+++ b/apps/ui/package.json
@@ -42,6 +42,8 @@
},
"type": "module",
"dependencies": {
+ "@sentry/svelte": "7.21.1",
+ "@sentry/tracing": "7.21.1",
"@sveltejs/adapter-static": "1.0.0-next.48",
"@tailwindcss/typography": "0.5.8",
"cuid": "2.1.8",
diff --git a/apps/ui/src/hooks.ts b/apps/ui/src/hooks.ts
index 30c352baa5..df3284d5af 100644
--- a/apps/ui/src/hooks.ts
+++ b/apps/ui/src/hooks.ts
@@ -1,4 +1,13 @@
+import * as Sentry from '@sentry/svelte';
export async function handle({ event, resolve }) {
const response = await resolve(event, { ssr: false });
return response;
-}
\ No newline at end of file
+}
+export const handleError = ({ error, event }) => {
+ Sentry.captureException(error, { event });
+
+ return {
+ message: 'Whoops!',
+ code: error?.code ?? 'UNKNOWN'
+ };
+};
\ No newline at end of file
diff --git a/apps/ui/src/routes/__layout.svelte b/apps/ui/src/routes/__layout.svelte
index 0ac80eebdc..4cd58e8007 100644
--- a/apps/ui/src/routes/__layout.svelte
+++ b/apps/ui/src/routes/__layout.svelte
@@ -64,6 +64,8 @@
</script>
<script lang="ts">
+ export let settings: any;
+ export let sentryDSN: any;
export let baseSettings: any;
export let pendingInvitations: any = 0;
@@ -96,12 +98,23 @@
import Tooltip from '$lib/components/Tooltip.svelte';
import { onMount } from 'svelte';
import LocalePicker from '$lib/components/LocalePicker.svelte';
+ import * as Sentry from '@sentry/svelte';
+ import { BrowserTracing } from '@sentry/tracing';
+ import { dev } from '$app/env';
if (userId) $appSession.userId = userId;
if (teamId) $appSession.teamId = teamId;
if (permission) $appSession.permission = permission;
if (isAdmin) $appSession.isAdmin = isAdmin;
-
+ if (settings.doNotTrack === false) {
+ Sentry.init({
+ dsn: sentryDSN,
+ environment: dev ? 'development' : 'production',
+ integrations: [new BrowserTracing()],
+ release: $appSession.version?.toString(),
+ tracesSampleRate: 0.2
+ });
+ }
async function logout() {
try {
Cookies.remove('token');
@@ -137,6 +150,7 @@
<PageLoader />
</div>
{/if}
+
<div class="drawer">
<input id="main-drawer" type="checkbox" class="drawer-toggle" />
<div class="drawer-content">
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 494c9b59fc..ad7e894e04 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -26,7 +26,7 @@ importers:
'@ladjs/graceful': 3.0.2
'@prisma/client': 4.6.1
'@sentry/node': 7.21.1
- '@sentry/tracing': ^7.21.1
+ '@sentry/tracing': 7.21.1
'@types/node': 18.11.9
'@types/node-os-utils': 1.3.0
'@typescript-eslint/eslint-plugin': 5.44.0
@@ -152,6 +152,8 @@ importers:
'@floating-ui/dom': 1.0.6
'@playwright/test': 1.28.0
'@popperjs/core': 2.11.6
+ '@sentry/svelte': ^7.21.1
+ '@sentry/tracing': 7.21.1
'@sveltejs/adapter-static': 1.0.0-next.48
'@sveltejs/kit': 1.0.0-next.405
'@tailwindcss/typography': 0.5.8
@@ -186,6 +188,8 @@ importers:
typescript: 4.9.3
vite: 3.2.4
dependencies:
+ '@sentry/svelte': [email protected]
+ '@sentry/tracing': 7.21.1
'@sveltejs/adapter-static': 1.0.0-next.48
'@tailwindcss/typography': [email protected]
cuid: 2.1.8
@@ -268,6 +272,7 @@ packages:
engines: {node: '>= 12.11'}
peerDependencies:
bree: '>=9.0.0'
+ tsconfig-paths: '>= 4'
dependencies:
bree: 9.1.2
ts-node: 10.8.2_wup25etrarvlqkprac7h35hj7u
@@ -321,23 +326,6 @@ packages:
- supports-color
dev: true
- /@eslint/eslintrc/1.3.3:
- resolution: {integrity: sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==}
- engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
- dependencies:
- ajv: 6.12.6
- debug: 4.3.4
- espree: 9.4.0
- globals: 13.15.0
- ignore: 5.2.0
- import-fresh: 3.3.0
- js-yaml: 4.1.0
- minimatch: 3.1.2
- strip-json-comments: 3.1.1
- transitivePeerDependencies:
- - supports-color
- dev: true
-
/@fastify/accept-negotiator/1.0.0:
resolution: {integrity: sha512-4R/N2KfYeld7A5LGkai+iUFMahXcxxYbDp+XS2B1yuL3cdmZLJ9TlCnNzT3q5xFTqsYm0GPpinLUwfSwjcVjyA==}
engines: {node: '>=14'}
@@ -558,6 +546,16 @@ packages:
requiresBuild: true
dev: false
+ /@sentry/browser/7.21.1:
+ resolution: {integrity: sha512-cS2Jz2+fs9+4pJqLJPtYqGyY97ywJDWAWIR1Yla3hs1QQuH6m0Nz3ojZD1gE2eKH9mHwkGbnNAh+hHcrYrfGzw==}
+ engines: {node: '>=8'}
+ dependencies:
+ '@sentry/core': 7.21.1
+ '@sentry/types': 7.21.1
+ '@sentry/utils': 7.21.1
+ tslib: 1.14.1
+ dev: false
+
/@sentry/core/7.21.1:
resolution: {integrity: sha512-Og5wEEsy24fNvT/T7IKjcV4EvVK5ryY2kxbJzKY6GU2eX+i+aBl+n/vp7U0Es351C/AlTkS+0NOUsp2TQQFxZA==}
engines: {node: '>=8'}
@@ -582,6 +580,20 @@ packages:
- supports-color
dev: false
+ /@sentry/svelte/[email protected]:
+ resolution: {integrity: sha512-WDb95bToY0k3rtYd0a0J5RXpj/l4X+qZfT35/fv2DF8LsvGV8w037CR3dR9O7NNRMfW5M2KZ1y4SCHJ4kXxoZA==}
+ engines: {node: '>=8'}
+ peerDependencies:
+ svelte: 3.x
+ dependencies:
+ '@sentry/browser': 7.21.1
+ '@sentry/types': 7.21.1
+ '@sentry/utils': 7.21.1
+ magic-string: 0.26.7
+ svelte: 3.53.1
+ tslib: 1.14.1
+ dev: false
+
/@sentry/tracing/7.21.1:
resolution: {integrity: sha512-b1BTPsRaNQpohzegoz59KGuBl+To651vEq0vMS4tCzSyIdxkYso3JCrjDdEqW/2MliQYANNVrUai2bmwmU9h1g==}
engines: {node: '>=8'}
@@ -2998,16 +3010,6 @@ packages:
eslint-visitor-keys: 2.1.0
dev: true
- /eslint-utils/[email protected]:
- resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==}
- engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0}
- peerDependencies:
- eslint: '>=5'
- dependencies:
- eslint: 8.25.0
- eslint-visitor-keys: 2.1.0
- dev: true
-
/eslint-visitor-keys/2.1.0:
resolution: {integrity: sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==}
engines: {node: '>=10'}
@@ -3066,53 +3068,6 @@ packages:
- supports-color
dev: true
- /eslint/8.25.0:
- resolution: {integrity: sha512-DVlJOZ4Pn50zcKW5bYH7GQK/9MsoQG2d5eDH0ebEkE8PbgzTTmtt/VTH9GGJ4BfeZCpBLqFfvsjX35UacUL83A==}
- engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
- hasBin: true
- dependencies:
- '@eslint/eslintrc': 1.3.3
- '@humanwhocodes/config-array': 0.10.7
- '@humanwhocodes/module-importer': 1.0.1
- ajv: 6.12.6
- chalk: 4.1.2
- cross-spawn: 7.0.3
- debug: 4.3.4
- doctrine: 3.0.0
- escape-string-regexp: 4.0.0
- eslint-scope: 7.1.1
- eslint-utils: [email protected]
- eslint-visitor-keys: 3.3.0
- espree: 9.4.0
- esquery: 1.4.0
- esutils: 2.0.3
- fast-deep-equal: 3.1.3
- file-entry-cache: 6.0.1
- find-up: 5.0.0
- glob-parent: 6.0.2
- globals: 13.15.0
- globby: 11.1.0
- grapheme-splitter: 1.0.4
- ignore: 5.2.0
- import-fresh: 3.3.0
- imurmurhash: 0.1.4
- is-glob: 4.0.3
- js-sdsl: 4.1.5
- js-yaml: 4.1.0
- json-stable-stringify-without-jsonify: 1.0.1
- levn: 0.4.1
- lodash.merge: 4.6.2
- minimatch: 3.1.2
- natural-compare: 1.4.0
- optionator: 0.9.1
- regexpp: 3.2.0
- strip-ansi: 6.0.1
- strip-json-comments: 3.1.1
- text-table: 0.2.0
- transitivePeerDependencies:
- - supports-color
- dev: true
-
/espree/9.4.0:
resolution: {integrity: sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -4419,7 +4374,6 @@ packages:
engines: {node: '>=12'}
dependencies:
sourcemap-codec: 1.4.8
- dev: true
/make-error/1.3.6:
resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==}
@@ -5720,7 +5674,6 @@ packages:
/sourcemap-codec/1.4.8:
resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==}
- dev: true
/spdx-correct/3.1.1:
resolution: {integrity: sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==}
@@ -6031,6 +5984,8 @@ packages:
resolution: {integrity: sha512-AhwtHCKMtR71JgeYDaswmZXhPcW9iuI9Sp2LvZPo9upDZ7231ZJ7eA9RaURbhpXGVlrjX4cFNlB4ieTetEb7hQ==}
engines: {node: '>=12.13.0'}
hasBin: true
+ peerDependencies:
+ postcss: ^8.0.9
dependencies:
arg: 5.0.2
chokidar: 3.5.3