Skip to content

Commit

Permalink
Merge branch 'development' into impressions_toggle_baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed Dec 26, 2024
2 parents d83c0ad + 1b9874e commit 58040dc
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2.1.0 (January XX, 2025)
- Added `trackImpressions` property to SDK Manager's `SplitView` type.
- Updated implementation of the impressions tracker and strategies to support feature flags with impressions tracking disabled.
- Bugfixing - Properly handle rejected promises when using targeting rules with segment matchers in consumer modes (e.g., Redis and Pluggable storages).

2.0.2 (December 3, 2024)
- Updated the factory `init` and `destroy` methods to support re-initialization after destruction. This update ensures compatibility of the React SDK with React Strict Mode, where the factory's `init` and `destroy` effects are executed an extra time to validate proper resource cleanup.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This library is compatible with JavaScript ES5 and above.
Please see [Contributors Guide](CONTRIBUTORS-GUIDE.md) to find all you need to submit a Pull Request (PR).

## License
Licensed under the Apache License, Version 2.0. See: [Apache License](http://www.apache.org/licenses/).
Licensed under the Apache License, Version 2.0. See: [Apache License](https://www.apache.org/licenses/).

## About Split

Expand Down Expand Up @@ -46,4 +46,4 @@ For a comprehensive list of open source projects visit our [Github page](https:/

**Learn more about Split:**

Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](http://help.split.io) for more detailed information.
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](https://help.split.io) for more detailed information.
7 changes: 0 additions & 7 deletions src/evaluator/matchers/large_segment.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { MaybeThenable } from '../../dtos/types';
import { ISegmentsCacheBase } from '../../storages/types';
import { thenable } from '../../utils/promise/thenable';

export function largeSegmentMatcherContext(largeSegmentName: string, storage: { largeSegments?: ISegmentsCacheBase }) {

return function largeSegmentMatcher(key: string): MaybeThenable<boolean> {
const isInLargeSegment = storage.largeSegments ? storage.largeSegments.isInSegment(largeSegmentName, key) : false;

if (thenable(isInLargeSegment)) {
isInLargeSegment.then(result => {
return result;
});
}

return isInLargeSegment;
};
}
7 changes: 0 additions & 7 deletions src/evaluator/matchers/segment.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { MaybeThenable } from '../../dtos/types';
import { ISegmentsCacheBase } from '../../storages/types';
import { thenable } from '../../utils/promise/thenable';

export function segmentMatcherContext(segmentName: string, storage: { segments: ISegmentsCacheBase }) {

return function segmentMatcher(key: string): MaybeThenable<boolean> {
const isInSegment = storage.segments.isInSegment(segmentName, key);

if (thenable(isInSegment)) {
isInSegment.then(result => {
return result;
});
}

return isInSegment;
};
}
2 changes: 1 addition & 1 deletion src/storages/inRedis/SplitsCacheInRedis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
return Promise.reject(this.redisError);
}

const splits: Record<string, ISplit | null> = {};
const keys = names.map(name => this.keys.buildSplitKey(name));
return this.redis.mget(...keys)
.then(splitDefinitions => {
const splits: Record<string, ISplit | null> = {};
names.forEach((name, idx) => {
const split = splitDefinitions[idx];
splits[name] = split && JSON.parse(split);
Expand Down
14 changes: 8 additions & 6 deletions src/sync/streaming/pushManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,14 @@ export function pushManagerFactory(
// Reconnects in case of a new client.
// Run in next event-loop cycle to save authentication calls
// in case multiple clients are created in the current cycle.
setTimeout(function checkForReconnect() {
if (connectForNewClient) {
connectForNewClient = false;
connectPush();
}
}, 0);
if (this.isRunning()) {
setTimeout(function checkForReconnect() {
if (connectForNewClient) {
connectForNewClient = false;
connectPush();
}
}, 0);
}
}
},
// [Only for client-side]
Expand Down
4 changes: 2 additions & 2 deletions src/sync/syncManagerOnline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,19 @@ export function syncManagerOnlineFactory(
if (!pollingManager) return;

const mySegmentsSyncTask = (pollingManager as IPollingManagerCS).add(matchingKey, readinessManager, storage);
if (syncEnabled && pushManager) pushManager.add(matchingKey, mySegmentsSyncTask);

if (running) {
if (syncEnabled) {
if (pushManager) {
if (pollingManager!.isRunning()) {
if (pollingManager.isRunning()) {
// if doing polling, we must start the periodic fetch of data
if (storage.splits.usesSegments()) mySegmentsSyncTask.start();
} else {
// if not polling, we must execute the sync task for the initial fetch
// of segments since `syncAll` was already executed when starting the main client
mySegmentsSyncTask.execute();
}
pushManager.add(matchingKey, mySegmentsSyncTask);
} else {
if (storage.splits.usesSegments()) mySegmentsSyncTask.start();
}
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Declaration file for JavaScript Browser Split Software SDK
// Project: http://www.split.io/
// Project: https://www.split.io/
// Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>

/// <reference path="./splitio.d.ts" />
2 changes: 1 addition & 1 deletion types/splitio.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Type definitions for Split Software SDKs
// Project: http://www.split.io/
// Project: https://www.split.io/

import { RedisOptions } from 'ioredis';
import { RequestOptions } from 'http';
Expand Down

0 comments on commit 58040dc

Please sign in to comment.