* Log experiment exposure for a feature if it has experiment data. * Deduplicates within a session - each feature is logged at most once.
(feature: string)
| 325 | * Deduplicates within a session - each feature is logged at most once. |
| 326 | */ |
| 327 | function logExposureForFeature(feature: string): void { |
| 328 | const canonicalFeature = toCanonicalAnalyticsName(feature) |
| 329 | // Skip if already logged this session (dedup) |
| 330 | if (loggedExposures.has(canonicalFeature)) { |
| 331 | return |
| 332 | } |
| 333 | |
| 334 | const expData = |
| 335 | experimentDataByFeature.get(canonicalFeature) ?? |
| 336 | experimentDataByFeature.get(feature) |
| 337 | if (expData) { |
| 338 | loggedExposures.add(canonicalFeature) |
| 339 | logGrowthBookExperimentTo1P({ |
| 340 | experimentId: expData.experimentId, |
| 341 | variationId: expData.variationId, |
| 342 | userAttributes: getUserAttributes(), |
| 343 | experimentMetadata: { |
| 344 | feature_id: canonicalFeature, |
| 345 | }, |
| 346 | }) |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | function updateExperimentDataForFeature( |
| 351 | feature: string, |
no test coverage detected