Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sigstat/on-device-evaluations

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sigstat/on-device-evaluations - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

build/on-device-evaluations.min.js

3

package.json
{
"name": "@sigstat/on-device-evaluations",
"version": "0.0.5",
"version": "0.0.6",
"dependencies": {

@@ -8,2 +8,3 @@ "@sigstat/core": "*",

},
"jsdelivr": "./build/on-device-evaluations.min.js",
"type": "commonjs",

@@ -10,0 +11,0 @@ "main": "./src/index.js",

@@ -17,3 +17,3 @@ "use strict";

exports.OnDeviceEvaluationsClient = OnDeviceEvaluationsClient_1.default;
window.__STATSIG__ = __assign(__assign({}, window.__STATSIG__), { OnDeviceEvaluationsClient: OnDeviceEvaluationsClient_1.default });
__STATSIG__ = __assign(__assign({}, __STATSIG__), { OnDeviceEvaluationsClient: OnDeviceEvaluationsClient_1.default });
//# sourceMappingURL=index.js.map
import { NetworkCore } from '@sigstat/core';
import { DownloadConfigSpecsResponse } from './SpecStore';
import { StatsigOptions } from './StatsigOptions';
export default class StatsigNetwork extends NetworkCore {
constructor(sdkKey: string, api: string);
private _downloadConfigSpecsUrl;
constructor(sdkKey: string, options?: StatsigOptions | null);
fetchConfigSpecs(): Promise<DownloadConfigSpecsResponse>;
}

@@ -19,12 +19,15 @@ "use strict";

var core_1 = require("@sigstat/core");
var StatsigMetadata_1 = require("./StatsigMetadata");
var StatsigNetwork = /** @class */ (function (_super) {
__extends(StatsigNetwork, _super);
function StatsigNetwork(sdkKey, api) {
return _super.call(this, sdkKey, StatsigMetadata_1.StatsigMetadata, '', api) || this;
function StatsigNetwork(sdkKey, options) {
if (options === void 0) { options = null; }
var _a;
var _this = _super.call(this, sdkKey, (_a = options === null || options === void 0 ? void 0 : options.api) !== null && _a !== void 0 ? _a : 'https://api.statsig.com/v1') || this;
_this._downloadConfigSpecsUrl =
// options.baseDownloadConfigSpecsUrl ??
"https://api.statsigcdn.com/v1/download_config_specs/".concat(sdkKey, ".json");
return _this;
}
StatsigNetwork.prototype.fetchConfigSpecs = function () {
return this._sendPostRequest("".concat(this._api, "/download_config_specs"), {
sinceTime: 0,
}, 2000);
return this._sendGetRequest(this._downloadConfigSpecsUrl, 2000);
};

@@ -31,0 +34,0 @@ return StatsigNetwork;

@@ -1,8 +0,12 @@

import { DynamicConfig, FeatureGate, Layer, OnDeviceEvaluationsInterface, StatsigEvent, StatsigLoadingStatus, StatsigUser } from '@sigstat/core';
import { DynamicConfig, Experiment, FeatureGate, Layer, OnDeviceEvaluationsInterface, StatsigClientBase, StatsigEvent, StatsigUser } from '@sigstat/core';
import { DownloadConfigSpecsResponse } from './SpecStore';
import { StatsigOptions } from './StatsigOptions';
export default class OnDeviceEvaluationsClient implements OnDeviceEvaluationsInterface {
loadingStatus: StatsigLoadingStatus;
declare global {
interface Window {
statsigConfigSpecs: DownloadConfigSpecsResponse | undefined;
}
}
export default class OnDeviceEvaluationsClient extends StatsigClientBase implements OnDeviceEvaluationsInterface {
private _network;
private _options;
private _logger;
private _store;

@@ -14,7 +18,7 @@ private _evaluator;

checkGate(user: StatsigUser, name: string): boolean;
getFeatureGate(_user: StatsigUser, _name: string): FeatureGate;
getDynamicConfig(_user: StatsigUser, _name: string): DynamicConfig;
getExperiment(_user: StatsigUser, _name: string): DynamicConfig;
getLayer(_user: StatsigUser, _name: string): Layer;
getFeatureGate(user: StatsigUser, name: string): FeatureGate;
getDynamicConfig(user: StatsigUser, name: string): DynamicConfig;
getExperiment(user: StatsigUser, name: string): Experiment;
getLayer(user: StatsigUser, name: string): Layer;
logEvent(_user: StatsigUser, _event: StatsigEvent): void;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -43,11 +58,15 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var SpecStore_1 = require("./SpecStore");
var OnDeviceEvaluationsClient = /** @class */ (function () {
var OnDeviceEvaluationsClient = /** @class */ (function (_super) {
__extends(OnDeviceEvaluationsClient, _super);
function OnDeviceEvaluationsClient(sdkKey, options) {
var _this = this;
if (options === void 0) { options = null; }
this.loadingStatus = 'Uninitialized';
this._options = options !== null && options !== void 0 ? options : { api: 'https://api.statsig.com/v1' };
this._network = new Network_1.default(sdkKey, this._options.api);
this._logger = new core_1.EventLogger(this._network);
this._store = new SpecStore_1.default();
this._evaluator = new Evaluator_1.default(this._store);
var network = new Network_1.default(sdkKey, options);
_this = _super.call(this, sdkKey, network) || this;
_this._options = options !== null && options !== void 0 ? options : {};
_this._network = network;
_this._logger = new core_1.EventLogger(_this._network);
_this._store = new SpecStore_1.default();
_this._evaluator = new Evaluator_1.default(_this._store);
return _this;
}

@@ -60,3 +79,8 @@ OnDeviceEvaluationsClient.prototype.initialize = function () {

case 0:
this.loadingStatus = 'Loading';
if (window.statsigConfigSpecs) {
this._store.setValues(window.statsigConfigSpecs);
this.setStatus('Bootstrap');
return [2 /*return*/];
}
this.setStatus('Loading');
return [4 /*yield*/, this._network.fetchConfigSpecs()];

@@ -67,6 +91,6 @@ case 1:

this._store.setValues(response);
this.loadingStatus = 'Network';
this.setStatus('Network');
}
else {
this.loadingStatus = 'Error';
this.setStatus('Error');
}

@@ -81,3 +105,3 @@ return [2 /*return*/];

return __generator(this, function (_a) {
throw new Error('Method not implemented.');
return [2 /*return*/, Promise.resolve()];
});

@@ -87,15 +111,31 @@ });

OnDeviceEvaluationsClient.prototype.checkGate = function (user, name) {
return this._evaluator.checkGate(user, name).value;
return this.getFeatureGate(user, name).value;
};
OnDeviceEvaluationsClient.prototype.getFeatureGate = function (_user, _name) {
throw new Error('Method not implemented.');
OnDeviceEvaluationsClient.prototype.getFeatureGate = function (user, name) {
var result = this._evaluator.checkGate(user, name);
return {
name: name,
ruleID: result.rule_id,
value: result.value,
};
};
OnDeviceEvaluationsClient.prototype.getDynamicConfig = function (_user, _name) {
throw new Error('Method not implemented.');
OnDeviceEvaluationsClient.prototype.getDynamicConfig = function (user, name) {
var result = this._evaluator.getConfig(user, name);
return {
name: name,
ruleID: result.rule_id,
value: result.json_value,
};
};
OnDeviceEvaluationsClient.prototype.getExperiment = function (_user, _name) {
throw new Error('Method not implemented.');
OnDeviceEvaluationsClient.prototype.getExperiment = function (user, name) {
return this.getDynamicConfig(user, name);
};
OnDeviceEvaluationsClient.prototype.getLayer = function (_user, _name) {
throw new Error('Method not implemented.');
OnDeviceEvaluationsClient.prototype.getLayer = function (user, name) {
var result = this._evaluator.getLayer(user, name);
var values = result.json_value;
return {
name: name,
ruleID: result.rule_id,
getValue: function (param) { var _a; return (_a = values[param]) !== null && _a !== void 0 ? _a : null; },
};
};

@@ -106,4 +146,4 @@ OnDeviceEvaluationsClient.prototype.logEvent = function (_user, _event) {

return OnDeviceEvaluationsClient;
}());
}(core_1.StatsigClientBase));
exports.default = OnDeviceEvaluationsClient;
//# sourceMappingURL=OnDeviceEvaluationsClient.js.map
import { StatsigOptionsCommon } from '@sigstat/core';
export type StatsigOptions = StatsigOptionsCommon & {
localEvalOption?: boolean;
baseDownloadConfigSpecsUrl?: string;
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc