Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Jan 5, 2024
1 parent b00cd6b commit 02b9a46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 6 additions & 5 deletions posthog-node/src/posthog-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,20 @@ export class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
})
.then((flags) => {
// Derive the relevant flag properties to add
const featureVariantProperties: Record<string, string | boolean> = {}
const additionalProperties: Record<string, any> = {}
if (flags) {
for (const [feature, variant] of Object.entries(flags)) {
if (variant !== false) {
featureVariantProperties[`$feature/${feature}`] = variant
additionalProperties[`$feature/${feature}`] = variant
}
}
}
const activeFlags = Object.keys(flags || {}).filter((flag) => flags?.[flag] !== false)
return {
$active_feature_flags: activeFlags || undefined,
...featureVariantProperties,
if (activeFlags.length > 0) {
additionalProperties['$active_feature_flags'] = activeFlags
}

return additionalProperties
})
.catch(() => {
// Something went wrong getting the flag info - we should capture the event anyways
Expand Down
1 change: 0 additions & 1 deletion posthog-node/test/posthog-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ describe('PostHog Node.js', () => {
$lib: 'posthog-node',
$lib_version: '1.2.3',
$geoip_disable: true,
$active_feature_flags: [],
},
timestamp: expect.any(String),
type: 'capture',
Expand Down

0 comments on commit 02b9a46

Please sign in to comment.