New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eppo/js-client-sdk-common

Package Overview
Dependencies
Maintainers
8
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eppo/js-client-sdk-common - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0-alpha

dist/dto/holdout-dto.d.ts

13

dist/assignment-logger.d.ts

@@ -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

47

dist/client/eppo-client.js

@@ -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;

4

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc