expf-sigma-node.js 0.1.0 → 0.1.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 +8 -2
  2. package/public/sigma.js +17 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expf-sigma-node.js",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "expf-sigma-node.js lets you manage features flags and remote config across web, server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.",
5
5
  "main": "public/sigma.js",
6
6
  "keywords": [
@@ -17,7 +17,10 @@
17
17
  "scripts": {
18
18
  "release": "np",
19
19
  "build": "esbuild --bundle ./src/sigma.js --platform=node --format=cjs --outdir=public",
20
- "dev": "esbuild --bundle ./src/sigma.js --platform=node --format=cjs --outdir=public --watch"
20
+ "dev": "esbuild --bundle ./src/sigma.js --platform=node --format=cjs --outdir=public --watch",
21
+ "lint": "eslint ./src/sigma.js",
22
+ "lint:all": "eslint \"**/*.js\"",
23
+ "test": "jest"
21
24
  },
22
25
  "dependencies": {
23
26
  "node-fetch": "^2.1.2"
@@ -27,6 +30,7 @@
27
30
  "@babel/plugin-proposal-class-properties": "^7.18.6",
28
31
  "@babel/preset-env": "^7.16.4",
29
32
  "babel-eslint": "^10.1.0",
33
+ "babel-jest": "^29.2.2",
30
34
  "babel-loader": "^8.2.3",
31
35
  "babel-plugin-add-module-exports": "^1.0.4",
32
36
  "clean-webpack-plugin": "^4.0.0",
@@ -36,6 +40,8 @@
36
40
  "eslint-plugin-jest": "^23.8.2",
37
41
  "eslint-plugin-node": "^11.1.0",
38
42
  "eslint-plugin-prettier": "^3.1.3",
43
+ "jest": "^29.2.2",
44
+ "jest-environment-jsdom": "^29.2.1",
39
45
  "js-cookie": "^3.0.1",
40
46
  "jshashes": "^1.0.8",
41
47
  "node-cache": "^5.1.2",
package/public/sigma.js CHANGED
@@ -5620,11 +5620,14 @@ var SigmaUserData = class {
5620
5620
  getUserNavigator() {
5621
5621
  const userNavigator = browser_detect_es5_default();
5622
5622
  const { user } = this;
5623
- const userOs = userNavigator.os.split(" ");
5624
- user.browser.name = userNavigator.name;
5625
- user.browser.version = userNavigator.version;
5626
- user.os.name = userOs[0];
5627
- user.os.version = userOs[1];
5623
+ let userOs;
5624
+ if (userNavigator.os) {
5625
+ userOs = userNavigator.os.split(" ");
5626
+ }
5627
+ user.browser.name = userNavigator.name ? userNavigator.name : void 0;
5628
+ user.browser.version = userNavigator.version ? userNavigator.version : void 0;
5629
+ user.os.name = userOs ? userOs[0] : void 0;
5630
+ user.os.version = userOs ? userOs[1] : void 0;
5628
5631
  }
5629
5632
  setUserId(userId) {
5630
5633
  this.user.userId = userId;
@@ -5980,6 +5983,7 @@ var Sigma = class {
5980
5983
  async getUserGeoData() {
5981
5984
  try {
5982
5985
  const data = await this.getDataFile(`${defaultApi}/geo`);
5986
+ this.sigmaUserData.setIp(data.ip);
5983
5987
  return data;
5984
5988
  } catch (error) {
5985
5989
  throw new Error(error);
@@ -6143,14 +6147,14 @@ var Sigma = class {
6143
6147
  return !conditionValues.includes(userValue);
6144
6148
  case "contains any of":
6145
6149
  for (let i = 0; i < conditionValues.length; i++) {
6146
- if (String(conditionValues[i]).includes(userValue)) {
6150
+ if (String(userValue).includes(conditionValues[i])) {
6147
6151
  return true;
6148
6152
  }
6149
6153
  }
6150
6154
  return false;
6151
6155
  case "contains none of":
6152
6156
  for (let i = 0; i < conditionValues.length; i++) {
6153
- if (String(conditionValues[i]).includes(userValue)) {
6157
+ if (String(userValue).includes(conditionValues[i])) {
6154
6158
  return false;
6155
6159
  }
6156
6160
  }
@@ -6315,7 +6319,7 @@ var Sigma = class {
6315
6319
  }
6316
6320
  if (!flag)
6317
6321
  return false;
6318
- return this.findingSpotCondition(flag);
6322
+ return this.findingSpotCondition(flag, false, experiment);
6319
6323
  };
6320
6324
  return {
6321
6325
  getParamValue,
@@ -6372,7 +6376,7 @@ var Sigma = class {
6372
6376
  }
6373
6377
  return groupName;
6374
6378
  }
6375
- findingSpotCondition(flag, saveToUser) {
6379
+ findingSpotCondition(flag, saveToUser = false, exp = null) {
6376
6380
  let flagRules = flag.rules;
6377
6381
  let flagDefaultResult = null;
6378
6382
  for (let defaultRule in flagRules) {
@@ -6397,7 +6401,10 @@ var Sigma = class {
6397
6401
  const conditions = flagRules[rule].conditions;
6398
6402
  let results = [];
6399
6403
  for (let i in conditions) {
6400
- let userValue = this.getUserParamValue(conditions[i].name, flag.is_private);
6404
+ let userValue = this.getUserParamValue(
6405
+ conditions[i].name,
6406
+ exp ? exp.is_private : flag.is_private
6407
+ );
6401
6408
  results.push(
6402
6409
  this.conditionOperation(
6403
6410
  userValue,