Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare 1.4.0 release #9

Merged
merged 87 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
6c26950
initial implementation
eli-darkly Apr 10, 2019
29f066f
misc fixes
eli-darkly Apr 11, 2019
12787eb
fix CI job
eli-darkly Apr 11, 2019
f6d411a
rm unused
eli-darkly Apr 11, 2019
de8c5eb
misc test fixes
eli-darkly Apr 11, 2019
3110dab
gitignore
eli-darkly Apr 11, 2019
e2ce2f1
indents
eli-darkly Apr 11, 2019
9e7835d
misc fixes
eli-darkly Apr 11, 2019
d28b930
support advanced TLS options
eli-darkly Apr 11, 2019
840d115
fix TS file
eli-darkly Apr 11, 2019
8a43e5f
tests for TLS behavior
eli-darkly Apr 12, 2019
fb2423c
Merge pull request #1 from launchdarkly/eb/ch35501/initial
eli-darkly Apr 12, 2019
2339f6e
Merge pull request #2 from launchdarkly/eb/ch36463/tls-config
eli-darkly Apr 12, 2019
37e34cd
test improvements
eli-darkly Apr 12, 2019
daf30ae
TS fix
eli-darkly Apr 13, 2019
bc5d158
Merge pull request #3 from launchdarkly/eb/ch36463/tls-config-test
eli-darkly Apr 18, 2019
9cf92e4
misc code cleanup and packaging fixes
eli-darkly Apr 18, 2019
4a37c50
Merge pull request #4 from launchdarkly/eb/ch35501/packaging-fixes
eli-darkly Apr 18, 2019
4de2da9
misc fixes + update for js-common 2.10 changes
eli-darkly Apr 20, 2019
3c2c781
misc build/release fixes
eli-darkly Apr 21, 2019
12d97dd
fix version string
eli-darkly Apr 21, 2019
e717e76
don't use Rollup
eli-darkly Apr 22, 2019
0d608e7
misc test/packaging fixes
eli-darkly Apr 22, 2019
c26d639
fix error detection
eli-darkly Apr 22, 2019
f16bbe9
update dev packages
eli-darkly Apr 22, 2019
55ab44e
fix test server setup
eli-darkly Apr 23, 2019
52acec2
fix http.request usage that doesn't work in older Nodes
eli-darkly Apr 23, 2019
39463f8
we don't really need ES6 imports
eli-darkly Apr 23, 2019
aeaf51d
disable audit job for now
eli-darkly Apr 23, 2019
906fdb1
linter
eli-darkly Apr 23, 2019
ca5ec55
fix dependency
eli-darkly Apr 23, 2019
c6b43c5
minor fix to local storage usage
eli-darkly Apr 23, 2019
d46fb86
misc cleanup
eli-darkly Apr 23, 2019
24a6d8f
doc comment
eli-darkly Apr 23, 2019
5bfa3a1
Merge branch 'master' of github.com:launchdarkly/node-client-sdk
eli-darkly Apr 23, 2019
9f6d5c3
Fixing a minor incorrect contribution guideline instruction (#5)
bwoskow-ld Jun 4, 2019
a918a7b
fix release script
eli-darkly Jun 6, 2019
7365f33
Apply markdown templates (#6)
bwoskow-ld Jun 25, 2019
3c55f0a
use new launchdarkly-js-sdk-common package name (#7)
bwoskow-ld Jun 25, 2019
a253743
change case (#8)
bwoskow-ld Jun 25, 2019
9c4837e
bump common package dependency & change to specific version
eli-darkly Jun 28, 2019
485b245
bump common package dependency
eli-darkly Jun 29, 2019
a7fbb46
allow patches of Winston
eli-darkly Jun 29, 2019
fa14618
minor cleanup
eli-darkly Jul 1, 2019
53fbf71
add doc comment
eli-darkly Jul 1, 2019
a91d241
removed the beta warning (#9)
bwoskow-ld Jul 3, 2019
ca0477d
Merge branch 'master' of github.com:launchdarkly/node-client-sdk
bwoskow-ld Jul 3, 2019
7c18d91
merge from public after release
LaunchDarklyCI Jul 3, 2019
ed3bb07
Merge branch 'master' of github.com:launchdarkly/node-client-sdk
bwoskow-ld Jul 3, 2019
980c002
Merge branch 'master' of github.com:launchdarkly/node-client-sdk
bwoskow-ld Jul 18, 2019
35237a1
Merge branch 'master' of github.com:launchdarkly/node-client-sdk
eli-darkly Aug 26, 2019
88ca0fd
update js-sdk-common dependency to get experimentation features
eli-darkly Oct 10, 2019
d0dd0d5
Merge pull request #10 from launchdarkly/eb/ch52421/experiments
eli-darkly Oct 10, 2019
1813c9f
merge from public after release
LaunchDarklyCI Oct 10, 2019
53c4ef0
update js-sdk-common dependency
eli-darkly Nov 6, 2019
32f127a
Merge pull request #11 from launchdarkly/eb/ch53224/js-common
eli-darkly Nov 6, 2019
4e201de
misc build fixes
eli-darkly Nov 6, 2019
5c879a4
need types package for TS checking, now that typedoc isn't installed
eli-darkly Nov 6, 2019
24080b7
merge from public after release
LaunchDarklyCI Nov 6, 2019
0827c03
rm typedoc dependency, don't commit installation of it during release
eli-darkly Nov 6, 2019
b1813c8
Merge pull request #12 from launchdarkly/eb/ch55415/typedoc-dep
eli-darkly Nov 6, 2019
f243b8a
merge from public after release
LaunchDarklyCI Nov 6, 2019
9eb3f2e
Merge branch 'master' of github.com:launchdarkly/node-client-sdk
bwoskow-ld Nov 7, 2019
41b9f56
use new test package, misc test cleanup
eli-darkly Dec 5, 2019
d6987a2
export SDK version
eli-darkly Dec 5, 2019
78c282e
Merge pull request #13 from launchdarkly/eb/ch57131/new-test-package
eli-darkly Dec 6, 2019
bb47978
Merge pull request #14 from launchdarkly/eb/ch58262/version
eli-darkly Dec 6, 2019
c55cbfb
use new config validation logic in js-sdk-common
eli-darkly Dec 12, 2019
0d07410
implement diagnostic events in client-side Node SDK
eli-darkly Dec 12, 2019
1e489ca
normalize platform name
eli-darkly Dec 12, 2019
c3bd539
Merge pull request #16 from launchdarkly/eb/ch58401/diagnostic-events
eli-darkly Dec 12, 2019
e4dc429
Merge pull request #15 from launchdarkly/eb/ch57985/config-validation
eli-darkly Dec 12, 2019
34afaf4
Merge branch 'master' into diagnostic-events
eli-darkly Dec 12, 2019
610c356
use latest common package release
eli-darkly Dec 13, 2019
3103435
merge from public after release
LaunchDarklyCI Dec 16, 2019
ba8e6c9
use js-sdk-common 3.1.1 for event payload ID fix
eli-darkly Jan 15, 2020
604a92a
Merge pull request #17 from launchdarkly/eb/ch61092/commonsdk-fix
eli-darkly Jan 15, 2020
1f6ed00
merge from public after release
LaunchDarklyCI Jan 15, 2020
6ff647f
add mention of singleton usage
eli-darkly Feb 11, 2020
691f470
use js-sdk-common 3.1.2
eli-darkly Feb 11, 2020
b3accc1
Merge pull request #18 from launchdarkly/eb/ch65200/singleton-comment
eli-darkly Feb 11, 2020
e788ba5
standardize linting
eli-darkly Feb 11, 2020
4c0a969
Merge branch 'master' into diagnostic-events
eli-darkly Feb 11, 2020
4dca2b3
misc fixes for latest js-sdk-common
eli-darkly Feb 11, 2020
bc26d7e
Merge pull request #19 from launchdarkly/eb/ch65303/linting
eli-darkly Feb 13, 2020
501683c
Merge branch 'master' into diagnostic-events
eli-darkly Feb 13, 2020
e264760
use js-sdk-common 3.2.2
eli-darkly Feb 14, 2020
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
84 changes: 38 additions & 46 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parser: babel-eslint
root: true
extends:
- prettier
- eslint:recommended # https://eslint.org/docs/rules/
env:
es6: true
node: true
Expand All @@ -17,24 +18,37 @@ globals:
jest: true
beforeEach: true
afterEach: true
window: true
document: true
window: false # client-side Node SDK should *not* reference "window" or "document"
document: false
rules:
# https://github.com/prettier/eslint-plugin-prettier
prettier/prettier:
# https://eslint.org/docs/rules/array-callback-return
array-callback-return: error

# https://eslint.org/docs/rules/arrow-body-style
arrow-body-style:
- error

- as-needed

# https://github.com/babel/eslint-plugin-babel
babel/semi: error

# https://eslint.org/docs/rules/array-callback-return
array-callback-return: error
# Deprecations are required to turn enforce this
camelcase: warn

# https://eslint.org/docs/rules/curly
curly:
- error
- all

# https://eslint.org/docs/rules/eqeqeq
eqeqeq: error

# https://eslint.org/docs/rules/no-array-constructor
no-array-constructor: error

# https://eslint.org/docs/rules/no-eval
no-eval: error

# https://eslint.org/docs/rules/no-implicit-coercion
no-implicit-coercion:
- 'off'
Expand All @@ -43,12 +57,18 @@ rules:
string: true
allow: []

# https://eslint.org/docs/rules/no-eval
no-eval: error

# https://eslint.org/docs/rules/no-implied-eval
no-implied-eval: error

# https://eslint.org/docs/rules/no-nested-ternary
no-nested-ternary: error

# https://eslint.org/docs/rules/no-new-object
no-new-object: error

# https://eslint.org/docs/rules/no-new-wrappers
no-new-wrappers: error

# https://eslint.org/docs/rules/no-param-reassign
no-param-reassign:
- error
Expand All @@ -60,51 +80,23 @@ rules:
# https://eslint.org/docs/rules/no-self-compare
no-self-compare: error

# https://eslint.org/docs/rules/radix
radix: error

# https://eslint.org/docs/rules/no-array-constructor
no-array-constructor: error

# https://eslint.org/docs/rules/no-new-wrappers
no-new-wrappers: error

# https://eslint.org/docs/rules/no-cond-assign
no-cond-assign: error

# https://eslint.org/docs/rules/no-use-before-define
no-use-before-define:
- error
- functions: false

# https://eslint.org/docs/rules/eqeqeq
eqeqeq: error

# Deprecations are required to turn enforce this
camelcase: warn

# https://eslint.org/docs/rules/no-new-object
no-new-object: error

# https://eslint.org/docs/rules/no-nested-ternary
no-nested-ternary: error

# https://eslint.org/docs/rules/no-unused-vars
no-unused-vars: error

# https://eslint.org/docs/rules/no-var
no-var: error

# https://eslint.org/docs/rules/prefer-const
prefer-const: error

# https://eslint.org/docs/rules/prefer-arrow-callback
prefer-arrow-callback: error

# https://eslint.org/docs/rules/arrow-body-style
arrow-body-style:
- error
- as-needed
# https://eslint.org/docs/rules/prefer-const
prefer-const: error

# https://eslint.org/docs/rules/no-undef
no-undef: error
# https://github.com/prettier/eslint-plugin-prettier
prettier/prettier:
- error

# https://eslint.org/docs/rules/radix
radix: error
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"launchdarkly-eventsource": "1.0.0",
"launchdarkly-js-sdk-common": "3.1.1",
"launchdarkly-js-sdk-common": "3.2.2",
"node-localstorage": "^1.3.1",
"original": "^1.0.0",
"winston": "^2.4.1"
Expand Down
74 changes: 49 additions & 25 deletions src/__tests__/LDClient-events-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const LDClient = require('../index');

const { TestHttpHandlers, TestHttpServers, withCloseable } = require('launchdarkly-js-test-helpers');

describe('LDClient', () => {
const envName = 'UNKNOWN_ENVIRONMENT_ID';
const user = { key: 'user' };
Expand All @@ -9,33 +11,55 @@ describe('LDClient', () => {
// should.

describe('event generation', () => {
function stubEventProcessor() {
const ep = { events: [] };
ep.start = function() {};
ep.flush = function() {};
ep.stop = function() {};
ep.enqueue = function(e) {
ep.events.push(e);
};
return ep;
}

// This tests that the client calls our platform's getCurrentUrl() and isDoNotTrack() methods.
it('sends an event for track()', done => {
const ep = stubEventProcessor();
const client = LDClient.initialize(envName, user, { eventProcessor: ep, bootstrap: {} });
const data = { thing: 'stuff' };
client.on('ready', () => {
client.track('eventkey', data);
it('sends an event for track()', async () => {
await withCloseable(TestHttpServers.start, async server => {
const config = { bootstrap: {}, eventsUrl: server.url, diagnosticOptOut: true };
const client = LDClient.initialize(envName, user, config);
await withCloseable(client, async () => {
const data = { thing: 'stuff' };
await client.waitForInitialization();

client.track('eventkey', data);
await client.flush();

const req = await server.nextRequest();
expect(req.path).toEqual('/events/bulk/' + envName);
const events = JSON.parse(req.body);
expect(events.length).toEqual(2); // first is identify event
const trackEvent = events[1];
expect(trackEvent.kind).toEqual('custom');
expect(trackEvent.key).toEqual('eventkey');
expect(trackEvent.userKey).toEqual(user.key);
expect(trackEvent.data).toEqual(data);
expect(trackEvent.url).toEqual(null);
});
});
});
});

expect(ep.events.length).toEqual(2);
const trackEvent = ep.events[1];
expect(trackEvent.kind).toEqual('custom');
expect(trackEvent.key).toEqual('eventkey');
expect(trackEvent.user).toEqual(user);
expect(trackEvent.data).toEqual(data);
expect(trackEvent.url).toEqual(null);
done();
describe('diagnostic events', () => {
it('sends diagnostic init event', async () => {
await withCloseable(TestHttpServers.start, async server => {
server.byDefault(TestHttpHandlers.respond(202));
const config = { bootstrap: {}, eventsUrl: server.url };
const client = LDClient.initialize(envName, user, config);
await withCloseable(client, async () => {
const req0 = await server.nextRequest();
const req1 = await server.nextRequest();
// We should have received both the client's usual identify event and a diagnostic init event, but we can't be sure of the ordering.
const expectedPath = '/events/diagnostic/' + envName;
expect([req0.path, req1.path]).toContain(expectedPath);
const req = req0.path === expectedPath ? req0 : req1;
const data = JSON.parse(req.body);
expect(data.kind).toEqual('diagnostic-init');
expect(data.platform).toMatchObject({
name: 'Node',
});
expect(data.sdk).toMatchObject({
name: 'node-client-sdk',
});
});
});
});
});
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/LDClient-tls-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('LDClient TLS configuration', () => {
baseUrl: server.url,
sendEvents: false,
tlsParams: { ca: server.certificate },
diagnosticOptOut: true,
};
await withCloseable(LDClient.initialize(envName, user, config), async client => {
await client.waitForInitialization();
Expand All @@ -43,6 +44,7 @@ describe('LDClient TLS configuration', () => {
baseUrl: server.url,
sendEvents: false,
logger: stubLogger,
diagnosticOptOut: true,
};
await withCloseable(LDClient.initialize(envName, user, config), async client => {
await expect(client.waitForInitialization()).rejects.toThrow(/network error.*self signed/);
Expand All @@ -64,6 +66,7 @@ describe('LDClient TLS configuration', () => {
streaming: true,
sendEvents: false,
tlsParams: { ca: server.certificate },
diagnosticOptOut: true,
};
await withCloseable(LDClient.initialize(envName, user, config), async client => {
const changeEvents = eventSink(client, 'change:flag');
Expand All @@ -86,6 +89,7 @@ describe('LDClient TLS configuration', () => {
baseUrl: server.url,
eventsUrl: server.url + '/events',
tlsParams: { ca: server.certificate },
diagnosticOptOut: true,
};
await withCloseable(LDClient.initialize(envName, user, config), async client => {
await client.waitForInitialization();
Expand Down
30 changes: 30 additions & 0 deletions src/nodePlatform.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { LocalStorage } = require('node-localstorage');
const { EventSource } = require('launchdarkly-eventsource');
const os = require('os');
const path = require('path');
const newHttpRequest = require('./httpRequest');
const packageJson = require('../package.json');

function makeNodePlatform(options) {
const tlsParams = filterTlsParams(options.tlsParams);
Expand Down Expand Up @@ -48,10 +50,38 @@ function makeNodePlatform(options) {
ret.eventSourceAllowsReport = true;

ret.userAgent = 'NodeClientSide';
ret.version = packageJson.version;

ret.diagnosticSdkData = {
name: 'node-client-sdk',
version: packageJson.version,
};

ret.diagnosticPlatformData = {
name: 'Node',
nodeVersion: process.versions.node,
osArch: os.arch(),
osName: normalizePlatformName(os.platform()),
osVersion: os.release(),
};

return ret;
}

function normalizePlatformName(platformName) {
// The following logic is based on how Node.js reports the platform name
switch (platformName) {
case 'darwin':
return 'MacOS';
case 'win32':
return 'Windows';
case 'linux':
return 'Linux';
default:
return platformName;
}
}

const httpsOptions = [
'pfx',
'key',
Expand Down
7 changes: 6 additions & 1 deletion typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ declare module 'launchdarkly-node-client-sdk' {
//// DOCBUILD-END-REPLACE

/**
* Creates an instance of the LaunchDarkly client to be used in the main process.
* Creates an instance of the LaunchDarkly client.
*
* Applications should instantiate a single instance for the lifetime of the application.
* The client will begin attempting to connect to LaunchDarkly as soon as it is created. To
* determine when it is ready to use, call [[LDClient.waitForInitialization]], or register an
* event listener for the `"ready"` event using [[LDClient.on]].
*
* @param envKey
* The LaunchDarkly environment ID.
Expand Down