@forge/cli-shared
9.4.0-next.4-experimental-c5755749.4.0-next.6
out/service/statsig-service.js~
out/service/statsig-service.jsModified+26
Index: package/out/service/statsig-service.js
===================================================================
--- package/out/service/statsig-service.js
+++ package/out/service/statsig-service.js
@@ -2,8 +2,30 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatsigService = exports.StatsigReader = void 0;
exports.cacheStatsigResult = cacheStatsigResult;
const index_1 = require("../index");
+const HINT_SEPARATOR = '::';
+const HINT_CATEGORY_SEPARATOR = ',';
+function parseHint(configured) {
+ const weightEnd = configured.indexOf(HINT_SEPARATOR);
+ if (weightEnd <= 0) {
+ return undefined;
+ }
+ const categoriesEnd = configured.indexOf(HINT_SEPARATOR, weightEnd + HINT_SEPARATOR.length);
+ if (categoriesEnd < 0) {
+ return undefined;
+ }
+ const weight = Number(configured.slice(0, weightEnd));
+ const categories = configured
+ .slice(weightEnd + HINT_SEPARATOR.length, categoriesEnd)
+ .split(HINT_CATEGORY_SEPARATOR)
+ .map((category) => category.trim().toLowerCase())
+ .filter((category) => category.length > 0);
+ const text = configured.slice(categoriesEnd + HINT_SEPARATOR.length);
+ return text && categories.length > 0 && Number.isFinite(weight) && weight > 0
+ ? { weight, categories, text }
+ : undefined;
+}
class StatsigReader {
async testForgeCliTestGate() {
return (await this.checkGate('forge-cli-test-gate')) ?? false;
}
@@ -51,8 +73,12 @@
}
async getCustomSpinnerConfig() {
return (await this.getDynamicConfig('forge-cli-enable-custom-spinner')) ?? null;
}
+ async getHints() {
+ const configured = await this.getDynamicConfig('forge-cli-hints');
+ return configured?.map(parseHint).filter((hint) => hint !== undefined) ?? null;
+ }
}
exports.StatsigReader = StatsigReader;
var STATSIG_API_KEYS;
(function (STATSIG_API_KEYS) {