feat(react): add Firebase Analytics hooks with tests#234
Conversation
Implement Analytics query and mutation hooks aligned with Firestore DX, wire the module for build/export, and add full test coverage.
|
To view this pull requests documentation preview, visit the following URL: docs.page/invertase/tanstack-query-firebase~234 Documentation is deployed and generated using docs.page. |
|
Resolve tsup.config.ts conflict by including both analytics and database packages.
Document analytics hooks and add sidebar navigation for the new module.
There was a problem hiding this comment.
Pull request overview
This PR adds React hooks for Firebase Analytics, exports the new analytics subpath, and documents the new API surface alongside tests.
Changes:
- Adds Analytics query/mutation hooks for support checks, client ID reads, event logging, consent, collection settings, screen, user ID, and user properties.
- Adds query key helpers, shared Analytics hook option/variable types, and Vitest coverage.
- Wires the analytics package export/build entry and adds documentation/navigation pages.
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/react/tsup.config.ts |
Adds Analytics to package build entries. |
packages/react/package.json |
Exposes ./analytics subpath. |
packages/react/src/analytics/index.ts |
Exports Analytics hooks and query keys. |
packages/react/src/analytics/types.ts |
Defines shared Analytics hook option and variable types. |
packages/react/src/analytics/queryKeys.ts |
Adds Analytics query key helpers. |
packages/react/src/analytics/queryKeys.test.ts |
Tests Analytics query key output. |
packages/react/src/analytics/useGetGoogleAnalyticsClientIdQuery.ts |
Adds client ID query hook. |
packages/react/src/analytics/useGetGoogleAnalyticsClientIdQuery.test.tsx |
Tests client ID query behavior. |
packages/react/src/analytics/useIsSupportedQuery.ts |
Adds Analytics support query hook. |
packages/react/src/analytics/useIsSupportedQuery.test.tsx |
Tests support query behavior. |
packages/react/src/analytics/useLogEventMutation.ts |
Adds event logging mutation hook. |
packages/react/src/analytics/useLogEventMutation.test.tsx |
Tests event logging mutation behavior. |
packages/react/src/analytics/useSetAnalyticsCollectionEnabledMutation.ts |
Adds collection enabled mutation hook. |
packages/react/src/analytics/useSetAnalyticsCollectionEnabledMutation.test.tsx |
Tests collection enabled mutation behavior. |
packages/react/src/analytics/useSetConsentMutation.ts |
Adds consent mutation hook. |
packages/react/src/analytics/useSetConsentMutation.test.tsx |
Tests consent mutation behavior. |
packages/react/src/analytics/useSetCurrentScreenMutation.ts |
Adds deprecated current screen mutation hook. |
packages/react/src/analytics/useSetCurrentScreenMutation.test.tsx |
Tests current screen mutation behavior. |
packages/react/src/analytics/useSetDefaultEventParametersMutation.ts |
Adds default event parameters mutation hook. |
packages/react/src/analytics/useSetDefaultEventParametersMutation.test.tsx |
Tests default event parameters mutation behavior. |
packages/react/src/analytics/useSetUserIdMutation.ts |
Adds user ID mutation hook. |
packages/react/src/analytics/useSetUserIdMutation.test.tsx |
Tests user ID mutation behavior. |
packages/react/src/analytics/useSetUserPropertiesMutation.ts |
Adds user properties mutation hook. |
packages/react/src/analytics/useSetUserPropertiesMutation.test.tsx |
Tests user properties mutation behavior. |
docs/react/index.mdx |
Links Analytics docs from React overview. |
docs/react/analytics/index.mdx |
Adds Analytics getting started documentation. |
docs/react/analytics/hooks/useGetGoogleAnalyticsClientIdQuery.mdx |
Documents client ID query hook. |
docs/react/analytics/hooks/useIsSupportedQuery.mdx |
Documents support query hook. |
docs/react/analytics/hooks/useLogEventMutation.mdx |
Documents event logging mutation hook. |
docs/react/analytics/hooks/useSetAnalyticsCollectionEnabledMutation.mdx |
Documents collection enabled mutation hook. |
docs/react/analytics/hooks/useSetConsentMutation.mdx |
Documents consent mutation hook. |
docs/react/analytics/hooks/useSetCurrentScreenMutation.mdx |
Documents current screen mutation hook. |
docs/react/analytics/hooks/useSetDefaultEventParametersMutation.mdx |
Documents default event parameters mutation hook. |
docs/react/analytics/hooks/useSetUserIdMutation.mdx |
Documents user ID mutation hook. |
docs/react/analytics/hooks/useSetUserPropertiesMutation.mdx |
Documents user properties mutation hook. |
docs.json |
Adds Analytics docs navigation entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { getAnalytics } from "firebase/analytics"; | ||
|
|
||
| // Initialize your Firebase app | ||
| initializeApp({ ... }); |
Implement Analytics query and mutation hooks aligned with Firestore DX, wire the module for build/export, and add full test coverage.