Devcycle To Openfeature Nodejs User Context Transform
Made for
Node.js
Last update
Mar 13, 2025
DevCycle to OpenFeature Node.js - User Context Transform CodeMod
This Codemod updates the DevCycleUser
object to an OpenFeature EvaluationContext
object:
- Replace the
DevCycleUser
object / types with anEvaluationContext
- Rename the
user_id
field totargetingKey
in theEvaluationContext
- If the code is using Typescript types where its typed as
DevCycleUser
, update it to useEvaluationContext
from@openfeature/server-sdk
.
Before
export interface DevCycleRequest extends Request {user: DevCycleUser;}const user: DevCycleUser = {user_id: "123",email: "test@test.com",name: "Test User",customData: {custom_field: "custom_value",number_field: 123,boolean_field: true,},privateCustomData: {private_field: "private_value",},};const varValue = devCycleClient.variableValue({ user_id: "123" },"test-variable","default");const user2 = { user_id: "1234", email: "test@test.com", name: "Test User" };const boolVarValue = devCycleClient.variable(user2,"test-boolean-variable",false);
After
export interface DevCycleRequest extends Request {user: EvaluationContext;}const user: EvaluationContext = {targetingKey: "123",email: "test@test.com",name: "Test User",customData: {custom_field: "custom_value",number_field: 123,boolean_field: true,},privateCustomData: {private_field: "private_value",},};const varValue = devCycleClient.variableValue({ targetingKey: "123" },"test-variable","default");const user2 = {targetingKey: "1234",email: "test@test.com",name: "Test User",};const boolVarValue = devCycleClient.variable(user2,"test-boolean-variable",false);
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community