@eppo/js-client-sdk-common
Advanced tools
Comparing version 1.7.0 to 1.8.0-alpha
@@ -0,1 +1,6 @@ | ||
export declare enum HoldoutVariationEnum { | ||
STATUS_QUO = "status_quo", | ||
ALL_SHIPPED = "all_shipped_variants" | ||
} | ||
export declare type NullableHoldoutVariationType = HoldoutVariationEnum | null; | ||
/** | ||
@@ -30,2 +35,10 @@ * Holds data about the variation a subject was assigned to. | ||
timestamp: string; | ||
/** | ||
* An Eppo holdout key | ||
*/ | ||
holdout: string | null; | ||
/** | ||
* The Eppo holdout variation for the assigned variation | ||
*/ | ||
holdoutVariation: NullableHoldoutVariationType; | ||
subjectAttributes: Record<string, any>; | ||
@@ -32,0 +45,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HoldoutVariationEnum = void 0; | ||
var HoldoutVariationEnum; | ||
(function (HoldoutVariationEnum) { | ||
HoldoutVariationEnum["STATUS_QUO"] = "status_quo"; | ||
HoldoutVariationEnum["ALL_SHIPPED"] = "all_shipped_variants"; | ||
})(HoldoutVariationEnum = exports.HoldoutVariationEnum || (exports.HoldoutVariationEnum = {})); | ||
//# sourceMappingURL=assignment-logger.js.map |
@@ -5,2 +5,3 @@ "use strict"; | ||
const assignment_cache_1 = require("../assignment-cache"); | ||
const assignment_logger_1 = require("../assignment-logger"); | ||
const constants_1 = require("../constants"); | ||
@@ -93,12 +94,18 @@ const eppo_value_1 = require("../eppo_value"); | ||
subjectAttributes = {}, assignmentHooks, obfuscated, valueType) { | ||
const { allocationKey, assignment } = this.getAssignmentInternal(subjectKey, flagKey, subjectAttributes, assignmentHooks, obfuscated, valueType); | ||
const { allocationKey, assignment, holdoutKey, holdoutVariation } = this.getAssignmentInternal(subjectKey, flagKey, subjectAttributes, assignmentHooks, obfuscated, valueType); | ||
assignmentHooks === null || assignmentHooks === void 0 ? void 0 : assignmentHooks.onPostAssignment(flagKey, subjectKey, assignment, allocationKey); | ||
if (!assignment.isNullType() && allocationKey !== null) | ||
this.logAssignment(flagKey, allocationKey, assignment, subjectKey, subjectAttributes); | ||
this.logAssignment(flagKey, allocationKey, assignment, subjectKey, holdoutKey, holdoutVariation, subjectAttributes); | ||
return assignment; | ||
} | ||
getAssignmentInternal(subjectKey, flagKey, subjectAttributes = {}, assignmentHooks, obfuscated, expectedValueType) { | ||
var _a; | ||
(0, validation_1.validateNotBlank)(subjectKey, 'Invalid argument: subjectKey cannot be blank'); | ||
(0, validation_1.validateNotBlank)(flagKey, 'Invalid argument: flagKey cannot be blank'); | ||
const nullAssignment = { allocationKey: null, assignment: eppo_value_1.EppoValue.Null() }; | ||
const nullAssignment = { | ||
allocationKey: null, | ||
assignment: eppo_value_1.EppoValue.Null(), | ||
holdoutKey: null, | ||
holdoutVariation: null, | ||
}; | ||
const experimentConfig = this.configurationStore.get(obfuscated ? (0, obfuscation_1.getMD5Hash)(flagKey) : flagKey); | ||
@@ -132,8 +139,32 @@ const allowListOverride = this.getSubjectVariationOverride(subjectKey, experimentConfig, expectedValueType); | ||
const { subjectShards } = experimentConfig; | ||
const { variations } = allocation; | ||
const shard = (0, shard_1.getShard)(`assignment-${subjectKey}-${flagKey}`, subjectShards); | ||
const assignedVariation = variations.find((variation) => (0, shard_1.isShardInRange)(shard, variation.shardRange)); | ||
const { variations, holdouts, statusQuoVariationKey, shippedVariationKey } = allocation; | ||
let assignedVariation; | ||
let holdoutVariation = null; | ||
const holdoutShard = (0, shard_1.getShard)(`holdout-${subjectKey}`, subjectShards); | ||
const matchingHoldout = holdouts.find((holdout) => { | ||
const { statusQuoShardRange, shippedShardRange } = holdout; | ||
if ((0, shard_1.isShardInRange)(holdoutShard, statusQuoShardRange)) { | ||
assignedVariation = variations.find((variation) => variation.variationKey === statusQuoVariationKey); | ||
// Only log the holdout variation if this is a rollout allocation | ||
// Only rollout allocations have shippedShardRange specified | ||
if (shippedShardRange) { | ||
holdoutVariation = assignment_logger_1.HoldoutVariationEnum.STATUS_QUO; | ||
} | ||
} | ||
else if (shippedShardRange && (0, shard_1.isShardInRange)(holdoutShard, shippedShardRange)) { | ||
assignedVariation = variations.find((variation) => variation.variationKey === shippedVariationKey); | ||
holdoutVariation = assignment_logger_1.HoldoutVariationEnum.ALL_SHIPPED; | ||
} | ||
return assignedVariation; | ||
}); | ||
const holdoutKey = (_a = matchingHoldout === null || matchingHoldout === void 0 ? void 0 : matchingHoldout.holdoutKey) !== null && _a !== void 0 ? _a : null; | ||
if (!matchingHoldout) { | ||
const assignmentShard = (0, shard_1.getShard)(`assignment-${subjectKey}-${flagKey}`, subjectShards); | ||
assignedVariation = variations.find((variation) => (0, shard_1.isShardInRange)(assignmentShard, variation.shardRange)); | ||
} | ||
const internalAssignment = { | ||
allocationKey: matchedRule.allocationKey, | ||
assignment: eppo_value_1.EppoValue.generateEppoValue(expectedValueType, assignedVariation === null || assignedVariation === void 0 ? void 0 : assignedVariation.value, assignedVariation === null || assignedVariation === void 0 ? void 0 : assignedVariation.typedValue), | ||
holdoutKey, | ||
holdoutVariation: holdoutVariation, | ||
}; | ||
@@ -174,3 +205,3 @@ return internalAssignment.assignment.isExpectedType() ? internalAssignment : nullAssignment; | ||
} | ||
logAssignment(flagKey, allocationKey, variation, subjectKey, | ||
logAssignment(flagKey, allocationKey, variation, subjectKey, holdout, holdoutVariation, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -194,2 +225,4 @@ subjectAttributes = {}) { | ||
subject: subjectKey, | ||
holdout, | ||
holdoutVariation, | ||
subjectAttributes, | ||
@@ -196,0 +229,0 @@ }; |
@@ -0,1 +1,2 @@ | ||
import { IHoldout } from './holdout-dto'; | ||
import { IVariation } from './variation-dto'; | ||
@@ -5,3 +6,6 @@ export interface IAllocation { | ||
variations: IVariation[]; | ||
statusQuoVariationKey: string | null; | ||
shippedVariationKey: string | null; | ||
holdouts: IHoldout[]; | ||
} | ||
//# sourceMappingURL=allocation-dto.d.ts.map |
@@ -7,2 +7,3 @@ import { IValue } from '../eppo_value'; | ||
export interface IVariation { | ||
variationKey: string; | ||
name: string; | ||
@@ -9,0 +10,0 @@ value: string; |
{ | ||
"name": "@eppo/js-client-sdk-common", | ||
"version": "1.7.0", | ||
"version": "1.8.0-alpha", | ||
"description": "Eppo SDK for client-side JavaScript applications (base for both web and react native)", | ||
@@ -66,3 +66,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"axios": "^0.27.2", | ||
"axios": "^1.6.0", | ||
"lru-cache": "^10.0.1", | ||
@@ -69,0 +69,0 @@ "md5": "^2.3.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
306786
81
1132
1
1
1
+ Addedaxios@1.7.9(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
- Removedaxios@0.27.2(transitive)
Updatedaxios@^1.6.0