Skip to content

fix(insights): clarify measured goal and funnel populations - #737

Merged
izadoesdev merged 2 commits into
stagingfrom
codex/insights-cohort-context
Sep 6, 2026
Merged

fix(insights): clarify measured goal and funnel populations#737
izadoesdev merged 2 commits into
stagingfrom
codex/insights-cohort-context

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 6, 2026

Copy link
Copy Markdown
Member

Goal and funnel briefs can attach valid counts to the wrong population: a workspace route's authenticated audience becomes the goal denominator, or a visitor funnel becomes a project count. Clarify the native visitor semantics and date-range behavior in the tool descriptions and investigation instructions, while trimming repeated guidance. Executable code, schemas, tools, turn limits and storage are unchanged; runtime source line count is unchanged.

Fresh synthetic comparison on production gpt-5.6-terra: 30 baseline / 30 candidate runs, plus 48 retained runs of rejected variants. Those 108 runs and 235 observable steps were reviewed. On that matched comparison (before the final review wording clarification), turns were 68 → 60, correction attempts 5 → 0, input tokens 454,522 → 390,998, and average brief length 49.2 → 46.3 words. Summed run time was 267.8 → 256.1 seconds; this small sample does not establish a durable latency gain.

The product gain is narrower, clearer cohort wording with fewer retries. Important limitations remain: all three final revenue cases still omitted an independent attribution decline, one funnel summary still described project volume, and empty category-filtered retention searches still led to overly broad capability conclusions. Both final tracking-gap briefs exceeded the 60-word target (64/65); other final briefs stayed within it. Rejected prompt/schema rewrites increased verbosity or redundant reads and are excluded from this diff.

Validation: root bun run lint, root bun run check-types (33 tasks), and relevant tests (361 insights, 573 AI) pass. An initial test attempt ran before the SDK build and failed to resolve its dist entry; the normal root test pipeline subsequently built dependencies and passed. No live customer data, writes, or notifications were used in evals. Local audit retains prompts, calls/results, rejected drafts, corrections, persisted outcomes, source revisions and per-run review notes; private reasoning is omitted.

Scope: investigation prompt and native goal/funnel tool descriptions, with eval review guidance. No dependencies on open PRs and no overlap with #680's bulk goal analytics implementation. AI assistance disclosed; maintainer contribution under the repository's policy exemption.

Review follow-up: the funnel instruction now explicitly distinguishes first-step entrants from all-step completions. Six fresh affected runs on the final code retained the visitor comparisons and repair conditions with zero correction turns; three still exceeded the word target (61/66/66). These limitations are retained rather than counted as full quality passes. Fresh lint, types and 934 relevant tests pass.

@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
databuddy-status Ready Ready Preview Sep 6, 2026 9:20pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
dashboard Skipped Skipped Sep 6, 2026 9:20pm UTC
documentation Skipped Skipped Sep 6, 2026 9:20pm UTC

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 27a3c935-ed4c-4711-9107-27e9831eed5e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@izadoesdev
izadoesdev marked this pull request as ready for review September 6, 2026 21:07
@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR clarifies the visitor populations represented by native goal and funnel analytics without changing executable query behavior or schemas.

  • Defines goal entrants as distinct website page-view visitors matching filters other than event_name.
  • Distinguishes site-to-goal conversion from authenticated-user or attempt-success rates.
  • Defines funnel entrants and completions as distinct visitors progressing through ordered steps.
  • Clarifies that source comparisons require separate calls for separate date ranges.
  • Adds manual evaluation guidance for detecting correct counts attached to incorrect populations.

Confidence Score: 5/5

The PR appears safe to merge because the revised descriptions match the implemented goal and funnel analytics semantics, and no actionable regression was identified.

The changes are limited to AI-facing descriptions and evaluation guidance; the asserted goal denominator, completion population, funnel visitor counts, and date-range behavior agree with the underlying implementations.

Important Files Changed

