-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Expected Behavior
When calling evaluateV2() with tracksExposure: true, the custom user_properties passed in ExperimentUser should be included in the [Experiment] Exposure event's user_properties.$set, so they are associated with the user profile in Amplitude.
const user: ExperimentUser = {
user_id: 'user-123',
device_id: 'device-456',
user_properties: { anonymous: true, plan: 'premium' },
};
const variants = client.evaluateV2(user, ['my-flag'], { tracksExposure: true });
// Expected: Exposure event should include user_properties in $set
// {
// event_type: '[Experiment] Exposure',
// user_id: 'user-123',
// device_id: 'device-456',
// user_properties: {
// $set: {
// anonymous: true, // <-- from ExperimentUser.user_properties
// plan: 'premium', // <-- from ExperimentUser.user_properties
// '[Experiment] my-flag': 'treatment'
// },
// $unset: {}
// }
// }Possible Solution
Merge exposure.user.user_properties into the $set object when building the event:
user_properties: {
$set: { ...exposure.user.user_properties, ...set },
$unset: unset,
},Current Behavior
The user_properties from ExperimentUser are only used for local evaluation targeting and are not forwarded to exposure events.
The same issue exists in assignment-service.ts.
Steps to Reproduce
- Initialize local evaluation client with exposureConfig
- Create an ExperimentUser with custom user_properties
- Call evaluateV2() with tracksExposure: true
- Check the exposure event in Amplitude - custom user_properties are missing
import { Experiment } from '@amplitude/experiment-node-server';
const client = Experiment.initializeLocal('DEPLOYMENT_KEY', {
exposureConfig: { apiKey: 'API_KEY' },
});
await client.start();
const user = {
user_id: 'user-123',
device_id: 'device-456',
user_properties: { anonymous: true },
};
// user_properties is used for targeting but NOT sent to Amplitude
const variants = client.evaluateV2(user, ['my-flag'], { tracksExposure: true });Environment
JS Server SDK Version: 1.13.2
Installation Method: yarn
Runtime: Node.js
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working