Skip to content

Treat FlakeHub logins as a funnel#199

Merged
grahamc merged 1 commit intomainfrom
gustavderdrache/push-mwwwyvquzwnz
Sep 9, 2025
Merged

Treat FlakeHub logins as a funnel#199
grahamc merged 1 commit intomainfrom
gustavderdrache/push-mwwwyvquzwnz

Conversation

@gustavderdrache
Copy link
Copy Markdown
Contributor

@gustavderdrache gustavderdrache commented Sep 9, 2025

Description

This PR restructures FlakeHub login events:

  • All logins begin with a start event.
  • Then, they proceed to either success or failure.
  • Finally, an end is recorded.

As a future maintenance note: we need to make sure that end is recorded in all code paths.

Checklist
  • Tested changes against a test repository
  • Added or updated relevant documentation (leave unchecked if not applicable)
  • (If this PR is for a release) Updated README to point to the new tag (leave unchecked if not applicable)

Summary by CodeRabbit

  • Refactor

    • Renamed and expanded telemetry events for the FlakeHub login flow.
  • Chores

    • Instrumented the login flow to emit start, success, and end events across all outcomes.
    • Removed outdated event usage and aligned event sequencing.
    • Minor control-flow adjustments to consistently emit end telemetry.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 9, 2025

Walkthrough

Renamed and extended FlakeHub login telemetry events in src/index.ts and instrumented the flakehubLogin flow to emit start, success, and end events across all paths, replacing the prior single event. Adjusted control flow to ensure end telemetry is consistently recorded on success, fork, misconfiguration, and failure.

Changes

Cohort / File(s) Summary
Telemetry event renaming and flow instrumentation
src/index.ts
Replaced EVENT_LOGIN_TO_FLAKEHUB with EVENT_LOGIN_START ("flakehub-login:start"), added EVENT_LOGIN_SUCCESS and EVENT_LOGIN_END; updated flakehubLogin to record start at entry, success on completion, and end on all exit paths including fork/not-configured/failure. Removed direct usage of the old event.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant A as Action (src/index.ts)
  participant FH as FlakeHub
  participant T as Telemetry

  U->>A: Trigger flakehubLogin
  A->>T: record EVENT_LOGIN_START
  A->>FH: Attempt login

  alt Success
    FH-->>A: Auth OK
    A->>T: record EVENT_LOGIN_SUCCESS
    A->>T: record EVENT_LOGIN_END
    A-->>U: Return success
  else Fork or Not Configured
    FH-->>A: Fork/Misconfig path
    A->>T: record failure (existing) + EVENT_LOGIN_END
    A-->>U: Return handled path
  else Failure
    FH-->>A: Error
    A->>T: record failure (existing)
    A->>T: record EVENT_LOGIN_END
    A-->>U: Return error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • grahamc

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly captures the PR’s primary change of restructuring FlakeHub login events into a funnel pattern, and it is clear, concise, and directly related to the core instrumentation update.
Description Check ✅ Passed The description clearly outlines the restructuring of FlakeHub login events into start, success/failure, and end stages, which matches the changeset, and includes a relevant future maintenance note.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

A hop, a bop, I log and then I lend—
Start, success, and finally, end.
Carrots count the pings I send,
Forks or fails, the trails I tend.
Thump-thump logs, my fluffy friend—
Telemetry’s tidy, carrot-commend! 🥕🐇

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gustavderdrache/push-mwwwyvquzwnz

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/index.ts (3)

23-23: Telemetry bug: install success constant is misnamed.

EVENT_INSTALL_NIX_SUCCESS equals "install_nix_start" causing start and success to be indistinguishable in analytics.

Apply this diff:

-const EVENT_INSTALL_NIX_SUCCESS = "install_nix_start";
+const EVENT_INSTALL_NIX_SUCCESS = "install_nix_success";

287-289: Wrong env value: writes user ID base from count.

NIX_INSTALLER_NIX_BUILD_USER_ID_BASE should use nixBuildUserBase, not nixBuildUserCount.

Apply this diff:

-  executionEnv.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nixBuildUserCount}`;
+  executionEnv.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nixBuildUserBase}`;

143-148: Start time recorded after install/login — events may be excluded from summary.

STATE_START_DATETIME is saved after install() finishes. Any events emitted during install (including the FlakeHub funnel) won’t be included in getRecentEvents(startDate).

Apply this diff to capture all events:

 async main(): Promise<void> {
-    await this.scienceDebugFly();
-    await this.detectAndForceNoSystemd();
-    await this.install();
-    actionsCore.saveState(STATE_START_DATETIME, new Date().toISOString());
+    actionsCore.saveState(STATE_START_DATETIME, new Date().toISOString());
+    await this.scienceDebugFly();
+    await this.detectAndForceNoSystemd();
+    await this.install();
 }
🧹 Nitpick comments (1)
src/index.ts (1)

766-767: Option: use finally for end/group.

A finally guard makes the end event and endGroup() robust to any early throws.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61ce789 and 5fcf9f3.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • src/index.ts (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/index.ts (1)
dist/index.js (3)
  • head (100506-100506)
  • base (100505-100505)
  • e (92944-92947)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Test: macos-14-large with determinate
  • GitHub Check: Test: macos-13-large with determinate
  • GitHub Check: Test: macos-14-xlarge with determinate
  • GitHub Check: Test: macos-14-large
  • GitHub Check: Test: macos-13-large
  • GitHub Check: Test: macos-14-xlarge
  • GitHub Check: Test: namespace-profile-default-arm64
  • GitHub Check: Test: ubuntu-latest
  • GitHub Check: Test: namespace-profile-default-arm64 with determinate
  • GitHub Check: Test: nscloud-ubuntu-22.04-amd64-4x16
🔇 Additional comments (5)
src/index.ts (5)

28-31: Event naming for FlakeHub funnel looks good.

start/success/end are consistently declared and scoped to FlakeHub.


721-722: Emit start at entry — LGTM.

Recording flakehub-login:start at the top aligns with the funnel.


734-735: Ensure end on fork path — LGTM.

Failure + end and early return prevent double-end later.


743-744: Ensure end on misconfiguration path — LGTM.

Failure + end before return is correct.


757-757: Don’t assume @actions/exec throws on non-zero exit — record failure on exitCode ≠ 0.

@actions/exec.exec returns an exit code; it won’t throw on failure by default. Current code will emit “success” even if the login command exits non-zero. Handle both non-zero exit and exceptions.

Apply this diff to make success/failure accurate and guarantee end/group closure:

-    actionsCore.startGroup("Logging in to FlakeHub");
-    try {
-      await actionsExec.exec(`determinate-nixd`, ["login", "github-action"]);
-      this.recordEvent(EVENT_LOGIN_SUCCESS);
-    } catch (e: unknown) {
-      actionsCore.warning(`FlakeHub Login failure: ${stringifyError(e)}`);
-      this.recordEvent(EVENT_LOGIN_FAILURE, {
-        reason: "failed",
-        exception: stringifyError(e),
-      });
-    }
-
-    this.recordEvent(EVENT_LOGIN_END);
-    actionsCore.endGroup();
+    actionsCore.startGroup("Logging in to FlakeHub");
+    try {
+      const exitCode = await actionsExec.exec("determinate-nixd", [
+        "login",
+        "github-action",
+      ]);
+      if (exitCode === 0) {
+        this.recordEvent(EVENT_LOGIN_SUCCESS);
+      } else {
+        this.recordEvent(EVENT_LOGIN_FAILURE, {
+          reason: "exit-code",
+          exitCode,
+        });
+      }
+    } catch (e: unknown) {
+      actionsCore.warning(`FlakeHub Login failure: ${stringifyError(e)}`);
+      this.recordEvent(EVENT_LOGIN_FAILURE, {
+        reason: "exception",
+        exception: stringifyError(e),
+      });
+    } finally {
+      this.recordEvent(EVENT_LOGIN_END);
+      actionsCore.endGroup();
+    }

Likely an incorrect or invalid review comment.

@grahamc grahamc merged commit f161ab0 into main Sep 9, 2025
18 checks passed
@grahamc grahamc deleted the gustavderdrache/push-mwwwyvquzwnz branch September 9, 2025 14:40
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.

2 participants