Filename Overview
apps/insights/src/agent.ts Clarifies goal and funnel cohort semantics while compressing general investigation and publication guidance without removing core evidence safeguards.
packages/ai/src/ai/tools/goals.ts Aligns the goal analytics tool description with the implemented distinct-visitor denominator, completion count, and conversion calculation.
packages/ai/src/ai/tools/funnels.ts Clarifies distinct-visitor funnel semantics and separate-period behavior for referrer breakdowns.
apps/insights/src/evals/README.md Adds manual review guidance for population attribution and prompt-compression regressions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  PV[Website page-view visitors matching non-event filters] --> GE[Goal entrants]
  GV[Visitors matching the complete goal definition] --> GC[Goal completions]
  GE --> GR[Goal conversion: completions / entrants]
  FS[Visitors reaching first funnel step] --> FE[Funnel entrants]
  FE --> FO[Visitors reaching every ordered step]
  FO --> FC[Funnel completions]
  FE --> SR[Referrer breakdown for one date range]
  FC --> SR
Loading

Reviews (1): Last reviewed commit: "fix(insights): clarify measured goal and..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Architecture diagram
sequenceDiagram
    participant Agent as Insights Agent (agent.ts)
    participant FunnelTools as Funnel Tools (funnels.ts)
    participant GoalTools as Goal Tools (goals.ts)
    participant Eval as Eval README (evals/)
    participant Model as LLM (gpt-5.6-terra)

    Note over Agent,Model: Runtime system flow with clarified population semantics

    Agent->>Model: Process insights task
    Agent->>Agent: Load investigation instructions (goal/funnel context)
    
    alt Goal signal detected
        Agent->>GoalTools: invoke goal analytics
        GoalTools->>GoalTools: Parse native counts (entrants/completed)
        Note over GoalTools: total_users_entered excludes event_name<br/>total_users_completed = visitors matching goal
        GoalTools-->>Agent: Return distinct visitor counts + conversion rate
        Agent->>Model: Interpret as site-to-goal conversion (not login)
    else Funnel signal detected
        Agent->>FunnelTools: invoke funnel analytics
        FunnelTools->>FunnelTools: Count distinct visitors per ordered step
        Note over FunnelTools: Entrants = first step<br/>Completions = all ordered steps
        FunnelTools-->>Agent: Return visitor counts (not projects/attempts)
        
        alt Required for ratio analysis
            Agent->>FunnelTools: invoke referrer breakdown
            Note over FunnelTools: Accepts single date range only
            Agent->>FunnelTools: Separate call for previous period
            FunnelTools-->>Agent: Source-grouped visitor counts
        end
    end

    Agent->>Agent: Busy comparison windows (current/previous)
    Agent->>Model: Draft brief with new guidance
    Note over Agent,Model: Correct numbers must attach to<br/>measured population (distinct visitors)

    alt Review process (eval)
        Agent->>Eval: Load cohort review guidance
        Note over Eval: Verify headline population, not just rubric success
        Eval-->>Agent: Manual check: goal denominator vs intended audience
    end

    Agent->>Model: Final publication decision
    Note over Agent,Model: Route audience ≠ measured cohort<br/>Prior activity ≠ current loss
Loading

Shadow auto-approve: would not auto-approve because issues were found.

Re-trigger cubic

Comment thread apps/insights/src/agent.ts Outdated
@unkey-deploy

unkey-deploy Bot commented Sep 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Sep 6, 2026 9:20pm

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Shadow auto-approve: would auto-approve. Clarifies goal/funnel tool descriptions and eval guidance so counts attach to the correct visitor population; prompts and docs only, no code, schema, or runtime behavior changed, validated by evals.

Re-trigger cubic

@izadoesdev
izadoesdev merged commit cc8923c into staging Sep 6, 2026
20 checks passed
@izadoesdev
izadoesdev deleted the codex/insights-cohort-context branch September 6, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant