Skip to content

[local-onboarding-funnel-telemetry-fill-gaps-in] Onboarding funnel telemetry: fill gaps in setup events - #849

Open
danii1 wants to merge 1 commit into
feature/local-onboarding-try-it-on-this-repo-first-sugfrom
feature/local-onboarding-funnel-telemetry-fill-gaps-in
Open

danii1 wants to merge 1 commit into
feature/local-onboarding-try-it-on-this-repo-first-sugfrom
feature/local-onboarding-funnel-telemetry-fill-gaps-in

Conversation

@danii1

@danii1 danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Why

Stacked on #846 (feature/local-onboarding-try-it-on-this-repo-first-sug, task local-onboarding-try-it-on-this-repo-first-sug): this PR targets that branch. Review and merge #846 first.

Task local-onboarding-funnel-telemetry-fill-gaps-in: Onboarding funnel telemetry: fill gaps in setup events

DevIntern already sent setup events, but nothing tied one init run's events together, and several steps had no event at all: host checks, tracker choice, credential and query checks, sign-in, service install, first task, and abandonment. The owner wants to see where real users stop during setup. The audit below lists the gaps.

What changed

  • Funnel state (new observability/setup-funnel.ts): one random setup_id per setup run, plus the last funnel step reached.
    • runInit always opens a fresh one.
    • runWorkerInit and worker init --non-interactive join an open one or open their own.
    • Whoever opens it closes it.
  • Existing events keep their names. They now carry setup_id and funnel_step:
    • setup_started and worker_init_started → init_started
    • setup_completed and worker_init_completed → completed
    • setup_failed and worker_init_failed → failed
    • setup_declined and a declined host check → declined
    • Failed and declined events also carry last_step.
  • Two new events:
    • setup_step has one funnel_step per step: host_checked, tracker_chosen, credentials_checked, query_checked, sign_in, service_install, first_task_started.
    • setup_abandoned fires on Ctrl+C, closed input, or too many invalid answers, with last_step. It is only queued before the usual exit flush, so it never adds delay beyond the existing flush limit.
  • Host check codes (worker-init-host.ts): agent_missing, agent_not_signed_in, git_missing, service_manager_unavailable, plus check_agent/check_git/check_service statuses.
    • agent-reuse.ts gained defaultAgentProblem, so "signed out" is known even when no other agent could replace it.
  • Tracker, credential and sign-in steps:
    • The tracker picker records the tracker id, whether it was the default, and whether it was try mode.
    • A tracker taken from saved config skips the picker and is recorded with reused_config.
    • Credential checks send pass/fail only.
    • Sign-in sends started, then passed, skipped or failed.
  • Query and service steps: each dry-run attempt is recorded, and the service step sends its install outcome.
  • First task, first PR, second task:
    • First task has three kinds: try, sample and the worker's own.
    • task_run and worker_task_run now carry pr_opened, set where a PR is created.
    • The try-mode foreground run gets DEVINTERN_SETUP_ID (UUID only) so its task_run joins the setup.
    • "Second task" is a second worker_task_run for the same anonymous id.
  • Property allowlist: ALLOWED_PROP_KEYS gained setup_id, funnel_step, last_step, harness, duration_ms, default_choice, try_mode, reused_config, pr_opened, task_kind, check_service and error_code. Values are enums, booleans or numbers.
  • Docs and tests:
    • docs/code/advanced-settings.md lists the setup events under the analytics section.
    • packages/code/AGENTS.md has a contributor note on keeping the names stable.
    • New tests/setup-funnel.test.ts has 13 tests.

Audit gaps. Everything marked "missing" had no event before this change.

Funnel step Before Now
init started existing now with setup_id
Host checks missing host_checked
Tracker chosen missing tracker_chosen
Credential check missing credentials_checked
Query check missing query_checked
Sign-in only login_result, outside init sign_in
Service install outcome only on the final event service_install
First task started missing first_task_started
First PR opened missing pr_opened on task events
Second task existing worker_task_run
Abandonment missing setup_abandoned

Website follow-up. The CLI docs are updated. The privacy page at https://devintern.com/privacy/ lives in the website repo and needs the same list of events and properties added there.

