mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 03:38:32 +02:00
* feat(analytics): suppress PostHog $pageview on desktop tab/workspace switches Desktop tab switches were emitting a $pageview every time the user clicked between already-open tabs (or workspaces), since the tracker fired on any change to the resolved active path. Real-data audit showed this was the single largest source of PostHog quota burn — desktop accounted for 51% of all $pageviews at ~34 pv/user/30d vs web's ~10 — and the re-emitted paths add no signal because the original navigation already fired. Detect "tab switch" as `(workspace, tabId)` identity changing while the surface stays `tab`, and skip the capture in that case while still updating the ref so the next in-tab navigation compares against the right baseline. Login transitions, overlay open/close, and intra-tab navigation continue to fire as before. Co-authored-by: multica-agent <github@multica.ai> * fix(analytics): only suppress $pageview for re-activations of known tabs Prior commit suppressed every (workspace, tabId) change while the surface stayed `tab`, which also swallowed the first $pageview for newly opened tabs (`openInNewTab` / `addTab`) and for cross-workspace `switchWorkspace` into a not-yet-seen tab. Track an observed `(workspace, tabId) → path` map seeded from the persisted tab store on mount. Suppress only when the active key is already in the map AND its recorded path matches the current path — i.e. genuine re-activation of an already-known tab. New tabs and cross-workspace navigation to a fresh tab now correctly emit one pageview. Adds a vitest covering the three behaviors GPT-Boy flagged plus the intra-tab navigation, overlay/login transitions, and persistence-restored mount paths. Wires the `@/` alias into `vitest.config.ts` so component tests can resolve renderer-relative imports. Co-authored-by: multica-agent <github@multica.ai> * refactor(analytics): reuse tab-store helpers and inline observed-tabs seed Replace the two ad-hoc tab selectors with the existing `useActiveTabIdentity()` + `getActiveTab()` helpers from tab-store, which already provide the (slug, tabId) primitive pair and the active tab lookup with the same stability guarantees. Move the observed-tabs Map seeding from a useEffect into a synchronous first-render initializer. The seed runs once per mount before any state-driven effect, so the previous useEffect-then-defensive-fallback pattern in the second effect was unreachable. Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: multica-agent <github@multica.ai>
20 lines
456 B
TypeScript
20 lines
456 B
TypeScript
import { resolve } from "path";
|
|
import { defineConfig } from "vitest/config";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
"@": resolve(__dirname, "src/renderer/src"),
|
|
},
|
|
},
|
|
test: {
|
|
globals: true,
|
|
include: ["src/**/*.test.{ts,tsx}", "scripts/**/*.test.mjs"],
|
|
environment: "jsdom",
|
|
setupFiles: ["./test/setup.ts"],
|
|
passWithNoTests: true,
|
|
},
|
|
});
|