
Research
/Security News
Shai Hulud Strikes Again (v2)
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.
cfg-kit-posthog
Advanced tools
A PostHog plugin for cfg-kit that allows you to define PostHog feature flags as configuration.
npm install cfg-kit-posthog posthog-node cfg-kit
# or
pnpm add cfg-kit-posthog posthog-node cfg-kit
# or
yarn add cfg-kit-posthog posthog-node cfg-kit
import { definePostHogConfig, PostHogPlugin } from 'cfg-kit-posthog'
const config = definePostHogConfig({
featureFlags: [
{
key: 'new-dashboard',
name: 'New Dashboard',
description: 'Enable the new dashboard design',
active: true,
filters: {
groups: [
{
properties: [],
rollout_percentage: 100
}
]
},
tags: ['ui', 'dashboard']
}
]
})
const plugin = new PostHogPlugin(config, {
apiKey: process.env.POSTHOG_API_KEY!,
projectId: process.env.POSTHOG_PROJECT_ID!,
host: 'https://app.posthog.com' // optional, defaults to app.posthog.com
})
import { defineConfig } from 'cfg-kit'
import { PostHogPlugin, definePostHogConfig } from 'cfg-kit-posthog'
export default defineConfig({
plugins: [
new PostHogPlugin(
definePostHogConfig({
featureFlags: [
{
key: 'beta-features',
name: 'Beta Features',
description: 'Enable beta features for testing',
active: true,
filters: {
groups: [
{
properties: [
{
key: 'email',
operator: 'icontains',
value: '@company.com'
}
],
rollout_percentage: 50
}
]
}
}
]
}),
{
apiKey: process.env.POSTHOG_API_KEY!,
projectId: process.env.POSTHOG_PROJECT_ID!
}
)
]
})
The plugin requires the following environment variables:
POSTHOG_API_KEY: Your PostHog API keyPOSTHOG_PROJECT_ID: Your PostHog project IDPOSTHOG_HOST: (optional) PostHog host URL, defaults to https://app.posthog.comtype PostHogFeatureFlag = {
key: string // Unique identifier for the feature flag
name: string // Display name
description?: string // Optional description
active?: boolean // Whether the flag is active (default: true)
filters?: { // Targeting filters
groups: Array<{
properties: Array<{
key: string
operator?: 'exact' | 'is_not' | 'icontains' | 'not_icontains' | 'regex' | 'not_regex' | 'gt' | 'gte' | 'lt' | 'lte' | 'is_set' | 'is_not_set'
value?: string | number | boolean | string[] | number[]
type?: 'person' | 'event' | 'element' | 'static-cohort' | 'behavioral'
}>
rollout_percentage: number // 0-100
variant?: string
}>
}
variants?: Array<{ // Optional feature flag variants
key: string
name?: string
rollout_percentage: number
}>
tags?: string[] // Optional tags for organization
}
For each feature flag, the plugin generates environment variables with the feature flag ID:
// For a feature flag with key 'new-dashboard'
// Generates: NEW_DASHBOARD with the PostHog feature flag ID
The plugin includes comprehensive error handling:
definePostHogConfig({
featureFlags: [
{
key: 'maintenance-mode',
name: 'Maintenance Mode',
description: 'Enable maintenance mode banner',
active: false
}
]
})
definePostHogConfig({
featureFlags: [
{
key: 'premium-features',
name: 'Premium Features',
description: 'Enable premium features for paid users',
active: true,
filters: {
groups: [
{
properties: [
{
key: 'subscription_tier',
operator: 'exact',
value: 'premium'
}
],
rollout_percentage: 100
}
]
},
tags: ['premium', 'features']
}
]
})
definePostHogConfig({
featureFlags: [
{
key: 'checkout-flow',
name: 'Checkout Flow Test',
description: 'A/B test different checkout flows',
active: true,
variants: [
{
key: 'control',
name: 'Control (Original)',
rollout_percentage: 50
},
{
key: 'variant-a',
name: 'Variant A (Simplified)',
rollout_percentage: 50
}
]
}
]
})
PostHogPluginMain plugin class for integrating with cfg-kit.
new PostHogPlugin(config: PostHogConfig, options: PostHogPluginOptions)
Parameters:
config: PostHog configuration objectoptions: Plugin options including API key and project IDdefinePostHogConfig(config)Helper function to define and validate PostHog configuration.
definePostHogFeatureFlag(featureFlag)Helper function to define and validate a single feature flag.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
PostHog plugin for cfg-kit - Define PostHog feature flags as configuration
We found that cfg-kit-posthog demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.