rapid-kangaroo-34065
03/27/2024, 11:01 PMgetFeatureValue
- anyone else experienced this?rapid-kangaroo-34065
03/27/2024, 11:35 PMimport {PatientAppUserInfo} from '@ciitizen/back-end-apps-patient-app-nestjs'
import {extractEmailDomain} from '@ciitizen/common-utils'
import {Experiment, GrowthBook, Result} from '@growthbook/growthbook'
import {Injectable} from '@nestjs/common'
type FeatureFlagKey = 'test-2'
const gb = new GrowthBook({
apiHost: '<https://cdn.growthbook.io>',
clientKey: '<redacted>',
enableDevMode: true,
subscribeToChanges: false,
trackingCallback: (experiment: Experiment<any>, result: Result<any>): void => {
// TODO: Make amplitude available on the backend to send events
},
})
@Injectable()
export class ExperimentationService {
private _growthbook: GrowthBook
constructor() {
this._growthbook = gb
}
async getCohort({user, featureFlagKey}: {user: PatientAppUserInfo; featureFlagKey: FeatureFlagKey}): Promise<string> {
await this._growthbook.loadFeatures()
await this._growthbook.setAttributes({
emailDomain: extractEmailDomain(user.email),
id: user?.authTokenInfo.auth0UserId,
})
const defaultValue = 'not enabled'
let result = defaultValue
// while (result === defaultValue) {
result = this._growthbook.getFeatureValue(featureFlagKey, defaultValue)
// }
return result
}
}
fresh-football-47124
fresh-football-47124
rapid-kangaroo-34065
03/28/2024, 4:16 PM