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
8 changes: 4 additions & 4 deletions lib/core/custom_attribute_condition_evaluator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function greaterThanEvaluator(condition: Condition, user: OptimizelyUserContext)
if (!validateValuesForNumericCondition(condition, user) || conditionValue === null) {
return null;
}
return userValue > conditionValue;
return userValue! > conditionValue;
}

/**
Expand All @@ -262,7 +262,7 @@ function greaterThanOrEqualEvaluator(condition: Condition, user: OptimizelyUserC
return null;
}

return userValue >= conditionValue;
return userValue! >= conditionValue;
}

/**
Expand All @@ -283,7 +283,7 @@ function lessThanEvaluator(condition: Condition, user: OptimizelyUserContext): b
return null;
}

return userValue < conditionValue;
return userValue! < conditionValue;
}

/**
Expand All @@ -304,7 +304,7 @@ function lessThanOrEqualEvaluator(condition: Condition, user: OptimizelyUserCont
return null;
}

return userValue <= conditionValue;
return userValue! <= conditionValue;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/core/decision_service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ export class DecisionService {
attributes.hasOwnProperty(CONTROL_ATTRIBUTES.BUCKETING_ID)
) {
if (typeof attributes[CONTROL_ATTRIBUTES.BUCKETING_ID] === 'string') {
bucketingId = attributes[CONTROL_ATTRIBUTES.BUCKETING_ID];
bucketingId = String(attributes[CONTROL_ATTRIBUTES.BUCKETING_ID]);
this.logger.log(LOG_LEVEL.DEBUG, LOG_MESSAGES.VALID_BUCKETING_ID, MODULE_NAME, bucketingId);
} else {
this.logger.log(LOG_LEVEL.WARNING, LOG_MESSAGES.BUCKETING_ID_NOT_STRING, MODULE_NAME);
Expand Down
2 changes: 1 addition & 1 deletion lib/core/event_builder/event_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function buildVisitorAttributes(
builtAttributes.push({
entityId: attributeId,
key: attributeKey,
value: attributes[attributeKey],
value: attributeValue!,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/event_builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function getCommonEventParams({
entity_id: attributeId,
key: attributeKey,
type: CUSTOM_ATTRIBUTE_FEATURE_TYPE,
value: attributes[attributeKey],
value: attributeValue!,
});
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/export_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

export {
UserAttributeValue,
UserAttributes,
OptimizelyConfig,
OptimizelyVariable,
Expand Down
3 changes: 2 additions & 1 deletion lib/optimizely_user_context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
OptimizelyDecision,
OptimizelyDecisionContext,
OptimizelyForcedDecision,
UserAttributeValue,
UserAttributes,
} from '../shared_types';
import { CONTROL_ATTRIBUTES } from '../utils/enums';
Expand Down Expand Up @@ -80,7 +81,7 @@ export default class OptimizelyUserContext implements IOptimizelyUserContext {
* @param {string} key An attribute key
* @param {any} value An attribute value
*/
setAttribute(key: string, value: unknown): void {
setAttribute(key: string, value: UserAttributeValue): void {
this.attributes[key] = value;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/shared_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export interface DecisionResponse<T> {
readonly reasons: (string | number)[][];
}

export type UserAttributeValue = string | number | boolean | null;

export type UserAttributes = {
// TODO[OASIS-6649]: Don't use any type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[name: string]: any;
[name: string]: UserAttributeValue;
};

export interface ExperimentBucketMap {
Expand Down