Skip to content

Commit 265726b

Browse files
LaunchDarklyReleaseBotkeelerm84LaunchDarklyReleaseBotkinyoklion
authored
prepare 3.3.0 release (#299)
## [3.3.0] - 2024-05-01 ### Added: - 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. ### Changed: - 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. ### Fixed: - Fixed the documentation for `evaluationReasons` for the `identify` method. --------- Co-authored-by: Matthew M. Keeler <[email protected]> Co-authored-by: LaunchDarklyReleaseBot <[email protected]> Co-authored-by: Ryan Lamb <[email protected]>
1 parent 1dd80b0 commit 265726b

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

example/example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ $(function() {
115115
client.on('change', function(allChanges) {
116116
showAllFlags(allChanges);
117117
});
118-
client.waitForInitialization().then(function() { showAllFlags(); });
118+
client.waitForInitialization(5).then(function() { showAllFlags(); });
119119
}
120120

121121
function identifyUser() {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
},
7878
"dependencies": {
7979
"escape-string-regexp": "^4.0.0",
80-
"launchdarkly-js-sdk-common": "5.1.0"
80+
"launchdarkly-js-sdk-common": "5.2.0"
8181
},
8282
"repository": {
8383
"type": "git",

src/__tests__/LDClient-events-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('LDClient', () => {
3333
const client = LDClient.initialize(envName, user, { eventProcessor: ep, bootstrap: {} });
3434
const data = { thing: 'stuff' };
3535

36-
await client.waitForInitialization();
36+
await client.waitForInitialization(5);
3737
client.track('eventkey', data);
3838

3939
expect(ep.events.length).toEqual(2);
@@ -52,7 +52,7 @@ describe('LDClient', () => {
5252
const client = LDClient.initialize(envName, user, { eventProcessor: ep, bootstrap: {} });
5353
const data = { thing: 'stuff' };
5454

55-
await client.waitForInitialization();
55+
await client.waitForInitialization(5);
5656
client.track('eventkey', data);
5757

5858
expect(ep.events.length).toEqual(0);
@@ -67,7 +67,7 @@ describe('LDClient', () => {
6767
bootstrap: {},
6868
eventUrlTransformer: (url) => url + suffix,
6969
});
70-
await client.waitForInitialization();
70+
await client.waitForInitialization(5);
7171
client.track('eventkey');
7272

7373
expect(ep.events.length).toEqual(2);

src/__tests__/LDClient-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ describe('LDClient', () => {
3737
describe('initialization', () => {
3838
it('should trigger the ready event', async () => {
3939
const client = LDClient.initialize(envName, user, { bootstrap: {}, sendEvents: false });
40-
await client.waitForInitialization();
40+
await client.waitForInitialization(5);
4141
});
4242

4343
it('should not fetch flag settings if bootstrap is provided, but should still fetch goals', async () => {
4444
const client = LDClient.initialize(envName, user, { bootstrap: {}, sendEvents: false });
45-
await client.waitForInitialization();
45+
await client.waitForInitialization(5);
4646
expect(server.requests.length).toEqual(1);
4747
expect(server.requests[0].url).toMatch(/sdk\/goals/);
4848
});
4949

5050
it('sends correct User-Agent in request', async () => {
5151
const client = LDClient.initialize(envName, user, { fetchGoals: false, sendEvents: false });
52-
await client.waitForInitialization();
52+
await client.waitForInitialization(5);
5353

5454
expect(server.requests.length).toEqual(1);
5555
expect(server.requests[0].requestHeaders['X-LaunchDarkly-User-Agent']).toMatch(/^JSClient\//);
@@ -61,7 +61,7 @@ describe('LDClient', () => {
6161
async function setupClient() {
6262
const config = { bootstrap: {}, flushInterval: 100000, fetchGoals: false, sendEvents: false };
6363
const client = LDClient.initialize(envName, user, config);
64-
await client.waitForInitialization();
64+
await client.waitForInitialization(5);
6565
return client;
6666
}
6767
function testWithUserAgent(desc, ua) {
@@ -91,7 +91,7 @@ describe('LDClient', () => {
9191
describe('goals', () => {
9292
it('fetches goals if fetchGoals is unspecified', async () => {
9393
const client = LDClient.initialize(envName, user, { sendEvents: false });
94-
await client.waitForInitialization();
94+
await client.waitForInitialization(5);
9595
expect(server.requests.length).toEqual(2);
9696
// The following line uses arrayContaining because we can't be sure whether the goals request will
9797
// be made before or after the flags request.
@@ -102,7 +102,7 @@ describe('LDClient', () => {
102102

103103
it('fetches goals if fetchGoals is true', async () => {
104104
const client = LDClient.initialize(envName, user, { fetchGoals: true, sendEvents: false });
105-
await client.waitForInitialization();
105+
await client.waitForInitialization(5);
106106
expect(server.requests.length).toEqual(2);
107107
expect(server.requests).toEqual(
108108
expect.arrayContaining([expect.objectContaining({ url: expect.stringMatching(/sdk\/goals/) })])
@@ -111,7 +111,7 @@ describe('LDClient', () => {
111111

112112
it('does not fetch goals if fetchGoals is false', async () => {
113113
const client = LDClient.initialize(envName, user, { fetchGoals: false, sendEvents: false });
114-
await client.waitForInitialization();
114+
await client.waitForInitialization(5);
115115
expect(server.requests.length).toEqual(1);
116116
expect(server.requests[0].url).toMatch(/sdk\/eval/);
117117
});
@@ -139,7 +139,7 @@ describe('LDClient', () => {
139139
server.respondWith([200, { 'Content-Type': 'application/json' }, '[{"key": "known", "kind": "custom"}]']);
140140

141141
const client = LDClient.initialize(envName, user, { bootstrap: {}, sendEvents: false });
142-
await client.waitForInitialization();
142+
await client.waitForInitialization(5);
143143
await client.waitUntilGoalsReady();
144144

145145
client.track('known');
@@ -151,7 +151,7 @@ describe('LDClient', () => {
151151
server.respondWith([200, { 'Content-Type': 'application/json' }, '[{"key": "known", "kind": "custom"}]']);
152152

153153
const client = LDClient.initialize(envName, user, { bootstrap: {}, sendEvents: false });
154-
await client.waitForInitialization();
154+
await client.waitForInitialization(5);
155155
await client.waitUntilGoalsReady();
156156

157157
client.track('unknown');
@@ -164,7 +164,7 @@ describe('LDClient', () => {
164164
it('normally uses asynchronous XHR', async () => {
165165
const config = { bootstrap: {}, flushInterval: 100000, fetchGoals: false, diagnosticOptOut: true };
166166
const client = LDClient.initialize(envName, user, config);
167-
await client.waitForInitialization();
167+
await client.waitForInitialization(5);
168168

169169
await client.flush();
170170

@@ -175,7 +175,7 @@ describe('LDClient', () => {
175175
async function setupClientAndTriggerPageHide() {
176176
const config = { bootstrap: {}, flushInterval: 100000, fetchGoals: false, diagnosticOptOut: true };
177177
const client = LDClient.initialize(envName, user, config);
178-
await client.waitForInitialization();
178+
await client.waitForInitialization(5);
179179

180180
Object.defineProperty(document, 'visibilityState', {
181181
configurable: true,

test-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const multiKindContext: ld.LDContext = {
8484
const client: ld.LDClient = ld.initialize('env', user, allOptions);
8585

8686
client.waitUntilReady().then(() => {});
87-
client.waitForInitialization().then(() => {});
87+
client.waitForInitialization(5).then(() => {});
8888
client.waitUntilGoalsReady().then(() => {});
8989

9090
client.identify(user).then(() => {});

0 commit comments

Comments
 (0)