[ef-14] feat: add package_installed/uninstalled telemetry and fix dashboard path#13
Conversation
- Add scripts/postinstall.mjs — fires package_installed PostHog event on npm install; warns if hooks config exists but hooks aren't registered - Add scripts/preuninstall.mjs — auto-removes failproofai hook entries from Claude Code settings on npm uninstall; fires package_uninstalled event - Add scripts/install-telemetry.mjs — shared fetch-based PostHog helper for lifecycle scripts (no external deps, mirrors hook-telemetry pattern) - Add postinstall/preuninstall entries to package.json scripts - Guard both scripts with INIT_CWD check so they skip during dev/CI installs - Fix scripts/launch.ts: resolve .next/standalone/server.js to an absolute path via import.meta.url — previously the dashboard would fail to start when failproofai was run from any directory other than the package root Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe changes introduce npm postinstall and preuninstall lifecycle hooks that integrate telemetry tracking and hook configuration management. A new telemetry module handles event submission to PostHog with stable instance identification. Hook configuration is validated during installation and cleaned up during uninstallation. Changes
Sequence DiagramssequenceDiagram
actor npm
participant postinstall as postinstall.mjs
participant config as hooks-config.json
participant claude as ~/.claude/settings.json
participant telemetry as install-telemetry.mjs
participant posthog as PostHog API
npm->>postinstall: npm postinstall lifecycle
postinstall->>config: read config & enabled policies
postinstall->>claude: check for hook marker registration
alt Hooks config found & policies enabled
alt Hook marker not found in Claude
postinstall->>postinstall: log warning for re-registration
end
end
postinstall->>telemetry: trackInstallEvent(package_installed, {platform, arch, hostname_hash, hook_status})
telemetry->>posthog: fetch capture with event & properties
posthog-->>telemetry: response
telemetry-->>postinstall: returns
postinstall-->>npm: success (errors suppressed)
sequenceDiagram
actor npm
participant preuninstall as preuninstall.mjs
participant settings as ~/.claude/settings.json<br/>.claude/settings.json<br/>.claude/settings.local.json
participant telemetry as install-telemetry.mjs
participant posthog as PostHog API
npm->>preuninstall: npm preuninstall lifecycle
loop For each settings file
preuninstall->>settings: read settings
preuninstall->>preuninstall: filter hooks by __failproofai_hook__ marker<br/>or command containing "failproofai --hook"
preuninstall->>settings: remove matching hooks, clean empty keys
preuninstall->>settings: rewrite JSON if changes made
end
preuninstall->>telemetry: trackInstallEvent(package_uninstalled, {platform, arch, hooks_removed_count})
telemetry->>posthog: fetch capture with event & properties
posthog-->>telemetry: response
telemetry-->>preuninstall: awaited return
preuninstall-->>npm: success (errors suppressed)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Summary
package_installed(postinstall) andpackage_uninstalled(preuninstall) npm lifecycle scripts — closes the gap vs claudeye; includes INIT_CWD guard so they don't fire during dev/CI installspreuninstall.mjsremoves failproofai hook entries from all Claude Code settings files (~/.claude/settings.json, project + local scopes) before the package is removedscripts/launch.tswas resolving.next/standalone/server.jsrelative to CWD — meaning the dashboard would crash whenfailproofaiwas run from any directory other than the package root (i.e., always after a real install). Fixed withimport.meta.url-anchored absolute path.Files changed
scripts/install-telemetry.mjsscripts/postinstall.mjspackage_installed, warns on stale hooks configscripts/preuninstall.mjspackage_uninstalledpackage.jsonpostinstall+preuninstallscript entriesscripts/launch.ts.next/standalone/server.jsTest plan
bunx tsc --noEmit— 0 errors)bun run lint— 0 errors, 1 pre-existing warning)v0.0.1-beta.1to trigger publish workflow🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Chores