Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion scripts/build-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ rm pkg/evo.js.bak web/pkg/evo.js.bak
# Update cache-busting version in index.html
echo "🔄 Updating cache busting version in index.html..."
sed -i.bak "s/src=\"js\/app\.js?v=[0-9a-f]*\"/src=\"js\/app.js?v=$CACHE_VERSION\"/g" web/index.html
sed -i.bak "s/src=\"js\/sentry-config\.js?v=[0-9a-z]*\"/src=\"js\/sentry-config.js?v=$CACHE_VERSION\"/g" web/index.html
sed -i.bak "s/src=\"js\/sentry\.js?v=[0-9a-z]*\"/src=\"js\/sentry.js?v=$CACHE_VERSION\"/g" web/index.html
# Cache-bust the stylesheet too — without a ?v= a stale style.css is served after a deploy.
sed -i.bak "s|href=\"css/style.css?v=[0-9a-z]*\"|href=\"css/style.css?v=$CACHE_VERSION\"|g" web/index.html
rm web/index.html.bak

node scripts/write-sentry-config.mjs evo web/js/sentry-config.js "$CACHE_VERSION"

# Verify the build
echo "🔍 Verifying build..."
if [ -f "pkg/evo.js" ] && [ -f "pkg/evo_bg.wasm" ]; then
Expand All @@ -118,4 +122,4 @@ fi
echo "🎉 Build complete! Run 'npm run dev' to start the server."
echo "📁 Built files:"
ls -la pkg/
echo "🔢 Cache version: $CACHE_VERSION"
echo "🔢 Cache version: $CACHE_VERSION"
19 changes: 19 additions & 0 deletions scripts/write-sentry-config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { writeFileSync } from 'node:fs';

const app = process.argv[2] || 'evo';
const target = process.argv[3] || 'web/js/sentry-config.js';
const fallbackRelease = process.argv[4] || '';

writeFileSync(
target,
`window.TRE_STATIC_SENTRY_CONFIG = ${JSON.stringify(
{
app,
dsn: process.env.SENTRY_DSN || '',
environment: process.env.SENTRY_ENVIRONMENT || 'production',
release: process.env.SENTRY_RELEASE || process.env.GITHUB_SHA || fallbackRelease,
},
null,
2,
)};\n`,
);
2 changes: 2 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@
</main>
</div>

<script src="js/sentry-config.js?v=dev"></script>
<script src="js/sentry.js?v=dev" defer></script>
<script type="module" src="js/app.js?v=9b218cf"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions web/js/sentry-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
window.TRE_STATIC_SENTRY_CONFIG = {
app: "evo",
dsn: "",
environment: "production",
release: "",
};
37 changes: 37 additions & 0 deletions web/js/sentry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(() => {
const config = window.TRE_STATIC_SENTRY_CONFIG;
if (!config?.dsn) return;

const script = document.createElement("script");
script.src = "https://browser.sentry-cdn.com/10.57.0/bundle.min.js";
script.crossOrigin = "anonymous";
script.onload = () => {
if (!window.Sentry) return;
window.Sentry.init({
dsn: config.dsn,
environment: config.environment || "production",
release: config.release,
sendDefaultPii: false,
tracesSampleRate: config.environment === "production" ? 0.01 : 0,
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 0,
beforeSend(event) {
if (event.request) {
delete event.request.cookies;
delete event.request.data;
if (event.request.headers) {
for (const key of Object.keys(event.request.headers)) {
const lowerKey = key.toLowerCase();
if (lowerKey.includes("authorization") || lowerKey.includes("cookie")) {
event.request.headers[key] = "[Filtered]";
}
}
}
}
event.tags = { ...event.tags, app: config.app || "evo" };
return event;
},
});
};
document.head.appendChild(script);
})();
Loading