mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-16 22:59:04 +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>
50 lines
2.2 KiB
Go
50 lines
2.2 KiB
Go
package analytics
|
|
|
|
import "testing"
|
|
|
|
func TestRuntimeReadyOmitsUnmeasuredDuration(t *testing.T) {
|
|
ev := RuntimeReady("user-1", "workspace-1", "runtime-1", "daemon-1", "codex", 0)
|
|
if _, ok := ev.Properties["ready_duration_ms"]; ok {
|
|
t.Fatalf("ready_duration_ms should be omitted until it is measured")
|
|
}
|
|
|
|
ev = RuntimeReady("user-1", "workspace-1", "runtime-1", "daemon-1", "codex", 123)
|
|
if got := ev.Properties["ready_duration_ms"]; got != int64(123) {
|
|
t.Fatalf("ready_duration_ms = %v, want 123", got)
|
|
}
|
|
}
|
|
|
|
func TestFailedEventsUseWillRetry(t *testing.T) {
|
|
runEv := AutopilotRunFailed("user-1", "workspace-1", "autopilot-1", "run-1", "manual", AutopilotAssignee{AgentID: "agent-1", AssigneeType: "agent"}, "manual", "task failed", "task_error", false, 10)
|
|
if got := runEv.Properties["will_retry"]; got != false {
|
|
t.Fatalf("autopilot will_retry = %v, want false", got)
|
|
}
|
|
if _, ok := runEv.Properties["recoverable"]; ok {
|
|
t.Fatalf("autopilot failure should not emit recoverable")
|
|
}
|
|
}
|
|
|
|
func TestIsMetricsOnly(t *testing.T) {
|
|
// As of MUL-4127, PostHog is retired for server-side product analytics:
|
|
// every server-side event is Prometheus-only and must not ship to PostHog.
|
|
for _, name := range []string{
|
|
// runtime / autopilot execution-lifecycle telemetry
|
|
EventRuntimeRegistered, EventRuntimeReady, EventRuntimeFailed, EventRuntimeOffline,
|
|
EventAutopilotRunStarted, EventAutopilotRunCompleted, EventAutopilotRunFailed,
|
|
// product-behaviour events (now DB + Grafana only)
|
|
EventSignup, EventWorkspaceCreated, EventIssueCreated, EventIssueExecuted,
|
|
EventChatMessageSent, EventTeamInviteSent, EventTeamInviteAccepted,
|
|
EventOnboardingStarted, EventOnboardingQuestionnaireSubmit, EventAgentCreated,
|
|
EventOnboardingCompleted, EventCloudWaitlistJoined, EventFeedbackSubmitted,
|
|
EventContactSalesSubmitted, EventSquadCreated, EventAutopilotCreated,
|
|
} {
|
|
if !IsMetricsOnly(name) {
|
|
t.Errorf("IsMetricsOnly(%q) = false, want true (server events stay out of PostHog since MUL-4127)", name)
|
|
}
|
|
}
|
|
// A name that isn't a declared server event is not metrics-only.
|
|
if IsMetricsOnly("$exception") {
|
|
t.Errorf("IsMetricsOnly(%q) = true, want false (frontend-only event)", "$exception")
|
|
}
|
|
}
|