Skip to content

[FSSDK-11504] rename log level presets #1049

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 1 commit into from
May 13, 2025
Merged
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
8 changes: 4 additions & 4 deletions lib/common_exports.ts
Original file line number Diff line number Diff line change
@@ -19,10 +19,10 @@ export { createStaticProjectConfigManager } from './project_config/config_manage
export { LogLevel } from './logging/logger';

export {
DebugLog,
InfoLog,
WarnLog,
ErrorLog,
DEBUG,
INFO,
WARN,
ERROR,
} from './logging/logger_factory';

export { createLogger } from './logging/logger_factory';
8 changes: 4 additions & 4 deletions lib/entrypoint.test-d.ts
Original file line number Diff line number Diff line change
@@ -78,10 +78,10 @@ export type Entrypoint = {

// logger related exports
LogLevel: typeof LogLevel;
DebugLog: OpaqueLevelPreset,
InfoLog: OpaqueLevelPreset,
WarnLog: OpaqueLevelPreset,
ErrorLog: OpaqueLevelPreset,
DEBUG: OpaqueLevelPreset,
INFO: OpaqueLevelPreset,
WARN: OpaqueLevelPreset,
ERROR: OpaqueLevelPreset,
createLogger: (config: LoggerConfig) => OpaqueLogger;

// error related exports
8 changes: 4 additions & 4 deletions lib/entrypoint.universal.test-d.ts
Original file line number Diff line number Diff line change
@@ -73,10 +73,10 @@ export type UniversalEntrypoint = {

// logger related exports
LogLevel: typeof LogLevel;
DebugLog: OpaqueLevelPreset,
InfoLog: OpaqueLevelPreset,
WarnLog: OpaqueLevelPreset,
ErrorLog: OpaqueLevelPreset,
DEBUG: OpaqueLevelPreset,
INFO: OpaqueLevelPreset,
WARN: OpaqueLevelPreset,
ERROR: OpaqueLevelPreset,
createLogger: (config: LoggerConfig) => OpaqueLogger;

// error related exports
2 changes: 1 addition & 1 deletion lib/event_processor/batch_event_processor.spec.ts
Original file line number Diff line number Diff line change
@@ -179,7 +179,7 @@ describe('BatchEventProcessor', async () => {
batchSize: 100,
});

expect(processor.process(createImpressionEvent('id-1'))).rejects.toThrow();
await expect(processor.process(createImpressionEvent('id-1'))).rejects.toThrow();
});

