@devcycle/nodejs-server-sdk
Advanced tools
Comparing version 1.32.1 to 1.32.2
@@ -178,3 +178,7 @@ "use strict"; | ||
catch (ex) { | ||
trackEvent(ex); | ||
if (this.hasConfig) { | ||
// TODO currently event queue in WASM requires a valid config | ||
// switch this to hit the events API directly | ||
trackEvent(ex); | ||
} | ||
logError(ex); | ||
@@ -181,0 +185,0 @@ res = null; |
@@ -178,3 +178,7 @@ "use strict"; | ||
catch (ex) { | ||
trackEvent(ex); | ||
if (this.hasConfig) { | ||
// TODO currently event queue in WASM requires a valid config | ||
// switch this to hit the events API directly | ||
trackEvent(ex); | ||
} | ||
logError(ex); | ||
@@ -181,0 +185,0 @@ res = null; |
{ | ||
"name": "@devcycle/nodejs-server-sdk", | ||
"version": "1.32.1", | ||
"version": "1.32.2", | ||
"description": "The DevCycle NodeJS Server SDK used for feature management.", | ||
@@ -23,3 +23,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@devcycle/bucketing-assembly-script": "^1.24.0", | ||
"@devcycle/bucketing-assembly-script": "^1.24.1", | ||
"@devcycle/js-cloud-server-sdk": "^1.14.0", | ||
@@ -26,0 +26,0 @@ "@devcycle/types": "^1.15.0", |
@@ -1,2 +0,6 @@ | ||
import { Exports } from '@devcycle/bucketing-assembly-script'; | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { WASMBucketingExports } from '@devcycle/bucketing-assembly-script'; | ||
import { DVCLogger, DVCReporter, DevCycleServerSDKOptions } from '@devcycle/types'; | ||
@@ -6,7 +10,5 @@ export declare const importBucketingLib: ({ logger, options, }?: { | ||
options?: DevCycleServerSDKOptions | undefined; | ||
}) => Promise<void>; | ||
export declare const startTrackingMemoryUsage: (logger?: DVCLogger, reporter?: DVCReporter, interval?: number) => void; | ||
export declare const trackMemoryUsage: (reporter: DVCReporter, logger?: DVCLogger) => void; | ||
export declare const getBucketingLib: () => Exports; | ||
export declare const cleanupBucketingLib: () => void; | ||
export declare const setConfigDataUTF8: (sdkKey: string, projectConfigStr: string) => void; | ||
}) => Promise<[WASMBucketingExports, NodeJS.Timer | undefined]>; | ||
export declare const startTrackingMemoryUsage: (bucketing: WASMBucketingExports, logger?: DVCLogger, reporter?: DVCReporter, interval?: number) => NodeJS.Timer | undefined; | ||
export declare const trackMemoryUsage: (bucketing: WASMBucketingExports, reporter: DVCReporter, logger?: DVCLogger) => void; | ||
export declare const setConfigDataUTF8: (bucketing: WASMBucketingExports, sdkKey: string, projectConfigStr: string) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setConfigDataUTF8 = exports.cleanupBucketingLib = exports.getBucketingLib = exports.trackMemoryUsage = exports.startTrackingMemoryUsage = exports.importBucketingLib = void 0; | ||
exports.setConfigDataUTF8 = exports.trackMemoryUsage = exports.startTrackingMemoryUsage = exports.importBucketingLib = void 0; | ||
const bucketing_assembly_script_1 = require("@devcycle/bucketing-assembly-script"); | ||
let Bucketing; | ||
let InstantiatePromise; | ||
const importBucketingLib = async ({ logger, options, } = {}) => { | ||
if (InstantiatePromise) { | ||
await InstantiatePromise; | ||
return; | ||
} | ||
const debugWASM = process.env.DEVCYCLE_DEBUG_WASM === '1'; | ||
InstantiatePromise = (0, bucketing_assembly_script_1.instantiate)(debugWASM).then((exports) => { | ||
Bucketing = exports; | ||
return Bucketing; | ||
}); | ||
await InstantiatePromise; | ||
(0, exports.startTrackingMemoryUsage)(logger, options === null || options === void 0 ? void 0 : options.reporter); | ||
const result = await (0, bucketing_assembly_script_1.instantiate)(debugWASM); | ||
const interval = (0, exports.startTrackingMemoryUsage)(result, logger, options === null || options === void 0 ? void 0 : options.reporter); | ||
return [result, interval]; | ||
}; | ||
exports.importBucketingLib = importBucketingLib; | ||
const startTrackingMemoryUsage = (logger, reporter, interval = 30 * 1000) => { | ||
const startTrackingMemoryUsage = (bucketing, logger, reporter, interval = 30 * 1000) => { | ||
if (!reporter) | ||
return; | ||
(0, exports.trackMemoryUsage)(reporter, logger); | ||
setInterval(() => (0, exports.trackMemoryUsage)(reporter, logger), interval); | ||
(0, exports.trackMemoryUsage)(bucketing, reporter, logger); | ||
return setInterval(() => (0, exports.trackMemoryUsage)(bucketing, reporter, logger), interval); | ||
}; | ||
exports.startTrackingMemoryUsage = startTrackingMemoryUsage; | ||
const trackMemoryUsage = (reporter, logger) => { | ||
const trackMemoryUsage = (bucketing, reporter, logger) => { | ||
if (!reporter) | ||
return; | ||
if (!Bucketing) { | ||
throw new Error('Bucketing lib not initialized'); | ||
} | ||
const memoryUsageMB = Bucketing.memory.buffer.byteLength / 1e6; | ||
const memoryUsageMB = bucketing.memory.buffer.byteLength / 1e6; | ||
logger === null || logger === void 0 ? void 0 : logger.debug(`WASM memory usage: ${memoryUsageMB} MB`); | ||
@@ -39,18 +27,7 @@ reporter.reportMetric('wasmMemoryMB', memoryUsageMB, {}); | ||
exports.trackMemoryUsage = trackMemoryUsage; | ||
const getBucketingLib = () => { | ||
if (!Bucketing) { | ||
throw new Error('Bucketing library not loaded'); | ||
} | ||
return Bucketing; | ||
}; | ||
exports.getBucketingLib = getBucketingLib; | ||
const cleanupBucketingLib = () => { | ||
Bucketing = null; | ||
}; | ||
exports.cleanupBucketingLib = cleanupBucketingLib; | ||
const setConfigDataUTF8 = (sdkKey, projectConfigStr) => { | ||
const setConfigDataUTF8 = (bucketing, sdkKey, projectConfigStr) => { | ||
const configBuffer = Buffer.from(projectConfigStr, 'utf8'); | ||
(0, exports.getBucketingLib)().setConfigDataUTF8(sdkKey, configBuffer); | ||
bucketing.setConfigDataUTF8(sdkKey, configBuffer); | ||
}; | ||
exports.setConfigDataUTF8 = setConfigDataUTF8; | ||
//# sourceMappingURL=bucketing.js.map |
@@ -9,3 +9,3 @@ import { BucketedUserConfig, DevCycleServerSDKOptions, VariableTypeAlias } from '@devcycle/types'; | ||
private sdkKey; | ||
private configHelper; | ||
private configHelper?; | ||
private clientConfigHelper?; | ||
@@ -17,4 +17,10 @@ private eventQueue; | ||
private openFeatureProvider; | ||
private bucketingLib; | ||
private bucketingTracker?; | ||
private bucketingImportPromise; | ||
get isInitialized(): boolean; | ||
constructor(sdkKey: string, options?: DevCycleServerSDKOptions); | ||
initializeBucketing({ options, }: { | ||
options?: DevCycleServerSDKOptions; | ||
}): Promise<void>; | ||
getOpenFeatureProvider(): Promise<DevCycleProvider>; | ||
@@ -33,2 +39,4 @@ /** | ||
track(user: DevCycleUser, event: DevCycleEvent): void; | ||
private queueEvent; | ||
private queueAggregateEvent; | ||
private trackSDKConfigEvent; | ||
@@ -35,0 +43,0 @@ /** |
@@ -61,16 +61,14 @@ "use strict"; | ||
} | ||
const initializePromise = (0, bucketing_1.importBucketingLib)({ | ||
this.bucketingImportPromise = this.initializeBucketing({ | ||
options, | ||
logger: this.logger, | ||
}) | ||
.catch((bucketingErr) => { | ||
}).catch((bucketingErr) => { | ||
throw new server_request_1.UserError(bucketingErr); | ||
}) | ||
.then(() => { | ||
}); | ||
const initializePromise = this.bucketingImportPromise.then(() => { | ||
var _a; | ||
this.configHelper = new config_manager_1.EnvironmentConfigManager(this.logger, sdkKey, bucketing_1.setConfigDataUTF8, setInterval, clearInterval, this.trackSDKConfigEvent.bind(this), options || {}); | ||
this.configHelper = new config_manager_1.EnvironmentConfigManager(this.logger, sdkKey, (sdkKey, projectConfig) => (0, bucketing_1.setConfigDataUTF8)(this.bucketingLib, sdkKey, projectConfig), setInterval, clearInterval, this.trackSDKConfigEvent.bind(this), options || {}); | ||
if (options === null || options === void 0 ? void 0 : options.enableClientBootstrapping) { | ||
this.clientConfigHelper = new config_manager_1.EnvironmentConfigManager(this.logger, sdkKey, bucketing_1.setConfigDataUTF8, setInterval, clearInterval, this.trackSDKConfigEvent.bind(this), { ...options, clientMode: true }); | ||
this.clientConfigHelper = new config_manager_1.EnvironmentConfigManager(this.logger, sdkKey, (sdkKey, projectConfig) => (0, bucketing_1.setConfigDataUTF8)(this.bucketingLib, sdkKey, projectConfig), setInterval, clearInterval, this.trackSDKConfigEvent.bind(this), { ...options, clientMode: true }); | ||
} | ||
this.eventQueue = new eventQueue_1.EventQueue(sdkKey, this.clientUUID, { | ||
this.eventQueue = new eventQueue_1.EventQueue(sdkKey, this.clientUUID, this.bucketingLib, { | ||
...options, | ||
@@ -86,3 +84,3 @@ logger: this.logger, | ||
}; | ||
(0, bucketing_1.getBucketingLib)().setPlatformData(JSON.stringify(platformData)); | ||
this.bucketingLib.setPlatformData(JSON.stringify(platformData)); | ||
return Promise.all([ | ||
@@ -112,2 +110,9 @@ this.configHelper.fetchConfigPromise, | ||
} | ||
async initializeBucketing({ options, }) { | ||
; | ||
[this.bucketingLib, this.bucketingTracker] = await (0, bucketing_1.importBucketingLib)({ | ||
options, | ||
logger: this.logger, | ||
}); | ||
} | ||
async getOpenFeatureProvider() { | ||
@@ -150,5 +155,5 @@ let DevCycleProviderClass; | ||
const populatedUser = (0, populatedUserHelpers_1.DVCPopulatedUserFromDevCycleUser)(incomingUser); | ||
if (!this.configHelper.hasConfig) { | ||
if (!((_a = this.configHelper) === null || _a === void 0 ? void 0 : _a.hasConfig)) { | ||
this.logger.warn('variable called before DevCycleClient has config, returning default value'); | ||
(_a = this.eventQueue) === null || _a === void 0 ? void 0 : _a.queueAggregateEvent(populatedUser, { | ||
this.queueAggregateEvent(populatedUser, { | ||
type: eventQueue_1.EventTypes.aggVariableDefaulted, | ||
@@ -163,3 +168,3 @@ target: key, | ||
} | ||
const configVariable = (0, userBucketingHelper_1.variableForUser_PB)(this.sdkKey, populatedUser, key, (0, userBucketingHelper_1.getVariableTypeCode)(type)); | ||
const configVariable = (0, userBucketingHelper_1.variableForUser_PB)(this.bucketingLib, this.sdkKey, populatedUser, key, (0, userBucketingHelper_1.getVariableTypeCode)(this.bucketingLib, type)); | ||
const options = { | ||
@@ -185,4 +190,5 @@ key, | ||
allVariables(user) { | ||
var _a; | ||
const incomingUser = castIncomingUser(user); | ||
if (!this.configHelper.hasConfig) { | ||
if (!((_a = this.configHelper) === null || _a === void 0 ? void 0 : _a.hasConfig)) { | ||
this.logger.warn('allVariables called before DevCycleClient has config'); | ||
@@ -192,8 +198,9 @@ return {}; | ||
const populatedUser = (0, populatedUserHelpers_1.DVCPopulatedUserFromDevCycleUser)(incomingUser); | ||
const bucketedConfig = (0, userBucketingHelper_1.bucketUserForConfig)(populatedUser, this.sdkKey); | ||
const bucketedConfig = (0, userBucketingHelper_1.bucketUserForConfig)(this.bucketingLib, populatedUser, this.sdkKey); | ||
return (bucketedConfig === null || bucketedConfig === void 0 ? void 0 : bucketedConfig.variables) || {}; | ||
} | ||
allFeatures(user) { | ||
var _a; | ||
const incomingUser = castIncomingUser(user); | ||
if (!this.configHelper.hasConfig) { | ||
if (!((_a = this.configHelper) === null || _a === void 0 ? void 0 : _a.hasConfig)) { | ||
this.logger.warn('allFeatures called before DevCycleClient has config'); | ||
@@ -203,3 +210,3 @@ return {}; | ||
const populatedUser = (0, populatedUserHelpers_1.DVCPopulatedUserFromDevCycleUser)(incomingUser); | ||
const bucketedConfig = (0, userBucketingHelper_1.bucketUserForConfig)(populatedUser, this.sdkKey); | ||
const bucketedConfig = (0, userBucketingHelper_1.bucketUserForConfig)(this.bucketingLib, populatedUser, this.sdkKey); | ||
return (bucketedConfig === null || bucketedConfig === void 0 ? void 0 : bucketedConfig.features) || {}; | ||
@@ -215,4 +222,17 @@ } | ||
const populatedUser = (0, populatedUserHelpers_1.DVCPopulatedUserFromDevCycleUser)(incomingUser); | ||
this.eventQueue.queueEvent(populatedUser, event); | ||
this.queueEvent(populatedUser, event); | ||
} | ||
queueEvent(populatedUser, event) { | ||
// we need the config in order to queue events since we need to know the featureVars | ||
this.onInitialized.then(() => { | ||
this.eventQueue.queueEvent(populatedUser, event); | ||
}); | ||
} | ||
queueAggregateEvent(populatedUser, event) { | ||
// we don't need the config for aggregate events since there are no featureVars stored, so just wait until | ||
// bucketing lib itself is initialized | ||
this.bucketingImportPromise.then(() => { | ||
this.eventQueue.queueAggregateEvent(populatedUser, event); | ||
}); | ||
} | ||
trackSDKConfigEvent(url, responseTimeMS, res, err, reqEtag, reqLastModified, sseConnected) { | ||
@@ -223,3 +243,3 @@ var _a, _b, _c, _d, _e; | ||
}); | ||
this.eventQueue.queueEvent(populatedUser, { | ||
this.queueEvent(populatedUser, { | ||
type: 'sdkConfig', | ||
@@ -254,3 +274,3 @@ target: url, | ||
} | ||
const clientSDKKey = (0, userBucketingHelper_1.getSDKKeyFromConfig)(`${this.sdkKey}_client`); | ||
const clientSDKKey = (0, userBucketingHelper_1.getSDKKeyFromConfig)(this.bucketingLib, `${this.sdkKey}_client`); | ||
if (!clientSDKKey) { | ||
@@ -263,3 +283,3 @@ throw new Error('Client bootstrapping config is malformed. Please contact DevCycle support.'); | ||
return { | ||
...(0, userBucketingHelper_1.bucketUserForConfig)(populatedUser, `${this.sdkKey}_client`), | ||
...(0, userBucketingHelper_1.bucketUserForConfig)(this.bucketingLib, populatedUser, `${this.sdkKey}_client`), | ||
clientSDKKey, | ||
@@ -275,9 +295,11 @@ }; | ||
async flushEvents(callback) { | ||
return this.eventQueue.flushEvents().then(callback); | ||
return this.bucketingImportPromise.then(() => this.eventQueue.flushEvents().then(callback)); | ||
} | ||
async close() { | ||
var _a; | ||
await this.onInitialized; | ||
await this.flushEvents(); | ||
this.configHelper.cleanup(); | ||
(_a = this.configHelper) === null || _a === void 0 ? void 0 : _a.cleanup(); | ||
this.eventQueue.cleanup(); | ||
clearInterval(this.bucketingTracker); | ||
} | ||
@@ -284,0 +306,0 @@ } |
import { DVCRequestEvent } from './models/requestEvent'; | ||
import { BucketedUserConfig, DVCLogger, DVCReporter } from '@devcycle/types'; | ||
import { DevCycleEvent, DVCPopulatedUser } from '@devcycle/js-cloud-server-sdk'; | ||
import { WASMBucketingExports } from '@devcycle/bucketing-assembly-script'; | ||
export declare const AggregateEventTypes: Record<string, string>; | ||
@@ -29,2 +30,3 @@ export declare const EventTypes: Record<string, string>; | ||
private readonly clientUUID; | ||
private readonly bucketing; | ||
private readonly logger; | ||
@@ -39,3 +41,3 @@ private readonly reporter?; | ||
private flushCallbacks; | ||
constructor(sdkKey: string, clientUUID: string, options: EventQueueOptions); | ||
constructor(sdkKey: string, clientUUID: string, bucketing: WASMBucketingExports, options: EventQueueOptions); | ||
cleanup(): void; | ||
@@ -42,0 +44,0 @@ private _flushEvents; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EventQueue = exports.EventTypes = exports.AggregateEventTypes = void 0; | ||
const bucketing_1 = require("./bucketing"); | ||
const request_1 = require("./request"); | ||
@@ -16,5 +15,6 @@ exports.AggregateEventTypes = { | ||
class EventQueue { | ||
constructor(sdkKey, clientUUID, options) { | ||
constructor(sdkKey, clientUUID, bucketing, options) { | ||
this.sdkKey = sdkKey; | ||
this.clientUUID = clientUUID; | ||
this.bucketing = bucketing; | ||
this.flushInProgress = false; | ||
@@ -52,3 +52,3 @@ this.flushCallbacks = []; | ||
this.flushInterval = setInterval(this.flushEvents.bind(this), this.eventFlushIntervalMS); | ||
(0, bucketing_1.getBucketingLib)().initEventQueue(sdkKey, this.clientUUID, JSON.stringify(options)); | ||
this.bucketing.initEventQueue(sdkKey, this.clientUUID, JSON.stringify(options)); | ||
} | ||
@@ -64,6 +64,6 @@ cleanup() { | ||
}; | ||
(_a = this.reporter) === null || _a === void 0 ? void 0 : _a.reportMetric('queueLength', (0, bucketing_1.getBucketingLib)().eventQueueSize(this.sdkKey), metricTags); | ||
(_a = this.reporter) === null || _a === void 0 ? void 0 : _a.reportMetric('queueLength', this.bucketing.eventQueueSize(this.sdkKey), metricTags); | ||
let flushPayloadsStr; | ||
try { | ||
flushPayloadsStr = (0, bucketing_1.getBucketingLib)().flushEventQueue(this.sdkKey); | ||
flushPayloadsStr = this.bucketing.flushEventQueue(this.sdkKey); | ||
(_b = this.reporter) === null || _b === void 0 ? void 0 : _b.reportMetric('flushPayloadSize', flushPayloadsStr === null || flushPayloadsStr === void 0 ? void 0 : flushPayloadsStr.length, metricTags); | ||
@@ -100,7 +100,7 @@ } | ||
results.retries++; | ||
(0, bucketing_1.getBucketingLib)().onPayloadFailure(this.sdkKey, flushPayload.payloadId, true); | ||
this.bucketing.onPayloadFailure(this.sdkKey, flushPayload.payloadId, true); | ||
} | ||
else { | ||
results.failures++; | ||
(0, bucketing_1.getBucketingLib)().onPayloadFailure(this.sdkKey, flushPayload.payloadId, false); | ||
this.bucketing.onPayloadFailure(this.sdkKey, flushPayload.payloadId, false); | ||
} | ||
@@ -110,3 +110,3 @@ } | ||
this.logger.debug(`DevCycle Flushed ${eventCount} Events, for ${flushPayload.records.length} Users`); | ||
(0, bucketing_1.getBucketingLib)().onPayloadSuccess(this.sdkKey, flushPayload.payloadId); | ||
this.bucketing.onPayloadSuccess(this.sdkKey, flushPayload.payloadId); | ||
results.successes++; | ||
@@ -117,3 +117,3 @@ } | ||
this.logger.debug(`DevCycle Error Flushing Events response message: ${ex.message}`); | ||
(0, bucketing_1.getBucketingLib)().onPayloadFailure(this.sdkKey, flushPayload.payloadId, true); | ||
this.bucketing.onPayloadFailure(this.sdkKey, flushPayload.payloadId, true); | ||
results.retries++; | ||
@@ -160,3 +160,3 @@ } | ||
} | ||
(0, bucketing_1.getBucketingLib)().queueEvent(this.sdkKey, JSON.stringify(user), JSON.stringify(event)); | ||
this.bucketing.queueEvent(this.sdkKey, JSON.stringify(user), JSON.stringify(event)); | ||
} | ||
@@ -172,6 +172,6 @@ /** | ||
} | ||
(0, bucketing_1.getBucketingLib)().queueAggregateEvent(this.sdkKey, JSON.stringify(event), JSON.stringify((bucketedConfig === null || bucketedConfig === void 0 ? void 0 : bucketedConfig.variableVariationMap) || {})); | ||
this.bucketing.queueAggregateEvent(this.sdkKey, JSON.stringify(event), JSON.stringify((bucketedConfig === null || bucketedConfig === void 0 ? void 0 : bucketedConfig.variableVariationMap) || {})); | ||
} | ||
checkEventQueueSize() { | ||
const queueSize = (0, bucketing_1.getBucketingLib)().eventQueueSize(this.sdkKey); | ||
const queueSize = this.bucketing.eventQueueSize(this.sdkKey); | ||
if (queueSize >= this.flushEventQueueSize) { | ||
@@ -178,0 +178,0 @@ this.flushEvents(); |
import { BucketedUserConfig, SDKVariable, VariableType } from '@devcycle/types'; | ||
import { DVCPopulatedUser } from '@devcycle/js-cloud-server-sdk'; | ||
export declare function bucketUserForConfig(user: DVCPopulatedUser, sdkKey: string): BucketedUserConfig; | ||
export declare function getSDKKeyFromConfig(sdkKey: string): string | null; | ||
export declare function getVariableTypeCode(type: VariableType): number; | ||
export declare function variableForUser(sdkKey: string, user: DVCPopulatedUser, key: string, type: number): SDKVariable | null; | ||
export declare function variableForUser_PB(sdkKey: string, user: DVCPopulatedUser, key: string, type: number): SDKVariable | null; | ||
import { WASMBucketingExports } from '@devcycle/bucketing-assembly-script'; | ||
export declare function bucketUserForConfig(bucketing: WASMBucketingExports, user: DVCPopulatedUser, sdkKey: string): BucketedUserConfig; | ||
export declare function getSDKKeyFromConfig(bucketing: WASMBucketingExports, sdkKey: string): string | null; | ||
export declare function getVariableTypeCode(bucketing: WASMBucketingExports, type: VariableType): number; | ||
export declare function variableForUser(bucketing: WASMBucketingExports, sdkKey: string, user: DVCPopulatedUser, key: string, type: number): SDKVariable | null; | ||
export declare function variableForUser_PB(bucketing: WASMBucketingExports, sdkKey: string, user: DVCPopulatedUser, key: string, type: number): SDKVariable | null; |
@@ -5,25 +5,23 @@ "use strict"; | ||
const types_1 = require("@devcycle/types"); | ||
const bucketing_1 = require("../bucketing"); | ||
const compiled_1 = require("@devcycle/bucketing-assembly-script/protobuf/compiled"); | ||
const pbTypeHelpers_1 = require("../pb-types/pbTypeHelpers"); | ||
const populatedUserHelpers_1 = require("../models/populatedUserHelpers"); | ||
function bucketUserForConfig(user, sdkKey) { | ||
return JSON.parse((0, bucketing_1.getBucketingLib)().generateBucketedConfigForUser(sdkKey, JSON.stringify(user))); | ||
function bucketUserForConfig(bucketing, user, sdkKey) { | ||
return JSON.parse(bucketing.generateBucketedConfigForUser(sdkKey, JSON.stringify(user))); | ||
} | ||
exports.bucketUserForConfig = bucketUserForConfig; | ||
function getSDKKeyFromConfig(sdkKey) { | ||
return (0, bucketing_1.getBucketingLib)().getSDKKeyFromConfig(sdkKey); | ||
function getSDKKeyFromConfig(bucketing, sdkKey) { | ||
return bucketing.getSDKKeyFromConfig(sdkKey); | ||
} | ||
exports.getSDKKeyFromConfig = getSDKKeyFromConfig; | ||
function getVariableTypeCode(type) { | ||
const Bucketing = (0, bucketing_1.getBucketingLib)(); | ||
function getVariableTypeCode(bucketing, type) { | ||
switch (type) { | ||
case types_1.VariableType.boolean: | ||
return Bucketing.VariableType.Boolean; | ||
return bucketing.VariableType.Boolean; | ||
case types_1.VariableType.number: | ||
return Bucketing.VariableType.Number; | ||
return bucketing.VariableType.Number; | ||
case types_1.VariableType.string: | ||
return Bucketing.VariableType.String; | ||
return bucketing.VariableType.String; | ||
case types_1.VariableType.json: | ||
return Bucketing.VariableType.JSON; | ||
return bucketing.VariableType.JSON; | ||
default: | ||
@@ -34,4 +32,4 @@ throw new Error(`Unknown variable type: ${type}`); | ||
exports.getVariableTypeCode = getVariableTypeCode; | ||
function variableForUser(sdkKey, user, key, type) { | ||
const bucketedVariable = (0, bucketing_1.getBucketingLib)().variableForUser(sdkKey, JSON.stringify(user), key, type, true); | ||
function variableForUser(bucketing, sdkKey, user, key, type) { | ||
const bucketedVariable = bucketing.variableForUser(sdkKey, JSON.stringify(user), key, type, true); | ||
if (!bucketedVariable) | ||
@@ -42,3 +40,3 @@ return null; | ||
exports.variableForUser = variableForUser; | ||
function variableForUser_PB(sdkKey, user, key, type) { | ||
function variableForUser_PB(bucketing, sdkKey, user, key, type) { | ||
const params = { | ||
@@ -55,3 +53,3 @@ sdkKey, | ||
const buffer = compiled_1.VariableForUserParams_PB.encode(params).finish(); | ||
const bucketedVariable = (0, bucketing_1.getBucketingLib)().variableForUser_PB(buffer); | ||
const bucketedVariable = bucketing.variableForUser_PB(buffer); | ||
if (!bucketedVariable) | ||
@@ -58,0 +56,0 @@ return null; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
331740
3198