mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-02 01:45:52 +02:00
* chore(analytics): retire redundant PostHog tracking (MUL-4127) PostHog had become a chaotic, largely-unused second copy of data we already query from the DB and Grafana. Remove the redundant instrumentation. Server: every product event (signup, workspace_created, issue_created, issue_executed, chat_message_sent, team_invite_*, onboarding_*, agent_created, cloud_waitlist_joined, feedback_submitted, contact_sales_submitted, squad_created, autopilot_created) is now in metricsOnlyEvents, so metrics.RecordEvent still increments the Prometheus/Grafana counter but no longer ships to PostHog. DB rows remain the source of truth. Runtime/autopilot/ agent_task lifecycle were already Prometheus-only. Frontend: delete the PostHog-only funnel instrumentation — $pageview (+ web and desktop trackers), download_intent_expressed/page_viewed/initiated, the onboarding_started mirror, onboarding_runtime_path_selected/detected, feedback_opened, and source_backfill_*. The source-backfill modal itself stays (it PATCHes the questionnaire to the DB). Kept on PostHog (frontend only): $exception autocapture and the client_crash / client_unresponsive stability telemetry (no DB equivalent), plus $identify/$set. captureSignupSource (attribution cookie) stays — it still feeds the signup_source Prometheus label. Verified: pnpm typecheck, pnpm lint (0 errors), vitest (core/views/web/desktop), go test ./internal/analytics/... ./internal/metrics/... Co-authored-by: multica-agent <github@multica.ai> * docs(analytics): fix stale PostHog references after MUL-4127 (review follow-up) Addresses review of #4996 — three spots still described server events as active PostHog signals after they became metrics-only: - docs/analytics.md: issue_executed is no longer a PostHog success signal; it is Prometheus-only (multica_issue_executed_total) + issue.first_executed_at, in both the event contract and the Reconciliation section. - docs/analytics.md: the signup $set_once person properties (email, signup_source) are no longer emitted — signup is Prometheus-only; only the bucketed signup_source survives as the multica_signup_total label. - server/internal/metrics/business_events.go: RecordEvent doc comment no longer claims it ships product events to PostHog / "PostHog is reserved for user/product-behaviour events" — every server event is now metrics-only. Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: J <j@multica.ai> Co-authored-by: multica-agent <github@multica.ai>
97 lines
3.2 KiB
TypeScript
97 lines
3.2 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { forwardRef, useImperativeHandle } from "react";
|
|
|
|
let storedDraftMessage = "saved draft";
|
|
|
|
vi.mock("react-i18next", () => ({
|
|
useTranslation: () => ({ t: (key: string) => key, i18n: { changeLanguage: vi.fn() } }),
|
|
Trans: ({ children }: { children: any }) => children,
|
|
initReactI18next: { type: "3rdParty", init: vi.fn() },
|
|
}));
|
|
|
|
vi.mock("../i18n", () => ({
|
|
useT: () => ({
|
|
t: (selector: (resources: any) => string) =>
|
|
selector({
|
|
feedback: {
|
|
title: "Feedback",
|
|
github_hint_prefix: "Prefer GitHub? ",
|
|
github_hint_link: "Open an issue",
|
|
placeholder: "Tell us what happened",
|
|
toast_uploading: "Uploading",
|
|
toast_too_long: "Too long",
|
|
toast_sent: "Sent",
|
|
toast_failed: "Failed",
|
|
sending: "Sending",
|
|
send: "Send",
|
|
},
|
|
}),
|
|
}),
|
|
}));
|
|
|
|
vi.mock("@multica/core/paths", () => ({ useCurrentWorkspace: () => ({ id: "ws1" }) }));
|
|
vi.mock("@multica/core/hooks/use-file-upload", () => ({
|
|
useFileUpload: () => ({ uploadWithToast: vi.fn() }),
|
|
}));
|
|
vi.mock("@multica/core/api", () => ({ api: {} }));
|
|
vi.mock("sonner", () => ({ toast: { info: vi.fn(), error: vi.fn(), success: vi.fn() } }));
|
|
vi.mock("@multica/core/platform", () => ({
|
|
formatShortcut: () => "⌘↵",
|
|
modKey: "mod",
|
|
enterKey: "enter",
|
|
}));
|
|
vi.mock("@multica/core/feedback", () => ({
|
|
FEEDBACK_KINDS: ["bug", "feature", "general", "praise"] as const,
|
|
useCreateFeedback: () => ({ isPending: false, mutateAsync: vi.fn() }),
|
|
useFeedbackDraftStore: (selector: any) =>
|
|
selector({ draft: { message: storedDraftMessage }, setDraft: vi.fn(), clearDraft: vi.fn() }),
|
|
}));
|
|
vi.mock("../editor", () => {
|
|
const ContentEditor = forwardRef(({ defaultValue }: any, ref) => {
|
|
useImperativeHandle(ref, () => ({
|
|
hasActiveUploads: () => false,
|
|
getMarkdown: () => defaultValue,
|
|
uploadFile: vi.fn(),
|
|
}));
|
|
return <textarea aria-label="feedback editor" defaultValue={defaultValue} />;
|
|
});
|
|
ContentEditor.displayName = "MockContentEditor";
|
|
return {
|
|
ContentEditor,
|
|
useFileDropZone: () => ({ isDragOver: false, dropZoneProps: {} }),
|
|
FileDropOverlay: () => null,
|
|
FileUploadButton: () => <button type="button">Upload</button>,
|
|
};
|
|
});
|
|
|
|
import { FeedbackModal } from "./feedback";
|
|
|
|
describe("FeedbackModal", () => {
|
|
beforeEach(() => {
|
|
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("uses a crash-report initialMessage when there is no saved draft", () => {
|
|
storedDraftMessage = "";
|
|
|
|
render(<FeedbackModal onClose={vi.fn()} initialMessage="kind: desktop_route_error" />);
|
|
|
|
expect(screen.getByLabelText("feedback editor")).toHaveValue("kind: desktop_route_error");
|
|
});
|
|
|
|
it("does not overwrite an existing feedback draft when crash report context is provided", () => {
|
|
storedDraftMessage = "saved draft";
|
|
|
|
render(<FeedbackModal onClose={vi.fn()} initialMessage="kind: desktop_route_error" />);
|
|
|
|
expect(screen.getByLabelText("feedback editor")).toHaveValue(
|
|
"saved draft\n\n---\n\nkind: desktop_route_error",
|
|
);
|
|
});
|
|
});
|