npm package diff

Package: @forge/bridge

Versions: 5.7.0-next.10 - 5.7.0-next.11

File: package/out/featureFlags/featureFlags.js

Index: package/out/featureFlags/featureFlags.js
===================================================================
--- package/out/featureFlags/featureFlags.js
+++ package/out/featureFlags/featureFlags.js
@@ -2,16 +2,20 @@
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.ForgeFeatureFlags = void 0;
 const js_client_1 = require("@statsig/js-client");
 const dataAdapter_1 = require("./dataAdapter");
+const types_1 = require("../types");
+const featureFlagEvents_1 = require("./featureFlagEvents");
 class ForgeFeatureFlags {
     constructor() {
         this.initialized = false;
         this.client = null;
         this.dataAdapter = null;
+        this.eventProps = {};
         this.CLIENT_KEY = 'client-forge-internal-key';
     }
     async initialize(user, config = {}) {
+        var _a;
         if (this.isInitialized()) {
             return;
         }
         this.dataAdapter = new dataAdapter_1.ForgeDataAdapter();
@@ -21,16 +25,19 @@
             loggingEnabled: js_client_1.LoggingEnabledOption.disabled,
             logLevel: js_client_1.LogLevel.None,
             dataAdapter: this.dataAdapter
         };
+        this.eventProps.environment = (_a = options.environment) === null || _a === void 0 ? void 0 : _a.tier;
         this.client = new js_client_1.StatsigClient(this.CLIENT_KEY, this.convertUser(user), options);
         await this.client.initializeAsync();
         this.initialized = true;
     }
     checkFlag(flagName) {
         if (!this.isInitialized() || !this.client) {
+            this.sendCheckFlagEvent(flagName, false);
             throw new Error('ForgeFeatureFlags not initialized. Call initialize() first.');
         }
+        this.sendCheckFlagEvent(flagName, true);
         return this.client.checkGate(flagName, { disableExposureLog: true });
     }
     async shutdown() {
         if (!this.isInitialized() || !this.client) {
@@ -51,6 +58,18 @@
             custom: { ...(user.custom || {}), ...(user.attributes || {}) },
             customIDs: user.identifiers || {}
         };
     }
+    sendCheckFlagEvent(flagName, success) {
+        const props = {
+            type: types_1.FeatureFlagEventType.CHECKFLAG,
+            properties: {
+                ...this.eventProps,
+                environment: this.eventProps.environment || 'development',
+                name: flagName,
+                success
+            }
+        };
+        void (0, featureFlagEvents_1.trackFeatureFlagEvent)(props);
+    }
 }
 exports.ForgeFeatureFlags = ForgeFeatureFlags;