Skip to content

Commit e5a4bc9

Browse files
committed
cleanu
1 parent bfbd1d5 commit e5a4bc9

File tree

3 files changed

+6
-345
lines changed

3 files changed

+6
-345
lines changed

lib/core/decision_service/index.ts

-235
Original file line numberDiff line numberDiff line change
@@ -340,52 +340,6 @@ export class DecisionService {
340340
reasons: decideReasons,
341341
});
342342
});
343-
344-
// const bucketerParams = this.buildBucketerParams(configObj, experiment, bucketingId, userId);
345-
// const decisionVariation = bucket(bucketerParams);
346-
// decideReasons.push(...decisionVariation.reasons);
347-
// const variationId = decisionVariation.result;
348-
// if (variationId) {
349-
// variation = configObj.variationIdMap[variationId];
350-
// }
351-
// if (!variation) {
352-
// this.logger?.debug(
353-
// USER_HAS_NO_VARIATION,
354-
// userId,
355-
// experimentKey,
356-
// );
357-
// decideReasons.push([
358-
// USER_HAS_NO_VARIATION,
359-
// userId,
360-
// experimentKey,
361-
// ]);
362-
// return {
363-
// result: null,
364-
// reasons: decideReasons,
365-
// };
366-
// }
367-
368-
// this.logger?.info(
369-
// USER_HAS_VARIATION,
370-
// userId,
371-
// variation.key,
372-
// experimentKey,
373-
// );
374-
// decideReasons.push([
375-
// USER_HAS_VARIATION,
376-
// userId,
377-
// variation.key,
378-
// experimentKey,
379-
// ]);
380-
// // persist bucketing if decide options do not include shouldIgnoreUPS
381-
// if (!shouldIgnoreUPS) {
382-
// this.updateUserProfile(experiment, variation, userProfileTracker);
383-
// }
384-
385-
// return {
386-
// result: variation.key,
387-
// reasons: decideReasons,
388-
// };
389343
}
390344

