Skip to content

chore(tooling): add Knip configuration to detect unused files and dependencies - #646

Open
sundaram2021 wants to merge 2 commits into
databuddy-analytics:stagingfrom
sundaram2021:feat/knip-config
Open

chore(tooling): add Knip configuration to detect unused files and dependencies#646
sundaram2021 wants to merge 2 commits into
databuddy-analytics:stagingfrom
sundaram2021:feat/knip-config

Conversation

@sundaram2021

@sundaram2021 sundaram2021 commented Aug 21, 2026

Copy link
Copy Markdown

Description

Adds a workspace-aware Knip configuration (knip.json) so unused files, dependencies, exports, and catalog entries can be detected across all 11 apps and 23 packages. Knip was already pinned in root devDependencies but had no config or script, making it unusable.

fixes #645

What's included:

  • knip.json — per-workspace entry points matching repo conventions:
    • Test-file globs per workspace (the root test:watch script shadows Knip's Bun plugin per-workspace parsing)
    • Fumadocs entries for apps/docs (source.config.ts, content/**/*.mdx)
    • Runtime/playground entries for packages/nuxt (resolved via string paths)
    • Source entries for dist-building published packages (sdk, devtools, nuxt, tracker)
    • ignoreBinaries for shell utilities in setup.ts and the mp4 output path in apps/video
    • apps/cron/** ignored (standalone ops scripts, not a real workspace)
  • Root script"knip": "knip" so it runs via bun run knip
  • Removed bogus root "module": "index.ts" field (pointed at a nonexistent file)

First run surfaces real findings (111 unused files, 58 unused deps, 355 unused exports, 24 unused catalog entries) to be cleaned up or baselined in follow-ups. It also exposed a pre-existing broken export in packages/email (./config → missing config.ts).

Slice

Checklist
  • This branch started from current staging and does not include another unmerged PR unless it is named above.
  • This is one independently reviewable slice; unrelated cleanup or refactors are in separate PRs.
  • I checked open PRs for overlapping files, contracts, schemas, or deployment configuration and made any dependency explicit above.
  • This PR targets staging; after it closes, this branch will not be reused for another change.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by cubic

Adds workspace-aware knip configuration and a root script to detect unused files, dependencies, and exports across all apps and packages. Previously knip was installed but unusable; now run it via bun run knip. Also removes the bogus root "module" field and adds a brief usage note to the internal SKILL guide. Satisfies #645.

  • Adds knip.json with per-workspace entries, targeted ignores (e.g., apps/cron/**, apps/video mp4 output), and scoped ignoreDependencies for apps/dashboard (topojson-specification) and packages/ui (tailwindcss, tw-animate-css).
  • Adds "knip": "knip" to the root package.json.

Review

  • Run bun run knip and confirm the schema loads and workspaces resolve.
  • Spot-check entries/ignores and dependency exceptions are narrowly scoped and intentional.
  • Confirm removing the root "module" field has no build/runtime impact.

Rollout

  • Tooling-only; no migrations. After merge, baseline findings with bun run knip.

Written for commit 45bb275. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

@sundaram2021 is attempting to deploy a commit to the Databuddy OSS Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 21, 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: Pro Plus

Run ID: 82e46032-94a2-4d47-8f62-21efd021208c

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.

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The pull request is substantially broader than its tooling-focused title: it adds Knip configuration while also introducing audit logging and audit-log UI, feature-flag activity telemetry, realtime-map changes, and revenue dashboard refinements.

  • Adds workspace-aware Knip configuration and a root knip script.
  • Expands tenant-scoped audit coverage for RPC and public feature-flag mutations, including an organization audit-log page.
  • Emits and aggregates feature-flag evaluation activity for display in the dashboard.
  • Refactors the realtime map and revenue reporting/settings interfaces.
  • Tightens several cache, RPC, schema, SDK, and tracker types and contracts.

Confidence Score: 4/5

The pull request appears safe to merge after the non-blocking revenue UI radius inconsistency is corrected.

The investigated audit, authorization, telemetry, and query-state paths did not yield a concrete blocking failure; the accepted issue is limited to changed revenue components violating the repository's UI-radius convention.

Files Needing Attention: apps/dashboard/app/(main)/websites/[id]/revenue/_components/revenue-settings-sheet.tsx, apps/dashboard/app/(main)/websites/[id]/revenue/_components/revenue-content.tsx

Important Files Changed

Filename Overview
knip.json Adds workspace-specific Knip entry points and targeted ignores for the monorepo.
apps/api/src/routes/public/flags.ts Adds tenant-scoped audit records around authenticated public feature-flag mutations.
packages/rpc/src/middleware/audit-mutation.ts Adds best-effort mutation audit middleware with actor, organization, target, and outcome resolution.
packages/rpc/src/routers/flags.ts Adds authenticated aggregation of recent feature-flag evaluation activity.
packages/sdk/src/core/flags/flags-manager.ts Adds per-context, per-value deduplicated browser telemetry for feature-flag evaluations.
apps/dashboard/app/(main)/websites/[id]/revenue/_components/revenue-settings-sheet.tsx Extracts revenue settings into a dedicated sheet, but introduces a repository-style violation in its radius utility.
apps/dashboard/app/(main)/websites/[id]/realtime/_components/realtime-map.tsx Refactors canvas geometry, resize handling, high-DPI rendering, hit testing, and pointer interactions.
packages/services/src/audit.ts Extends append-only audit persistence, replay, and cursor-based read behavior.

Sequence Diagram

sequenceDiagram
  participant Browser as Customer Browser
  participant SDK as Flags SDK
  participant Tracker as Analytics Tracker
  participant API as API / RPC
  participant Store as Analytics Store
  participant Dashboard as Flags Dashboard
  Browser->>SDK: Evaluate feature flag
  SDK->>Tracker: Emit deduplicated $flag_evaluated
  Tracker->>Store: Persist evaluation event
  Dashboard->>API: Request flag activity statistics
  API->>Store: Aggregate recent evaluations by flag
  Store-->>API: Counts and latest evaluation
  API-->>Dashboard: Activity statistics
Loading

Reviews (1): Last reviewed commit: "chore(tooling): add Knip configuration t..." | Re-trigger Greptile

@sundaram2021
sundaram2021 changed the base branch from main to staging August 21, 2026 09:11
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.

chore(tooling): add knip configuration to detect unused files, dependencies and exports across the monorepo

1 participant