launchdarkly-node-client-sdk 2.2.1 → 3.0.0

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.
@@ -4,6 +4,11 @@ repo:
4
4
  public: node-client-sdk
5
5
  private: node-client-sdk-private
6
6
 
7
+ branches:
8
+ - name: main
9
+ description: 3.x
10
+ - name: 2.x
11
+
7
12
  publications:
8
13
  - url: https://www.npmjs.com/package/launchdarkly-node-client-sdk
9
14
  description: npm
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
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.2.2] - 2022-12-19
6
+ ### Fixed:
7
+ - Upgraded to `js-sdk-common` version `4.3.3` which fixed this [issue](https://github.com/launchdarkly/js-sdk-common/issues/84): Warning: Accessing non-existent property 'messages' of module exports inside circular dependency
8
+
9
+ ## [2.2.1] - 2022-10-21
10
+ ### Changed:
11
+ - Upgraded to `js-sdk-common` version `4.3.2` which includes implementations of `jitter` and `backoff` for streaming connections. When a connection fails the retry will start at the `streamReconnectDelay` and will double on each unsuccessful consecutive connection attempt (`backoff`) to a max of 30 seconds. The delay will be adjusted from 50%-100% of the calculated delay to prevent many clients from attempting to reconnect at the same time (`jitter`).
12
+
5
13
  ## [2.2.0] - 2022-10-18
6
14
  ### Changed:
7
15
  - Upgrade to `js-sdk-common` `4.3.1` which added support for `Inspectors` that can be used for collecting information for monitoring, analytics, and debugging.
@@ -22,7 +22,8 @@ app.get('/', (req, res) => {
22
22
  capabilities: [
23
23
  'client-side',
24
24
  'service-endpoints',
25
- 'tags'
25
+ 'tags',
26
+ 'user-type',
26
27
  ],
27
28
  });
28
29
  });
@@ -16,7 +16,8 @@ function makeSdkConfig(options, tag) {
16
16
  autoAliasingOptOut: options.clientSide.autoAliasingOptOut,
17
17
  evaluationReasons: options.clientSide.evaluationReasons,
18
18
  logger: sdkLogger(tag),
19
- useReport: options.clientSide.useReport
19
+ useReport: options.clientSide.useReport,
20
+ sendEventsOnlyForVariation: true,
20
21
  };
21
22
 
22
23
  if (options.serviceEndpoints) {
@@ -47,8 +48,7 @@ function makeSdkConfig(options, tag) {
47
48
  cf.eventCapacity = options.events.capacity;
48
49
  cf.diagnosticOptOut = !options.events.enableDiagnostics;
49
50
  cf.flushInterval = maybeTime(options.events.flushIntervalMs);
50
- cf.inlineUsersInEvents = options.events.inlineUsers;
51
- cf.privateAttributeNames = options.events.globalPrivateAttributes;
51
+ cf.privateAttributes = options.events.globalPrivateAttributes;
52
52
  } else {
53
53
  cf.sendEvents = false;
54
54
  }
@@ -63,8 +63,8 @@ function makeSdkConfig(options, tag) {
63
63
  return cf;
64
64
  }
65
65
 
66
- function makeDefaultInitialUser() {
67
- return {key: 'key-not-specified'};
66
+ function makeDefaultInitialContext() {
67
+ return {kind: 'user', key: 'key-not-specified'};
68
68
  }
69
69
 
70
70
  async function newSdkClientEntity(options) {
@@ -78,11 +78,12 @@ async function newSdkClientEntity(options) {
78
78
  ? options.configuration.startWaitTimeMs
79
79
  : 5000;
80
80
  const sdkConfig = makeSdkConfig(options.configuration, options.tag);
81
- const initialUser = (options.configuration.clientSide && options.configuration.clientSide.initialUser)
82
- || makeDefaultInitialUser();
81
+ const initialContext = options.configuration.clientSide?.initialUser ||
82
+ options.configuration.clientSide?.initialContext ||
83
+ makeDefaultInitialContext();
83
84
  const client = ld.initialize(
84
85
  options.configuration.credential || 'unknown-env-id',
85
- initialUser,
86
+ initialContext,
86
87
  sdkConfig
87
88
  );
88
89
  let failed = false;
@@ -119,7 +120,7 @@ async function newSdkClientEntity(options) {
119
120
  return { state: client.allFlags() };
120
121
 
121
122
  case 'identifyEvent':
122
- await client.identify(params.identifyEvent.user);
123
+ await client.identify(params.identifyEvent.user || params.identifyEvent.context);
123
124
  return undefined;
124
125
 
125
126
  case 'customEvent': {
@@ -128,10 +129,6 @@ async function newSdkClientEntity(options) {
128
129
  return undefined;
129
130
  }
130
131
 
131
- case 'aliasEvent':
132
- client.alias(params.aliasEvent.user, params.aliasEvent.previousUser);
133
- return undefined;
134
-
135
132
  case 'flushEvents':
136
133
  client.flush();
137
134
  return undefined;
package/docs/Makefile CHANGED
@@ -15,13 +15,8 @@
15
15
 
16
16
  html: prepare
17
17
  ../node_modules/.bin/typedoc --options typedoc.js
18
- mv before-typedoc-package.json ../package.json
19
- mv before-typedoc-package-lock.json ../package-lock.json
20
18
 
21
19
  prepare:
22
- cp ../package.json before-typedoc-package.json
23
- cp ../package-lock.json before-typedoc-package-lock.json
24
- cd .. && npm install "typedoc@<0.20.0"
25
20
  rm -rf build
26
21
  mkdir build
27
22
  @# Extract the whole module declaration from launchdarkly-js-sdk-common, then remove the first and last lines
package/docs/doc.md ADDED
@@ -0,0 +1,7 @@
1
+ This is the API reference for the LaunchDarkly Client-Side Node SDK.
2
+
3
+ In typical usage, you will call [[initialize]] in the main process at startup time to obtain an
4
+ an instance of [[LDClient]].
5
+
6
+ For more information, see the [SDK reference guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
7
+
package/docs/typedoc.js CHANGED
@@ -1,3 +1,6 @@
1
+ // Note that the format of this file is barely documented on the TypeDoc site. In general,
2
+ // the properties are equivalent to the command-line options described here:
3
+ // https://typedoc.org/api/
1
4
 
2
5
  let version = process.env.VERSION;
3
6
  if (!version) {
@@ -8,8 +11,7 @@ if (!version) {
8
11
  module.exports = {
9
12
  out: './build/html',
10
13
  name: 'LaunchDarkly Client-Side Node SDK (' + version + ')',
11
- readme: 'none', // don't add a home page with a copy of README.md
12
- mode: 'file', // don't treat "typings.d.ts" itself as a parent module
13
- includeDeclarations: true, // allows it to process a .d.ts file instead of actual TS code
14
- entryPoint: '"launchdarkly-node-client-sdk"' // note extra quotes - workaround for a TypeDoc bug
14
+ readme: 'doc.md',
15
+ entryPointStrategy: 'resolve', // Allows us to specify the specific entrypoints.
16
+ entryPoints: ["./build/typings.d.ts"] // This is the updated version created by the makefile.
15
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launchdarkly-node-client-sdk",
3
- "version": "2.2.1",
3
+ "version": "3.0.0",
4
4
  "description": "LaunchDarkly Client-Side SDK for Node.js",
5
5
  "author": "LaunchDarkly <team@launchdarkly.com>",
6
6
  "license": "Apache-2.0",
@@ -17,7 +17,7 @@
17
17
  "test": "jest --ci",
18
18
  "check-typescript": "node_modules/typescript/bin/tsc",
19
19
  "contract-test-service": "npm --prefix contract-tests install && npm --prefix contract-tests start",
20
- "contract-test-harness": "curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/main/downloader/run.sh \\ | VERSION=v1 PARAMS=\"-url http://localhost:8000 -debug -stop-service-at-end $TEST_HARNESS_PARAMS\" sh",
20
+ "contract-test-harness": "curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/main/downloader/run.sh \\ | VERSION=v2 PARAMS=\"-url http://localhost:8000 -debug -stop-service-at-end $TEST_HARNESS_PARAMS\" sh",
21
21
  "contract-tests": "npm run contract-test-service & npm run contract-test-harness"
22
22
  },
23
23
  "engines": {
@@ -40,7 +40,8 @@
40
40
  "jest-junit": "^14.0.1",
41
41
  "launchdarkly-js-test-helpers": "1.2.1",
42
42
  "prettier": "2.7.1",
43
- "typescript": "^4.8.4"
43
+ "typescript": "^4.8.4",
44
+ "typedoc": "^0.23.24"
44
45
  },
45
46
  "jest": {
46
47
  "rootDir": "src",
@@ -64,7 +65,7 @@
64
65
  },
65
66
  "dependencies": {
66
67
  "launchdarkly-eventsource": "1.4.3",
67
- "launchdarkly-js-sdk-common": "4.3.2",
68
+ "launchdarkly-js-sdk-common": "5.0.1",
68
69
  "node-localstorage": "^1.3.1"
69
70
  },
70
71
  "repository": {
@@ -4,7 +4,7 @@ const { TestHttpHandlers, TestHttpServers, sleepAsync, withCloseable } = require
4
4
 
5
5
  describe('LDClient', () => {
6
6
  const envName = 'UNKNOWN_ENVIRONMENT_ID';
7
- const user = { key: 'user' };
7
+ const context = { key: 'user' };
8
8
 
9
9
  // Event generation in general is tested in a non-platform-specific way in launchdarkly-js-sdk-common.
10
10
  // The following tests just demonstrate that the common client calls our platform object when it
@@ -15,7 +15,7 @@ describe('LDClient', () => {
15
15
  it('sends an event for track()', async () => {
16
16
  await withCloseable(TestHttpServers.start, async server => {
17
17
  const config = { bootstrap: {}, eventsUrl: server.url, diagnosticOptOut: true };
18
- const client = LDClient.initialize(envName, user, config);
18
+ const client = LDClient.initialize(envName, context, config);
19
19
  await withCloseable(client, async () => {
20
20
  const data = { thing: 'stuff' };
21
21
  await client.waitForInitialization();
@@ -30,7 +30,7 @@ describe('LDClient', () => {
30
30
  const trackEvent = events[1];
31
31
  expect(trackEvent.kind).toEqual('custom');
32
32
  expect(trackEvent.key).toEqual('eventkey');
33
- expect(trackEvent.userKey).toEqual(user.key);
33
+ expect(trackEvent.contextKeys).toEqual({ user: 'user' });
34
34
  expect(trackEvent.data).toEqual(data);
35
35
  expect(trackEvent.url).toEqual(null);
36
36
  });
@@ -65,7 +65,7 @@ describe('LDClient', () => {
65
65
  await withCloseable(TestHttpServers.start, async server => {
66
66
  server.byDefault(TestHttpHandlers.respond(202));
67
67
  const config = { bootstrap: {}, eventsUrl: server.url };
68
- const client = LDClient.initialize(envName, user, config);
68
+ const client = LDClient.initialize(envName, context, config);
69
69
  await withCloseable(client, async () => {
70
70
  const data = await expectDiagnosticEventAndDiscardRegularEvent(server);
71
71
  expect(data.kind).toEqual('diagnostic-init');
@@ -15,9 +15,9 @@ const {
15
15
 
16
16
  describe('LDClient streaming', () => {
17
17
  const envName = 'UNKNOWN_ENVIRONMENT_ID';
18
- const user = { key: 'user' };
19
- const encodedUser = 'eyJrZXkiOiJ1c2VyIn0';
20
- const expectedGetUrl = '/eval/' + envName + '/' + encodedUser;
18
+ const context = { key: 'user' };
19
+ const encodedContext = 'eyJrZXkiOiJ1c2VyIn0';
20
+ const expectedGetUrl = '/eval/' + envName + '/' + encodedContext;
21
21
  const expectedReportUrl = '/eval/' + envName;
22
22
 
23
23
  it('makes GET request and receives an event', async () => {
@@ -34,7 +34,7 @@ describe('LDClient streaming', () => {
34
34
  streamUrl: server.url,
35
35
  sendEvents: false,
36
36
  };
37
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
37
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
38
38
  const changeEvents = eventSink(client, 'change:flag');
39
39
  await client.waitForInitialization();
40
40
 
@@ -62,7 +62,7 @@ describe('LDClient streaming', () => {
62
62
  sendEvents: false,
63
63
  useReport: true,
64
64
  };
65
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
65
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
66
66
  const changeEvents = eventSink(client, 'change:flag');
67
67
  await client.waitForInitialization();
68
68
 
@@ -71,7 +71,7 @@ describe('LDClient streaming', () => {
71
71
 
72
72
  expect(server.requestCount()).toEqual(1);
73
73
  const req = await server.nextRequest();
74
- expect(req.body).toEqual(JSON.stringify(user));
74
+ expect(req.body).toEqual(JSON.stringify(context));
75
75
  });
76
76
  });
77
77
  });
@@ -5,7 +5,7 @@ const { TestHttpHandlers, TestHttpServers, withCloseable } = require('launchdark
5
5
 
6
6
  describe('LDClient', () => {
7
7
  const envName = 'UNKNOWN_ENVIRONMENT_ID';
8
- const user = { key: 'user' };
8
+ const context = { key: 'user' };
9
9
 
10
10
  it('should exist', () => {
11
11
  expect(LDClient).toBeDefined();
@@ -20,7 +20,7 @@ describe('LDClient', () => {
20
20
  await withCloseable(TestHttpServers.start, async server => {
21
21
  server.byDefault(TestHttpHandlers.respondJson({}));
22
22
  const config = { baseUrl: server.url, sendEvents: false };
23
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
23
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
24
24
  await client.waitForInitialization();
25
25
  });
26
26
  });
@@ -30,7 +30,7 @@ describe('LDClient', () => {
30
30
  await withCloseable(TestHttpServers.start, async server => {
31
31
  server.byDefault(TestHttpHandlers.respondJson({}));
32
32
  const config = { baseUrl: server.url, sendEvents: false };
33
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
33
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
34
34
  await client.waitForInitialization();
35
35
 
36
36
  expect(server.requestCount()).toEqual(1);
@@ -50,7 +50,7 @@ describe('LDClient', () => {
50
50
  error: jest.fn(),
51
51
  };
52
52
  const config = { bootstrap: {}, sendEvents: false, logger: logger };
53
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
53
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
54
54
  await client.waitForInitialization();
55
55
 
56
56
  client.track('whatever');
@@ -17,10 +17,10 @@ const stubLogger = {
17
17
 
18
18
  describe('LDClient TLS configuration', () => {
19
19
  const envName = 'UNKNOWN_ENVIRONMENT_ID';
20
- const user = { key: 'user' };
21
- const encodedUser = 'eyJrZXkiOiJ1c2VyIn0';
22
- const expectedPollingUrl = '/sdk/evalx/' + envName + '/users/' + encodedUser;
23
- const expectedStreamingUrl = '/eval/' + envName + '/' + encodedUser;
20
+ const context = { key: 'user' };
21
+ const encodedContext = 'eyJrZXkiOiJ1c2VyIn0';
22
+ const expectedPollingUrl = '/sdk/evalx/' + envName + '/contexts/' + encodedContext;
23
+ const expectedStreamingUrl = '/eval/' + envName + '/' + encodedContext;
24
24
 
25
25
  it('can connect via HTTPS to a server with a self-signed certificate, if CA is specified', async () => {
26
26
  await withCloseable(TestHttpServers.startSecure, async server => {
@@ -31,7 +31,7 @@ describe('LDClient TLS configuration', () => {
31
31
  tlsParams: { ca: server.certificate },
32
32
  diagnosticOptOut: true,
33
33
  };
34
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
34
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
35
35
  await client.waitForInitialization();
36
36
  });
37
37
  });
@@ -46,7 +46,7 @@ describe('LDClient TLS configuration', () => {
46
46
  logger: stubLogger,
47
47
  diagnosticOptOut: true,
48
48
  };
49
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
49
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
50
50
  await expect(client.waitForInitialization()).rejects.toThrow(/network error.*self[- ]signed/);
51
51
  });
52
52
  });
@@ -68,7 +68,7 @@ describe('LDClient TLS configuration', () => {
68
68
  tlsParams: { ca: server.certificate },
69
69
  diagnosticOptOut: true,
70
70
  };
71
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
71
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
72
72
  const changeEvents = eventSink(client, 'change:flag');
73
73
 
74
74
  await client.waitForInitialization();
@@ -91,7 +91,7 @@ describe('LDClient TLS configuration', () => {
91
91
  tlsParams: { ca: server.certificate },
92
92
  diagnosticOptOut: true,
93
93
  };
94
- await withCloseable(LDClient.initialize(envName, user, config), async client => {
94
+ await withCloseable(LDClient.initialize(envName, context, config), async client => {
95
95
  await client.waitForInitialization();
96
96
  await client.flush();
97
97
 
package/src/index.js CHANGED
@@ -4,7 +4,7 @@ const nodePlatform = require('./nodePlatform');
4
4
  const packageJson = require('../package.json');
5
5
 
6
6
  // This creates a client-side SDK instance to be used in Node.
7
- function initialize(env, user, options = {}) {
7
+ function initialize(env, context, options = {}) {
8
8
  // Pass our platform object to the common code to create the Node version of the client
9
9
  const platform = nodePlatform(options);
10
10
  const extraOptionDefs = {
@@ -14,7 +14,7 @@ function initialize(env, user, options = {}) {
14
14
  if (!options.logger) {
15
15
  extraOptionDefs.logger = { default: basicLogger() };
16
16
  }
17
- const clientVars = common.initialize(env, user, options, platform, extraOptionDefs);
17
+ const clientVars = common.initialize(env, context, options, platform, extraOptionDefs);
18
18
 
19
19
  clientVars.start();
20
20
 
package/test-types.ts CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  import * as ld from 'launchdarkly-node-client-sdk';
6
6
 
7
- var ver: string = ld.version;
7
+ const ver: string = ld.version;
8
8
 
9
- var emptyOptions: ld.LDOptions = {};
10
- var logger: ld.LDLogger = ld.basicLogger({ level: 'info' });
11
- var allOptions: ld.LDOptions = {
9
+ const emptyOptions: ld.LDOptions = {};
10
+ const logger: ld.LDLogger = ld.basicLogger({ level: 'info' });
11
+ const allOptions: ld.LDOptions = {
12
12
  bootstrap: { },
13
13
  baseUrl: '',
14
14
  eventsUrl: '',
@@ -19,18 +19,16 @@ var allOptions: ld.LDOptions = {
19
19
  evaluationReasons: true,
20
20
  sendEvents: true,
21
21
  allAttributesPrivate: true,
22
- privateAttributeNames: [ 'x' ],
23
- inlineUsersInEvents: true,
24
- allowFrequentDuplicateEvents: true,
22
+ privateAttributes: [ 'x' ],
25
23
  sendEventsOnlyForVariation: true,
26
24
  flushInterval: 1,
27
25
  streamReconnectDelay: 1,
28
- logger: logger,
29
- autoAliasingOptOut: true
26
+ logger: logger
30
27
  };
31
- var userWithKeyOnly: ld.LDUser = { key: 'user' };
32
- var anonymousUser: ld.LDUser = { key: 'anon-user', anonymous: true };
33
- var user: ld.LDUser = {
28
+ const userWithKeyOnly: ld.LDUser = { key: 'user' };
29
+ const contextWithKey: ld.LDContext = {kind: 'user', key: 'user-key'};
30
+ const anonymousUser: ld.LDUser = { key: 'anon-user', anonymous: true };
31
+ const user: ld.LDUser = {
34
32
  key: 'user',
35
33
  name: 'name',
36
34
  firstName: 'first',
@@ -50,7 +48,31 @@ var user: ld.LDUser = {
50
48
  },
51
49
  privateAttributeNames: [ 'name', 'email' ]
52
50
  };
53
- var client: ld.LDClient = ld.initialize('env', user, allOptions);
51
+
52
+ const singleContext: ld.LDContext = {
53
+ kind: 'user',
54
+ key: 'user',
55
+ name: 'name',
56
+ firstName: 'first',
57
+ lastName: 'last',
58
+ email: 'test@example.com',
59
+ avatar: 'http://avatar.url',
60
+ ip: '1.1.1.1',
61
+ country: 'us',
62
+ anonymous: true,
63
+ _meta: {
64
+ privateAttributes: ['country']
65
+ }
66
+ };
67
+
68
+ const multiContext: ld.LDContext = {
69
+ kind: 'multi',
70
+ user: { key: 'user-key' },
71
+ org: { key: 'org-key' }
72
+ };
73
+
74
+
75
+ const client: ld.LDClient = ld.initialize('env', user, allOptions);
54
76
 
55
77
  client.waitUntilReady().then(() => {});
56
78
  client.waitForInitialization().then(() => {});
@@ -59,21 +81,32 @@ client.identify(user).then(() => {});
59
81
  client.identify(user, undefined, () => {});
60
82
  client.identify(user, 'hash').then(() => {});
61
83
 
62
- client.alias(user, anonymousUser);
84
+ client.identify(contextWithKey).then(() => {});
85
+ client.identify(contextWithKey, undefined, () => {});
86
+ client.identify(contextWithKey, 'hash').then(() => {});
87
+
88
+ client.identify(singleContext).then(() => {});
89
+ client.identify(singleContext, undefined, () => {});
90
+ client.identify(singleContext, 'hash').then(() => {});
91
+
92
+ client.identify(multiContext).then(() => {});
93
+ client.identify(multiContext, undefined, () => {});
94
+ client.identify(multiContext, 'hash').then(() => {});
95
+
63
96
 
64
- var user: ld.LDUser = client.getUser();
97
+ const context: ld.LDContext = client.getContext();
65
98
 
66
99
  client.flush(() => {});
67
100
  client.flush().then(() => {});
68
101
 
69
- var boolFlagValue: ld.LDFlagValue = client.variation('key', false);
70
- var numberFlagValue: ld.LDFlagValue = client.variation('key', 2);
71
- var stringFlagValue: ld.LDFlagValue = client.variation('key', 'default');
102
+ const boolFlagValue: ld.LDFlagValue = client.variation('key', false);
103
+ const numberFlagValue: ld.LDFlagValue = client.variation('key', 2);
104
+ const stringFlagValue: ld.LDFlagValue = client.variation('key', 'default');
72
105
 
73
- var detail: ld.LDEvaluationDetail = client.variationDetail('key', 'default');
74
- var detailValue: ld.LDFlagValue = detail.value;
75
- var detailIndex: number | undefined = detail.variationIndex;
76
- var detailReason: ld.LDEvaluationReason | undefined = detail.reason;
106
+ const detail: ld.LDEvaluationDetail = client.variationDetail('key', 'default');
107
+ const detailValue: ld.LDFlagValue = detail.value;
108
+ const detailIndex: number | undefined = detail.variationIndex;
109
+ const detailReason: ld.LDEvaluationReason | undefined = detail.reason;
77
110
 
78
111
  client.setStreaming(true);
79
112
  client.setStreaming();
@@ -86,8 +119,8 @@ client.track('event');
86
119
  client.track('event', { someData: 'x' });
87
120
  client.track('event', null, 3.5);
88
121
 
89
- var flagSet: ld.LDFlagSet = client.allFlags();
90
- var flagSetValue: ld.LDFlagValue = flagSet['key'];
122
+ const flagSet: ld.LDFlagSet = client.allFlags();
123
+ const flagSetValue: ld.LDFlagValue = flagSet['key'];
91
124
 
92
125
  client.close(() => {});
93
126
  client.close().then(() => {});
package/typings.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- /**
2
- * This is the API reference for the LaunchDarkly Client-Side Node SDK.
3
- *
4
- * In typical usage, you will call [[initialize]] in the main process at startup time to obtain an
5
- * an instance of [[LDClient]].
6
- *
7
- * For more information, see the [SDK reference guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
8
- */
9
1
  declare module 'launchdarkly-node-client-sdk' {
10
2
 
11
3
  //// DOCBUILD-START-REPLACE (see docs/Makefile)
@@ -20,7 +12,7 @@ declare module 'launchdarkly-node-client-sdk' {
20
12
  LDClientBase,
21
13
  LDLogger,
22
14
  LDOptionsBase,
23
- LDUser
15
+ LDContext
24
16
  } from 'launchdarkly-js-sdk-common';
25
17
  //// DOCBUILD-END-REPLACE
26
18
 
@@ -39,22 +31,22 @@ declare module 'launchdarkly-node-client-sdk' {
39
31
  *
40
32
  * @param envKey
41
33
  * The LaunchDarkly environment ID.
42
- * @param user
43
- * The initial user properties. These can be changed later with [[LDClient.identify]].
44
- * The user must have a `key` property, except that if you omit `user.key` and set `user.anonymous` to
34
+ * @param context
35
+ * The initial context properties. These can be changed later with [[LDClient.identify]].
36
+ * The context must have a `key` property, except that if you omit `context.key` and set `context.anonymous` to
45
37
  * true, the SDK will create a randomized unique key (which will be cached in local storage for the
46
38
  * current OS user account, so the next initialization will reuse the same key).
47
39
  * @param options
48
40
  * Optional configuration settings.
49
41
  */
50
- export function initialize(envKey: string, user: LDUser, options?: LDOptions): LDClient;
42
+ export function initialize(envKey: string, context: LDContext, options?: LDOptions): LDClient;
51
43
 
52
44
  /**
53
45
  * Initialization options for the LaunchDarkly client.
54
46
  */
55
47
  export interface LDOptions extends LDOptionsBase {
56
48
  /**
57
- * Determines where flag values and anonymous user keys are cached in the filesystem. By
49
+ * Determines where flag values and anonymous context keys are cached in the filesystem. By
58
50
  * default, this is the current directory.
59
51
  */
60
52
  localStoragePath?: string;