Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/client_factory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2025, Optimizely
* Copyright 2025-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@ import { extractOdpManager } from "./odp/odp_manager_factory";
import { extractVuidManager } from "./vuid/vuid_manager_factory";
import { RequestHandler } from "./utils/http_request_handler/http";
import { CLIENT_VERSION, DEFAULT_CMAB_BACKOFF_MS, DEFAULT_CMAB_CACHE_SIZE, DEFAULT_CMAB_CACHE_TIMEOUT_MS, DEFAULT_CMAB_RETRIES, JAVASCRIPT_CLIENT_ENGINE } from "./utils/enums";
import Optimizely from "./optimizely";
import Optimizely, { OptimizelyOptions } from "./optimizely";
import { DefaultCmabClient } from "./core/decision_service/cmab/cmab_client";
import { CmabCacheValue, DefaultCmabService } from "./core/decision_service/cmab/cmab_service";
import { InMemoryLruCache } from "./utils/cache/in_memory_lru_cache";
Expand Down Expand Up @@ -76,7 +76,7 @@ export const getOptimizelyInstance = (config: OptimizelyFactoryConfig): Optimize
logger: logger?.child()
});

const optimizelyOptions = {
const optimizelyOptions: OptimizelyOptions = {
cmabService,
clientEngine: clientEngine || JAVASCRIPT_CLIENT_ENGINE,
clientVersion: clientVersion || CLIENT_VERSION,
Expand All @@ -91,6 +91,9 @@ export const getOptimizelyInstance = (config: OptimizelyFactoryConfig): Optimize
eventProcessor,
odpManager,
vuidManager,
// UNSTABLE_conditionEvaluators is not exposed in the public types, but we want to pass it through
// for internal use cases.
UNSTABLE_conditionEvaluators: (config as any).UNSTABLE_conditionEvaluators,
};

return new Optimizely(optimizelyOptions);
Expand Down
1 change: 1 addition & 0 deletions lib/core/decision_service/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var createLogger = () => ({
warn: () => {},
error: () => {},
child: () => createLogger(),
setName: () => {},
})

describe('lib/core/decision_service', function() {
Expand Down
5 changes: 4 additions & 1 deletion lib/core/decision_service/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2017-2022, 2024-2025, Optimizely
* Copyright 2017-2022, 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -158,6 +158,8 @@ export type DecideOptionsMap = Partial<Record<OptimizelyDecideOption, boolean>>;

export const CMAB_DUMMY_ENTITY_ID= '$'

export const LOGGER_NAME = 'DecisionService';

/**
* Optimizely's decision service that determines which variation of an experiment the user will be allocated to.
*
Expand All @@ -183,6 +185,7 @@ export class DecisionService {

constructor(options: DecisionServiceOptions) {
this.logger = options.logger;
this.logger?.setName(LOGGER_NAME);
this.audienceEvaluator = createAudienceEvaluator(options.UNSTABLE_conditionEvaluators, this.logger);
this.forcedVariationMap = {};
this.userProfileService = options.userProfileService;
Expand Down
5 changes: 3 additions & 2 deletions lib/optimizely/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ var createLogger = () => ({
warn: () => {},
error: () => {},
child: () => createLogger(),
setName: () => {},
})

const getOptlyInstance = ({ datafileObj, defaultDecideOptions }) => {
Expand Down Expand Up @@ -240,7 +241,7 @@ describe('lib/optimizely', function() {
sinon.assert.calledWith(decisionService.createDecisionService, {
userProfileService: userProfileServiceInstance,
userProfileServiceAsync: undefined,
logger: createdLogger,
logger: sinon.match.any,
cmabService,
UNSTABLE_conditionEvaluators: undefined,
});
Expand Down Expand Up @@ -272,7 +273,7 @@ describe('lib/optimizely', function() {
sinon.assert.calledWith(decisionService.createDecisionService, {
userProfileService: undefined,
userProfileServiceAsync: undefined,
logger: createdLogger,
logger: sinon.match.any,
UNSTABLE_conditionEvaluators: undefined,
cmabService,
});
Expand Down
4 changes: 2 additions & 2 deletions lib/optimizely/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2020-2025, Optimizely
* Copyright 2020-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -242,7 +242,7 @@ export default class Optimizely extends BaseService implements Client {
userProfileService: userProfileService,
userProfileServiceAsync: config.userProfileServiceAsync || undefined,
cmabService: config.cmabService,
logger: this.logger,
logger: this.logger?.child(),
UNSTABLE_conditionEvaluators: config.UNSTABLE_conditionEvaluators,
});

Expand Down
1 change: 1 addition & 0 deletions lib/optimizely_user_context/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var createLogger = () => ({
warn: () => {},
error: () => {},
child: () => createLogger(),
setName: () => {},
});

const getOptlyInstance = ({ datafileObj, defaultDecideOptions }) => {
Expand Down
Loading