@@ -22,7 +22,7 @@ import { DecisionObj } from '../decision_service';
2222 * @returns {string } Experiment key or empty string if experiment is null
2323 */
2424export function getExperimentKey ( decisionObj : DecisionObj ) : string {
25- return decisionObj . experiment ?. key ?? '' ;
25+ return decisionObj . experiment ?. key ?? '' ;
2626}
2727
2828/**
@@ -31,7 +31,7 @@ export function getExperimentKey(decisionObj: DecisionObj): string {
3131 * @returns {string } Variation key or empty string if variation is null
3232 */
3333export function getVariationKey ( decisionObj : DecisionObj ) : string {
34- return decisionObj . variation ?. key ?? '' ;
34+ return decisionObj . variation ?. key ?? '' ;
3535}
3636
3737/**
@@ -40,7 +40,7 @@ export function getVariationKey(decisionObj: DecisionObj): string {
4040 * @returns {boolean } featureEnabled boolean or false if variation is null
4141 */
4242export function getFeatureEnabledFromVariation ( decisionObj : DecisionObj ) : boolean {
43- return decisionObj . variation ?. featureEnabled ?? false ;
43+ return decisionObj . variation ?. featureEnabled ?? false ;
4444}
4545
4646/**
@@ -49,5 +49,14 @@ export function getFeatureEnabledFromVariation(decisionObj: DecisionObj): boolea
4949 * @returns {string } Experiment id or null if experiment is null
5050 */
5151export function getExperimentId ( decisionObj : DecisionObj ) : string | null {
52- return decisionObj . experiment ?. id ?? null ;
52+ return decisionObj . experiment ?. id ?? null ;
53+ }
54+
55+ /**
56+ * Get variation id from the provided decision object
57+ * @param {DecisionObj } decisionObj Object representing decision
58+ * @returns {string } Variation id or null if variation is null
59+ */
60+ export function getVariationId ( decisionObj : DecisionObj ) : string | null {
61+ return decisionObj . variation ?. id ?? null ;
5362}
0 commit comments