Skip to content

[FSSDK-10619] Refactor project config manager to be injectable #945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a961147
saving
raju-opti Aug 22, 2024
eb9110c
saving
raju-opti Aug 27, 2024
f88fd9f
up
raju-opti Aug 27, 2024
c406523
fix test
raju-opti Aug 28, 2024
de99436
fix more tests
raju-opti Aug 29, 2024
ef85d65
fix tests
raju-opti Aug 29, 2024
580a0b6
saving
raju-opti Aug 30, 2024
7940193
saving
raju-opti Sep 2, 2024
08636b7
emitter test
raju-opti Sep 3, 2024
f1a68e4
save
raju-opti Sep 4, 2024
5439eb2
fix more test
raju-opti Sep 5, 2024
2ff16c9
fix tests
raju-opti Sep 5, 2024
a5305f9
fix tests
raju-opti Sep 5, 2024
9c6e8ee
fix
raju-opti Sep 6, 2024
2441875
update
raju-opti Sep 9, 2024
3755d24
update
raju-opti Sep 9, 2024
2d25fd5
update
raju-opti Sep 9, 2024
a086e62
saving
raju-opti Sep 10, 2024
c705ccb
add tests
raju-opti Sep 10, 2024
3c8a57c
add test
raju-opti Sep 10, 2024
b276b7e
tests
raju-opti Sep 11, 2024
cae172f
update
raju-opti Sep 13, 2024
53ccf3e
update
raju-opti Sep 13, 2024
8dea409
tests
raju-opti Sep 17, 2024
f57c315
add more tests
raju-opti Sep 17, 2024
1643628
add tests
raju-opti Sep 18, 2024
b41f28f
update
raju-opti Sep 18, 2024
0098fc2
update
raju-opti Sep 18, 2024
5758a9b
tests
raju-opti Sep 18, 2024
a71fdd9
add more tests
raju-opti Sep 19, 2024
5a29def
add tests
raju-opti Sep 19, 2024
fcbef0d
update name
raju-opti Sep 19, 2024
acf7bcf
remove notification registry
raju-opti Sep 19, 2024
4a98a6d
fix repeater test
raju-opti Sep 19, 2024
a24e263
fixes
raju-opti Sep 19, 2024
d27b3b1
updates
raju-opti Sep 20, 2024
3cc4e7c
update
raju-opti Sep 20, 2024
515696e
update
raju-opti Sep 20, 2024
f92b56f
update
raju-opti Sep 20, 2024
56ebf5e
update
raju-opti Sep 20, 2024
a877e9d
upd
raju-opti Sep 20, 2024
c2fbc70
exclude spec from build
raju-opti Sep 20, 2024
19877a2
private
raju-opti Sep 20, 2024
ef4879d
update
raju-opti Sep 27, 2024
0b8c06d
update
raju-opti Sep 27, 2024
c483d85
updating
raju-opti Sep 27, 2024
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
4 changes: 3 additions & 1 deletion lib/common_exports.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2023 Optimizely
* Copyright 2023-2024 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 @@ -17,3 +17,5 @@
export { LogLevel, LogHandler, getLogger, setLogHandler } from './modules/logging';
export { LOG_LEVEL } from './utils/enums';
export { createLogger } from './plugins/logger';
export { createStaticProjectConfigManager } from './project_config/config_manager_factory';
export { PollingConfigManagerConfig } from './project_config/config_manager_factory';
4 changes: 2 additions & 2 deletions lib/core/bucketer/index.tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2017, 2019-2022, Optimizely
* Copyright 2016-2017, 2019-2022, 2024, 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 @@ -25,7 +25,7 @@ import {
LOG_LEVEL,
} from '../../utils/enums';
import { createLogger } from '../../plugins/logger';
import projectConfig from '../project_config';
import projectConfig from '../../project_config/project_config';
import { getTestProjectConfig } from '../../tests/test_data';

var buildLogMessageFromArgs = args => sprintf(args[1], ...args.splice(2));
Expand Down
38 changes: 21 additions & 17 deletions lib/core/decision_service/index.tests.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/****************************************************************************
* Copyright 2017-2022 Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
/**
* Copyright 2017-2022, 2024, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import sinon from 'sinon';
import { assert } from 'chai';
import cloneDeep from 'lodash/cloneDeep';
Expand All @@ -29,11 +29,13 @@ import { createForwardingEventProcessor } from '../../plugins/event_processor/fo
import { createNotificationCenter } from '../notification_center';
import Optimizely from '../../optimizely';
import OptimizelyUserContext from '../../optimizely_user_context';
import projectConfig from '../project_config';
import projectConfig, { createProjectConfig } from '../../project_config/project_config';
import AudienceEvaluator from '../audience_evaluator';
import errorHandler from '../../plugins/error_handler';
import eventDispatcher from '../../plugins/event_dispatcher/index.node';
import * as jsonSchemaValidator from '../../utils/json_schema_validator';
import { getMockProjectConfigManager } from '../../tests/mock/mock_project_config_manager';

import {
getTestProjectConfig,
getTestProjectConfigWithFeatures,
Expand Down Expand Up @@ -1067,7 +1069,9 @@ describe('lib/core/decision_service', function() {
beforeEach(function() {
optlyInstance = new Optimizely({
clientEngine: 'node-sdk',
datafile: cloneDeep(testData),
projectConfigManager: getMockProjectConfigManager({
initConfig: createProjectConfig(cloneDeep(testData))
}),
jsonSchemaValidator: jsonSchemaValidator,
isValidInstance: true,
logger: createdLogger,
Expand Down
32 changes: 16 additions & 16 deletions lib/core/decision_service/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/****************************************************************************
* Copyright 2017-2022 Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
/**
* Copyright 2017-2022, 2024, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LogHandler } from '../../modules/logging';
import { sprintf } from '../../utils/fns';

Expand All @@ -38,7 +38,7 @@
getVariationKeyFromId,
isActive,
ProjectConfig,
} from '../project_config';
} from '../../project_config/project_config';
import { AudienceEvaluator, createAudienceEvaluator } from '../audience_evaluator';
import * as stringValidator from '../../utils/string_value_validator';
import {
Expand Down Expand Up @@ -484,7 +484,7 @@

try {
return this.userProfileService.lookup(userId);
} catch (ex: any) {

Check warning on line 487 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 487 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 487 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (16)

Unexpected any. Specify a different type

Check warning on line 487 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 487 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
this.logger.log(
LOG_LEVEL.ERROR,
ERROR_MESSAGES.USER_PROFILE_LOOKUP_ERROR,
Expand Down Expand Up @@ -532,7 +532,7 @@
experiment.key,
userId,
);
} catch (ex: any) {

Check warning on line 535 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 535 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 535 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (16)

Unexpected any. Specify a different type

Check warning on line 535 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 535 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
this.logger.log(LOG_LEVEL.ERROR, ERROR_MESSAGES.USER_PROFILE_SAVE_ERROR, MODULE_NAME, userId, ex.message);
}
}
Expand Down Expand Up @@ -972,7 +972,7 @@
reasons: decideReasons,
};
}
} catch (ex: any) {

Check warning on line 975 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 975 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 975 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (16)

Unexpected any. Specify a different type

Check warning on line 975 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 975 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
// catching experiment not in datafile
this.logger.log(LOG_LEVEL.ERROR, ex.message);
decideReasons.push(ex.message);
Expand Down Expand Up @@ -1065,7 +1065,7 @@
);
return false;
}
} catch (ex: any) {

Check warning on line 1068 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 1068 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 1068 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (16)

Unexpected any. Specify a different type

Check warning on line 1068 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 1068 in lib/core/decision_service/index.ts

View workflow job for this annotation

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
// catching experiment not in datafile
this.logger.log(LOG_LEVEL.ERROR, ex.message);
return false;
Expand Down
4 changes: 2 additions & 2 deletions lib/core/event_builder/event_helpers.tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020, Optimizely
* Copyright 2019-2020, 2024, 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 @@ -17,7 +17,7 @@ import sinon from 'sinon';
import { assert } from 'chai';

import fns from '../../utils/fns';
import * as projectConfig from '../project_config';
import * as projectConfig from '../../project_config/project_config';
import * as decision from '../decision';
import { buildImpressionEvent, buildConversionEvent } from './event_helpers';

Expand Down
4 changes: 2 additions & 2 deletions lib/core/event_builder/event_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019-2022, Optimizely
* Copyright 2019-2022, 2024, 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 @@ -27,7 +27,7 @@ import {
getEventId,
getLayerId,
ProjectConfig,
} from '../project_config';
} from '../../project_config/project_config';

const logger = getLogger('EVENT_BUILDER');

Expand Down
4 changes: 2 additions & 2 deletions lib/core/event_builder/index.tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2021, Optimizely
* Copyright 2016-2021, 2024, 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 @@ -18,7 +18,7 @@ import { assert } from 'chai';

import fns from '../../utils/fns';
import testData from '../../tests/test_data';
import projectConfig from '../project_config';
import projectConfig from '../../project_config/project_config';
import packageJSON from '../../../package.json';
import { getConversionEvent, getImpressionEvent } from './';

Expand Down
4 changes: 2 additions & 2 deletions lib/core/event_builder/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2022, Optimizely
* Copyright 2016-2022, 2024, 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 @@ -24,7 +24,7 @@ import {
getLayerId,
getVariationKeyFromId,
ProjectConfig,
} from '../project_config';
} from '../../project_config/project_config';
import * as eventTagUtils from '../../utils/event_tag_utils';
import { isAttributeValid } from '../../utils/attributes_validator';
import { EventTags, UserAttributes, Event as EventLoggingEndpoint } from '../../shared_types';
Expand Down
62 changes: 0 additions & 62 deletions lib/core/notification_center/notification_registry.tests.ts

This file was deleted.

65 changes: 0 additions & 65 deletions lib/core/notification_center/notification_registry.ts

This file was deleted.

4 changes: 2 additions & 2 deletions lib/core/odp/odp_event_api_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { LogHandler, LogLevel } from '../../modules/logging';
import { OdpEvent } from './odp_event';
import { RequestHandler } from '../../utils/http_request_handler/http';
import { HttpMethod, RequestHandler } from '../../utils/http_request_handler/http';
import { OdpConfig } from './odp_config';
import { ERROR_MESSAGES } from '../../utils/enums';

Expand Down Expand Up @@ -109,7 +109,7 @@ export abstract class OdpEventApiManager implements IOdpEventApiManager {
odpConfig: OdpConfig,
events: OdpEvent[]
): {
method: string;
method: HttpMethod;
endpoint: string;
headers: { [key: string]: string };
data: string;
Expand Down
4 changes: 2 additions & 2 deletions lib/core/odp/odp_event_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { OdpConfig } from './odp_config';
import { IOdpEventApiManager } from './odp_event_api_manager';
import { invalidOdpDataFound } from './odp_utils';
import { IUserAgentParser } from './user_agent_parser';
import { scheduleMicrotaskOrTimeout } from '../../utils/microtask';
import { scheduleMicrotask } from '../../utils/microtask';

const MAX_RETRIES = 3;

Expand Down Expand Up @@ -394,7 +394,7 @@ export abstract class OdpEventManager implements IOdpEventManager {

if (batch.length > 0) {
// put sending the event on another event loop
scheduleMicrotaskOrTimeout(async () => {
scheduleMicrotask(async () => {
let shouldRetry: boolean;
let attemptNumber = 0;
do {
Expand Down
4 changes: 2 additions & 2 deletions lib/core/optimizely_config/index.tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019-2021, Optimizely
* Copyright 2019-2021, 2024, 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 @@ -18,7 +18,7 @@ import { cloneDeep } from 'lodash';
import sinon from 'sinon';

import { createOptimizelyConfig, OptimizelyConfig } from './';
import { createProjectConfig } from '../project_config';
import { createProjectConfig } from '../../project_config/project_config';
import {
getTestProjectConfigWithFeatures,
getTypedAudiencesConfig,
Expand Down
4 changes: 2 additions & 2 deletions lib/core/optimizely_config/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2020-2023, Optimizely
* Copyright 2020-2024, 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 @@ -14,7 +14,7 @@
* limitations under the License.
*/
import { LoggerFacade, getLogger } from '../../modules/logging';
import { ProjectConfig } from '../project_config';
import { ProjectConfig } from '../../project_config/project_config';
import { DEFAULT_OPERATOR_TYPES } from '../condition_tree_evaluator';
import {
Audience,
Expand Down
Loading
Loading