Skip to content

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

source maps for traceway fe

dduxbbb70a95c9a1
diff --git a/backend/app/controllers/sourcemap.controller.go b/backend/app/controllers/sourcemap.controller.go
index 0c7a2eea..da7b605e 100644
--- a/backend/app/controllers/sourcemap.controller.go
+++ b/backend/app/controllers/sourcemap.controller.go
@@ -33,8 +33,7 @@ func (s sourceMapController) Upload(c *gin.Context) {
version := c.Request.FormValue("version")
if version == "" {
- c.JSON(http.StatusBadRequest, gin.H{"error": "version is required"})
- return
+ version = "unversioned"
}
files := c.Request.MultipartForm.File["files"]
diff --git a/frontend/src/routes/connection/+page.svelte b/frontend/src/routes/connection/+page.svelte
index f8299739..cde0602b 100644
--- a/frontend/src/routes/connection/+page.svelte
+++ b/frontend/src/routes/connection/+page.svelte
@@ -9,6 +9,7 @@
import { Button } from '$lib/components/ui/button';
import { Copy, Check, KeyRound } from 'lucide-svelte';
import { projectsState, type ProjectWithToken, isJsFramework, isOtelFramework, isCloudflareFramework } from '$lib/state/projects.svelte';
+ import { authState } from '$lib/state/auth.svelte';
import { LoadingCircle } from '$lib/components/ui/loading-circle';
import FrameworkIcon from '$lib/components/framework-icon.svelte';
import Highlight from 'svelte-highlight';
@@ -76,6 +77,9 @@
);
const isJs = $derived(projectWithToken ? isJsFramework(projectWithToken.framework) : false);
+ const isReadonly = $derived(
+ authState.getRoleForOrganization(projectsState.currentProject?.organizationId ?? 0) === 'readonly'
+ );
const sourceMapToken = $derived(projectWithToken?.sourceMapToken ?? null);
const uploadCommand = $derived(
@@ -350,7 +354,7 @@
</div>
</CardContent>
</Card>
- {#if isJs}
+ {#if isJs && !isReadonly}
<Card>
<CardHeader>
<CardTitle class="flex items-center gap-2">
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index d11b0144..fcd2d80c 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -57,6 +57,9 @@ export default defineConfig(({ mode }) => {
__TRACEWAY_URL__: JSON.stringify(env.TRACEWAY_URL || ''),
__TURNSTILE_SITE_KEY__: JSON.stringify(env.PUBLIC_TURNSTILE_SITE_KEY || '')
},
+ build: {
+ sourcemap: 'hidden'
+ },
resolve: {
dedupe: ['d3-scale', 'd3-array', 'lucide-svelte', 'svelte']
},
diff --git a/scripts/build-and-bundle-frontend.sh b/scripts/build-and-bundle-frontend.sh
index 48a17e93..f6ce3b19 100755
--- a/scripts/build-and-bundle-frontend.sh
+++ b/scripts/build-and-bundle-frontend.sh
@@ -57,6 +57,9 @@ else
echo "Building without Traceway self-monitoring"
fi
+# Ask for sourcemap upload token
+read -p "Enter sourcemap upload token or leave empty to skip upload: " SOURCEMAP_TOKEN_INPUT
+
# Build frontend
npm install
npm run build
@@ -66,4 +69,15 @@ rm -rf "$ROOT_DIR/backend/static/dist"
mkdir -p "$ROOT_DIR/backend/static/dist"
cp -r "$ROOT_DIR/frontend/build/"* "$ROOT_DIR/backend/static/dist/"
+if [ -n "$SOURCEMAP_TOKEN_INPUT" ]; then
+ APP_VERSION=${NEW_VERSION:-$CURRENT_VERSION}
+ echo "Uploading sourcemaps for version $APP_VERSION..."
+ npx @tracewayapp/sourcemap-upload \
+ --url https://cloud.tracewayapp.com \
+ --token "$SOURCEMAP_TOKEN_INPUT" \
+ --version "$APP_VERSION" \
+ --directory "$ROOT_DIR/frontend/build"
+ echo "Sourcemaps uploaded successfully"
+fi
+
echo "Frontend built and bundled into backend/static/dist/"