it('should enqueue event without dispatching immediately', async () => {
6 changes: 3 additions & 3 deletions lib/logging/logger_factory.spec.ts
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ vi.mock('./logger', async (importOriginal) => {
});

import { OptimizelyLogger, ConsoleLogHandler, LogLevel } from './logger';
import { createLogger, extractLogger, InfoLog } from './logger_factory';
import { createLogger, extractLogger, INFO } from './logger_factory';
import { errorResolver, infoResolver } from '../message/message_resolver';

describe('create', () => {
@@ -41,7 +41,7 @@ describe('create', () => {
const mockLogHandler = { log: vi.fn() };

const logger = extractLogger(createLogger({
level: InfoLog,
level: INFO,
logHandler: mockLogHandler,
}));

@@ -56,7 +56,7 @@ describe('create', () => {

it('should use a ConsoleLogHandler if no logHandler is provided', () => {
const logger = extractLogger(createLogger({
level: InfoLog,
level: INFO,
}));

expect(logger).toBe(MockedOptimizelyLogger.mock.instances[0]);
8 changes: 4 additions & 4 deletions lib/logging/logger_factory.ts
Original file line number Diff line number Diff line change
@@ -50,19 +50,19 @@ export type OpaqueLevelPreset = {
[levelPresetSymbol]: unknown;
};

export const DebugLog: OpaqueLevelPreset = {
export const DEBUG: OpaqueLevelPreset = {
[levelPresetSymbol]: debugPreset,
};

export const InfoLog: OpaqueLevelPreset = {
export const INFO: OpaqueLevelPreset = {
[levelPresetSymbol]: infoPreset,
};

export const WarnLog: OpaqueLevelPreset = {
export const WARN: OpaqueLevelPreset = {
[levelPresetSymbol]: warnPreset,
};

export const ErrorLog: OpaqueLevelPreset = {
export const ERROR: OpaqueLevelPreset = {
[levelPresetSymbol]: errorPreset,
};

2 changes: 1 addition & 1 deletion lib/project_config/polling_datafile_manager.spec.ts
Original file line number Diff line number Diff line change
@@ -495,7 +495,7 @@ describe('PollingDatafileManager', () => {
manager.start();
for(let i = 0; i < 2; i++) {
const ret = repeater.execute(0);
expect(ret).rejects.toThrow();
await expect(ret).rejects.toThrow();
}

repeater.execute(0);

Unchanged files with check annotations Beta

isQualifiedFor: segment => segments ? segments.indexOf(segment) > -1 : false,
qualifiedSegments: segments || [],
getUserId: () => 'mockUserId',
setAttribute: (key: string, value: any) => {},

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

'value' is defined but never used

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

'key' is defined but never used

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

'value' is defined but never used

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

'key' is defined but never used

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

'value' is defined but never used

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

'key' is defined but never used

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

'value' is defined but never used

Check warning on line 33 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

'key' is defined but never used
decide: (key: string, options?: OptimizelyDecideOption[]): OptimizelyDecision => ({

Check warning on line 35 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

'options' is defined but never used

Check warning on line 35 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

'key' is defined but never used

Check warning on line 35 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

'options' is defined but never used

Check warning on line 35 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

'key' is defined but never used

Check warning on line 35 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

'options' is defined but never used

Check warning on line 35 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

'key' is defined but never used

Check warning on line 35 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

'options' is defined but never used

Check warning on line 35 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

'key' is defined but never used
variationKey: 'mockVariationKey',
enabled: true,
variables: { mockVariable: 'mockValue' },
});
it('calls customAttributeConditionEvaluator.evaluate in the leaf evaluator for audience conditions', () => {
vi.spyOn(conditionTreeEvaluator, 'evaluate').mockImplementation((conditions: any, leafEvaluator) => {

Check warning on line 253 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 253 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 253 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 253 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
return leafEvaluator(conditions[1]);
});
});
it('logs correctly when conditionTreeEvaluator.evaluate returns null', () => {
vi.spyOn(conditionTreeEvaluator, 'evaluate').mockImplementationOnce((conditions: any, leafEvaluator) => {

Check warning on line 295 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 295 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 295 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 295 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
return leafEvaluator(conditions[1]);
});
});
it('logs correctly when conditionTreeEvaluator.evaluate returns true', () => {
vi.spyOn(conditionTreeEvaluator, 'evaluate').mockImplementationOnce((conditions: any, leafEvaluator) => {

Check warning on line 322 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 322 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 322 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 322 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
return leafEvaluator(conditions[1]);
});
});
it('logs correctly when conditionTreeEvaluator.evaluate returns false', () => {
vi.spyOn(conditionTreeEvaluator, 'evaluate').mockImplementationOnce((conditions: any, leafEvaluator) => {

Check warning on line 348 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 348 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 348 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 348 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
return leafEvaluator(conditions[1]);
});
};
audienceEvaluator = createAudienceEvaluator({
special_condition_type: {
evaluate: (condition: any, user: any) => {

Check warning on line 384 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 384 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (18)

Unexpected any. Specify a different type

Check warning on line 384 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (22)

Unexpected any. Specify a different type

Check warning on line 384 in lib/core/audience_evaluator/index.spec.ts

GitHub Actions / unit_tests (20)

Unexpected any. Specify a different type
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const result = mockEnvironment[condition.value] && user.getAttributes()[condition.match] > 0;