Skip to content

Commit 51c47b1

Browse files
committed
chore: reverting sheddable defaults
1 parent af00d4f commit 51c47b1

4 files changed

Lines changed: 23 additions & 28 deletions

File tree

packages/sdk/browser/src/BrowserClient.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ class BrowserClientImpl extends LDClientImpl {
238238
context: LDContext,
239239
identifyOptions?: LDIdentifyOptions,
240240
): Promise<LDIdentifyResult> {
241-
const res = await super.identifyResult(context, identifyOptions);
241+
const options =
242+
identifyOptions?.sheddable === undefined
243+
? { ...identifyOptions, sheddable: true }
244+
: identifyOptions;
245+
const res = await super.identifyResult(context, options);
242246
// Ensure that we do not start the goal manager if start() is not called.
243247
if (this.startPromise) {
244248
this._goalManager?.startTracking();

packages/sdk/electron/src/ElectronClient.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
LDFlagValue,
1818
LDHeaders,
1919
LDIdentifyOptions,
20+
LDIdentifyResult,
2021
LDPluginEnvironmentMetadata,
2122
LDWaitForInitializationOptions,
2223
LDWaitForInitializationResult,
@@ -136,6 +137,17 @@ export class ElectronClient extends LDClientImpl {
136137
internal.safeRegisterPlugins(this.logger, this.environmentMetadata, client, this._plugins);
137138
}
138139

140+
override async identifyResult(
141+
context: LDContext,
142+
identifyOptions?: LDIdentifyOptions,
143+
): Promise<LDIdentifyResult> {
144+
const options =
145+
identifyOptions?.sheddable === undefined
146+
? { ...identifyOptions, sheddable: true }
147+
: identifyOptions;
148+
return super.identifyResult(context, options);
149+
}
150+
139151
async setConnectionMode(mode: ConnectionMode): Promise<void> {
140152
if (mode === 'offline') {
141153
this.setEventSendingEnabled(false, true);

packages/shared/sdk-client/__tests__/LDClientImpl.start.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ describe('LDClientImpl.start()', () => {
275275
expect(result.status).toBe('completed');
276276
});
277277

278-
it('defaults sheddable to true for post-start identifies when requiresStart is true', async () => {
278+
it('defaults sheddable to false for identifies in the base class', async () => {
279279
const mockPlatform = setupStreamingPlatform();
280280
const { ldc } = setupClient(mockPlatform, { requiresStart: true, initialContext: context });
281281

@@ -292,21 +292,6 @@ describe('LDClientImpl.start()', () => {
292292
]);
293293

294294
expect(startResult.status).toBe('complete');
295-
expect(result1.status).toBe('shed');
296-
expect(result2.status).toBe('shed');
297-
expect(result3.status).toBe('completed');
298-
});
299-
300-
it('does not default sheddable when requiresStart is false', async () => {
301-
const mockPlatform = setupStreamingPlatform();
302-
const { ldc } = setupClient(mockPlatform, { requiresStart: false });
303-
304-
const promise1 = ldc.identifyResult({ kind: 'user', key: 'user-1' });
305-
const promise2 = ldc.identifyResult({ kind: 'user', key: 'user-2' });
306-
const promise3 = ldc.identifyResult({ kind: 'user', key: 'user-3' });
307-
308-
const [result1, result2, result3] = await Promise.all([promise1, promise2, promise3]);
309-
310295
expect(result1.status).toBe('completed');
311296
expect(result2.status).toBe('completed');
312297
expect(result3.status).toBe('completed');

packages/shared/sdk-client/src/LDClientImpl.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,8 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
381381
return { status: 'error', error: new Error('Identify called before start') };
382382
}
383383

384-
let effectiveOptions = identifyOptions;
385-
if (this._requiresStart && identifyOptions?.sheddable === undefined) {
386-
effectiveOptions = { ...identifyOptions, sheddable: true };
387-
}
388-
389-
const identifyTimeout = effectiveOptions?.timeout ?? DEFAULT_IDENTIFY_TIMEOUT_SECONDS;
390-
const noTimeout =
391-
effectiveOptions?.timeout === undefined && effectiveOptions?.noTimeout === true;
384+
const identifyTimeout = identifyOptions?.timeout ?? DEFAULT_IDENTIFY_TIMEOUT_SECONDS;
385+
const noTimeout = identifyOptions?.timeout === undefined && identifyOptions?.noTimeout === true;
392386

393387
// When noTimeout is specified, and a timeout is not specified, then this condition cannot
394388
// be encountered. (Our default would need to be greater)
@@ -410,7 +404,7 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
410404
}
411405
const checkedContext = Context.fromLDContext(context);
412406
if (checkedContext.valid) {
413-
const afterIdentify = this._hookRunner.identify(context, effectiveOptions?.timeout);
407+
const afterIdentify = this._hookRunner.identify(context, identifyOptions?.timeout);
414408
return {
415409
context,
416410
checkedContext,
@@ -443,7 +437,7 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
443437
identifyResolve,
444438
identifyReject,
445439
checkedContext,
446-
effectiveOptions,
440+
identifyOptions,
447441
);
448442

449443
return identifyPromise;
@@ -458,7 +452,7 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
458452
}
459453
},
460454
},
461-
effectiveOptions?.sheddable ?? false,
455+
identifyOptions?.sheddable ?? false,
462456
)
463457
.then((res) => {
464458
if (res.status === 'error') {

0 commit comments

Comments
 (0)