launchdarkly-node-client-sdk 1.5.0 → 2.0.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/.circleci/config.yml +47 -12
- package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.ldrelease/config.yml +8 -3
- package/CHANGELOG.md +36 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +8 -7
- package/package.json +12 -10
- package/src/__tests__/LDClient-test.js +1 -1
- package/src/__tests__/LDClient-tls-test.js +1 -1
- package/src/basicLogger.js +10 -0
- package/src/index.js +4 -21
- package/test-types.ts +5 -3
- package/typings.d.ts +45 -2
package/.circleci/config.yml
CHANGED
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
|
|
3
3
|
orbs:
|
|
4
|
-
win: circleci/windows@
|
|
4
|
+
win: circleci/windows@2.4.0
|
|
5
5
|
|
|
6
6
|
workflows:
|
|
7
7
|
test:
|
|
8
8
|
jobs:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
# CircleCI's current generation of Node images, cimg/node, allow you to leave the
|
|
10
|
+
# patch version unpinned, but require you to specify the minor version. The one
|
|
11
|
+
# exception is cimg/node:current, which will always give us the latest release in
|
|
12
|
+
# the latest major version-- and the latest major version is where it's most likely
|
|
13
|
+
# that there would be a new minor version, anyway.
|
|
14
|
+
- build-test-linux:
|
|
15
|
+
name: latest Node version
|
|
16
|
+
docker-image: cimg/node:current
|
|
17
|
+
run-lint: true
|
|
18
|
+
- build-test-linux:
|
|
19
|
+
name: Node 16.3
|
|
20
|
+
docker-image: cimg/node:16.3
|
|
21
|
+
- build-test-linux:
|
|
22
|
+
name: Node 15.14
|
|
23
|
+
docker-image: cimg/node:15.14
|
|
24
|
+
- build-test-linux:
|
|
25
|
+
name: Node 14.17
|
|
26
|
+
docker-image: cimg/node:14.17
|
|
27
|
+
- build-test-linux:
|
|
28
|
+
name: Node 13.14
|
|
29
|
+
docker-image: cimg/node:13.14
|
|
30
|
+
- build-test-linux:
|
|
31
|
+
name: Node 12.22
|
|
32
|
+
docker-image: cimg/node:12.22
|
|
33
|
+
- build-test-windows:
|
|
34
|
+
name: Windows
|
|
17
35
|
|
|
18
36
|
jobs:
|
|
19
|
-
build-test:
|
|
37
|
+
build-test-linux:
|
|
20
38
|
parameters:
|
|
21
39
|
docker-image:
|
|
22
40
|
type: string
|
|
23
|
-
|
|
41
|
+
run-lint:
|
|
24
42
|
type: boolean
|
|
25
43
|
default: false
|
|
26
44
|
|
|
27
45
|
docker:
|
|
28
46
|
- image: <<parameters.docker-image>>
|
|
29
47
|
|
|
48
|
+
environment:
|
|
49
|
+
NODE_ENV: test
|
|
50
|
+
|
|
30
51
|
steps:
|
|
31
52
|
- checkout
|
|
32
53
|
- run: echo "Node version:" `node --version`
|
|
@@ -39,7 +60,7 @@ jobs:
|
|
|
39
60
|
JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml"
|
|
40
61
|
|
|
41
62
|
- when:
|
|
42
|
-
condition: <<parameters.
|
|
63
|
+
condition: <<parameters.run-lint>>
|
|
43
64
|
steps:
|
|
44
65
|
- run: npm run lint:all
|
|
45
66
|
- run: npm run check-typescript
|
|
@@ -52,3 +73,17 @@ jobs:
|
|
|
52
73
|
path: reports/junit
|
|
53
74
|
- store_artifacts:
|
|
54
75
|
path: reports/junit
|
|
76
|
+
|
|
77
|
+
build-test-windows:
|
|
78
|
+
executor:
|
|
79
|
+
name: win/default
|
|
80
|
+
shell: powershell.exe
|
|
81
|
+
|
|
82
|
+
environment:
|
|
83
|
+
NODE_ENV: test
|
|
84
|
+
|
|
85
|
+
steps:
|
|
86
|
+
- checkout
|
|
87
|
+
- run: node --version
|
|
88
|
+
- run: npm install
|
|
89
|
+
- run: npm test
|
|
@@ -8,7 +8,7 @@ assignees: ''
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
**Is this a support request?**
|
|
11
|
-
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going [here](https://support.launchdarkly.com/)
|
|
11
|
+
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going [here](https://support.launchdarkly.com/hc/en-us/requests/new) or by emailing support@launchdarkly.com.
|
|
12
12
|
|
|
13
13
|
Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.
|
|
14
14
|
|
package/.ldrelease/config.yml
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
|
|
1
3
|
repo:
|
|
2
4
|
public: node-client-sdk
|
|
3
5
|
private: node-client-sdk-private
|
|
@@ -6,11 +8,14 @@ publications:
|
|
|
6
8
|
- url: https://www.npmjs.com/package/launchdarkly-node-client-sdk
|
|
7
9
|
description: npm
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
jobs:
|
|
12
|
+
- docker:
|
|
13
|
+
image: node:12-buster
|
|
14
|
+
template:
|
|
15
|
+
name: npm
|
|
11
16
|
|
|
12
17
|
documentation:
|
|
13
|
-
|
|
18
|
+
gitHubPages: true
|
|
14
19
|
title: LaunchDarkly Client-Side Node SDK
|
|
15
20
|
|
|
16
21
|
sdk:
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,42 @@
|
|
|
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
|
+
## [2.0.0] - 2022-01-26
|
|
6
|
+
This major version release is for updating Node.js compatibility, simplifying the SDK's dependencies, and removing deprecated names.
|
|
7
|
+
|
|
8
|
+
Except for the dependency changes described below which may require minor changes in your build, and a minor new logging feature, usage of the SDK has not changed in this release. For more details about changes that may be necessary, see the [1.x to 2.0 migration guide](https://docs.launchdarkly.com/sdk/client-side/node-js/migration-1-to-2).
|
|
9
|
+
|
|
10
|
+
Dropping support for obsolete Node.js versions makes it easier to maintain the SDK and keep its dependencies up to date. See LaunchDarkly's [End of Life Policy](https://launchdarkly.com/policies/end-of-life-policy/) regarding platform version support.
|
|
11
|
+
|
|
12
|
+
Simplifying dependencies reduces the size of the SDK bundle, as well as reducing potential compatibility problems and vulnerabilities.
|
|
13
|
+
|
|
14
|
+
### Added:
|
|
15
|
+
- Added `basicLogger`, allowing customization of the SDK's default logging behavior without having to use Winston or provide a full `LDLogger` implementation.
|
|
16
|
+
|
|
17
|
+
### Changed:
|
|
18
|
+
- The minimum Node.js version is now 12.0.
|
|
19
|
+
- Updated dependencies to newer versions and/or more actively maintained packages.
|
|
20
|
+
- In TypeScript, the property `LDEvaluationDetail.reason` now has a type of `LDEvaluationReason | undefined`, which correctly reflects the fact that evaluation reasons may not always be available.
|
|
21
|
+
|
|
22
|
+
### Fixed:
|
|
23
|
+
- If the platform local storage mechanism throws an exception (for instance, if file permissions do not allow the data to be saved), the SDK now correctly catches the exception and logs a message about the failure. It will only log this message once during the lifetime of the SDK client.
|
|
24
|
+
|
|
25
|
+
### Removed:
|
|
26
|
+
- Removed the dependency on [Winston](https://www.npmjs.com/package/winston). You can still tell the SDK to use a Winston logger instance that you have created, just as before, so this change should not affect any applications that are using Winston. But the SDK no longer uses Winston to create a default logger if the application does not specify a logger; instead, it uses the `basicLogger` implementation, which uses the same format as the previous default Winston configuration, so again there should be no visible difference.
|
|
27
|
+
- Removed `createConsoleLogger`, which is replaced by the more flexible `basicLogger`.
|
|
28
|
+
- Removed the type `NonNullableLDEvaluationReason`, which was a side effect of `LDEvaluationDetail.reason` being incorrectly defined before.
|
|
29
|
+
- Removed all types, properties, and functions that were deprecated as of the last 1.x release.
|
|
30
|
+
|
|
31
|
+
## [1.5.2] - 2021-06-10
|
|
32
|
+
### Fixed:
|
|
33
|
+
- Events for the [LaunchDarkly debugger](https://docs.launchdarkly.com/home/flags/debugger) are now properly pre-processed to omit private user attributes, as well as enforce only expected top level attributes are sent.
|
|
34
|
+
- Events for the [LaunchDarkly debugger](https://docs.launchdarkly.com/home/flags/debugger) now include the index of the variation responsible for the evaluation result.
|
|
35
|
+
- Updated transitive dependency on the package `url-parse` due to a [vulnerability warning](https://github.com/advisories/GHSA-9m6j-fcg5-2442).
|
|
36
|
+
|
|
37
|
+
## [1.5.1] - 2021-04-01
|
|
38
|
+
### Fixed:
|
|
39
|
+
- The property `LDOptions.inlineUsersInEvents` was not included in the TypeScript definitions.
|
|
40
|
+
|
|
5
41
|
## [1.5.0] - 2021-01-27
|
|
6
42
|
### Added:
|
|
7
43
|
- Added the `alias` method. This method can be used to associate two user objects for analytics purposes. When invoked, this method will queue a new alias event to be sent to LaunchDarkly.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Contributing to the LaunchDarkly Client-Side SDK for Node.js
|
|
2
2
|
|
|
3
|
-
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/
|
|
3
|
+
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/sdk/concepts/contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK.
|
|
4
4
|
|
|
5
5
|
## Submitting bug reports and feature requests
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ We encourage pull requests and other contributions from the community. Before su
|
|
|
14
14
|
|
|
15
15
|
### Prerequisites
|
|
16
16
|
|
|
17
|
-
The project uses `npm`, which is bundled in all supported versions of Node.
|
|
17
|
+
The project should be built and tested against the lowest compatible version, Node 12. It uses `npm`, which is bundled in all supported versions of Node.
|
|
18
18
|
|
|
19
19
|
Note that much of the basic SDK logic, which is common to all of the LaunchDarkly client-side JavaScript-based SDKs, is in the `launchdarkly-js-sdk-common` package within [js-client-sdk](https://github.com/launchdarkly/js-client-sdk). This is pulled in automatically by `npm` when you build the SDK, but if you are planning to make changes that affect the common code, you will need to check out that repository as well.
|
|
20
20
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# LaunchDarkly Client-Side SDK for Node.js
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/launchdarkly-node-client-sdk)
|
|
4
|
+
[](https://circleci.com/gh/launchdarkly/node-client-sdk)
|
|
5
|
+
[](https://launchdarkly.github.io/node-client-sdk)
|
|
4
6
|
|
|
5
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.
|
|
6
8
|
|
|
@@ -8,21 +10,21 @@ For using LaunchDarkly in *server-side* Node.js applications, refer to our [Serv
|
|
|
8
10
|
|
|
9
11
|
## LaunchDarkly overview
|
|
10
12
|
|
|
11
|
-
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/
|
|
13
|
+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
|
|
12
14
|
|
|
13
15
|
[](https://twitter.com/intent/follow?screen_name=launchdarkly)
|
|
14
16
|
|
|
15
17
|
## Supported Node versions
|
|
16
18
|
|
|
17
|
-
This version of the LaunchDarkly SDK
|
|
19
|
+
This version of the LaunchDarkly SDK is compatible with Node.js versions 12 and above.
|
|
18
20
|
|
|
19
21
|
## Getting started
|
|
20
22
|
|
|
21
|
-
Refer to the [SDK documentation](https://docs.launchdarkly.com/
|
|
23
|
+
Refer to the [SDK documentation](https://docs.launchdarkly.com/sdk/client-side/node-js#getting-started) for instructions on getting started with using the SDK.
|
|
22
24
|
|
|
23
25
|
## Learn more
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
Read our [documentation](https://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/docs/node-client-sdk-reference).
|
|
26
28
|
|
|
27
29
|
The authoritative description of all properties and methods is in the [TypeScript documentation](https://launchdarkly.github.io/node-client-sdk/).
|
|
28
30
|
|
|
@@ -41,10 +43,9 @@ We encourage pull requests and other contributions from the community. Check out
|
|
|
41
43
|
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
|
|
42
44
|
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
|
|
43
45
|
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
|
|
44
|
-
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies.
|
|
46
|
+
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
|
|
45
47
|
* Explore LaunchDarkly
|
|
46
48
|
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
|
|
47
49
|
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
|
|
48
50
|
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
|
|
49
51
|
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
|
|
50
|
-
* [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "launchdarkly-node-client-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "LaunchDarkly Client-Side SDK for Node.js",
|
|
5
5
|
"author": "LaunchDarkly <team@launchdarkly.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,10 +14,13 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"lint": "eslint --format 'node_modules/eslint-formatter-pretty' --ignore-path .eslintignore",
|
|
16
16
|
"lint:all": "eslint --format 'node_modules/eslint-formatter-pretty' --ignore-path .eslintignore src",
|
|
17
|
-
"test": "
|
|
18
|
-
"test:junit": "
|
|
17
|
+
"test": "jest",
|
|
18
|
+
"test:junit": "jest --testResultsProcessor jest-junit",
|
|
19
19
|
"check-typescript": "node_modules/typescript/bin/tsc"
|
|
20
20
|
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">= 12.0.0"
|
|
23
|
+
},
|
|
21
24
|
"devDependencies": {
|
|
22
25
|
"@babel/core": "^7.9.6",
|
|
23
26
|
"@babel/preset-env": "^7.9.6",
|
|
@@ -32,9 +35,9 @@
|
|
|
32
35
|
"eslint-formatter-pretty": "^3.0.1",
|
|
33
36
|
"eslint-plugin-babel": "^5.3.0",
|
|
34
37
|
"eslint-plugin-prettier": "^3.1.3",
|
|
35
|
-
"jest": "^
|
|
36
|
-
"jest-junit": "^
|
|
37
|
-
"launchdarkly-js-test-helpers": "1.1
|
|
38
|
+
"jest": "^27.4.7",
|
|
39
|
+
"jest-junit": "^13.0.0",
|
|
40
|
+
"launchdarkly-js-test-helpers": "1.2.1",
|
|
38
41
|
"prettier": "^2.0.5",
|
|
39
42
|
"readline-sync": "^1.4.9",
|
|
40
43
|
"semver": "^5.5.0",
|
|
@@ -42,11 +45,10 @@
|
|
|
42
45
|
"typescript": "^3.8.3"
|
|
43
46
|
},
|
|
44
47
|
"dependencies": {
|
|
45
|
-
"launchdarkly-eventsource": "1.4.
|
|
46
|
-
"launchdarkly-js-sdk-common": "
|
|
48
|
+
"launchdarkly-eventsource": "1.4.2",
|
|
49
|
+
"launchdarkly-js-sdk-common": "4.0.3",
|
|
47
50
|
"node-localstorage": "^1.3.1",
|
|
48
|
-
"original": "^1.0.0"
|
|
49
|
-
"winston": "^3.2.1"
|
|
51
|
+
"original": "^1.0.0"
|
|
50
52
|
},
|
|
51
53
|
"repository": {
|
|
52
54
|
"type": "git",
|
|
@@ -35,7 +35,7 @@ describe('LDClient', () => {
|
|
|
35
35
|
|
|
36
36
|
expect(server.requestCount()).toEqual(1);
|
|
37
37
|
const req = await server.nextRequest();
|
|
38
|
-
expect(req.headers['
|
|
38
|
+
expect(req.headers['user-agent']).toMatch(/^NodeClientSide\//);
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
});
|
|
@@ -47,7 +47,7 @@ describe('LDClient TLS configuration', () => {
|
|
|
47
47
|
diagnosticOptOut: true,
|
|
48
48
|
};
|
|
49
49
|
await withCloseable(LDClient.initialize(envName, user, config), async client => {
|
|
50
|
-
await expect(client.waitForInitialization()).rejects.toThrow(/network error.*self signed/);
|
|
50
|
+
await expect(client.waitForInitialization()).rejects.toThrow(/network error.*self[- ]signed/);
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { commonBasicLogger } = require('launchdarkly-js-sdk-common');
|
|
2
|
+
const { format } = require('util');
|
|
3
|
+
|
|
4
|
+
function basicLogger(options) {
|
|
5
|
+
return commonBasicLogger({ destination: console.log, ...options }, format);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
basicLogger,
|
|
10
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const common = require('launchdarkly-js-sdk-common');
|
|
2
|
-
const
|
|
2
|
+
const { basicLogger } = require('./basicLogger');
|
|
3
3
|
const nodePlatform = require('./nodePlatform');
|
|
4
4
|
const packageJson = require('../package.json');
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@ function initialize(env, user, options = {}) {
|
|
|
12
12
|
tlsParams: { type: 'object' },
|
|
13
13
|
};
|
|
14
14
|
if (!options.logger) {
|
|
15
|
-
extraOptionDefs.logger = { default:
|
|
15
|
+
extraOptionDefs.logger = { default: basicLogger() };
|
|
16
16
|
}
|
|
17
17
|
const clientVars = common.initialize(env, user, options, platform, extraOptionDefs);
|
|
18
18
|
|
|
@@ -21,25 +21,8 @@ function initialize(env, user, options = {}) {
|
|
|
21
21
|
return clientVars.client;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function createDefaultLogger() {
|
|
25
|
-
const prefixFormat = winston.format(info => {
|
|
26
|
-
// eslint-disable-next-line no-param-reassign
|
|
27
|
-
info.message = `[LaunchDarkly] ${info.message ? info.message : ''}`;
|
|
28
|
-
return info;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return winston.createLogger({
|
|
32
|
-
level: 'info',
|
|
33
|
-
transports: [
|
|
34
|
-
new winston.transports.Console({
|
|
35
|
-
format: winston.format.combine(prefixFormat(), winston.format.simple()),
|
|
36
|
-
}),
|
|
37
|
-
],
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
24
|
module.exports = {
|
|
42
|
-
initialize
|
|
43
|
-
|
|
25
|
+
initialize,
|
|
26
|
+
basicLogger,
|
|
44
27
|
version: packageJson.version,
|
|
45
28
|
};
|
package/test-types.ts
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import * as ld from 'launchdarkly-node-client-sdk';
|
|
6
6
|
|
|
7
|
+
var ver: string = ld.version;
|
|
8
|
+
|
|
7
9
|
var emptyOptions: ld.LDOptions = {};
|
|
8
|
-
var logger: ld.LDLogger = ld.
|
|
10
|
+
var logger: ld.LDLogger = ld.basicLogger({ level: 'info' });
|
|
9
11
|
var allOptions: ld.LDOptions = {
|
|
10
12
|
bootstrap: { },
|
|
11
13
|
baseUrl: '',
|
|
@@ -18,10 +20,10 @@ var allOptions: ld.LDOptions = {
|
|
|
18
20
|
sendEvents: true,
|
|
19
21
|
allAttributesPrivate: true,
|
|
20
22
|
privateAttributeNames: [ 'x' ],
|
|
23
|
+
inlineUsersInEvents: true,
|
|
21
24
|
allowFrequentDuplicateEvents: true,
|
|
22
25
|
sendEventsOnlyForVariation: true,
|
|
23
26
|
flushInterval: 1,
|
|
24
|
-
samplingInterval: 1,
|
|
25
27
|
streamReconnectDelay: 1,
|
|
26
28
|
logger: logger,
|
|
27
29
|
autoAliasingOptOut: true
|
|
@@ -71,7 +73,7 @@ var stringFlagValue: ld.LDFlagValue = client.variation('key', 'default');
|
|
|
71
73
|
var detail: ld.LDEvaluationDetail = client.variationDetail('key', 'default');
|
|
72
74
|
var detailValue: ld.LDFlagValue = detail.value;
|
|
73
75
|
var detailIndex: number | undefined = detail.variationIndex;
|
|
74
|
-
var detailReason: ld.LDEvaluationReason = detail.reason;
|
|
76
|
+
var detailReason: ld.LDEvaluationReason | undefined = detail.reason;
|
|
75
77
|
|
|
76
78
|
client.setStreaming(true);
|
|
77
79
|
client.setStreaming();
|
package/typings.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* In typical usage, you will call [[initialize]] in the main process at startup time to obtain an
|
|
5
5
|
* an instance of [[LDClient]].
|
|
6
6
|
*
|
|
7
|
-
* For more information, see the [SDK reference guide](
|
|
7
|
+
* For more information, see the [SDK reference guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
|
|
8
8
|
*/
|
|
9
9
|
declare module 'launchdarkly-node-client-sdk' {
|
|
10
10
|
|
|
@@ -12,16 +12,23 @@ declare module 'launchdarkly-node-client-sdk' {
|
|
|
12
12
|
export * from 'launchdarkly-js-sdk-common';
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
+
BasicLoggerOptions,
|
|
15
16
|
LDEvaluationDetail,
|
|
16
17
|
LDEvaluationReason,
|
|
17
18
|
LDFlagSet,
|
|
18
19
|
LDFlagValue,
|
|
19
20
|
LDClientBase,
|
|
21
|
+
LDLogger,
|
|
20
22
|
LDOptionsBase,
|
|
21
23
|
LDUser
|
|
22
24
|
} from 'launchdarkly-js-sdk-common';
|
|
23
25
|
//// DOCBUILD-END-REPLACE
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
* The current version string of the SDK.
|
|
29
|
+
*/
|
|
30
|
+
export const version: string;
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
33
|
* Creates an instance of the LaunchDarkly client.
|
|
27
34
|
*
|
|
@@ -84,8 +91,44 @@ declare module 'launchdarkly-node-client-sdk' {
|
|
|
84
91
|
*
|
|
85
92
|
* Applications should configure the client at startup time with [[initialize]], and reuse the same instance.
|
|
86
93
|
*
|
|
87
|
-
* For more information, see the [SDK Reference Guide](
|
|
94
|
+
* For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
|
|
88
95
|
*/
|
|
89
96
|
export interface LDClient extends LDClientBase {
|
|
90
97
|
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Provides a simple [[LDLogger]] implementation.
|
|
101
|
+
*
|
|
102
|
+
* This logging implementation uses a simple format that includes only the log level
|
|
103
|
+
* and the message text. Output is written to the standard error stream (`console.error`).
|
|
104
|
+
* You can filter by log level as described in [[BasicLoggerOptions.level]].
|
|
105
|
+
*
|
|
106
|
+
* To use the logger created by this function, put it into [[LDOptions.logger]]. If
|
|
107
|
+
* you do not set [[LDOptions.logger]] to anything, the SDK uses a default logger
|
|
108
|
+
* that is equivalent to `ld.basicLogger({ level: 'info' })`.
|
|
109
|
+
*
|
|
110
|
+
* @param options Configuration for the logger. If no options are specified, the
|
|
111
|
+
* logger uses `{ level: 'info' }`.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* This example shows how to use `basicLogger` in your SDK options to enable console
|
|
115
|
+
* logging only at `warn` and `error` levels.
|
|
116
|
+
* ```javascript
|
|
117
|
+
* const ldOptions = {
|
|
118
|
+
* logger: ld.basicLogger({ level: 'warn' }),
|
|
119
|
+
* };
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* This example shows how to use `basicLogger` in your SDK options to cause log
|
|
124
|
+
* output to go to `console.log` instead of `console.error`.
|
|
125
|
+
* ```javascript
|
|
126
|
+
* const ldOptions = {
|
|
127
|
+
* logger: ld.basicLogger({ destination: console.log }),
|
|
128
|
+
* };
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export function basicLogger(
|
|
132
|
+
options?: BasicLoggerOptions
|
|
133
|
+
): LDLogger;
|
|
91
134
|
}
|