feat: add feature usage tracker for nightly surveys#8175
feat: add feature usage tracker for nightly surveys#8175christian-byrne merged 5 commits intomainfrom
Conversation
🎨 Storybook Build Status✅ Build completed successfully! ⏰ Completed at: 01/20/2026, 09:30:24 PM UTC 🔗 Links🎉 Your Storybook is ready for review! |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a new Vue composition function Changes
Sequence DiagramsequenceDiagram
participant VueComponent as Vue Component
participant Tracker as useFeatureUsageTracker
participant UseStorage as useStorage (`@vueuse/core`)
participant LocalStorage as localStorage
VueComponent->>Tracker: call trackUsage()
activate Tracker
Tracker->>Tracker: increment useCount
Tracker->>Tracker: set firstUsed if unset
Tracker->>Tracker: update lastUsed
Tracker->>UseStorage: update reactive store
activate UseStorage
UseStorage->>LocalStorage: persist "comfy.featureUsage" data
deactivate UseStorage
deactivate Tracker
VueComponent->>Tracker: read usage / useCount (computed)
VueComponent->>Tracker: call reset()
activate Tracker
Tracker->>UseStorage: remove feature record
activate UseStorage
UseStorage->>LocalStorage: persist removal
deactivate UseStorage
deactivate Tracker
Suggested reviewers
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. Comment |
🎭 Playwright Tests:
|
eeca05d to
c64f94f
Compare
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 22.4 kB (baseline 22.4 kB) • ⚪ 0 BMain entry bundles and manifests
Graph Workspace — 1.02 MB (baseline 1.02 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Views & Navigation — 80.7 kB (baseline 80.7 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Panels & Settings — 430 kB (baseline 430 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
User & Accounts — 3.94 kB (baseline 3.94 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Editors & Dialogs — 2.8 kB (baseline 2.8 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
UI Components — 32.8 kB (baseline 32.8 kB) • ⚪ 0 BReusable component library chunks
Data & Services — 3.04 MB (baseline 3.04 MB) • ⚪ 0 BStores, services, APIs, and repositories
Utilities & Hooks — 18.7 kB (baseline 18.7 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Vendor & Third-Party — 10.4 MB (baseline 10.4 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Other — 6.25 MB (baseline 6.25 MB) • ⚪ 0 BBundles that do not match a named category
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/platform/surveys/useFeatureUsageTracker.test.ts`:
- Around line 51-61: The test uses a real setTimeout which is flaky; convert it
to Vitest fake timers by calling vi.useFakeTimers() at the start of the test,
replace the await new Promise((r) => setTimeout(r, 10)) with
vi.advanceTimersByTime(10) (or vi.advanceTimersToNextTimer()/vi.runAllTimers()
as appropriate), then call vi.useRealTimers()/vi.restoreAllMocks() at the end to
clean up; update the test around useFeatureUsageTracker/trackUsage/usage to use
these vi timer APIs so lastUsed progression is deterministic in CI.
00f47d8 to
184d91c
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/platform/surveys/useFeatureUsageTracker.test.ts`:
- Around line 96-107: The persistence test should use fake timers to
deterministically flush the async storage write: before invoking
useFeatureUsageTracker('persisted-feature') call vi.useFakeTimers(), call
trackUsage(), then advance timers with vi.runAllTimers() (or
vi.runOnlyPendingTimers()) to force the useStorage flush, read localStorage
(STORAGE_KEY) and assert, and finally restore timers with vi.useRealTimers();
reference the useFeatureUsageTracker hook, the trackUsage call, and STORAGE_KEY
when making the change.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/platform/surveys/useFeatureUsageTracker.test.ts`:
- Around line 35-49: Use fake timers to make the timestamp assertions
deterministic: call vi.useFakeTimers() and vi.setSystemTime(fixedTs) at the
start of the test, then import useFeatureUsageTracker(), call trackUsage(),
assert usage.value.firstUsed === fixedTs, advance/set system time again before
the second trackUsage() call to assert firstUsed remains unchanged, and finally
call vi.useRealTimers() to restore real timers; reference the
useFeatureUsageTracker import and the usage/trackUsage variables in your
changes.
Introduces `useFeatureUsageTracker` composable that tracks how many times a user has used a specific feature, along with first and last usage timestamps. Data persists to localStorage using `@vueuse/core`'s `useStorage`. This composable provides the foundation for triggering surveys after a configurable number of feature uses. Includes comprehensive unit tests. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8175-feat-add-feature-usage-tracker-for-nightly-surveys-2ee6d73d36508118859ece6fcf17561d) by [Unito](https://www.unito.io)
…vey(s) (#8189) ## Summary Adds `useSurveyEligibility` composable that determines whether a user should see a survey based on multiple criteria: nightly localhost build only (`isNightly && !isCloud && !isDesktop`), configurable usage threshold (default 3), 14-day global cooldown between any surveys, once-per-feature-ever display, optional percentage-based sampling, and user opt-out support. All state persists to localStorage. Includes extensive unit tests covering all eligibility conditions. See: - #8149 - #8175 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8189-feat-add-composable-to-determine-if-user-is-eligible-for-nightly-survey-s-2ee6d73d365081f088f2fd76032cc60a) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Alexander Brown <drjkl@comfy.org>
Introduces
useFeatureUsageTrackercomposable that tracks how many times a user has used a specific feature, along with first and last usage timestamps. Data persists to localStorage using@vueuse/core'suseStorage. This composable provides the foundation for triggering surveys after a configurable number of feature uses. Includes comprehensive unit tests.┆Issue is synchronized with this Notion page by Unito