391345
private getDecisionForCmabExperiment<OP extends OpType>(
@@ -405,17 +359,6 @@ export class DecisionService {
405359

406360
const cmabPromise = this.cmabService.getDecision(configObj, user, experiment.id, decideOptions).then(
407361
(cmabDecision) => {
408-
// const variationId = cmabDecision.variationId;
409-
// const variationKey = getVariationKeyFromId(configObj, variationId);
410-
// if (!variationKey) {
411-
// this.logger?.error(CMAB_FETCHED_VARIATION_INVALID, variationId, experiment.key);
412-
// return {
413-
// error: true,
414-
// result: {},
415-
// reasons: [[CMAB_FETCHED_VARIATION_INVALID, variationId, experiment.key]] as DecisionReason[],
416-
// };
417-
// }
418-
419362
return {
420363
error: false,
421364
result: cmabDecision,
@@ -454,44 +397,6 @@ export class DecisionService {
454397
},
455398
reasons: decisionVariation.reasons,
456399
});
457-
// decideReasons.push(...decisionVariation.reasons);
458-
// const variationId = decisionVariation.result;
459-
// const variation = variationId ? configObj.variationIdMap[variationId] : undefined;
460-
461-
// if (!variation) {
462-
// this.logger?.debug(
463-
// USER_HAS_NO_VARIATION,
464-
// userId,
465-
// experiment.key,
466-
// );
467-
// decideReasons.push([
468-
// USER_HAS_NO_VARIATION,
469-
// userId,
470-
// experiment.key,
471-
// ]);
472-
// return Value.of(op, {
473-
// result: {},
474-
// reasons: decideReasons,
475-
// });
476-
// }
477-
478-
// this.logger?.info(
479-
// USER_HAS_VARIATION,
480-
// userId,
481-
// variation.key,
482-
// experiment.key,
483-
// );
484-
// decideReasons.push([
485-
// USER_HAS_VARIATION,
486-
// userId,
487-
// variation.key,
488-
// experiment.key,
489-
// ]);
490-
491-
// return Value.of(op, {
492-
// result: { variationKey: variation.key },
493-
// reasons: decideReasons,
494-
// });
495400
}
496401

497402
/**
@@ -861,16 +766,6 @@ export class DecisionService {
861766
});
862767
});
863768

864-
// if(!shouldIgnoreUPS) {
865-
// // userProfileTracker = opThen(op, this.resolveExperimentBucketMap(op, userId, attributes), (userProfile) => {
866-
// // return opValue(op, {
867-
// // isProfileUpdated: false,
868-
// // userProfile: userProfile,
869-
// // });
870-
// // });
871-
// // optThen
872-
// // userProfileTracker.userProfile = this.resolveExperimentBucketMap(userId, attributes);
873-
// }
874769
return userProfileTrackerValue.then((userProfileTracker) => {
875770
const flagResults = featureFlags.map((feature) => this.resolveVariationForFlag(op, configObj, feature, user, options, userProfileTracker));
876771
const opFlagResults = Value.all(op, flagResults);
@@ -882,53 +777,6 @@ export class DecisionService {
882777
return opFlagResults;
883778
});
884779
});
885-
886-
// return opThen(op, opFlagResults, (flagResults) => {
887-
// if(!shouldIgnoreUPS) {
888-
// this.saveUserProfile(userId, flagResults);
889-
// }
890-
891-
// return opFlagResults;
892-
// }
893-
894-
// for(const feature of featureFlags) {
895-
// const decideReasons: DecisionReason[] = [];
896-
// const decisionVariation = this.getVariationForFeatureExperiment(configObj, feature, user, shouldIgnoreUPS, userProfileTracker);
897-
// decideReasons.push(...decisionVariation.reasons);
898-
// const experimentDecision = decisionVariation.result;
899-
900-
// if (experimentDecision.variation !== null) {
901-
// decisions.push({
902-
// result: experimentDecision,
903-
// reasons: decideReasons,
904-
// });
905-
// continue;
906-
// }
907-
908-
// const decisionRolloutVariation = this.getVariationForRollout(configObj, feature, user);
909-
// decideReasons.push(...decisionRolloutVariation.reasons);
910-
// const rolloutDecision = decisionRolloutVariation.result;
911-
// const userId = user.getUserId();
912-
913-
// if (rolloutDecision.variation) {
914-
// this.logger?.debug(USER_IN_ROLLOUT, userId, feature.key);
915-
// decideReasons.push([USER_IN_ROLLOUT, userId, feature.key]);
916-
// } else {
917-
// this.logger?.debug(USER_NOT_IN_ROLLOUT, userId, feature.key);
918-
// decideReasons.push([USER_NOT_IN_ROLLOUT, userId, feature.key]);
919-
// }
920-
921-
// decisions.push({
922-
// result: rolloutDecision,
923-
// reasons: decideReasons,
924-
// });
925-
// }
926-
927-
// if(!shouldIgnoreUPS) {
928-
// this.saveUserProfile(userId, userProfileTracker);
929-
// }
930-
931-
// return decisions;
932780
}
933781

934782
private resolveVariationForFlag<OP extends OpType>(
@@ -1036,89 +884,6 @@ export class DecisionService {
1036884
}
1037885

1038886
return this.traverseFeatureExperimentList(op, configObj, feature, 0, user, [], decideOptions, userProfileTracker);
1039-
// return feature.experimentIds.reduce((prevValue, experimentId) => {
1040-
// return prevValue.then((prevResponse) => {
1041-
// if (prevResponse.result.variation || prevResponse.error) {
1042-
// return prevValue;
1043-
// }
1044-
1045-
// const experiment = getExperimentFromId(configObj, experimentId, this.logger);
1046-
// if (!experiment) {
1047-
// return prevValue;
1048-
// }
1049-
1050-
// const decisionVariation = this.getVariationFromExperimentRule(
1051-
// op, configObj, feature.key, experiment, user, userProfileTracker,
1052-
// );
1053-
1054-
// return opThen(op, decisionVariation, (decisionVariation) => {
1055-
// prevResponse.reasons.push(...decisionVariation.reasons);
1056-
// if (decisionVariation.result) {
1057-
// const variationKey = decisionVariation.result;
1058-
// let variation: Variation | null = experiment.variationKeyMap[variationKey];
1059-
// if (!variation) {
1060-
// variation = getFlagVariationByKey(configObj, feature.key, variationKey);
1061-
// }
1062-
1063-
// return opValue(op, {
1064-
// result: {
1065-
// experiment,
1066-
// variation,
1067-
// decisionSource: DECISION_SOURCES.FEATURE_TEST,
1068-
// },
1069-
// reasons: prevResponse.reasons,
1070-
// });
1071-
// } else {
1072-
// return opValue(op, prevResponse);
1073-
// }
1074-
// });
1075-
// });
1076-
// }, Value.of(op, nullResult([])));
1077-
1078-
1079-
// Check if the feature flag is under an experiment and the the user is bucketed into one of these experiments
1080-
// if (feature.experimentIds.length > 0) {
1081-
// // Evaluate each experiment ID and return the first bucketed experiment variation
1082-
// for (index = 0; index < feature.experimentIds.length; index++) {
1083-
// const experiment = getExperimentFromId(configObj, feature.experimentIds[index], this.logger);
1084-
// if (experiment) {
1085-
// decisionVariation = this.getVariationFromExperimentRule(configObj, feature.key, experiment, user, shouldIgnoreUPS, userProfileTracker);
1086-
// decideReasons.push(...decisionVariation.reasons);
1087-
// variationKey = decisionVariation.result;
1088-
// if (variationKey) {
1089-
// let variation = null;
1090-
// variation = experiment.variationKeyMap[variationKey];
1091-
// if (!variation) {
1092-
// variation = getFlagVariationByKey(configObj, feature.key, variationKey);
1093-
// }
1094-
// variationForFeatureExperiment = {
1095-
// experiment: experiment,
1096-
// variation: variation,
1097-
// decisionSource: DECISION_SOURCES.FEATURE_TEST,
1098-
// };
1099-
1100-
// return {
1101-
// result: variationForFeatureExperiment,
1102-
// reasons: decideReasons,
1103-
// }
1104-
// }
1105-
// }
1106-
// }
1107-
// } else {
1108-
// this.logger?.debug(FEATURE_HAS_NO_EXPERIMENTS, feature.key);
1109-
// decideReasons.push([FEATURE_HAS_NO_EXPERIMENTS, feature.key]);
1110-
// }
1111-
1112-
// variationForFeatureExperiment = {
1113-
// experiment: null,
1114-
// variation: null,
1115-
// decisionSource: DECISION_SOURCES.FEATURE_TEST,
1116-
// };
1117-
1118-
// return {
1119-
// result: variationForFeatureExperiment,
1120-
// reasons: decideReasons,
1121-
// };
1122887
}
1123888

1124889
private traverseFeatureExperimentList<OP extends OpType>(

lib/entrypoint.universal.test-d.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ import {
4848
import { LogLevel } from './logging/logger';
4949

5050
import { OptimizelyDecideOption } from './shared_types';
51+
import { UniversalConfig } from './index.universal';
5152

5253
export type UniversalEntrypoint = {
5354
// client factory
54-
createInstance: (config: Config) => Client | null;
55+
createInstance: (config: UniversalConfig) => Client | null;
5556

5657
// config manager related exports
5758
createStaticProjectConfigManager: (config: StaticConfigManagerConfig) => OpaqueConfigManager;
@@ -92,4 +93,4 @@ export type UniversalEntrypoint = {
9293
}
9394

9495

95-
// expectTypeOf(universalEntrypoint).toEqualTypeOf<UniversalEntrypoint>();
96+
expectTypeOf(universalEntrypoint).toEqualTypeOf<UniversalEntrypoint>();

0 commit comments

Comments
 (0)