@eppo/js-client-sdk-common
Advanced tools
Comparing version 2.1.1-alpha.0 to 2.1.1-alpha.1
@@ -23,4 +23,4 @@ import { AssignmentCache, Cacheable } from '../assignment-cache'; | ||
getAssignment(subjectKey: string, flagKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks): string | null; | ||
_pollerStats(): any; | ||
_getStringAssignmentWithReason(subjectKey: string, flagKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks, obfuscated?: boolean): { | ||
pollerStats(): any; | ||
getStringAssignmentWithReason(subjectKey: string, flagKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks, obfuscated?: boolean): { | ||
assignment: string | null; | ||
@@ -47,2 +47,3 @@ reason: string; | ||
useCustomAssignmentCache(cache: AssignmentCache<Cacheable>): void; | ||
setConfigurationRequestParameters(configurationRequestParameters: ExperimentConfigurationRequestParameters): void; | ||
fetchFlagConfigurations(): void; | ||
@@ -70,9 +71,7 @@ stopPolling(): void; | ||
private configurationStore; | ||
private configurationRequestConfig; | ||
private configurationRequestParameters; | ||
private requestPoller; | ||
constructor(configurationStore: IConfigurationStore, configurationRequestConfig?: ExperimentConfigurationRequestParameters); | ||
/** | ||
* @deprecated added for temporary debugging | ||
*/ | ||
_pollerStats(): { | ||
constructor(configurationStore: IConfigurationStore, configurationRequestParameters?: ExperimentConfigurationRequestParameters); | ||
setConfigurationRequestParameters(configurationRequestParameters: ExperimentConfigurationRequestParameters): void; | ||
pollerStats(): { | ||
initializations: number; | ||
@@ -89,6 +88,3 @@ attemptedPolls: number; | ||
getStringAssignment(subjectKey: string, flagKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks | undefined, obfuscated?: boolean): string | null; | ||
/** | ||
* @deprecated added for temporary debugging | ||
*/ | ||
_getStringAssignmentWithReason(subjectKey: string, flagKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks | undefined, obfuscated?: boolean): { | ||
getStringAssignmentWithReason(subjectKey: string, flagKey: string, subjectAttributes?: Record<string, any>, assignmentHooks?: IAssignmentHooks | undefined, obfuscated?: boolean): { | ||
assignment: string | null; | ||
@@ -95,0 +91,0 @@ reason: string; |
@@ -17,18 +17,18 @@ "use strict"; | ||
class EppoClient { | ||
constructor(configurationStore, configurationRequestConfig) { | ||
constructor(configurationStore, configurationRequestParameters) { | ||
this.queuedEvents = []; | ||
this.isGracefulFailureMode = true; | ||
this.configurationStore = configurationStore; | ||
this.configurationRequestConfig = configurationRequestConfig; | ||
this.configurationRequestParameters = configurationRequestParameters; | ||
} | ||
/** | ||
* @deprecated added for temporary debugging | ||
*/ | ||
_pollerStats() { | ||
return (0, poller_1._pollerStats)(); | ||
setConfigurationRequestParameters(configurationRequestParameters) { | ||
this.configurationRequestParameters = configurationRequestParameters; | ||
} | ||
pollerStats() { | ||
return (0, poller_1.pollerStats)(); | ||
} | ||
async fetchFlagConfigurations() { | ||
var _a, _b, _c, _d, _e; | ||
if (!this.configurationRequestConfig) { | ||
throw new Error('Eppo SDK unable to fetch flag configurations without a request configuration'); | ||
if (!this.configurationRequestParameters) { | ||
throw new Error('Eppo SDK unable to fetch flag configurations without configuration request parameters'); | ||
} | ||
@@ -40,17 +40,17 @@ if (this.requestPoller) { | ||
const axiosInstance = axios_1.default.create({ | ||
baseURL: this.configurationRequestConfig.baseUrl || constants_1.BASE_URL, | ||
timeout: this.configurationRequestConfig.requestTimeoutMs || constants_1.DEFAULT_REQUEST_TIMEOUT_MS, | ||
baseURL: this.configurationRequestParameters.baseUrl || constants_1.BASE_URL, | ||
timeout: this.configurationRequestParameters.requestTimeoutMs || constants_1.DEFAULT_REQUEST_TIMEOUT_MS, | ||
}); | ||
const httpClient = new http_client_1.default(axiosInstance, { | ||
apiKey: this.configurationRequestConfig.apiKey, | ||
sdkName: this.configurationRequestConfig.sdkName, | ||
sdkVersion: this.configurationRequestConfig.sdkVersion, | ||
apiKey: this.configurationRequestParameters.apiKey, | ||
sdkName: this.configurationRequestParameters.sdkName, | ||
sdkVersion: this.configurationRequestParameters.sdkVersion, | ||
}); | ||
const configurationRequestor = new experiment_configuration_requestor_1.default(this.configurationStore, httpClient); | ||
this.requestPoller = (0, poller_1.default)(constants_1.POLL_INTERVAL_MS, configurationRequestor.fetchAndStoreConfigurations.bind(configurationRequestor), { | ||
maxStartRetries: (_a = this.configurationRequestConfig.numInitialRequestRetries) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES, | ||
maxPollRetries: (_b = this.configurationRequestConfig.numPollRequestRetries) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_POLL_CONFIG_REQUEST_RETRIES, | ||
pollAfterSuccessfulStart: (_c = this.configurationRequestConfig.pollAfterSuccessfulInitialization) !== null && _c !== void 0 ? _c : false, | ||
pollAfterFailedStart: (_d = this.configurationRequestConfig.pollAfterFailedInitialization) !== null && _d !== void 0 ? _d : false, | ||
errorOnFailedStart: (_e = this.configurationRequestConfig.throwOnFailedInitialization) !== null && _e !== void 0 ? _e : false, | ||
maxStartRetries: (_a = this.configurationRequestParameters.numInitialRequestRetries) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES, | ||
maxPollRetries: (_b = this.configurationRequestParameters.numPollRequestRetries) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_POLL_CONFIG_REQUEST_RETRIES, | ||
pollAfterSuccessfulStart: (_c = this.configurationRequestParameters.pollAfterSuccessfulInitialization) !== null && _c !== void 0 ? _c : false, | ||
pollAfterFailedStart: (_d = this.configurationRequestParameters.pollAfterFailedInitialization) !== null && _d !== void 0 ? _d : false, | ||
errorOnFailedStart: (_e = this.configurationRequestParameters.throwOnFailedInitialization) !== null && _e !== void 0 ? _e : false, | ||
}); | ||
@@ -87,6 +87,3 @@ await this.requestPoller.start(); | ||
} | ||
/** | ||
* @deprecated added for temporary debugging | ||
*/ | ||
_getStringAssignmentWithReason(subjectKey, flagKey, | ||
getStringAssignmentWithReason(subjectKey, flagKey, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -93,0 +90,0 @@ subjectAttributes = {}, assignmentHooks, obfuscated = false) { |
@@ -5,6 +5,3 @@ export interface IPoller { | ||
} | ||
/** | ||
* @deprecated added for temporary debugging | ||
*/ | ||
export declare function _pollerStats(): { | ||
export declare function pollerStats(): { | ||
initializations: number; | ||
@@ -11,0 +8,0 @@ attemptedPolls: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._pollerStats = void 0; | ||
exports.pollerStats = void 0; | ||
const constants_1 = require("./constants"); | ||
@@ -12,6 +12,3 @@ // Basic stats | ||
const failureMessages = []; | ||
/** | ||
* @deprecated added for temporary debugging | ||
*/ | ||
function _pollerStats() { | ||
function pollerStats() { | ||
return { | ||
@@ -26,3 +23,3 @@ initializations, | ||
} | ||
exports._pollerStats = _pollerStats; | ||
exports.pollerStats = pollerStats; | ||
// TODO: change this to a class with methods instead of something that returns a function | ||
@@ -29,0 +26,0 @@ function initPoller(intervalMs, |
{ | ||
"name": "@eppo/js-client-sdk-common", | ||
"version": "2.1.1-alpha.0", | ||
"version": "2.1.1-alpha.1", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
569506
1587