@statsig/on-device-eval-core 3.30.2 → 3.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/Evaluator.js +4 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/on-device-eval-core",
3
- "version": "3.30.2",
3
+ "version": "3.31.1",
4
4
  "license": "ISC",
5
5
  "homepage": "https://github.com/statsig-io/js-client-monorepo",
6
6
  "repository": {
@@ -9,8 +9,8 @@
9
9
  "directory": "packages/on-device-eval-core"
10
10
  },
11
11
  "dependencies": {
12
- "@statsig/client-core": "3.30.2",
13
- "@statsig/sha256": "3.30.2"
12
+ "@statsig/client-core": "3.31.1",
13
+ "@statsig/sha256": "3.31.1"
14
14
  },
15
15
  "type": "commonjs",
16
16
  "main": "./src/index.js",
package/src/Evaluator.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Evaluator = void 0;
4
+ const client_core_1 = require("@statsig/client-core");
4
5
  const sha256_1 = require("@statsig/sha256");
5
6
  const EvaluationComparison_1 = require("./EvaluationComparison");
6
7
  const EvaluationResult_1 = require("./EvaluationResult");
@@ -181,13 +182,13 @@ class Evaluator {
181
182
  break;
182
183
  case 'user_bucket': {
183
184
  const salt = String((_b = (_a = condition.additionalValues) === null || _a === void 0 ? void 0 : _a['salt']) !== null && _b !== void 0 ? _b : '');
184
- const unitID = (_c = _getUnitIDFromUser(user, idType)) !== null && _c !== void 0 ? _c : '';
185
+ const unitID = (_c = (0, client_core_1._getUnitIDFromUser)(user, idType)) !== null && _c !== void 0 ? _c : '';
185
186
  const userHash = _computeUserHash(salt + '.' + unitID);
186
187
  value = Number(userHash % BigInt(USER_BUCKET_COUNT));
187
188
  break;
188
189
  }
189
190
  case 'unit_id':
190
- value = _getUnitIDFromUser(user, idType);
191
+ value = (0, client_core_1._getUnitIDFromUser)(user, idType);
191
192
  break;
192
193
  default:
193
194
  return (0, EvaluationResult_1.makeEvalResult)({ unsupported: true });
@@ -343,13 +344,6 @@ class Evaluator {
343
344
  }
344
345
  }
345
346
  exports.Evaluator = Evaluator;
346
- function _getUnitIDFromUser(user, idType) {
347
- var _a, _b, _c;
348
- if (typeof idType === 'string' && idType.toLowerCase() !== 'userid') {
349
- return (_b = (_a = user.customIDs) === null || _a === void 0 ? void 0 : _a[idType]) !== null && _b !== void 0 ? _b : (_c = user === null || user === void 0 ? void 0 : user.customIDs) === null || _c === void 0 ? void 0 : _c[idType.toLowerCase()];
350
- }
351
- return user.userID;
352
- }
353
347
  function _evalPassPercent(rule, user, config) {
354
348
  var _a, _b;
355
349
  if (rule.passPercentage === 100) {
@@ -362,7 +356,7 @@ function _evalPassPercent(rule, user, config) {
362
356
  '.' +
363
357
  ((_a = rule.salt) !== null && _a !== void 0 ? _a : rule.id) +
364
358
  '.' +
365
- ((_b = _getUnitIDFromUser(user, rule.idType)) !== null && _b !== void 0 ? _b : ''));
359
+ ((_b = (0, client_core_1._getUnitIDFromUser)(user, rule.idType)) !== null && _b !== void 0 ? _b : ''));
366
360
  return (Number(hash % BigInt(CONDITION_SEGMENT_COUNT)) < rule.passPercentage * 100);
367
361
  }
368
362
  function _computeUserHash(userHash) {