Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

prepare 5.5.0 release #124

Merged
merged 80 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
68d3556
Make things prettier, add RedisFeatureStore to toplevel ts declaratio…
atrakh Jul 11, 2018
c5c665f
Add modules for ldclient StreamProcessor, Requestor, and FeatureStore
atrakh Jul 11, 2018
407e6ce
address review
atrakh Jul 11, 2018
bef407a
Merge pull request #86 from launchdarkly/at/ch20232/add-flag-util-met…
atrakh Jul 19, 2018
762b1c8
fix: package.json to reduce vulnerabilities
snyk-bot Jul 19, 2018
69d7219
Merge pull request #87 from launchdarkly/snyk-fix-0c23hh
eli-darkly Jul 19, 2018
d2c6c18
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Jul 19, 2018
640703c
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Jul 19, 2018
c45414e
remove npm dependency on "crypto", use built-in version instead
eli-darkly Jul 26, 2018
b4fe5f4
update package-lock
eli-darkly Jul 26, 2018
04bc0e8
Merge pull request #88 from launchdarkly/eb/ch17629/built-in-crypto
eli-darkly Jul 26, 2018
d4e15b1
treat HTTP 400 as a recoverable error
eli-darkly Aug 1, 2018
0484c64
Merge pull request #89 from launchdarkly/eb/19705/400-error
eli-darkly Aug 1, 2018
797b4a8
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 1, 2018
ccbb753
update doc comment for new waitForInitialization behavior
eli-darkly Aug 1, 2018
bcb4f0e
Merge pull request #90 from launchdarkly/eb/wait-for-init-docs
eli-darkly Aug 1, 2018
018c6f2
fix waitForInitialization to always resolve with a value
eli-darkly Aug 1, 2018
44f2d4a
Merge pull request #91 from launchdarkly/eb/wait-for-init-value
eli-darkly Aug 1, 2018
1664025
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 1, 2018
9595181
Update feature store type for versioned data kind
atrakh Aug 17, 2018
94a7cc6
Merge pull request #92 from launchdarkly/at/update-types
atrakh Aug 17, 2018
e51d554
add new version of allFlags() that captures more metadata
eli-darkly Aug 20, 2018
38616c8
add deprecation warning for allFlags
eli-darkly Aug 20, 2018
90e1c1c
typo
eli-darkly Aug 21, 2018
2b672fb
name function toJSON so JSON.stringify will use it
eli-darkly Aug 21, 2018
1a35b79
comment edits
eli-darkly Aug 21, 2018
72e2e24
fix test
eli-darkly Aug 21, 2018
ba0d334
add $valid property in case we care about that on the front end
eli-darkly Aug 21, 2018
db69f7a
Merge pull request #93 from launchdarkly/eb/ch22308/all-flags-state
eli-darkly Aug 21, 2018
a9a5c2f
add ability to filter for only client-side flags
eli-darkly Aug 21, 2018
06bdb46
fix comment
eli-darkly Aug 22, 2018
37c1e82
Merge pull request #94 from launchdarkly/eb/ch12124/client-side-filter
eli-darkly Aug 22, 2018
e7f92fc
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 22, 2018
aa39f0e
add npm audit to build
eli-darkly Aug 22, 2018
2dd2edc
run npm audit fix
eli-darkly Aug 22, 2018
511e783
run npm audit only in current Node
eli-darkly Aug 22, 2018
fd8da86
Merge pull request #95 from launchdarkly/eb/ch21851/npm-audit
eli-darkly Aug 22, 2018
01d415e
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 22, 2018
00e08c8
implement evaluation with explanation
eli-darkly Aug 23, 2018
bece5f2
add doc comment
eli-darkly Aug 23, 2018
69f27da
uncomment test
eli-darkly Aug 23, 2018
ad940ea
tests for default logic
eli-darkly Aug 24, 2018
2e44cff
Merge branch 'master' into all-flags-state
eli-darkly Aug 24, 2018
45dad9d
typo
eli-darkly Aug 24, 2018
d15fef4
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 27, 2018
277c77c
fix allFlagsState behavior when options are omitted
eli-darkly Aug 27, 2018
9317316
Merge pull request #97 from launchdarkly/eb/ch22880/optional-options
eli-darkly Aug 27, 2018
727ff9b
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 27, 2018
1217a54
fix for ch22995 - send event for prerequisite even if it's off
eli-darkly Aug 29, 2018
071f96d
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 29, 2018
07b6eb4
validate TypeScript definitions in CI build
eli-darkly Aug 29, 2018
01c8371
add tsc build step
eli-darkly Aug 29, 2018
a15959c
fix tsc command
eli-darkly Aug 29, 2018
aad1895
add npm script
eli-darkly Aug 29, 2018
aef2575
Merge pull request #98 from launchdarkly/eb/ch22998/check-typescript
eli-darkly Aug 29, 2018
623956a
typo
eli-darkly Aug 29, 2018
de65a33
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 29, 2018
35f97cc
Merge branch 'explanation' into eb/ch19976/explanations
eli-darkly Aug 29, 2018
48e750b
TS syntax error
eli-darkly Aug 29, 2018
85dde8d
Merge pull request #96 from launchdarkly/eb/ch19976/explanations
eli-darkly Aug 30, 2018
8e6a700
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Aug 30, 2018
7f2c797
fix "indirect put" and add tests for streaming
eli-darkly Aug 31, 2018
135b458
fix error handling for malformed flags
eli-darkly Sep 5, 2018
3fcfcb2
Merge pull request #100 from launchdarkly/eb/ch23452/flag-errors
eli-darkly Sep 5, 2018
dd86d01
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Sep 6, 2018
e4af191
prevent unhandled rejection from background flush
eli-darkly Sep 6, 2018
0123790
Merge pull request #101 from launchdarkly/eb/ch22053/flush-errors
eli-darkly Sep 6, 2018
f6e5ad6
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Sep 6, 2018
eb2fcc8
Merge pull request #99 from launchdarkly/eb/ch23303/stream-indirect-put
eli-darkly Sep 19, 2018
3ea8cb2
add option to reduce front-end metadata for untracked flags
eli-darkly Oct 5, 2018
6f11b2d
Merge branch 'master' of github.com:launchdarkly/node-client
eli-darkly Oct 5, 2018
2aee263
add unit tests for default value bug
eli-darkly Oct 5, 2018
7c532d9
Merge pull request #103 from launchdarkly/eb/defaults-unit-tests
eli-darkly Oct 5, 2018
6d4feea
refactor LDClient tests and add some new ones
eli-darkly Oct 5, 2018
1a6c80a
rm unused vars
eli-darkly Oct 5, 2018
5a49e12
Merge pull request #104 from launchdarkly/eb/refactor-client-tests
eli-darkly Oct 5, 2018
8a53c4d
Merge branch 'master' into eb/ch24449/less-metadata
eli-darkly Oct 5, 2018
47524ae
Merge pull request #102 from launchdarkly/eb/ch24449/less-metadata
eli-darkly Oct 8, 2018
1fa81a4
fix broken event source construction
eli-darkly Oct 8, 2018
7f51fd2
Merge pull request #105 from launchdarkly/eb/fix-stream-constructor
eli-darkly Oct 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion feature_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function InMemoryFeatureStore() {
var items = this.allData[kind.namespace];
if (!items) {
items = {};
this.allData[kind] = items;
this.allData[kind.namespace] = items;
}

if (Object.hasOwnProperty.call(items, key)) {
Expand Down
19 changes: 11 additions & 8 deletions flags_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ function FlagsStateBuilder(valid) {
var flagValues = {};
var flagMetadata = {};

builder.addFlag = function(flag, value, variation, reason) {
builder.addFlag = function(flag, value, variation, reason, detailsOnlyIfTracked) {
flagValues[flag.key] = value;
var meta = {
version: flag.version,
trackEvents: flag.trackEvents
};
var meta = {};
if (!detailsOnlyIfTracked || flag.trackEvents || flag.debugEventsUntilDate) {
meta.version = flag.version;
if (reason) {
meta.reason = reason;
}
}
if (variation !== undefined && variation !== null) {
meta.variation = variation;
}
if (flag.trackEvents) {
meta.trackEvents = true;
}
if (flag.debugEventsUntilDate !== undefined && flag.debugEventsUntilDate !== null) {
meta.debugEventsUntilDate = flag.debugEventsUntilDate;
}
if (reason) {
meta.reason = reason;
}
flagMetadata[flag.key] = meta;
};

Expand Down
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,17 @@ declare module 'ldclient-node' {
* client-side SDK. By default, all flags are included.
*/
clientSideOnly?: boolean;
/**
* True if evaluation reason data should be captured in the state object (see LDClient.variationDetail).
* By default, it is not.
*/
withReasons?: boolean;
/**
* True if any flag metadata that is normally only used for event generation - such as flag versions and
* evaluation reasons - should be omitted for any flag that does not have event tracking or debugging turned on.
* This reduces the size of the JSON data if you are passing the flag state to the front end.
*/
detailsOnlyForTrackedFlags?: boolean;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ var newClient = function(sdkKey, config) {
var builder = FlagsStateBuilder(true);
var clientOnly = options.clientSideOnly;
var withReasons = options.withReasons;
var detailsOnlyIfTracked = options.detailsOnlyForTrackedFlags;
config.featureStore.all(dataKind.features, function(flags) {
async.forEachOf(flags, function(flag, key, iterateeCb) {
if (clientOnly && !flag.clientSide) {
Expand All @@ -299,7 +300,7 @@ var newClient = function(sdkKey, config) {
if (err != null) {
maybeReportError(new Error('Error for feature flag "' + flag.key + '" while evaluating all flags: ' + err));
}
builder.addFlag(flag, detail.value, detail.variationIndex, withReasons ? detail.reason : null);
builder.addFlag(flag, detail.value, detail.variationIndex, withReasons ? detail.reason : null, detailsOnlyIfTracked);
setImmediate(iterateeCb);
});
}
Expand Down
40 changes: 33 additions & 7 deletions streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ var errors = require('./errors');
var EventSource = require('./eventsource');
var dataKind = require('./versioned_data_kind');

function StreamProcessor(sdkKey, config, requestor) {
function StreamProcessor(sdkKey, config, requestor, eventSourceFactory) {
var processor = {},
featureStore = config.featureStore,
es;

eventSourceFactory = eventSourceFactory || EventSource;

function getKeyFromPath(kind, path) {
return path.startsWith(kind.streamApiPath) ? path.substring(kind.streamApiPath.length) : null;
}

processor.start = function(fn) {
var cb = fn || function(){};
es = new EventSource(config.streamUri + "/all",
es = new eventSourceFactory(config.streamUri + "/all",
{
agent: config.proxyAgent,
headers: {'Authorization': sdkKey,'User-Agent': config.userAgent}
Expand All @@ -24,10 +26,22 @@ function StreamProcessor(sdkKey, config, requestor) {
cb(new errors.LDStreamingError(err.message, err.code));
};

function reportJsonError(type, data) {
config.logger.error('Stream received invalid data in "' + type + '" message');
config.logger.debug('Invalid JSON follows: ' + data);
cb(new errors.LDStreamingError('Malformed JSON data in event stream'));
}

es.addEventListener('put', function(e) {
config.logger.debug('Received put event');
if (e && e.data) {
var all = JSON.parse(e.data);
var all;
try {
all = JSON.parse(e.data);
} catch (err) {
reportJsonError('put', e.data);
return;
}
var initData = {};
initData[dataKind.features.namespace] = all.data.flags;
initData[dataKind.segments.namespace] = all.data.segments;
Expand All @@ -42,7 +56,13 @@ function StreamProcessor(sdkKey, config, requestor) {
es.addEventListener('patch', function(e) {
config.logger.debug('Received patch event');
if (e && e.data) {
var patch = JSON.parse(e.data);
var patch;
try {
patch = JSON.parse(e.data);
} catch (err) {
reportJsonError('patch', e.data);
return;
}
for (var k in dataKind) {
var kind = dataKind[k];
var key = getKeyFromPath(kind, patch.path);
Expand All @@ -60,8 +80,14 @@ function StreamProcessor(sdkKey, config, requestor) {
es.addEventListener('delete', function(e) {
config.logger.debug('Received delete event');
if (e && e.data) {
var data = JSON.parse(e.data),
version = data.version;
var data, version;
try {
data = JSON.parse(e.data);
} catch (err) {
reportJsonError('delete', e.data);
return;
}
version = data.version;
for (var k in dataKind) {
var kind = dataKind[k];
var key = getKeyFromPath(kind, data.path);
Expand All @@ -78,7 +104,7 @@ function StreamProcessor(sdkKey, config, requestor) {

es.addEventListener('indirect/put', function(e) {
config.logger.debug('Received indirect put event')
requestor.requestAllFlags(function (err, resp) {
requestor.requestAllData(function (err, resp) {
if (err) {
cb(err);
} else {
Expand Down
Loading