@devcycle/nodejs-server-sdk
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "@devcycle/nodejs-server-sdk", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "The DevCycle NodeJS Server SDK used for feature management.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -91,2 +91,5 @@ "use strict"; | ||
this.logger = (options === null || options === void 0 ? void 0 : options.logger) || (0, logger_1.dvcDefaultLogger)({ level: options === null || options === void 0 ? void 0 : options.logLevel }); | ||
if (options === null || options === void 0 ? void 0 : options.enableEdgeDB) { | ||
this.logger.info('EdgeDB can only be enabled for the DVC Cloud Client.'); | ||
} | ||
var initializePromise = (0, bucketing_1.importBucketingLib)() | ||
@@ -93,0 +96,0 @@ .then(function () { |
@@ -5,2 +5,3 @@ import { DVCOptions, DVCVariableValue, DVCVariable as DVCVariableInterface, DVCVariableSet, DVCFeatureSet, DVCEvent, DVCUser } from './types'; | ||
private logger; | ||
private options; | ||
constructor(environmentKey: string, options: DVCOptions); | ||
@@ -7,0 +8,0 @@ variable(user: DVCUser, key: string, defaultValue: DVCVariableValue): Promise<DVCVariableInterface>; |
@@ -24,2 +24,3 @@ "use strict"; | ||
this.logger = options.logger || (0, logger_1.dvcDefaultLogger)({ level: options.logLevel }); | ||
this.options = options; | ||
this.logger.info("Running DevCycle NodeJS SDK in Cloud Bucketing mode"); | ||
@@ -32,3 +33,3 @@ } | ||
(0, paramUtils_1.checkParamDefined)('defaultValue', defaultValue); | ||
return (0, request_1.getVariable)(requestUser, this.environmentKey, key) | ||
return (0, request_1.getVariable)(requestUser, this.environmentKey, key, this.options.enableEdgeDB) | ||
.then(function (res) { | ||
@@ -48,3 +49,3 @@ return new variable_1.DVCVariable(__assign(__assign({}, res.data), { defaultValue: defaultValue })); | ||
var requestUser = new populatedUser_1.DVCPopulatedUser(user); | ||
return (0, request_1.getAllVariables)(requestUser, this.environmentKey) | ||
return (0, request_1.getAllVariables)(requestUser, this.environmentKey, this.options.enableEdgeDB) | ||
.then(function (res) { | ||
@@ -61,3 +62,3 @@ return res.data || {}; | ||
var requestUser = new populatedUser_1.DVCPopulatedUser(user); | ||
return (0, request_1.getAllFeatures)(requestUser, this.environmentKey) | ||
return (0, request_1.getAllFeatures)(requestUser, this.environmentKey, this.options.enableEdgeDB) | ||
.then(function (res) { | ||
@@ -77,3 +78,3 @@ return res.data || {}; | ||
var requestUser = new populatedUser_1.DVCPopulatedUser(user); | ||
(0, request_1.postTrack)(requestUser, event, this.environmentKey, this.logger); | ||
(0, request_1.postTrack)(requestUser, event, this.environmentKey, this.logger, this.options.enableEdgeDB); | ||
}; | ||
@@ -80,0 +81,0 @@ return DVCCloudClient; |
@@ -10,7 +10,7 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
export declare function getEnvironmentConfig(url: string, requestTimeout: number, etag?: string): Promise<AxiosResponse>; | ||
export declare function getAllFeatures(user: DVCPopulatedUser, envKey: string): Promise<AxiosResponse>; | ||
export declare function getAllVariables(user: DVCPopulatedUser, envKey: string): Promise<AxiosResponse>; | ||
export declare function getVariable(user: DVCPopulatedUser, envKey: string, variableKey: string): Promise<AxiosResponse>; | ||
export declare function postTrack(user: DVCPopulatedUser, event: DVCEvent, envKey: string, logger: DVCLogger): Promise<void>; | ||
export declare function getAllFeatures(user: DVCPopulatedUser, envKey: string, enableEdgeDB?: boolean): Promise<AxiosResponse>; | ||
export declare function getAllVariables(user: DVCPopulatedUser, envKey: string, enableEdgeDB?: boolean): Promise<AxiosResponse>; | ||
export declare function getVariable(user: DVCPopulatedUser, envKey: string, variableKey: string, enableEdgeDB?: boolean): Promise<AxiosResponse>; | ||
export declare function postTrack(user: DVCPopulatedUser, event: DVCEvent, envKey: string, logger: DVCLogger, enableEdgeDB?: boolean): Promise<void>; | ||
export declare function post(requestConfig: AxiosRequestConfig, envKey: string): Promise<AxiosResponse>; | ||
export declare function get(requestConfig: AxiosRequestConfig): Promise<AxiosResponse>; |
@@ -66,2 +66,3 @@ "use strict"; | ||
var BUCKETING_URL = "".concat(BUCKETING_BASE).concat(exports.HOST); | ||
var EDGE_DB_QUERY_PARAM = '?enableEdgeDB='; | ||
function publishEvents(logger, envKey, eventsBatch) { | ||
@@ -116,10 +117,15 @@ var _a, _b; | ||
exports.getEnvironmentConfig = getEnvironmentConfig; | ||
function getAllFeatures(user, envKey) { | ||
function getAllFeatures(user, envKey, enableEdgeDB) { | ||
if (enableEdgeDB === void 0) { enableEdgeDB = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var baseUrl, postUrl; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, post({ | ||
url: "".concat(BUCKETING_URL).concat(FEATURES_PATH), | ||
data: user | ||
}, envKey)]; | ||
case 0: | ||
baseUrl = "".concat(BUCKETING_URL).concat(FEATURES_PATH); | ||
postUrl = baseUrl.concat(enableEdgeDB ? EDGE_DB_QUERY_PARAM.concat('true') : ''); | ||
return [4 /*yield*/, post({ | ||
url: postUrl, | ||
data: user | ||
}, envKey)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -131,10 +137,16 @@ } | ||
exports.getAllFeatures = getAllFeatures; | ||
function getAllVariables(user, envKey) { | ||
function getAllVariables(user, envKey, enableEdgeDB) { | ||
if (enableEdgeDB === void 0) { enableEdgeDB = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var baseUrl, postUrl; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, post({ | ||
url: "".concat(BUCKETING_URL).concat(VARIABLES_PATH), | ||
data: user | ||
}, envKey)]; | ||
case 0: | ||
baseUrl = "".concat(BUCKETING_URL).concat(VARIABLES_PATH); | ||
postUrl = baseUrl.concat(enableEdgeDB ? EDGE_DB_QUERY_PARAM.concat('true') : ''); | ||
return [4 /*yield*/, post({ | ||
url: postUrl, | ||
headers: { 'Authorization': envKey, 'Content-Type': 'application/json' }, | ||
data: user | ||
}, envKey)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -146,10 +158,15 @@ } | ||
exports.getAllVariables = getAllVariables; | ||
function getVariable(user, envKey, variableKey) { | ||
function getVariable(user, envKey, variableKey, enableEdgeDB) { | ||
if (enableEdgeDB === void 0) { enableEdgeDB = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var baseUrl, postUrl; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, post({ | ||
url: "".concat(BUCKETING_URL).concat(VARIABLES_PATH, "/").concat(variableKey), | ||
data: user | ||
}, envKey)]; | ||
case 0: | ||
baseUrl = "".concat(BUCKETING_URL).concat(VARIABLES_PATH, "/").concat(variableKey); | ||
postUrl = baseUrl.concat(enableEdgeDB ? EDGE_DB_QUERY_PARAM.concat('true') : ''); | ||
return [4 /*yield*/, post({ | ||
url: postUrl, | ||
data: user | ||
}, envKey)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -161,11 +178,16 @@ } | ||
exports.getVariable = getVariable; | ||
function postTrack(user, event, envKey, logger) { | ||
function postTrack(user, event, envKey, logger, enableEdgeDB) { | ||
if (enableEdgeDB === void 0) { enableEdgeDB = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var ex_1; | ||
var baseUrl, postUrl, ex_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
baseUrl = "".concat(BUCKETING_URL).concat(TRACK_PATH); | ||
postUrl = baseUrl.concat(enableEdgeDB ? EDGE_DB_QUERY_PARAM.concat('true') : ''); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, post({ | ||
url: "".concat(BUCKETING_URL).concat(TRACK_PATH), | ||
url: postUrl, | ||
data: { | ||
@@ -176,11 +198,11 @@ user: user, | ||
}, envKey)]; | ||
case 1: | ||
case 2: | ||
_a.sent(); | ||
logger.debug("DVC Event Tracked"); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
ex_1 = _a.sent(); | ||
logger.error("DVC Error Tracking Event. Response message: ".concat(ex_1.message)); | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -187,0 +209,0 @@ }); |
@@ -80,2 +80,7 @@ import { DVCLogger, DVCDefaultLogLevel } from '@devcycle/types'; | ||
enableCloudBucketing?: boolean; | ||
/** | ||
* Enables the usage of EdgeDB for DevCycle that syncs User Data to DevCycle. | ||
* NOTE: This is only available with Cloud Bucketing. | ||
*/ | ||
enableEdgeDB?: boolean; | ||
} | ||
@@ -82,0 +87,0 @@ export declare type DVCVariableValue = string | number | boolean | JSON; |
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
97933
1506