Skip to content

The only tool you need to know what is happening and how to fix it.

feat: added traceway svelte for frontend tracking

ddux3a5bc7263249
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 24d45b9e..16eaf89a 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -1,14 +1,15 @@
{
"name": "frontend",
- "version": "1.0.9",
+ "version": "1.0.10",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "frontend",
- "version": "1.0.9",
+ "version": "1.0.10",
"dependencies": {
"@sveltejs/svelte-json-tree": "^2.2.1",
+ "@tracewayapp/svelte": "^0.3.0",
"lucide-svelte": "^0.562.0",
"luxon": "^3.7.2",
"svelte-highlight": "^7.9.0",
@@ -1601,6 +1602,30 @@
"vite": "^5.2.0 || ^6 || ^7"
}
},
+ "node_modules/@tracewayapp/core": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/@tracewayapp/core/-/core-0.3.0.tgz",
+ "integrity": "sha512-TloIV5fq6y+200CMSdsLzj3GA/c7nThAau2V/K3o9udmp3t//7eKp3LX41oTHC+HdcCSi3fgx3f/TjN/7aI8/Q=="
+ },
+ "node_modules/@tracewayapp/frontend": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/@tracewayapp/frontend/-/frontend-0.3.0.tgz",
+ "integrity": "sha512-CTjIbumhCRZYG59kEReDIYa+3iB0y0z7aLDUBr/I20Db4TmDk9XQMAJ+JkirWHKbrr/uKriueaSIqHG3rLvumg==",
+ "dependencies": {
+ "@tracewayapp/core": "0.3.0"
+ }
+ },
+ "node_modules/@tracewayapp/svelte": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/@tracewayapp/svelte/-/svelte-0.3.0.tgz",
+ "integrity": "sha512-ifzfh3D0DYy4AbyPvllXWl0WhuRbMcGDa/c4lUUazjaP8wKwBCNu/fR0MExxwf05ZUx1pqVdzfY+cU1CPmmWgg==",
+ "dependencies": {
+ "@tracewayapp/frontend": "0.3.0"
+ },
+ "peerDependencies": {
+ "svelte": ">=4.0.0"
+ }
+ },
"node_modules/@types/cookie": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index dbaad00d..2a2a9838 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,7 @@
{
"name": "frontend",
"private": true,
- "version": "1.0.9",
+ "version": "1.0.10",
"type": "module",
"scripts": {
"dev": "vite dev",
@@ -53,6 +53,7 @@
},
"dependencies": {
"@sveltejs/svelte-json-tree": "^2.2.1",
+ "@tracewayapp/svelte": "^0.3.0",
"lucide-svelte": "^0.562.0",
"luxon": "^3.7.2",
"svelte-highlight": "^7.9.0",
diff --git a/frontend/src/app.d.ts b/frontend/src/app.d.ts
index 4881416e..c913bfe5 100644
--- a/frontend/src/app.d.ts
+++ b/frontend/src/app.d.ts
@@ -12,6 +12,7 @@ declare global {
const __APP_VERSION__: string;
const __CLOUD_MODE__: string;
const __TURNSTILE_SITE_KEY__: string;
+ const __TRACEWAY_URL__: string;
}
export {};
diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte
index 443e8e44..4329de04 100644
--- a/frontend/src/routes/+layout.svelte
+++ b/frontend/src/routes/+layout.svelte
@@ -8,14 +8,22 @@
import AppSidebar from '$lib/components/app-sidebar.svelte';
import AddProjectModal from '$lib/components/add-project-modal.svelte';
import FrameworkIcon from '$lib/components/framework-icon.svelte';
- import * as Sidebar from "$lib/components/ui/sidebar";
- import { Button } from "$lib/components/ui/button";
- import { Sun, Moon, LogOut, Plus, Check } from "@lucide/svelte";
- import { onMount } from "svelte";
- import * as DropdownMenu from "$lib/components/ui/dropdown-menu/index.js";
+ import * as Sidebar from '$lib/components/ui/sidebar';
+ import { Button } from '$lib/components/ui/button';
+ import { Sun, Moon, LogOut, Plus, Check } from '@lucide/svelte';
+ import { onMount } from 'svelte';
+ import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
import { ChevronDown } from 'lucide-svelte';
import { Toaster, toast } from 'svelte-sonner';
import { page } from '$app/state';
+ import { setupTraceway } from '@tracewayapp/svelte';
+ import { captureException } from '@tracewayapp/frontend';
+
+ if (__TRACEWAY_URL__) {
+ setupTraceway({
+ connectionString: __TRACEWAY_URL__
+ });
+ }
let { children } = $props();
let showAddProjectModal = $state(false);
@@ -57,8 +65,8 @@
}
function handleAddProjectClick() {
- const organizationId = projectsState.currentProject?.organizationId
- ?? authState.organizations[0]?.id;
+ const organizationId =
+ projectsState.currentProject?.organizationId ?? authState.organizations[0]?.id;
if (organizationId) {
const role = authState.getRoleForOrganization(organizationId);
if (role === 'readonly') {
@@ -80,7 +88,7 @@
<!-- This is not ideal, but because our layout is a top level route it can end up showing sidebar on the login page (after the login before the transition). -->
<!-- We could consider moving this to a lower level layout for the actual app, for now it's just a path check -->
-{#if authState.isAuthenticated && page.url.pathname !== "/login" && page.url.pathname !== "/register" && !page.url.pathname.startsWith("/accept-invitation")}
+{#if authState.isAuthenticated && page.url.pathname !== '/login' && page.url.pathname !== '/register' && !page.url.pathname.startsWith('/accept-invitation')}
<Sidebar.SidebarProvider>
<AppSidebar />
<Sidebar.SidebarInset>
@@ -89,7 +97,9 @@
<div class="h-4 w-px bg-border"></div>
<h1 class="text-lg font-semibold">
<DropdownMenu.Root>
- <DropdownMenu.Trigger class="flex flex-row items-center gap-2 hover:bg-accent hover:text-accent-foreground rounded-md px-2 py-1 transition-colors">
+ <DropdownMenu.Trigger
+ class="flex flex-row items-center gap-2 rounded-md px-2 py-1 transition-colors hover:bg-accent hover:text-accent-foreground"
+ >
{#if projectsState.currentProject}
<FrameworkIcon framework={projectsState.currentProject.framework} />
{/if}
@@ -103,7 +113,7 @@
{#each projectsState.projects as project}
<DropdownMenu.Item
onclick={() => handleProjectSelect(project.id)}
- class="flex items-center justify-between cursor-pointer"
+ class="flex cursor-pointer items-center justify-between"
>
<div class="flex items-center gap-2">
<FrameworkIcon framework={project.framework} />
@@ -127,7 +137,12 @@
</DropdownMenu.Root>
</h1>
<div class="ml-auto flex items-center gap-2">
- <Button variant="ghost" size="icon" onclick={toggleTheme} title={themeState.isDark ? "Switch to Light Mode" : "Switch to Dark Mode"}>
+ <Button
+ variant="ghost"
+ size="icon"
+ onclick={toggleTheme}
+ title={themeState.isDark ? 'Switch to Light Mode' : 'Switch to Dark Mode'}
+ >
{#if themeState.isDark}
<Sun class="h-5 w-5" />
{:else}
@@ -139,7 +154,7 @@
</Button>
</div>
</header>
- <main class="flex-1 min-w-0 p-4">
+ <main class="min-w-0 flex-1 p-4">
{@render children()}
</main>
</Sidebar.SidebarInset>
@@ -147,7 +162,7 @@
<AddProjectModal
open={showAddProjectModal}
- onOpenChange={(open) => showAddProjectModal = open}
+ onOpenChange={(open) => (showAddProjectModal = open)}
onProjectCreated={handleProjectCreated}
/>
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index fd55ded9..97063d03 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -18,13 +18,13 @@ function injectBillingSource(): Plugin {
transform(code, id) {
if (id.endsWith('.css') && code.includes('@source "$BILLING_PATH"')) {
if (billingExists) {
- return code.replace('@source "$BILLING_PATH"', `@source "${resolvedBillingPath}"`)
+ return code.replace('@source "$BILLING_PATH"', `@source "${resolvedBillingPath}"`);
} else {
- return code.replace('@source "$BILLING_PATH";', '')
+ return code.replace('@source "$BILLING_PATH";', '');
}
}
}
- }
+ };
}
export default defineConfig(({ mode }) => {
@@ -36,6 +36,7 @@ export default defineConfig(({ mode }) => {
__APP_VERSION__: JSON.stringify(env.PUBLIC_APP_VERSION || pkg.version),
__CLOUD_MODE__: env.CLOUD_MODE,
__BILLING_AVAILABLE__: billingExists,
+ __TRACEWAY_URL__: JSON.stringify(env.TRACEWAY_URL || ''),
__TURNSTILE_SITE_KEY__: JSON.stringify(env.PUBLIC_TURNSTILE_SITE_KEY || '')
},
resolve: {
diff --git a/scripts/build-and-bundle-frontend.sh b/scripts/build-and-bundle-frontend.sh
index e324bfdf..48a17e93 100755
--- a/scripts/build-and-bundle-frontend.sh
+++ b/scripts/build-and-bundle-frontend.sh
@@ -48,6 +48,15 @@ else
echo "Building without Turnstile captcha"
fi
+# Ask for Traceway URL
+read -p "Enter Traceway connection string (e.g., token@https://host/api/report) or leave empty: " TRACEWAY_URL_INPUT
+if [ -n "$TRACEWAY_URL_INPUT" ]; then
+ export TRACEWAY_URL="$TRACEWAY_URL_INPUT"
+ echo "Traceway self-monitoring enabled"
+else
+ echo "Building without Traceway self-monitoring"
+fi
+
# Build frontend
npm install
npm run build