Scope

Included: the events above, the property allowlist, abandonment on prompt aborts, docs, the AGENTS.md note, and tests.

Excluded:

  • The manual init wizard has no host_checked event. It only lists agents after setup, so a host step there would break funnel order.
  • --non-interactive setup only gets setup_id and funnel_step on its existing started, completed and failed events. It has no per-step events. A failed run also sends the report's code as error_code.
  • Signal kills outside a prompt (a SIGINT outside a prompt, or SIGKILL) don't send setup_abandoned.
  • agent_not_signed_in is only detected for the default agent with no explicit AGENT_HARNESS.
  • No changelog entry.

Tradeoffs

  • No shared event for tracker setup: tracker_chosen and credentials_checked are emitted inside runTrackerSetup, which both wizards share, so they appear in both flows without duplicated code. The cost is that shared code now sends analytics.
  • Silent outside setup: trackFunnelStep does nothing when no setup run is open, so the shared picker and sign-in code send nothing outside setup.
  • Process-level state: funnel state is process-wide, so one process can only have one setup open. That fits a one-shot CLI.
  • first_pr_opened is not a setup_step event: it is a property on task_run, so funnels must read it from there. This kept the event count down.

Blast Radius

  • Callers of runTrackerSetup, runInit, runWorkerInit, hostStep, serviceStep, signInOnce and the first-task and try offers now send extra analytics calls. These are fire-and-forget, never throw, and skip when telemetry is off.
  • findAgentReuseOffer was refactored onto the new defaultAgentProblem. The existing agent-reuse tests pass.
  • trackInteractiveTaskRun and trackWorkerTaskRun gained pr_opened, which adds a field to the existing events.
  • trackWorkerInitFailed gained an optional third parameter.
  • worker/cli.ts now opens the funnel for --non-interactive.
  • Nothing printed to the user or in --json output changed, so I didn't update the offline e2e tests.

Verification

  • bun run typecheck: pass.
  • bun run lint: oxlint, knip and the ratchet all pass. After the final cleanup I re-ran only lint:knip and lint:ratchet, not the full lint.
  • bun run format: ran.
  • tests/setup-funnel.test.ts: 13 pass. Covered:
    • happy path with one setup_id and the funnel order;
    • host failure codes;
    • query fail then pass;
    • try mode;
    • credential check failure with no token in the payload;
    • early abort: setup_abandoned once, with last_step;
    • init → worker sharing one setup_id;
    • a declined host check;
    • telemetry disabled: nothing sent;
    • nothing sent outside a setup run;
    • the allowlist.
    • The init → worker test only throws inside runWorkerInit, so the runInit catch path is not independently covered.
  • Full bun run test in packages/code: 6554 pass, 3 fail on the first run; 6500 pass, 12 fail on the second.
    • The second run's failures were review-polling, GitLab, review-adapter mention and review-worktree tests.
    • The 10 test files containing the second run's failing tests pass when run alone: 297 pass, 0 fail. I did not run the base commit to confirm this was already flaky.
    • I didn't capture which 3 tests failed on the first run.
  • E2E: cli-privacy-egress and worker-init-try pass (12 tests). I did not run the full offline e2e suite.

🤖 Opened by DevIntern from local-onboarding-funnel-telemetry-fill-gaps-in

@danii1 danii1 added the devintern-authored Pull request written by DevIntern working its own backlog label Dec 4, 2026
@danii1

danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Artifacts & verification

Run: 1712 · Commit: d3dbbd33b8fdd18b1709f7cc296a8d731f26f0ab

Verification report

Produced by __verify-1, execution 1 at 86cdcf6d9873cb9ce08d4c2a322ee4d8286be3fc.

