Skip to content

Commit 045e38b

Browse files
Merge branch 'impressions_toggle_baseline' into impressions_toggle_manager
2 parents 84238a2 + 0d3b71b commit 045e38b

File tree

9 files changed

+18
-24
lines changed

9 files changed

+18
-24
lines changed

src/listeners/node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class NodeSignalListener implements ISignalListener {
5656
// Cleaned up, remove handlers.
5757
this.stop();
5858

59-
// This handler prevented the default behaviour, start again.
59+
// This handler prevented the default behavior, start again.
6060
// eslint-disable-next-line no-undef
6161
process.kill(process.pid, SIGTERM);
6262
};
@@ -72,7 +72,7 @@ export class NodeSignalListener implements ISignalListener {
7272
}
7373

7474
if (thenable(handlerResult)) {
75-
// Always exit, even with errors. The promise is returned for UT purposses.
75+
// Always exit, even with errors. The promise is returned for UT purposes.
7676
return handlerResult.then(wrapUp).catch(wrapUp);
7777
} else {
7878
wrapUp();

src/logger/__tests__/index.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,22 @@ function testLogLevels(levelToTest: SplitIO.LogLevel) {
9797

9898
}
9999

100-
test('SPLIT LOGGER / Logger class public methods behaviour - instance.debug', () => {
100+
test('SPLIT LOGGER / Logger class public methods behavior - instance.debug', () => {
101101
testLogLevels(LogLevels.DEBUG);
102102

103103
});
104104

105-
test('SPLIT LOGGER / Logger class public methods behaviour - instance.info', () => {
105+
test('SPLIT LOGGER / Logger class public methods behavior - instance.info', () => {
106106
testLogLevels(LogLevels.INFO);
107107

108108
});
109109

110-
test('SPLIT LOGGER / Logger class public methods behaviour - instance.warn', () => {
110+
test('SPLIT LOGGER / Logger class public methods behavior - instance.warn', () => {
111111
testLogLevels(LogLevels.WARN);
112112

113113
});
114114

115-
test('SPLIT LOGGER / Logger class public methods behaviour - instance.error', () => {
115+
test('SPLIT LOGGER / Logger class public methods behavior - instance.error', () => {
116116
testLogLevels(LogLevels.ERROR);
117117

118118
});

src/readiness/__tests__/readinessManager.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ test('READINESS MANAGER / Cancel timeout if ready fired', (done) => {
214214

215215
const readinessManager = readinessManagerFactory(EventEmitter, settingsWithTimeout);
216216
readinessManager.init(); // Start the timeout
217+
readinessManager.destroy(); // Should cancel the timeout
218+
readinessManager.init(); // Start the timeout again
217219

218220
readinessManager.gate.on(SDK_READY_TIMED_OUT, () => { sdkReadyTimedoutCalled = true; });
219221
readinessManager.gate.once(SDK_READY, () => { sdkReadyCalled = true; });

src/readiness/__tests__/sdkReadinessManager.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe('SDK Readiness Manager - Event emitter', () => {
201201

202202
describe('SDK Readiness Manager - Ready promise', () => {
203203

204-
test('.ready() promise behaviour for clients', async () => {
204+
test('.ready() promise behavior for clients', async () => {
205205
const sdkReadinessManager = sdkReadinessManagerFactory(EventEmitterMock, fullSettings);
206206

207207
const ready = sdkReadinessManager.sdkStatus.ready();

src/storages/inRedis/__tests__/RedisAdapter.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('STORAGE Redis Adapter', () => {
181181

182182
expect(ioredisMock.once).toBeCalledTimes(2); // If the method was called, it should have called the `once` function twice. If that it the case we can assume that the method was called on creation.
183183

184-
// Reset stubs again, we'll check the behaviour calling the method directly.
184+
// Reset stubs again, we'll check the behavior calling the method directly.
185185
clearAllMocks();
186186
expect(ioredisMock.once).not.toBeCalled(); // Control assertion
187187
expect(ioredisMock[METHODS_TO_PROMISE_WRAP[METHODS_TO_PROMISE_WRAP.length - 1]]).not.toBeCalled(); // Control assertion

src/trackers/__tests__/impressionsTracker.spec.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const fakeSettingsWithListener = {
3636
};
3737
const fakeWhenInit = (cb: () => void) => cb();
3838

39-
// @TODO validate logic with `impression.track` false
4039
const fakeNoneStrategy = {
4140
process: jest.fn(() => false)
4241
};
@@ -53,13 +52,6 @@ describe('Impressions Tracker', () => {
5352

5453
const strategy = strategyDebugFactory(impressionObserverCSFactory());
5554

56-
test('Tracker API', () => {
57-
expect(typeof impressionsTrackerFactory).toBe('function'); // The module should return a function which acts as a factory.
58-
59-
const instance = impressionsTrackerFactory(fakeSettings, fakeImpressionsCache, fakeNoneStrategy,strategy, fakeWhenInit);
60-
expect(typeof instance.track).toBe('function'); // The instance should implement the track method which will actually track queued impressions.
61-
});
62-
6355
test('Should be able to track impressions (in DEBUG mode without Previous Time).', () => {
6456
const tracker = impressionsTrackerFactory(fakeSettings, fakeImpressionsCache, fakeNoneStrategy, strategy, fakeWhenInit);
6557

@@ -75,9 +67,9 @@ describe('Impressions Tracker', () => {
7567

7668
expect(fakeImpressionsCache.track).not.toBeCalled(); // cache method should not be called by just creating a tracker
7769

78-
tracker.track([{ imp: imp1 }, { imp: imp2 }, { imp: imp3 }]);
70+
tracker.track([{ imp: imp1 }, { imp: imp2, track: true }, { imp: imp3, track: false }]);
7971

80-
expect(fakeImpressionsCache.track.mock.calls[0][0]).toEqual([imp1, imp2, imp3]); // Should call the storage track method once we invoke .track() method, passing queued params in a sequence.
72+
expect(fakeImpressionsCache.track.mock.calls[0][0]).toEqual([imp1, imp2]); // Should call the storage track method once we invoke .track() method, passing impressions with `track` enabled
8173
});
8274

8375
test('Tracked impressions should be sent to impression listener and integration manager when we invoke .track()', (done) => {
@@ -98,9 +90,9 @@ describe('Impressions Tracker', () => {
9890
expect(fakeIntegrationsManager.handleImpression).not.toBeCalled(); // The integrations manager handleImpression method should not be invoked if we haven't tracked impressions.
9991

10092
// We signal that we actually want to track the queued impressions.
101-
tracker.track([{ imp: fakeImpression }, { imp: fakeImpression2 }], fakeAttributes);
93+
tracker.track([{ imp: fakeImpression }, { imp: fakeImpression2, track: false }], fakeAttributes);
10294

103-
expect(fakeImpressionsCache.track.mock.calls[0][0]).toEqual([fakeImpression, fakeImpression2]); // Even with a listener, impression should be sent to the cache
95+
expect(fakeImpressionsCache.track.mock.calls[0][0]).toEqual([fakeImpression]); // Even with a listener, impressions (with `track` enabled) should be sent to the cache
10496
expect(fakeListener.logImpression).not.toBeCalled(); // The listener should not be executed synchronously.
10597
expect(fakeIntegrationsManager.handleImpression).not.toBeCalled(); // The integrations manager handleImpression method should not be executed synchronously.
10698

@@ -162,7 +154,7 @@ describe('Impressions Tracker', () => {
162154
expect(fakeImpressionsCache.track).not.toBeCalled(); // storage method should not be called until impressions are tracked.
163155

164156
trackers.forEach(tracker => {
165-
tracker.track([{ imp: impression }, { imp: impression2 }, { imp: impression3 }]);
157+
tracker.track([{ imp: impression, track: true }, { imp: impression2 }, { imp: impression3 }]);
166158

167159
const lastArgs = fakeImpressionsCache.track.mock.calls[fakeImpressionsCache.track.mock.calls.length - 1];
168160

src/trackers/eventTracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function eventTrackerFactory(
3636
whenInit(() => {
3737
// Wrap in a timeout because we don't want it to be blocking.
3838
setTimeout(() => {
39-
// copy of event, to avoid unexpected behaviour if modified by integrations
39+
// copy of event, to avoid unexpected behavior if modified by integrations
4040
const eventDataCopy = objectAssign({}, eventData);
4141
if (properties) eventDataCopy.properties = objectAssign({}, properties);
4242
// integrationsManager does not throw errors (they are internally handled by each integration module)

src/trackers/impressionsTracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function impressionsTrackerFactory(
5959
if (impressionListener || integrationsManager) {
6060
for (let i = 0; i < impressionsLength; i++) {
6161
const impressionData: SplitIO.ImpressionData = {
62-
// copy of impression, to avoid unexpected behaviour if modified by integrations or impressionListener
62+
// copy of impression, to avoid unexpected behavior if modified by integrations or impressionListener
6363
impression: objectAssign({}, impressions[i].imp),
6464
attributes,
6565
ip,

src/utils/settingsValidation/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
159159
if (withDefaults.mode === LOCALHOST_MODE && maybeKey === undefined) {
160160
withDefaults.core.key = 'localhost_key';
161161
} else {
162-
// Keeping same behaviour than JS SDK: if settings key or TT are invalid,
162+
// Keeping same behavior than JS SDK: if settings key or TT are invalid,
163163
// `false` value is used as bound key/TT of the default client, which leads to some issues.
164164
// @ts-ignore, @TODO handle invalid keys as a non-recoverable error?
165165
withDefaults.core.key = validateKey(log, maybeKey, LOG_PREFIX_CLIENT_INSTANTIATION);

0 commit comments

Comments
 (0)