feat(nuxt): Added feature flag composables
Problem
Currently the Nuxt module is pretty barebones, and one major feature of Posthog imo is feature flags, so I am creating a PR to add some useful composables starting with feature flags.
Changes
Added 4 Nuxt Composables:
- usePostHog(): posthog | undefined
- useFeatureFlagEnabled(flag: string): Ref<boolean | undefined>
- useFeatureFlagPayload(flag: string): Ref<JsonType>
- useFeatureFlagVariantKey(flag: string): Ref<string | boolean | undefined>
Release info Sub-libraries affected
Libraries affected
- [ ] All of them
- [ ] posthog-js (web)
- [ ] posthog-js-lite (web lite)
- [ ] posthog-node
- [ ] posthog-react-native
- [ ] @posthog/react
- [ ] @posthog/ai
- [ ] @posthog/nextjs-config
- [x] @posthog/nuxt
Checklist
- [x] Tests for new code
- [ ] Accounted for the impact of any changes across different platforms
- [x] Accounted for backwards compatibility of any changes (no breaking changes!)
- [x] Took care not to unnecessarily increase the bundle size
If releasing new changes
- [x] Ran
pnpm changesetto generate a changeset file - [ ] Added the "release" label to the PR to indicate we're publishing new versions for the affected packages
@geferon is attempting to deploy a commit to the PostHog Team on Vercel.
A member of the Team first needs to authorize it.
I haven't created a changeset because I'm wondering if this should be a minor or a major bump. Hope this is helpful...
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.
It would be nice if it would be checked out and merged, since this functionality would be nice Nuxt features to have
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.
Still waiting for a review/response, so please don't stale it bot :)
Tagging @dmarticus
Many thanks!
@geferon FYI; I think we're having some build issues for this contribution (nothing to do with your changes, just how our CI interacts with external branches), so in the name of getting this change into our SDK as quickly as possible I'm going to port these changes to my own branch and get it merged. Sorry for the delay!
reimplemented this changes here: https://github.com/PostHog/posthog-js/pull/2778