Show artifact
{
  "summary": "The change meets the functional requirements. It adds a shared `setup_id` and `funnel_step`, a new `setup_step` event plus `setup_abandoned`, and extends `ALLOWED_PROP_KEYS`. Existing event names are unchanged. The contributor note in `packages/code/AGENTS.md` and the user-facing events table in `docs/code/advanced-settings.md` are both there. I ran `tests/setup-funnel.test.ts` and all 13 tests passed. They cover the happy path, a try-mode first run, early abort, a declined host check, telemetry disabled, and a try-run child process joining the setup. The blast radius looks contained. `funnelProps` and `trackFunnelStep` return nothing when no setup is open, and `setAnalyticsCaptureForTests` resets the funnel state, so the shared code paths (tracker picker, sign-in, `trackSetupFailed` and `trackSetupDeclined` from `first-run.ts`) send no new properties outside a setup run. There are a few small gaps against the task text. I could not check the 'list the gaps in the PR' item, because the PR description is not in the diff.",
  "items": [
    {
      "priority": "low",
      "confidence": "medium",
      "category": "bug",
      "file": "packages/code/src/lib/observability/setup-funnel.ts",
      "line": "29",
      "issue": "`second_task_run` is declared as a funnel step but nothing emits it. The `FirstTaskKind` value `worker` is also never emitted. The 'second task' step only exists as a `worker_task_run` count per anonymous id, so a funnel built on the declared step names will show a step that never fires.",
      "evidence": "grep for `second_task_run` in packages/code/src finds only the declaration at setup-funnel.ts:29. `taskKind` is only ever set to `sample` or `try`, in `worker-init-first-task.ts` and `worker-init-try.ts`.",
      "suggestion": "Remove the unused step and kind, or emit them. Also state in the AGENTS.md note that the second task is derived from `worker_task_run`, not from a funnel step."
    },
    {
      "priority": "low",
      "confidence": "medium",
      "category": "bug",
      "file": "packages/code/src/lib/init/worker-init-activation.ts",
      "line": "666",
      "issue": "The task asks for 'service installed/failed (code)'. The `service_install` step only carries the coarse `serviceInstall` outcome (installed, failed and so on), with no failure code. `reason` is never set.",
      "evidence": "Lines 666-675 pass `serviceInstall: install` and a derived result, but no `reason` or `error_code`.",
      "suggestion": "If the service report already has a stable code, pass it as an allowlisted `error_code`."
    },
    {
      "priority": "low",
      "confidence": "low",
      "category": "testing",
      "file": "packages/code/tests/setup-funnel.test.ts",
      "line": "1",
      "issue": "The `devintern init` wizard's own sign-in funnel events (`runPostSetup` in `wizard.ts`) and the non-interactive `worker init` path have no direct sequence test. Only the worker wizard's sign-in is asserted. The sample-task `first_task_started` events are also not asserted.",
      "evidence": "Not proven; the tests call `runWorkerInit`, `runTrackerSetup`, `tryStep`, and `runInit` with a stubbed worker setup.",
      "suggestion": "Add a test that drives `runPostSetup`'s sign-in passed, skipped and failed branches, and one for the sample first-task event."
    },
    {
      "priority": "info",
      "confidence": "low",
      "category": "documentation",
      "file": "docs/code/advanced-settings.md",
      "line": "79",
      "issue": "The docs list the collected events in the CLI docs, but the privacy page the first-run notice links to (devintern.com/privacy) lives on the website. The task asks for a PR note about a website follow-up. The diff cannot show whether that note exists.",
      "evidence": "The AGENTS.md says the marketing site is in a separate repository; no website changes are in the diff.",
      "suggestion": "Make sure the PR description lists the website follow-up and the audit of gaps in the existing events."
    }
  ],
  "approved": true
}

Auto-review summary

Produced by auto-review, execution 1 at d3dbbd33b8fdd18b1709f7cc296a8d731f26f0ab.

