@forge/bridge
5.15.2-next.0-experimental-5b726e65.16.0-next.1
out/featureFlags/featureFlags.js~
out/featureFlags/featureFlags.jsModified+9
Index: package/out/featureFlags/featureFlags.js
===================================================================
--- package/out/featureFlags/featureFlags.js
+++ package/out/featureFlags/featureFlags.js
@@ -9,8 +9,11 @@
constructor() {
this.initialized = false;
this.eventProps = {};
}
+ /**
+ * Initialize the feature flags client
+ */
async initialize(user, config = { environment: 'development' }) {
if (this.isInitialized()) {
return;
}
@@ -21,16 +24,22 @@
const result = await (0, initFeatureFlags_1.initFeatureFlags)({ user, config });
this.initialized = true;
this.evaluator = new evaluator_1.Evaluator(result);
}
+ /**
+ * Check if a feature flag is enabled for the user
+ */
checkFlag(flagName, defaultValue = false) {
if (!this.isInitialized() || !this.evaluator) {
this.sendCheckFlagEvent(flagName, false);
throw new Error('FeatureFlags not initialized. Call initialize() first.');
}
this.sendCheckFlagEvent(flagName, true);
return this.evaluator.checkFlag(flagName, defaultValue);
}
+ /**
+ * Shutdown the feature flags client
+ */
shutdown() {
if (!this.isInitialized()) {
return;
}