From 3ca0a949e2cd571394873f1439ea3c4add7d796e Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 1 Oct 2026 11:47:05 -0700 Subject: [PATCH] fix(client): pass connectionId through instead of clientKey The CourierClient constructor set `connectionId: props.clientKey`, so a caller-supplied connectionId was dropped and the native client received the client key (or undefined under JWT auth) as its socket connection id. Adds tests covering connectionId passthrough and the undefined default. Co-Authored-By: Claude Opus 5.5 --- src/__tests__/courier-client.test.tsx | 24 ++++++++++++++++++++++++ src/client/CourierClient.tsx | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/__tests__/courier-client.test.tsx b/src/__tests__/courier-client.test.tsx index b6d8664..a76c189 100644 --- a/src/__tests__/courier-client.test.tsx +++ b/src/__tests__/courier-client.test.tsx @@ -57,6 +57,30 @@ describe('CourierClient', () => { expect(client.options.showLogs).toBe(true); }); + it('passes connectionId through to addClient', () => { + const client = new CourierClient({ + userId: 'u1', + clientKey: 'ck-1', + connectionId: 'conn-1', + showLogs: false, + }); + + expect(client.options.connectionId).toBe('conn-1'); + expect(Modules.Client.addClient).toHaveBeenCalledWith( + expect.objectContaining({ clientKey: 'ck-1', connectionId: 'conn-1' }) + ); + }); + + it('leaves connectionId undefined when not provided', () => { + const client = new CourierClient({ + userId: 'u1', + clientKey: 'ck-1', + showLogs: false, + }); + + expect(client.options.connectionId).toBeUndefined(); + }); + it('defaults showLogs when omitted', () => { const client = new CourierClient({ userId: 'u1' }); expect(typeof client.options.showLogs).toBe('boolean'); diff --git a/src/client/CourierClient.tsx b/src/client/CourierClient.tsx index 1661102..d3788b9 100644 --- a/src/client/CourierClient.tsx +++ b/src/client/CourierClient.tsx @@ -38,7 +38,7 @@ export class CourierClient extends ClientModule { showLogs: props.showLogs ?? __DEV__, jwt: props.jwt, clientKey: props.clientKey, - connectionId: props.clientKey, + connectionId: props.connectionId, tenantId: props.tenantId, apiUrls: props.apiUrls ? { ...props.apiUrls } : undefined, };