diff --git a/src/sdkClient/client.ts b/src/sdkClient/client.ts index a572047e..5b0b7de2 100644 --- a/src/sdkClient/client.ts +++ b/src/sdkClient/client.ts @@ -123,6 +123,7 @@ export function clientFactory(params: IClientFactoryParams): SplitIO.IClient | S getTreatmentWithConfig, getTreatments, getTreatmentsWithConfig, - track + track, + isBrowserClient: false } as SplitIO.IClient | SplitIO.IAsyncClient; } diff --git a/src/sdkClient/clientCS.ts b/src/sdkClient/clientCS.ts index 8cf0d6a2..16648bc6 100644 --- a/src/sdkClient/clientCS.ts +++ b/src/sdkClient/clientCS.ts @@ -23,6 +23,8 @@ export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: Sp getTreatmentsWithConfig: clientCS.getTreatmentsWithConfig.bind(clientCS, key), // Key is bound to the `track` method. Same thing happens with trafficType but only if provided - track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key) + track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key), + + isBrowserClient: true }) as SplitIO.ICsClient; } diff --git a/src/services/splitHttpClient.ts b/src/services/splitHttpClient.ts index ee031149..d9ec90f7 100644 --- a/src/services/splitHttpClient.ts +++ b/src/services/splitHttpClient.ts @@ -49,7 +49,7 @@ export function splitHttpClientFactory(settings: Pick { - const resp = error.response; + const resp = error && error.response; let msg = ''; if (resp) { // An HTTP error diff --git a/src/types.ts b/src/types.ts index 9a94dd45..46451a60 100644 --- a/src/types.ts +++ b/src/types.ts @@ -381,6 +381,10 @@ interface IBasicClient extends IStatusInterface { * @returns {Promise} */ destroy(): Promise + + // Whether the client implements the client-side API, i.e, with bound key, (true), or the server-side API (false). + // Exposed for internal purposes only. Not considered part of the public API, and might be renamed eventually. + isBrowserClient: boolean } /** * Common definitions between SDK instances for different environments interface. @@ -1139,7 +1143,7 @@ export namespace SplitIO { /** * Removes from client's in memory attributes storage the attribute with the given key * @function removeAttribute - * @param {string} attributeName + * @param {string} attributeName * @returns {boolean} true if attribute was removed and false otherways */ removeAttribute(attributeName: string): boolean,