Skip to content

Commit c7a4af8

Browse files
committed
chore: deprecate useSDKEvaluation and warn when enabled
1 parent 5b5abee commit c7a4af8

3 files changed

Lines changed: 53 additions & 2 deletions

File tree

packages/sdks/javascript/src/lib/Ninetailed.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { waitFor } from '@testing-library/dom';
22
import {
33
FEATURES,
44
NinetailedApiClient,
5+
logger,
56
} from '@ninetailed/experience.js-shared';
67
import {
78
ElementClickedPayload,
@@ -101,6 +102,43 @@ describe('Ninetailed core class', () => {
101102
});
102103
expect(instance).toBeInstanceOf(Ninetailed);
103104
});
105+
it('should warn when useSDKEvaluation is enabled', () => {
106+
const warnSpy = jest
107+
.spyOn(logger, 'warn')
108+
.mockImplementation(() => undefined);
109+
110+
new Ninetailed(
111+
{
112+
clientId: 'test',
113+
},
114+
{
115+
useSDKEvaluation: true,
116+
}
117+
);
118+
119+
expect(warnSpy).toHaveBeenCalledWith(
120+
"You are using the 'useSDKEvaluation' option. This feature is deprecated and will be removed in a future major release."
121+
);
122+
});
123+
it('should not warn when useSDKEvaluation is disabled', () => {
124+
const warnSpy = jest
125+
.spyOn(logger, 'warn')
126+
.mockImplementation(() => undefined);
127+
128+
new Ninetailed({
129+
clientId: 'test',
130+
});
131+
new Ninetailed(
132+
{
133+
clientId: 'test',
134+
},
135+
{
136+
useSDKEvaluation: false,
137+
}
138+
);
139+
140+
expect(warnSpy).not.toHaveBeenCalled();
141+
});
104142
it('should be able to create a new instance with a outside instantiated NinetailedApiClient', () => {
105143
const instance = new Ninetailed(
106144
new NinetailedApiClient({ clientId: 'test' })

packages/sdks/javascript/src/lib/Ninetailed.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ type Options = {
121121
onInitProfileId?: OnInitProfileId;
122122
buildClientContext?: () => NinetailedRequestContext;
123123
storageImpl?: Storage;
124+
/**
125+
* @deprecated This option is deprecated and will be removed in a future major version.
126+
*/
124127
useSDKEvaluation?: boolean;
125128
};
126129

@@ -181,7 +184,9 @@ export class Ninetailed implements NinetailedInstance {
181184
public readonly logger: Logger;
182185

183186
private readonly componentViewTrackingThreshold: number;
184-
187+
/**
188+
* @deprecated This option is deprecated and will be removed in a future major version.
189+
*/
185190
private readonly useSDKEvaluation: boolean;
186191

187192
public readonly eventBuilder: EventBuilder;
@@ -215,6 +220,12 @@ export class Ninetailed implements NinetailedInstance {
215220

216221
this.useSDKEvaluation = useSDKEvaluation;
217222

223+
if (useSDKEvaluation) {
224+
logger.warn(
225+
"You are using the 'useSDKEvaluation' option. This feature is deprecated and will be removed in a future major release."
226+
);
227+
}
228+
218229
if (ninetailedApiClientInstanceOrOptions instanceof NinetailedApiClient) {
219230
this.apiClient = ninetailedApiClientInstanceOrOptions;
220231
} else {

packages/sdks/react/src/lib/NinetailedProvider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export type NinetailedProviderInstantiationProps = {
3030
buildClientContext?: () => NinetailedRequestContext;
3131
onInitProfileId?: OnInitProfileId;
3232
storageImpl?: Storage;
33-
33+
/**
34+
* @deprecated This option is deprecated and will be removed in a future major version.
35+
*/
3436
useSDKEvaluation?: boolean;
3537
};
3638

0 commit comments

Comments
 (0)