Skip to content

Commit

Permalink
chore: add feature name prop to event (#1624)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Dec 20, 2024
1 parent 44f0bdb commit ba53bac
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/posthog-featureflags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Properties,
JsonType,
Compression,
EarlyAccessFeature,
} from './types'
import { PostHogPersistence } from './posthog-persistence'

Expand Down Expand Up @@ -410,14 +411,25 @@ export class PostHogFeatureFlags {
}

updateEarlyAccessFeatureEnrollment(key: string, isEnrolled: boolean): void {
const existing_early_access_features: EarlyAccessFeature[] =
this.instance.get_property(PERSISTENCE_EARLY_ACCESS_FEATURES) || []
const feature = existing_early_access_features.find((f) => f.flagKey === key)

const enrollmentPersonProp = {
[`$feature_enrollment/${key}`]: isEnrolled,
}
this.instance.capture('$feature_enrollment_update', {

const properties: Properties = {
$feature_flag: key,
$feature_enrollment: isEnrolled,
$set: enrollmentPersonProp,
})
}

if (feature) {
properties['$early_access_feature_name'] = feature.name
}

this.instance.capture('$feature_enrollment_update', properties)
this.setPersonPropertiesForFlags(enrollmentPersonProp, false)

const newFlags = { ...this.getFlagVariants(), [key]: isEnrolled }
Expand Down

0 comments on commit ba53bac

Please sign in to comment.