Show artifact
{
  "iterations": 0,
  "success": true,
  "finalFeedback": {
    "summary": "Additive telemetry: a process-local `setup_id` state module, `trackFunnelStep` calls at each setup step, and an allowlisted property set. I found no blocking defects. The change is safe because every new emit goes through `funnelProps`/`trackFunnelStep`, which return nothing when no setup run is open (`setup-funnel.ts` `state === null`), and because `track()` still applies `scrubProps` and the opt-out check. I confirmed this by reading the code and did not run the test suite. Task outcome events are the exception. They gain `pr_opened` unconditionally, and that is safe because `trackWorkerTaskRun` runs in a per-task subprocess (`state/task-run.ts:47`), so the process-level flag cannot go stale. A few unused or loose pieces remain.",
    "items": [
      {
        "priority": "low",
        "confidence": "medium",
        "category": "code-quality",
        "file": "packages/code/src/lib/observability/setup-funnel.ts",
        "line": "19-30",
        "issue": "`second_task_run` is in `FUNNEL_PROGRESS_STEPS` and `\"worker\"` is in `FirstTaskKind`, but nothing in the diff emits either. The AGENTS.md text says \"second task\" is derived from a second `worker_task_run` per anonymous id. Dead enum members in a contract that AGENTS.md calls public invite dashboards built on events that never fire.",
        "evidence": "Searched the diff: no `trackFunnelStep(\"second_task_run\"` and no `taskKind: \"worker\"` call site exists.",
        "suggestion": "Remove the unused members, or emit them. AGENTS.md says to add steps rather than repurpose them, so removal is cheap now and costly later."
      },
      {
        "priority": "low",
        "confidence": "medium",
        "category": "bug",
        "file": "packages/code/src/lib/observability/analytics.ts",
        "line": "540-560",
        "issue": "`inheritedFunnelProps` sets `funnel_step: \"first_pr_opened\"` on `task_run`, not on a `setup_step` event. A funnel keyed on `setup_step` + `funnel_step` will therefore miss the first-PR step. Also, `trackWorkerTaskRun` (`analytics.ts:712`) carries `pr_opened` but no `setup_id`, so worker tasks cannot be joined to a setup run.",
        "evidence": "analytics.ts `trackInteractiveTaskRun` and `trackWorkerTaskRun` in the diff; the AGENTS.md text documents this as intended (`task_run`/`worker_task_run` with `pr_opened: true`).",
        "suggestion": "Document in the docs table that `first_pr_opened` arrives on `task_run`. Optionally have the child emit a `setup_step` event."
      },
      {
        "priority": "low",
        "confidence": "medium",
        "category": "testing",
        "file": "packages/code/src/lib/init/worker-init-activation.ts",
        "line": "663-675",
        "issue": "The `service_install` result mapping (installed/updated/existing → passed, failed → failed, else skipped) is only tested for the `skipped` case, so the `passed` and `failed` branches are unexercised. The flags-mode path (`flagsStartService`, `--start`) emits no `service_install` step, so the funnel differs between wizard and `worker init --non-interactive`. The same applies to the `sign_in` step, which is emitted only by the wizard code paths and by `signInOnce`.",
        "evidence": "setup-funnel.test.ts asserts only `service_install` with outcome `skipped`; the `else if (run.args.start)` branch has no `trackFunnelStep`.",
        "suggestion": "Add a test for installed and failed. Decide whether flags mode should emit these steps, and document the choice."
      },
      {
        "priority": "info",
        "confidence": "low",
        "category": "documentation",
        "file": "docs/code/advanced-settings.md",
        "line": "79-90",
        "issue": "The docs list `service_install` in the event table, but the `setup_step` row's description is long and the table's column widths are misaligned, which oxfmt may reformat. The docs also don't say that `duration_ms` and `harness` are sent, though they say events carry only step names, tracker/agent type, pass/fail, codes, durations and flags, so this is roughly covered.",
        "evidence": "Reading the diff only; `bun run format` was not run.",
        "suggestion": "Run `bun run format` before committing."
      }
    ],
    "approved": true
  },
  "unresolved": [],
  "stopReason": "approved",
  "commitSha": "d3dbbd33b8fdd18b1709f7cc296a8d731f26f0ab",
  "history": [
    {
      "iteration": 1,
      "feedback": {
        "summary": "Additive telemetry: a process-local `setup_id` state module, `trackFunnelStep` calls at each setup step, and an allowlisted property set. I found no blocking defects. The change is safe because every new emit goes through `funnelProps`/`trackFunnelStep`, which return nothing when no setup run is open (`setup-funnel.ts` `state === null`), and because `track()` still applies `scrubProps` and the opt-out check. I confirmed this by reading the code and did not run the test suite. Task outcome events are the exception. They gain `pr_opened` unconditionally, and that is safe because `trackWorkerTaskRun` runs in a per-task subprocess (`state/task-run.ts:47`), so the process-level flag cannot go stale. A few unused or loose pieces remain.",
        "items": [
          {
            "priority": "low",
            "confidence": "medium",
            "category": "code-quality",
            "file": "packages/code/src/lib/observability/setup-funnel.ts",
            "line": "19-30",
            "issue": "`second_task_run` is in `FUNNEL_PROGRESS_STEPS` and `\"worker\"` is in `FirstTaskKind`, but nothing in the diff emits either. The AGENTS.md text says \"second task\" is derived from a second `worker_task_run` per anonymous id. Dead enum members in a contract that AGENTS.md calls public invite dashboards built on events that never fire.",
            "evidence": "Searched the diff: no `trackFunnelStep(\"second_task_run\"` and no `taskKind: \"worker\"` call site exists.",
            "suggestion": "Remove the unused members, or emit them. AGENTS.md says to add steps rather than repurpose them, so removal is cheap now and costly later."
          },
          {
            "priority": "low",
            "confidence": "medium",
            "category": "bug",
            "file": "packages/code/src/lib/observability/analytics.ts",
            "line": "540-560",
            "issue": "`inheritedFunnelProps` sets `funnel_step: \"first_pr_opened\"` on `task_run`, not on a `setup_step` event. A funnel keyed on `setup_step` + `funnel_step` will therefore miss the first-PR step. Also, `trackWorkerTaskRun` (`analytics.ts:712`) carries `pr_opened` but no `setup_id`, so worker tasks cannot be joined to a setup run.",
            "evidence": "analytics.ts `trackInteractiveTaskRun` and `trackWorkerTaskRun` in the diff; the AGENTS.md text documents this as intended (`task_run`/`worker_task_run` with `pr_opened: true`).",
            "suggestion": "Document in the docs table that `first_pr_opened` arrives on `task_run`. Optionally have the child emit a `setup_step` event."
          },
          {
            "priority": "low",
            "confidence": "medium",
            "category": "testing",
            "file": "packages/code/src/lib/init/worker-init-activation.ts",
            "line": "663-675",
            "issue": "The `service_install` result mapping (installed/updated/existing → passed, failed → failed, else skipped) is only tested for the `skipped` case, so the `passed` and `failed` branches are unexercised. The flags-mode path (`flagsStartService`, `--start`) emits no `service_install` step, so the funnel differs between wizard and `worker init --non-interactive`. The same applies to the `sign_in` step, which is emitted only by the wizard code paths and by `signInOnce`.",
            "evidence": "setup-funnel.test.ts asserts only `service_install` with outcome `skipped`; the `else if (run.args.start)` branch has no `trackFunnelStep`.",
            "suggestion": "Add a test for installed and failed. Decide whether flags mode should emit these steps, and document the choice."
          },
          {
            "priority": "info",
            "confidence": "low",
            "category": "documentation",
            "file": "docs/code/advanced-settings.md",
            "line": "79-90",
            "issue": "The docs list `service_install` in the event table, but the `setup_step` row's description is long and the table's column widths are misaligned, which oxfmt may reformat. The docs also don't say that `duration_ms` and `harness` are sent, though they say events carry only step names, tracker/agent type, pass/fail, codes, durations and flags, so this is roughly covered.",
            "evidence": "Reading the diff only; `bun run format` was not run.",
            "suggestion": "Run `bun run format` before committing."
          }
        ],
        "approved": true
      },
      "addressed": [],
      "commitSha": "d3dbbd33b8fdd18b1709f7cc296a8d731f26f0ab"
    }
  ]
}

…arding funnel telemetry: fill gaps in setup events
@danii1
danii1 force-pushed the feature/local-onboarding-funnel-telemetry-fill-gaps-in branch from d3dbbd3 to 1bab475 Compare December 4, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devintern-authored Pull request written by DevIntern working its own backlog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant