launchdarkly-node-client-sdk 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.sdk_metadata.json +12 -0
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/contract-tests/sdkClientEntity.js +5 -5
- package/package.json +3 -3
- package/src/__tests__/LDClient-events-test.js +1 -1
- package/src/__tests__/LDClient-streaming-test.js +2 -2
- package/src/__tests__/LDClient-test.js +3 -3
- package/src/__tests__/LDClient-tls-test.js +4 -4
- package/test-types.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the LaunchDarkly Client-Side SDK for Node.js will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [3.2.0] - 2024-05-01
|
|
6
|
+
### Added:
|
|
7
|
+
- Added an optional timeout to the `waitForInitialization` method. When a timeout is specified the returned promise will be rejected after the timeout elapses if the client has not finished initializing within that time. When no timeout is specified the returned promise will not be resolved or rejected until the initialization either completes or fails.
|
|
8
|
+
|
|
9
|
+
### Changed:
|
|
10
|
+
- The track method now validates that the provided metricValue is a number. If a metric value is provided, and it is not a number, then a warning will be logged.
|
|
11
|
+
|
|
12
|
+
### Fixed:
|
|
13
|
+
- Fixed the documentation for `evaluationReasons` for the `identify` method.
|
|
14
|
+
- Upgraded to launchdarkly-eventsource version 2.0.2. This version contains performance improvements and logging improvements compared the the version that was in use.
|
|
15
|
+
|
|
16
|
+
## [3.1.0] - 2024-03-19
|
|
17
|
+
### Changed:
|
|
18
|
+
- Redact anonymous attributes within feature events
|
|
19
|
+
- Always inline contexts for feature events
|
|
20
|
+
|
|
5
21
|
## [3.0.2] - 2023-03-21
|
|
6
22
|
### Changed:
|
|
7
23
|
- Update `LDContext` to allow for key to be optional. This is used when making an anonymous context with a generated key.
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
The LaunchDarkly Client-Side SDK for Node.js is designed primarily for use by code that is deployed to an end user, such as in a desktop application or a smart device. It follows the client-side LaunchDarkly model for single-user contexts (much like our mobile or JavaScript SDKs). It is not intended for use in multi-user systems such as web servers and applications.
|
|
8
8
|
|
|
9
|
-
For using LaunchDarkly in *server-side* Node.js applications, refer to our [Server-side Node.js SDK](https://github.com/launchdarkly/
|
|
9
|
+
For using LaunchDarkly in *server-side* Node.js applications, refer to our [Server-side Node.js SDK](https://github.com/launchdarkly/js-core/tree/main/packages/sdk/server-node).
|
|
10
10
|
|
|
11
11
|
## LaunchDarkly overview
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@ function makeSdkConfig(options, tag) {
|
|
|
19
19
|
useReport: options.clientSide.useReport,
|
|
20
20
|
sendEventsOnlyForVariation: true,
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
if (options.serviceEndpoints) {
|
|
24
24
|
cf.streamUrl = options.serviceEndpoints.streaming;
|
|
25
25
|
cf.baseUrl = options.serviceEndpoints.polling;
|
|
@@ -72,7 +72,7 @@ async function newSdkClientEntity(options) {
|
|
|
72
72
|
const log = Log(options.tag);
|
|
73
73
|
|
|
74
74
|
log.info('Creating client with configuration: ' + JSON.stringify(options.configuration));
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
const timeout =
|
|
77
77
|
options.configuration.startWaitTimeMs !== null && options.configuration.startWaitTimeMs !== undefined
|
|
78
78
|
? options.configuration.startWaitTimeMs
|
|
@@ -88,10 +88,10 @@ async function newSdkClientEntity(options) {
|
|
|
88
88
|
);
|
|
89
89
|
let failed = false;
|
|
90
90
|
try {
|
|
91
|
-
await
|
|
91
|
+
await client.waitForInitialization(timeout);
|
|
92
92
|
} catch (_) {
|
|
93
|
-
// we get here if waitForInitialization() rejects or if we timed out
|
|
94
|
-
failed = true
|
|
93
|
+
// we get here if waitForInitialization(5) rejects or if we timed out
|
|
94
|
+
failed = true;
|
|
95
95
|
}
|
|
96
96
|
if (failed && !options.configuration.initCanFail) {
|
|
97
97
|
client.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "launchdarkly-node-client-sdk",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "LaunchDarkly Client-Side SDK for Node.js",
|
|
5
5
|
"author": "LaunchDarkly <team@launchdarkly.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"outputName": "junit.xml"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"launchdarkly-eventsource": "
|
|
68
|
-
"launchdarkly-js-sdk-common": "5.
|
|
67
|
+
"launchdarkly-eventsource": "2.0.3",
|
|
68
|
+
"launchdarkly-js-sdk-common": "5.2.0",
|
|
69
69
|
"node-localstorage": "^1.3.1"
|
|
70
70
|
},
|
|
71
71
|
"repository": {
|
|
@@ -18,7 +18,7 @@ describe('LDClient', () => {
|
|
|
18
18
|
const client = LDClient.initialize(envName, context, config);
|
|
19
19
|
await withCloseable(client, async () => {
|
|
20
20
|
const data = { thing: 'stuff' };
|
|
21
|
-
await client.waitForInitialization();
|
|
21
|
+
await client.waitForInitialization(5);
|
|
22
22
|
|
|
23
23
|
client.track('eventkey', data);
|
|
24
24
|
await client.flush();
|
|
@@ -36,7 +36,7 @@ describe('LDClient streaming', () => {
|
|
|
36
36
|
};
|
|
37
37
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
38
38
|
const changeEvents = eventSink(client, 'change:flag');
|
|
39
|
-
await client.waitForInitialization();
|
|
39
|
+
await client.waitForInitialization(5);
|
|
40
40
|
|
|
41
41
|
const value = await changeEvents.take();
|
|
42
42
|
expect(value).toEqual(['yes', undefined]); // second parameter to change event is old value
|
|
@@ -64,7 +64,7 @@ describe('LDClient streaming', () => {
|
|
|
64
64
|
};
|
|
65
65
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
66
66
|
const changeEvents = eventSink(client, 'change:flag');
|
|
67
|
-
await client.waitForInitialization();
|
|
67
|
+
await client.waitForInitialization(5);
|
|
68
68
|
|
|
69
69
|
const value = await changeEvents.take();
|
|
70
70
|
expect(value).toEqual(['yes', undefined]); // second parameter to change event is old value
|
|
@@ -21,7 +21,7 @@ describe('LDClient', () => {
|
|
|
21
21
|
server.byDefault(TestHttpHandlers.respondJson({}));
|
|
22
22
|
const config = { baseUrl: server.url, sendEvents: false };
|
|
23
23
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
24
|
-
await client.waitForInitialization();
|
|
24
|
+
await client.waitForInitialization(5);
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
});
|
|
@@ -31,7 +31,7 @@ describe('LDClient', () => {
|
|
|
31
31
|
server.byDefault(TestHttpHandlers.respondJson({}));
|
|
32
32
|
const config = { baseUrl: server.url, sendEvents: false };
|
|
33
33
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
34
|
-
await client.waitForInitialization();
|
|
34
|
+
await client.waitForInitialization(5);
|
|
35
35
|
|
|
36
36
|
expect(server.requestCount()).toEqual(1);
|
|
37
37
|
const req = await server.nextRequest();
|
|
@@ -51,7 +51,7 @@ describe('LDClient', () => {
|
|
|
51
51
|
};
|
|
52
52
|
const config = { bootstrap: {}, sendEvents: false, logger: logger };
|
|
53
53
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
54
|
-
await client.waitForInitialization();
|
|
54
|
+
await client.waitForInitialization(5);
|
|
55
55
|
|
|
56
56
|
client.track('whatever');
|
|
57
57
|
expect(logger.warn).not.toHaveBeenCalled();
|
|
@@ -32,7 +32,7 @@ describe('LDClient TLS configuration', () => {
|
|
|
32
32
|
diagnosticOptOut: true,
|
|
33
33
|
};
|
|
34
34
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
35
|
-
await client.waitForInitialization();
|
|
35
|
+
await client.waitForInitialization(5);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
});
|
|
@@ -47,7 +47,7 @@ describe('LDClient TLS configuration', () => {
|
|
|
47
47
|
diagnosticOptOut: true,
|
|
48
48
|
};
|
|
49
49
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
50
|
-
await expect(client.waitForInitialization()).rejects.toThrow(/network error.*self[- ]signed/);
|
|
50
|
+
await expect(client.waitForInitialization(5)).rejects.toThrow(/network error.*self[- ]signed/);
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
});
|
|
@@ -71,7 +71,7 @@ describe('LDClient TLS configuration', () => {
|
|
|
71
71
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
72
72
|
const changeEvents = eventSink(client, 'change:flag');
|
|
73
73
|
|
|
74
|
-
await client.waitForInitialization();
|
|
74
|
+
await client.waitForInitialization(5);
|
|
75
75
|
|
|
76
76
|
const value = await changeEvents.take();
|
|
77
77
|
expect(value).toEqual(['yes', undefined]); // second parameter to change event is old value
|
|
@@ -92,7 +92,7 @@ describe('LDClient TLS configuration', () => {
|
|
|
92
92
|
diagnosticOptOut: true,
|
|
93
93
|
};
|
|
94
94
|
await withCloseable(LDClient.initialize(envName, context, config), async client => {
|
|
95
|
-
await client.waitForInitialization();
|
|
95
|
+
await client.waitForInitialization(5);
|
|
96
96
|
await client.flush();
|
|
97
97
|
|
|
98
98
|
expect(server.requestCount()).toEqual(1);
|
package/test-types.ts
CHANGED
|
@@ -75,7 +75,7 @@ const multiContext: ld.LDContext = {
|
|
|
75
75
|
const client: ld.LDClient = ld.initialize('env', user, allOptions);
|
|
76
76
|
|
|
77
77
|
client.waitUntilReady().then(() => {});
|
|
78
|
-
client.waitForInitialization().then(() => {});
|
|
78
|
+
client.waitForInitialization(5).then(() => {});
|
|
79
79
|
|
|
80
80
|
client.identify(user).then(() => {});
|
|
81
81
|
client.identify(user, undefined, () => {});
|