Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: track CI/CD layout switch events to hub.bytebase.com (#18001)

boojack1606a2eab6cc
diff --git a/backend/server/echo_routes.go b/backend/server/echo_routes.go
index 6f5e0232fb..fa27c4743e 100644
--- a/backend/server/echo_routes.go
+++ b/backend/server/echo_routes.go
@@ -110,7 +110,7 @@ func securityHeadersMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
"script-src 'self' " + strings.Join(scriptHashes, " ") + " 'wasm-unsafe-eval'; " +
"style-src 'self' 'unsafe-inline'; " +
"img-src 'self' data: blob: discordapp.com; " +
- "connect-src 'self' data: ws: wss: https://api.github.com; " +
+ "connect-src 'self' data: ws: wss: https://api.github.com https://hub.bytebase.com; " +
"font-src 'self'; " +
"object-src 'none'; " +
"base-uri 'self'; " +
diff --git a/frontend/src/composables/useIssueLayoutVersion.ts b/frontend/src/composables/useIssueLayoutVersion.ts
index 7642871456..e072f41f41 100644
--- a/frontend/src/composables/useIssueLayoutVersion.ts
+++ b/frontend/src/composables/useIssueLayoutVersion.ts
@@ -1,4 +1,6 @@
import { useLocalStorage } from "@vueuse/core";
+import { useActuatorV1Store, useCurrentUserV1 } from "@/store";
+import { isDev } from "@/utils";
const STORAGE_KEY = "bb.issue.layout";
@@ -6,6 +8,43 @@ const STORAGE_KEY = "bb.issue.layout";
// This helps to reset user preferences to the new default layout.
const CURRENT_DEFAULT_VERSION = 1;
+// Send event to hub.bytebase.com when switching to legacy layout.
+async function trackLayoutSwitch() {
+ try {
+ const actuatorStore = useActuatorV1Store();
+ const currentUser = useCurrentUserV1();
+
+ const workspaceId = actuatorStore.info?.workspaceId;
+ const email = currentUser.value.email;
+ const version = actuatorStore.version;
+ const commit = actuatorStore.gitCommitBE;
+
+ // Only track when switching to legacy layout
+ if (!workspaceId || !email) {
+ return;
+ }
+
+ // Send event to hub.bytebase.com
+ await fetch("https://hub.bytebase.com/v1/events", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ workspaceId,
+ email,
+ version,
+ commit,
+ consoleCicdLayoutSwitchToLegacy: {
+ reason: "",
+ },
+ }),
+ });
+ } catch {
+ // Silently fail if tracking fails - don't block user action
+ }
+}
+
export function useIssueLayoutVersion() {
// Store whether user prefers the new layout (true) or old layout (false).
const enabled = useLocalStorage<boolean>(`${STORAGE_KEY}.enabled`, true);
@@ -25,9 +64,15 @@ export function useIssueLayoutVersion() {
// Toggle between layouts
const toggleLayout = () => {
+ const switchingToLegacy = enabled.value === true;
enabled.value = !enabled.value;
lastVersion.value = CURRENT_DEFAULT_VERSION;
+ // Track the switch event when switching to legacy layout in production.
+ if (switchingToLegacy && !isDev()) {
+ trackLayoutSwitch();
+ }
+
// Reload the window to ensure clean state transition.
window.location.reload();
};