Skip to content

Misc #868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025
Merged

Misc #868

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
Expand Down
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- `storage.expirationDays` to specify the validity period of the rollout plan cache in days.
- `storage.clearOnInit` to clear the rollout plan cache on SDK initialization.
- Updated SDK_READY_FROM_CACHE event when using the `LOCALSTORAGE` storage type to be emitted alongside the SDK_READY event if it has not already been emitted.
- Updated @splitsoftware/splitio-commons package to version 2.2.0.

11.1.0 (January 17, 2025)
- Added support for the new impressions tracking toggle available on feature flags, both respecting the setting and including the new field being returned on `SplitView` type objects. Read more in our docs.
Expand Down
64 changes: 48 additions & 16 deletions ts-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ const attributes: SplitIO.Attributes = {
attr6: [1, 2],
attr7: true
};
const evaluationOptions: SplitIO.EvaluationOptions = {
properties: {
prop1: 1,
prop2: '2',
prop3: true,
prop4: null
}
};
const splitKeyObj: SplitIO.SplitKeyObject = {
matchingKey: 'matchingKey',
bucketingKey: 'bucketingKey'
Expand Down Expand Up @@ -254,58 +262,74 @@ promise = SDK.destroy();
// We can call getTreatment with or without a key.
treatment = client.getTreatment(splitKey, 'mySplit');
treatment = browserClient.getTreatment('mySplit');
// Attributes parameter is optional on both signatures.
// Attributes and EvaluationOptions parameters are optional
treatment = client.getTreatment(splitKey, 'mySplit', attributes);
treatment = client.getTreatment(splitKey, 'mySplit', undefined, evaluationOptions);
treatment = browserClient.getTreatment('mySplit', attributes);
treatment = browserClient.getTreatment('mySplit', undefined, evaluationOptions);

// We can call getTreatments with or without a key.
treatments = client.getTreatments(splitKey, ['mySplit']);
treatments = browserClient.getTreatments(['mySplit']);
// Attributes parameter is optional on both signatures.
// Attributes and EvaluationOptions parameters are optional
treatments = client.getTreatments(splitKey, ['mySplit'], attributes);
treatments = client.getTreatments(splitKey, ['mySplit'], undefined, evaluationOptions);
treatments = browserClient.getTreatments(['mySplit'], attributes);
treatments = browserClient.getTreatments(['mySplit'], undefined, evaluationOptions);

// We can call getTreatmentWithConfig with or without a key.
treatmentWithConfig = client.getTreatmentWithConfig(splitKey, 'mySplit');
treatmentWithConfig = browserClient.getTreatmentWithConfig('mySplit');
// Attributes parameter is optional on both signatures.
// Attributes and EvaluationOptions parameters are optional
treatmentWithConfig = client.getTreatmentWithConfig(splitKey, 'mySplit', attributes);
treatmentWithConfig = client.getTreatmentWithConfig(splitKey, 'mySplit', undefined, evaluationOptions);
treatmentWithConfig = browserClient.getTreatmentWithConfig('mySplit', attributes);
treatmentWithConfig = browserClient.getTreatmentWithConfig('mySplit', undefined, evaluationOptions);

// We can call getTreatmentsWithConfig with or without a key.
treatmentsWithConfig = client.getTreatmentsWithConfig(splitKey, ['mySplit']);
treatmentsWithConfig = browserClient.getTreatmentsWithConfig(['mySplit']);
// Attributes parameter is optional on both signatures.
// Attributes and EvaluationOptions parameters are optional
treatmentsWithConfig = client.getTreatmentsWithConfig(splitKey, ['mySplit'], attributes);
treatmentsWithConfig = client.getTreatmentsWithConfig(splitKey, ['mySplit'], undefined, evaluationOptions);
treatmentsWithConfig = browserClient.getTreatmentsWithConfig(['mySplit'], attributes);
treatmentsWithConfig = browserClient.getTreatmentsWithConfig(['mySplit'], undefined, evaluationOptions);

// We can call getTreatmentsByFlagSet with or without a key.
treatments = client.getTreatmentsByFlagSet(splitKey, 'set_a');
treatments = browserClient.getTreatmentsByFlagSet('set_a');
// Attributes parameter is optional.
// Attributes and EvaluationOptions parameters are optional
treatments = client.getTreatmentsByFlagSet(splitKey, 'set_a', attributes);
treatments = client.getTreatmentsByFlagSet(splitKey, 'set_a', undefined, evaluationOptions);
treatments = browserClient.getTreatmentsByFlagSet('set_a', attributes);
treatments = browserClient.getTreatmentsByFlagSet('set_a', undefined, evaluationOptions);

// We can call getTreatmentsByFlagSets with or without a key.
treatments = client.getTreatmentsByFlagSets(splitKey, ['set_a']);
treatments = browserClient.getTreatmentsByFlagSets(['set_a']);
// Attributes parameter is optional.
// Attributes and EvaluationOptions parameters are optional
treatments = client.getTreatmentsByFlagSets(splitKey, ['set_a'], attributes);
treatments = client.getTreatmentsByFlagSets(splitKey, ['set_a'], undefined, evaluationOptions);
treatments = browserClient.getTreatmentsByFlagSets(['set_a'], attributes);
treatments = browserClient.getTreatmentsByFlagSets(['set_a'], undefined, evaluationOptions);

// We can call getTreatmentsWithConfigByFlagSet with or without a key.
treatmentsWithConfig = client.getTreatmentsWithConfigByFlagSet(splitKey, 'set_a');
treatmentsWithConfig = browserClient.getTreatmentsWithConfigByFlagSet('set_a');
// Attributes parameter is optional.
// Attributes and EvaluationOptions parameters are optional
treatmentsWithConfig = client.getTreatmentsWithConfigByFlagSet(splitKey, 'set_a', attributes);
treatmentsWithConfig = client.getTreatmentsWithConfigByFlagSet(splitKey, 'set_a', undefined, evaluationOptions);
treatmentsWithConfig = browserClient.getTreatmentsWithConfigByFlagSet('set_a', attributes);
treatmentsWithConfig = browserClient.getTreatmentsWithConfigByFlagSet('set_a', undefined, evaluationOptions);

// We can call getTreatmentsWithConfigByFlagSets with or without a key.
treatmentsWithConfig = client.getTreatmentsWithConfigByFlagSets(splitKey, ['set_a']);
treatmentsWithConfig = browserClient.getTreatmentsWithConfigByFlagSets(['set_a']);
// Attributes parameter is optional.
// Attributes and EvaluationOptions parameters are optional
treatmentsWithConfig = client.getTreatmentsWithConfigByFlagSets(splitKey, ['set_a'], attributes);
treatmentsWithConfig = client.getTreatmentsWithConfigByFlagSets(splitKey, ['set_a'], undefined, evaluationOptions);
treatmentsWithConfig = browserClient.getTreatmentsWithConfigByFlagSets(['set_a'], attributes);
treatmentsWithConfig = browserClient.getTreatmentsWithConfigByFlagSets(['set_a'], undefined, evaluationOptions);

// We can call track with or without a key.
tracked = client.track(splitKey, 'myTrafficType', 'myEventType'); // all params
Expand Down Expand Up @@ -343,43 +367,51 @@ promise = AsyncSDK.destroy();

// We can call getTreatment but always with a key.
asyncTreatment = asyncClient.getTreatment(splitKey, 'mySplit');
// Attributes parameter is optional
// Attributes and EvaluationOptions parameters are optional
asyncTreatment = asyncClient.getTreatment(splitKey, 'mySplit', attributes);
asyncTreatment = asyncClient.getTreatment(splitKey, 'mySplit', undefined, evaluationOptions);

// We can call getTreatments but always with a key.
asyncTreatments = asyncClient.getTreatments(splitKey, ['mySplit']);
// Attributes parameter is optional
// Attributes and EvaluationOptions parameters are optional
asyncTreatments = asyncClient.getTreatments(splitKey, ['mySplit'], attributes);
asyncTreatments = asyncClient.getTreatments(splitKey, ['mySplit'], undefined, evaluationOptions);

// We can call getTreatmentWithConfig but always with a key.
asyncTreatmentWithConfig = asyncClient.getTreatmentWithConfig(splitKey, 'mySplit');
// Attributes parameter is optional
// Attributes and EvaluationOptions parameters are optional
asyncTreatmentWithConfig = asyncClient.getTreatmentWithConfig(splitKey, 'mySplit', attributes);
asyncTreatmentWithConfig = asyncClient.getTreatmentWithConfig(splitKey, 'mySplit', undefined, evaluationOptions);

// We can call getTreatments but always with a key.
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfig(splitKey, ['mySplit']);
// Attributes parameter is optional
// Attributes and EvaluationOptions parameters are optional
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfig(splitKey, ['mySplit'], attributes);
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfig(splitKey, ['mySplit'], undefined, evaluationOptions);

// We can call getTreatmentsByFlagSet
asyncTreatments = asyncClient.getTreatmentsByFlagSet(splitKey, 'set_a');
// Attributes parameter is optional
// Attributes and EvaluationOptions parameters are optional
asyncTreatments = asyncClient.getTreatmentsByFlagSet(splitKey, 'set_a', attributes);
asyncTreatments = asyncClient.getTreatmentsByFlagSet(splitKey, 'set_a', undefined, evaluationOptions);

// We can call getTreatmentsByFlagSets
asyncTreatments = asyncClient.getTreatmentsByFlagSets(splitKey, ['set_a']);
// Attributes parameter is optional
// Attributes and EvaluationOptions parameters are optional
asyncTreatments = asyncClient.getTreatmentsByFlagSets(splitKey, ['set_a'], attributes);
asyncTreatments = asyncClient.getTreatmentsByFlagSets(splitKey, ['set_a'], undefined, evaluationOptions);

// We can call getTreatmentsWithConfigByFlagSet
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfigByFlagSet(splitKey, 'set_a');
// Attributes parameter is optional
// Attributes and EvaluationOptions parameters are optional
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfigByFlagSet(splitKey, 'set_a', attributes);
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfigByFlagSet(splitKey, 'set_a', undefined, evaluationOptions);

// We can call getTreatmentsByFlagSets but always with a key.
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfigByFlagSets(splitKey, ['set_a']);
// Attributes parameter is optional
// Attributes and EvaluationOptions parameters are optional
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfigByFlagSets(splitKey, ['set_a'], attributes);
asyncTreatmentsWithConfig = asyncClient.getTreatmentsWithConfigByFlagSets(splitKey, ['set_a'], undefined, evaluationOptions);

// We can call track only with a key.
trackPromise = asyncClient.track(splitKey, 'myTrafficType', 'myEventType'); // all required params
Expand Down