Skip to content

Commit

Permalink
v4.14.1 (#157)
Browse files Browse the repository at this point in the history
* v4.14.1

* bump version
  • Loading branch information
tore-statsig authored May 6, 2022
1 parent fe5c6b4 commit 9b12b4b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "statsig-node",
"version": "4.14.0",
"version": "4.14.1",
"description": "Statsig Node.js SDK for usage in multi-user server environments.",
"main": "dist/src/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/LogEventProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function LogEventProcessor(options, secretKey) {

let metadataKey = '';
if (metadata && typeof(metadata) === 'object') {
customIdKey = Object.values(metadata).join();
metadataKey = Object.values(metadata).join();
}

const keyList = [
Expand Down
45 changes: 43 additions & 2 deletions src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ describe('Verify behavior of top level index functions', () => {
expect(spy).toHaveBeenCalledWith(configExposure);
});

test('Verify that getConfig() and getExperiment() are deduped with same metadata', async () => {
test('Verify that checkGate() getConfig() and getExperiment() are deduped with same metadata', async () => {
expect.assertions(1);

const statsig = require('../index');
Expand All @@ -431,6 +431,9 @@ describe('Verify behavior of top level index functions', () => {
number: 12345,
});
});
jest.spyOn(Evaluator, 'checkGate').mockImplementation((_, configName) => {
return new ConfigEvaluation(true, 'rule_id_config', [], {});
});
await statsig.initialize(secretKey);

let user = { userID: 123, privateAttributes: { secret: 'do not log' } };
Expand All @@ -439,9 +442,47 @@ describe('Verify behavior of top level index functions', () => {
const spy = jest.spyOn(statsig._logger, 'log');
for (let ii = 0 ; ii < 10000; ii++) {
await statsig.getConfig(user, configName);
await statsig.checkGate(user, "test_gate");
}

expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledTimes(2);
});

test('Verify that checkGate() getConfig() and getExperiment() are not deduped with different customIDs', async () => {
expect.assertions(2);

const statsig = require('../index');
const { Evaluator, ConfigEvaluation } = require('../Evaluator');
jest.spyOn(Evaluator, 'getConfig').mockImplementation((_, configName) => {
return new ConfigEvaluation(true, 'rule_id_config', [], {
string: '12345',
number: 12345,
});
});
jest.spyOn(Evaluator, 'checkGate').mockImplementation((_, configName) => {
return new ConfigEvaluation(true, 'rule_id_config', [], {});
});
await statsig.initialize(secretKey);

let user = { userID: 123, customIDs: {"project": "def", company: "abc"}, privateAttributes: { secret: 'do not log' } };
let configName = 'config_downloaded';
const gateName = "test";

const spy = jest.spyOn(statsig._logger, 'log');
for (let ii = 0 ; ii < 10000; ii++) {
await statsig.getConfig(user, configName);
await statsig.checkGate(user, gateName);
}

expect(spy).toHaveBeenCalledTimes(2);

for (let ii = 0 ; ii < 10000; ii++) {
user.customIDs.project = ii + "";
await statsig.getConfig(user, configName);
await statsig.checkGate(user, gateName);
}

expect(spy).toHaveBeenCalledTimes(20002);
});

test('Verify that getConfig() and getExperiment() are not deduped with different user', async () => {
Expand Down

0 comments on commit 9b12b4b

Please sign in to comment.