@devcycle/nodejs-server-sdk
Version:
The DevCycle NodeJS Server SDK used for feature management.
66 lines (65 loc) • 3.31 kB
TypeScript
import { BucketedUserConfig, DevCycleServerSDKOptions, VariableDefinitions, InferredVariableType, DVCCustomDataJSON, ConfigMetadata } from '@devcycle/types';
import { DevCycleUser, DVCVariable, DVCVariableValue, DVCVariableSet, DVCFeatureSet, DevCycleEvent, VariableAndMetadata } from '@devcycle/js-cloud-server-sdk';
import { DevCycleOptionsLocalEnabled } from './index';
import { DevCycleProvider } from './open-feature/DevCycleProvider';
import { EvalHook } from './hooks/EvalHook';
export declare class DevCycleClient<Variables extends VariableDefinitions = VariableDefinitions> {
private clientUUID;
private hostname;
private sdkKey;
private configHelper?;
private clientConfigHelper?;
private eventQueue;
private onInitialized;
private logger;
private _isInitialized;
private openFeatureProvider;
private bucketingLib;
private bucketingTracker?;
private bucketingImportPromise;
private platformDetails;
private sdkPlatform?;
private hooksRunner;
get isInitialized(): boolean;
constructor(sdkKey: string, options?: DevCycleOptionsLocalEnabled);
private setPlatformDataInBucketingLib;
initializeBucketing({ options, }: {
options?: DevCycleServerSDKOptions;
}): Promise<void>;
/**
* @deprecated Use DevCycleProvider directly instead.
* See docs: https://docs.devcycle.com/sdk/server-side-sdks/node/node-openfeature
*/
getOpenFeatureProvider(): Promise<DevCycleProvider>;
/**
* Notify the user when Features have been loaded from the server.
* An optional callback can be passed in, and will return a promise if no callback has been passed in.
*
* @param onInitialized
*/
onClientInitialized(onInitialized?: (err?: Error) => void): Promise<DevCycleClient<Variables>>;
variable<K extends string & keyof Variables, T extends DVCVariableValue & Variables[K]>(user: DevCycleUser, key: K, defaultValue: T): DVCVariable<T>;
_variable<K extends string & keyof Variables, T extends DVCVariableValue & Variables[K]>(user: DevCycleUser, key: K, defaultValue: T): VariableAndMetadata<T>;
variableValue<K extends string & keyof Variables, T extends DVCVariableValue & Variables[K]>(user: DevCycleUser, key: K, defaultValue: T): InferredVariableType<K, T>;
allVariables(user: DevCycleUser): DVCVariableSet;
allFeatures(user: DevCycleUser): DVCFeatureSet;
track(user: DevCycleUser, event: DevCycleEvent): void;
addHook(hook: EvalHook): void;
private queueEvent;
private queueAggregateEvent;
private trackSDKConfigEvent;
/**
* Call this to obtain a config that is suitable for use in the "bootstrapConfig" option of client-side JS SDKs
* Useful for serverside-rendering use cases where the server performs the initial rendering pass, and provides it
* to the client along with the DevCycle config to allow hydration
* @param user
* @param userAgent
*/
getClientBootstrapConfig(user: DevCycleUser, userAgent: string): Promise<BucketedUserConfig & {
clientSDKKey: string;
}>;
flushEvents(callback?: () => void): Promise<void>;
close(): Promise<void>;
setClientCustomData(clientCustomData: DVCCustomDataJSON): void;
getConfigMetadata(): ConfigMetadata | undefined;
}