Skip to content

Commit 654c096

Browse files
committed
upd
1 parent b0e95ec commit 654c096

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

lib/client_factory.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const getOptimizelyInstance = (config: OptimizelyFactoryConfig): Client |
4949
clientVersion,
5050
jsonSchemaValidator,
5151
userProfileService,
52+
userProfileServiceAsync,
5253
defaultDecideOptions,
5354
disposable,
5455
requestHandler,
@@ -76,6 +77,7 @@ export const getOptimizelyInstance = (config: OptimizelyFactoryConfig): Client |
7677
clientVersion: clientVersion || CLIENT_VERSION,
7778
jsonSchemaValidator,
7879
userProfileService,
80+
userProfileServiceAsync,
7981
defaultDecideOptions,
8082
disposable,
8183
logger,

lib/core/decision_service/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ const getDecisionService = (opt: DecisionServiceInstanceOpt = {}): DecisionServi
9898
const decisionService = new DecisionService({
9999
logger,
100100
userProfileService,
101+
userProfileServiceAsync,
101102
UNSTABLE_conditionEvaluators: {},
102103
cmabService,
103104
});
@@ -1452,7 +1453,7 @@ describe('DecisionService', () => {
14521453
);
14531454
});
14541455

1455-
it.only('should use userProfileServiceAsync if available but sync user profile service is unavialable', async () => {
1456+
it.only('should use userProfileServiceAsync if available and sync user profile service is unavialable', async () => {
14561457
const { decisionService, cmabService, userProfileServiceAsync } = getDecisionService({
14571458
userProfileService: false,
14581459
userProfileServiceAsync: true,
@@ -1498,7 +1499,6 @@ describe('DecisionService', () => {
14981499

14991500
const variation = (await value)[0];
15001501

1501-
expect(variation.error).toBe(true);
15021502
expect(variation.result).toEqual({
15031503
experiment: config.experimentKeyMap['exp_3'],
15041504
variation: config.variationIdMap['5001'],

lib/core/decision_service/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ export class DecisionService {
290290
this.getDecisionFromBucketer(op, configObj, experiment, user);
291291

292292
return decisionVariationValue.then((variationResult): Value<OP, VariationResult> => {
293-
console.log('variationResult', variationResult);
294293
decideReasons.push(...variationResult.reasons);
295294
if (variationResult.error) {
296295
return Value.of(op, {
@@ -336,7 +335,6 @@ export class DecisionService {
336335
this.updateUserProfile(experiment, variation, userProfileTracker);
337336
}
338337

339-
console.log('variationResult', variationResult.result);
340338
return Value.of(op, {
341339
result: { variationKey: variation.key, cmabUuid: variationResult.result.cmabUuid },
342340
reasons: decideReasons,
@@ -425,7 +423,6 @@ export class DecisionService {
425423
};
426424
}
427425
).catch((ex: any) => {
428-
console.log('cmab error got ....', ex)
429426
this.logger?.error(CMAB_FETCH_FAILED, experiment.key);
430427
return {
431428
error: true,
@@ -1160,7 +1157,6 @@ export class DecisionService {
11601157
decideReasons.push(...decisionVariation.reasons);
11611158

11621159
if (decisionVariation.error) {
1163-
console.log('reasons are ,,,', decideReasons, decisionVariation.reasons);
11641160
return Value.of(op, {
11651161
error: true,
11661162
result: {
@@ -1645,7 +1641,6 @@ export class DecisionService {
16451641
const decisionVariationValue = this.resolveVariation(op, configObj, rule, user, decideOptions, userProfileTracker);
16461642

16471643
return decisionVariationValue.then((variationResult) => {
1648-
// console.log('variationResult a', variationResult);
16491644
decideReasons.push(...variationResult.reasons);
16501645
return Value.of(op, {
16511646
error: variationResult.error,

lib/optimizely/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
FeatureVariableValue,
3737
OptimizelyDecision,
3838
Client,
39+
UserProfileServiceAsync,
3940
} from '../shared_types';
4041
import { newErrorDecision } from '../optimizely_decision';
4142
import OptimizelyUserContext from '../optimizely_user_context';
@@ -130,6 +131,7 @@ export type OptimizelyOptions = {
130131
};
131132
logger?: LoggerFacade;
132133
userProfileService?: UserProfileService | null;
134+
userProfileServiceAsync?: UserProfileServiceAsync | null;
133135
defaultDecideOptions?: OptimizelyDecideOption[];
134136
odpManager?: OdpManager;
135137
vuidManager?: VuidManager
@@ -228,6 +230,7 @@ export default class Optimizely extends BaseService implements Client {
228230

229231
this.decisionService = createDecisionService({
230232
userProfileService: userProfileService,
233+
userProfileServiceAsync: config.userProfileServiceAsync || undefined,
231234
cmabService: config.cmabService,
232235
logger: this.logger,
233236
UNSTABLE_conditionEvaluators: config.UNSTABLE_conditionEvaluators,

lib/shared_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ export interface Config {
366366
errorNotifier?: OpaqueErrorNotifier;
367367
// user profile that contains user information
368368
userProfileService?: UserProfileService;
369+
userProfileServiceAsync?: UserProfileServiceAsync;
369370
// dafault options for decide API
370371
defaultDecideOptions?: OptimizelyDecideOption[];
371372
clientEngine?: string;

0 commit comments

Comments
 (0)