Skip to content

feat: extend hook revalidation keys to remaining hooks#83

Open
utopyin wants to merge 1 commit intouseautumn:mainfrom
utopyin:utopy/extra-query-keys
Open

feat: extend hook revalidation keys to remaining hooks#83
utopyin wants to merge 1 commit intouseautumn:mainfrom
utopyin:utopy/extra-query-keys

Conversation

@utopyin
Copy link
Copy Markdown

@utopyin utopyin commented Feb 28, 2026

Summary

This PR extends the hook revalidation-key pattern from PR #82 "feat: add extraQueryKeys param" to the rest of the SWR-backed hooks.

Specifically, it adds support for:

  • extraQueryKeys?: (string | null | undefined)[]

and appends those keys to SWR query keys so consumers can trigger declarative refetches when external values change.

Changes

  • Added extraQueryKeys support to:
    • usePaywall
    • useListEvents
    • useAggregateEvents
    • useAnalytics
    • useProductsBase
    • usePricingTableBase
    • usePricingTable (react + next wrappers via shared param typing)
  • Ensured non-API fields are not forwarded into API calls where needed (useListEvents, useAggregateEvents, useAnalytics).

Open question

I did run pnpm install and found out the lock file was not up to date. Should I remove it from the patch?

AI Disclaimer

Part of this code has been generated with the help of Codex. I reviewed the entirety of the patch.


Summary by cubic

Extends extraQueryKeys to all SWR-backed hooks so apps can trigger refetches when external values change. Also stops non-API fields from being sent to the server.

  • New Features

    • Added extraQueryKeys to: usePaywall, useListEvents, useAggregateEvents, useAnalytics, useProductsBase, usePricingTableBase, and React/Next usePricingTable; appended to SWR keys.
    • Unified pricing table params with UsePricingTableParams for shared typing.
  • Bug Fixes

    • Prevented swrConfig and extraQueryKeys from being forwarded to API calls in useListEvents, useAggregateEvents, and useAnalytics.

Written for commit 4a08fab. Summary will update on new commits.

Greptile Summary

This PR successfully extends the extraQueryKeys pattern from PR #82 to all remaining SWR-backed hooks, enabling declarative cache revalidation when external values change.

Key Changes:

  • API changes: Added extraQueryKeys?: (string | null | undefined)[] parameter to usePaywall, useListEvents, useAggregateEvents, useAnalytics, useProductsBase, and usePricingTableBase
  • Improvements: Proper parameter destructuring in hooks with API calls (useListEvents, useAggregateEvents, useAnalytics) ensures non-API fields aren't forwarded to backend
  • Improvements: Shared UsePricingTableParams interface used consistently across React and Next.js usePricingTable wrappers

Implementation Quality:
The implementation follows the established pattern correctly. All hooks properly append extraQueryKeys to their SWR query keys using the spread operator with nullish coalescing (...(extraQueryKeys ?? [])). Hooks that make API calls properly destructure extraQueryKeys and swrConfig to prevent them from being forwarded to the backend.

Regarding pnpm-lock.yaml:
The lockfile changes (7,479 deletions) appear to be dependency cleanup from running pnpm install, which is unrelated to the feature implementation. Consider whether these changes should be in a separate commit or PR to keep the feature changes focused.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean, consistent, and follows the established pattern from PR feat: add extraQueryKeys param to useCustomer and useEntity for declarative revalidation #82. All hooks correctly implement the extraQueryKeys parameter, and hooks with API calls properly prevent non-API fields from being forwarded. No logical errors or breaking changes detected.
  • No files require special attention beyond reviewing the pnpm-lock.yaml changes as a separate concern

Important Files Changed

Filename Overview
package/src/libraries/react/hooks/useAggregateEvents.tsx Added extraQueryKeys parameter following the established pattern, properly prevents forwarding to API
package/src/libraries/react/hooks/useAnalytics.tsx Added extraQueryKeys parameter with proper destructuring to prevent API forwarding
package/src/libraries/react/hooks/useListEvents.tsx Added extraQueryKeys parameter, correctly destructured alongside swrConfig to avoid API forwarding
package/src/libraries/react/hooks/usePaywall.tsx Added extraQueryKeys parameter and appended to query key for cache invalidation
package/src/libraries/react/hooks/usePricingTableBase.tsx Added UsePricingTableParams interface with extraQueryKeys and updated query key generation
pnpm-lock.yaml Lockfile updates from running pnpm install - unrelated to feature changes

Last reviewed commit: 4a08fab

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 28, 2026

@utopyin is attempting to deploy a commit to the Autumn Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

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.

1 participant