Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

user_properties from ExperimentUser are not forwarded to exposure/assignment events

Aperta
#72 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@FabricioFFC ci sta già lavorando.

Dal 6/2/2026.

  • #74 di @FabricioFFC — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
backend

Direzione di ricerca

Individua la costruzione dell’evento di esposizione e la logica corrispondente in assignment-service.ts. Verifica come vengono assemblati ExperimentUser.user_properties e i campi $set generati, quindi verifica che sia gli eventi di esposizione sia quelli di assegnazione conservino le proprietà personalizzate insieme alle assegnazioni dei flag. Il lavoro è completato quando gli eventi includono le user_properties fornite per le chiamate a evaluateV2() con tracksExposure abilitato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

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

  1. Initialize local evaluation client with exposureConfig
  2. Create an ExperimentUser with custom user_properties
  3. Call evaluateV2() with tracksExposure: true
  4. 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

Lingua principale
TypeScript
Stelle
2
Fork
9
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di amplitude/experiment-node-server

Tutte le issue di amplitude/experiment-node-server

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.