expf-sigma-node.js 0.0.5 → 0.0.6

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 +1 -1
  2. package/public/sigma.js +18 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expf-sigma-node.js",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
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": [
package/public/sigma.js CHANGED
@@ -5795,6 +5795,7 @@ var Sigma = class {
5795
5795
  this.api = api2 || `${defaultApi}/config.json`;
5796
5796
  this.retries = retries;
5797
5797
  this.sigmaUserData = sigmaUserData;
5798
+ this.userData.userId = this.validateUserDataUserId(this.userData.userId);
5798
5799
  this.sigmaUserData.init({
5799
5800
  userId: this.userData.userId || null,
5800
5801
  ip: this.userData.ip || null,
@@ -5802,13 +5803,24 @@ var Sigma = class {
5802
5803
  appVersion: this.userData.appVersion || null,
5803
5804
  custom: this.userData.custom || null
5804
5805
  });
5805
- if (!this.userData.userId) {
5806
- this.setUserCookie();
5807
- this.sigmaUserData.setUserId(cache.get(sigmaUserId));
5808
- } else {
5809
- cache.set(sigmaUserId, this.userData.userId);
5810
- this.sigmaUserData.setUserId(this.userData.userId);
5806
+ cache.set(sigmaUserId, this.userData.userId);
5807
+ this.setUserCookie();
5808
+ }
5809
+ validateUserDataUserId(userId) {
5810
+ let hasMakeId = false;
5811
+ if (typeof userId === "undefined") {
5812
+ hasMakeId = true;
5813
+ }
5814
+ userId = String(userId).trim();
5815
+ if (userId.length === 0) {
5816
+ hasMakeId = true;
5817
+ }
5818
+ if (hasMakeId && cache.get(sigmaUserId)) {
5819
+ userId = cache.get(sigmaUserId);
5820
+ } else if (hasMakeId) {
5821
+ userId = this.makeIdCookie();
5811
5822
  }
5823
+ return userId;
5812
5824
  }
5813
5825
  delay(ms) {
5814
5826
  new Promise((resolve) => setTimeout(() => resolve(void 0), ms));