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
5
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.2.2 to 1.3.0

7

dist/assignment-hooks.d.ts

@@ -9,2 +9,3 @@ /**

*
* @param experimentKey key of the experiment being assigned
* @param subject id of subject being assigned

@@ -15,11 +16,13 @@ * @returns variation to override for the given subject. If null is returned,

*/
onPreAssignment(subject: string): Promise<string | null>;
onPreAssignment(experimentKey: string, subject: string): string | null;
/**
* Invoked after a subject is assigned. Useful for any post assignment logic needed which is specific
* to an experiment/flag. Do not use this for logging assignments - use IAssignmentLogger instead.
* @param experimentKey key of the experiment being assigned
* @param subject id of subject being assigned
* @param variation the assigned variation
* @public
*/
onPostAssignment(variation: string): Promise<void>;
onPostAssignment(experimentKey: string, subject: string, variation: string): void;
}
//# sourceMappingURL=assignment-hooks.d.ts.map

@@ -16,18 +16,7 @@ import { IAssignmentHooks } from '../assignment-hooks';

* The subject attributes are used for evaluating any targeting rules tied to the experiment.
* @param assignmentHooks optional interface for pre and post assignment hooks
* @returns a variation value if the subject is part of the experiment sample, otherwise null
* @public
*/
getAssignment(subjectKey: string, experimentKey: string, subjectAttributes?: Record<string, any>): string;
/**
* Asynchronously maps a subject to a variation for a given experiment, with pre and post assignment hooks
*
* @param subjectKey an identifier of the experiment subject, for example a user ID.
* @param experimentKey experiment identifier
* @param assignmentHooks interface for pre and post assignment hooks
* @param subjectAttributes optional attributes associated with the subject, for example name and email.
* The subject attributes are used for evaluating any targeting rules tied to the experiment.
* @returns a variation value if the subject is part of the experiment sample, otherwise null
* @public
*/
getAssignmentWithHooks(subjectKey: string, experimentKey: string, assignmentHooks: IAssignmentHooks, subjectAttributes?: Record<string, any>): Promise<string>;
getAssignment(subjectKey: string, experimentKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks): string;
}

@@ -39,4 +28,4 @@ export default class EppoClient implements IEppoClient {

constructor(configurationStore: IConfigurationStore);
getAssignment(subjectKey: string, experimentKey: string, subjectAttributes?: {}): string;
getAssignmentWithHooks(subjectKey: string, experimentKey: string, assignmentHooks: IAssignmentHooks, subjectAttributes?: {}): Promise<string>;
getAssignment(subjectKey: string, experimentKey: string, subjectAttributes?: {}, assignmentHooks?: IAssignmentHooks): string;
private getAssignmentInternal;
setLogger(logger: IAssignmentLogger): void;

@@ -43,0 +32,0 @@ private flushQueuedEvents;

@@ -14,5 +14,12 @@ "use strict";

}
getAssignment(subjectKey, experimentKey, subjectAttributes = {}) {
getAssignment(subjectKey, experimentKey, subjectAttributes = {}, assignmentHooks = null) {
(0, validation_1.validateNotBlank)(subjectKey, 'Invalid argument: subjectKey cannot be blank');
(0, validation_1.validateNotBlank)(experimentKey, 'Invalid argument: experimentKey cannot be blank');
const assignment = this.getAssignmentInternal(subjectKey, experimentKey, subjectAttributes, assignmentHooks);
assignmentHooks === null || assignmentHooks === void 0 ? void 0 : assignmentHooks.onPostAssignment(experimentKey, subjectKey, assignment);
if (assignment !== null)
this.logAssignment(experimentKey, assignment, subjectKey, subjectAttributes);
return assignment;
}
getAssignmentInternal(subjectKey, experimentKey, subjectAttributes = {}, assignmentHooks = null) {
const experimentConfig = this.configurationStore.get(experimentKey);

@@ -25,2 +32,7 @@ const allowListOverride = this.getSubjectVariationOverride(subjectKey, experimentConfig);

return null;
// check for overridden assignment via hook
const overriddenAssignment = assignmentHooks === null || assignmentHooks === void 0 ? void 0 : assignmentHooks.onPreAssignment(experimentKey, subjectKey);
if (overriddenAssignment !== null && overriddenAssignment !== undefined) {
return overriddenAssignment;
}
// Attempt to match a rule from the list.

@@ -39,14 +51,4 @@ const matchedRule = (0, rule_evaluator_1.findMatchingRule)(subjectAttributes || {}, experimentConfig.rules);

const assignedVariation = variations.find((variation) => (0, shard_1.isShardInRange)(shard, variation.shardRange)).value;
// Finally, log assignment and return assignment.
this.logAssignment(experimentKey, assignedVariation, subjectKey, subjectAttributes);
return assignedVariation;
}
async getAssignmentWithHooks(subjectKey, experimentKey, assignmentHooks, subjectAttributes = {}) {
let assignment = await (assignmentHooks === null || assignmentHooks === void 0 ? void 0 : assignmentHooks.onPreAssignment(subjectKey));
if (assignment == null) {
assignment = this.getAssignment(subjectKey, experimentKey, subjectAttributes);
}
assignmentHooks === null || assignmentHooks === void 0 ? void 0 : assignmentHooks.onPostAssignment(assignment);
return assignment;
}
setLogger(logger) {

@@ -53,0 +55,0 @@ this.assignmentLogger = logger;

{
"name": "@eppo/js-client-sdk-common",
"version": "1.2.2",
"version": "1.3.0",
"description": "Eppo SDK for client-side JavaScript applications (base for both web and react native)",

@@ -33,4 +33,2 @@ "main": "dist/index.js",

"devDependencies": {
"@microsoft/api-documenter": "^7.17.17",
"@microsoft/api-extractor": "^7.25.0",
"@types/jest": "^28.1.1",

@@ -46,3 +44,2 @@ "@types/md5": "^2.3.2",

"eslint-plugin-promise": "^6.0.0",
"husky": "^8.0.1",
"jest": "^28.1.1",

@@ -49,0 +46,0 @@ "jest-environment-jsdom": "^28.1.1",

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