@eppo/js-client-sdk-common
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -42,2 +42,3 @@ import { IAssignmentHooks } from '../assignment-hooks'; | ||
private assignmentLogger; | ||
private isGracefulFailureMode; | ||
constructor(configurationStore: IConfigurationStore); | ||
@@ -50,5 +51,7 @@ getAssignment(subjectKey: string, flagKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks | undefined): string | null; | ||
getParsedJSONAssignment(subjectKey: string, flagKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks | undefined): object | null; | ||
private rethrowIfNotGraceful; | ||
private getAssignmentVariation; | ||
private getAssignmentInternal; | ||
setLogger(logger: IAssignmentLogger): void; | ||
setIsGracefulFailureMode(gracefulFailureMode: boolean): void; | ||
private flushQueuedEvents; | ||
@@ -55,0 +58,0 @@ private logAssignment; |
@@ -13,2 +13,3 @@ "use strict"; | ||
this.queuedEvents = []; | ||
this.isGracefulFailureMode = true; | ||
} | ||
@@ -20,4 +21,9 @@ // @deprecated getAssignment is deprecated in favor of the typed get<Type>Assignment methods | ||
var _a; | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks) | ||
.stringValue) !== null && _a !== void 0 ? _a : null); | ||
try { | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks) | ||
.stringValue) !== null && _a !== void 0 ? _a : null); | ||
} | ||
catch (error) { | ||
return this.rethrowIfNotGraceful(error); | ||
} | ||
} | ||
@@ -28,3 +34,8 @@ getStringAssignment(subjectKey, flagKey, | ||
var _a; | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.StringType).stringValue) !== null && _a !== void 0 ? _a : null); | ||
try { | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.StringType).stringValue) !== null && _a !== void 0 ? _a : null); | ||
} | ||
catch (error) { | ||
return this.rethrowIfNotGraceful(error); | ||
} | ||
} | ||
@@ -35,7 +46,17 @@ getBoolAssignment(subjectKey, flagKey, | ||
var _a; | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.BoolType).boolValue) !== null && _a !== void 0 ? _a : null); | ||
try { | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.BoolType).boolValue) !== null && _a !== void 0 ? _a : null); | ||
} | ||
catch (error) { | ||
return this.rethrowIfNotGraceful(error); | ||
} | ||
} | ||
getNumericAssignment(subjectKey, flagKey, subjectAttributes, assignmentHooks) { | ||
var _a; | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.NumericType).numericValue) !== null && _a !== void 0 ? _a : null); | ||
try { | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.NumericType).numericValue) !== null && _a !== void 0 ? _a : null); | ||
} | ||
catch (error) { | ||
return this.rethrowIfNotGraceful(error); | ||
} | ||
} | ||
@@ -46,3 +67,8 @@ getJSONStringAssignment(subjectKey, flagKey, | ||
var _a; | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.JSONType).stringValue) !== null && _a !== void 0 ? _a : null); | ||
try { | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.JSONType).stringValue) !== null && _a !== void 0 ? _a : null); | ||
} | ||
catch (error) { | ||
return this.rethrowIfNotGraceful(error); | ||
} | ||
} | ||
@@ -53,4 +79,16 @@ getParsedJSONAssignment(subjectKey, flagKey, | ||
var _a; | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.JSONType).objectValue) !== null && _a !== void 0 ? _a : null); | ||
try { | ||
return ((_a = this.getAssignmentVariation(subjectKey, flagKey, subjectAttributes, assignmentHooks, eppo_value_1.ValueType.JSONType).objectValue) !== null && _a !== void 0 ? _a : null); | ||
} | ||
catch (error) { | ||
return this.rethrowIfNotGraceful(error); | ||
} | ||
} | ||
rethrowIfNotGraceful(err) { | ||
if (this.isGracefulFailureMode) { | ||
console.error(`[Eppo SDK] Error getting assignment: ${err.message}`); | ||
return null; | ||
} | ||
throw err; | ||
} | ||
getAssignmentVariation(subjectKey, flagKey, | ||
@@ -110,2 +148,5 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
setIsGracefulFailureMode(gracefulFailureMode) { | ||
this.isGracefulFailureMode = gracefulFailureMode; | ||
} | ||
flushQueuedEvents() { | ||
@@ -112,0 +153,0 @@ var _a; |
{ | ||
"name": "@eppo/js-client-sdk-common", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Eppo SDK for client-side JavaScript applications (base for both web and react native)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
153274
798