@featbit/js-client-sdk 2.0.2 → 3.0.1
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.
- package/LICENSE +21 -201
- package/README.md +160 -152
- package/dist/esm/Configuration.d.ts +35 -0
- package/dist/esm/Configuration.d.ts.map +1 -0
- package/dist/esm/Configuration.js +179 -0
- package/dist/esm/Configuration.js.map +1 -0
- package/dist/esm/Context.d.ts +23 -0
- package/dist/esm/Context.d.ts.map +1 -0
- package/dist/esm/Context.js +49 -0
- package/dist/esm/Context.js.map +1 -0
- package/dist/esm/FbClientBuilder.d.ts +90 -0
- package/dist/esm/FbClientBuilder.d.ts.map +1 -0
- package/dist/esm/FbClientBuilder.js +133 -0
- package/dist/esm/FbClientBuilder.js.map +1 -0
- package/dist/esm/FbClientCore.d.ts +57 -0
- package/dist/esm/FbClientCore.d.ts.map +1 -0
- package/dist/esm/FbClientCore.js +283 -0
- package/dist/esm/FbClientCore.js.map +1 -0
- package/dist/esm/IContextProperty.d.ts +5 -0
- package/dist/esm/IContextProperty.d.ts.map +1 -0
- package/dist/esm/IContextProperty.js +3 -0
- package/dist/esm/IContextProperty.js.map +1 -0
- package/dist/esm/IDataKind.d.ts +12 -0
- package/dist/esm/IDataKind.d.ts.map +1 -0
- package/dist/esm/IDataKind.js +3 -0
- package/dist/esm/IDataKind.js.map +1 -0
- package/dist/esm/IFbClient.d.ts +30 -0
- package/dist/esm/IFbClient.d.ts.map +1 -0
- package/dist/esm/IFbClient.js +3 -0
- package/dist/esm/IFbClient.js.map +1 -0
- package/dist/esm/IFbClientCore.d.ts +240 -0
- package/dist/esm/IFbClientCore.d.ts.map +1 -0
- package/dist/esm/IFbClientCore.js +3 -0
- package/dist/esm/IFbClientCore.js.map +1 -0
- package/dist/esm/IVersionedData.d.ts +18 -0
- package/dist/esm/IVersionedData.d.ts.map +1 -0
- package/dist/esm/IVersionedData.js +3 -0
- package/dist/esm/IVersionedData.js.map +1 -0
- package/dist/esm/bootstrap/IBootstrapProvider.d.ts +5 -0
- package/dist/esm/bootstrap/IBootstrapProvider.d.ts.map +1 -0
- package/dist/esm/bootstrap/IBootstrapProvider.js +3 -0
- package/dist/esm/bootstrap/IBootstrapProvider.js.map +1 -0
- package/dist/esm/bootstrap/JsonBootstrapProvider.d.ts +9 -0
- package/dist/esm/bootstrap/JsonBootstrapProvider.d.ts.map +1 -0
- package/dist/esm/bootstrap/JsonBootstrapProvider.js +29 -0
- package/dist/esm/bootstrap/JsonBootstrapProvider.js.map +1 -0
- package/dist/esm/bootstrap/NullBootstrapProvider.d.ts +8 -0
- package/dist/esm/bootstrap/NullBootstrapProvider.d.ts.map +1 -0
- package/dist/esm/bootstrap/NullBootstrapProvider.js +19 -0
- package/dist/esm/bootstrap/NullBootstrapProvider.js.map +1 -0
- package/dist/esm/bootstrap/index.d.ts +4 -0
- package/dist/esm/bootstrap/index.d.ts.map +1 -0
- package/dist/esm/bootstrap/index.js +20 -0
- package/dist/esm/bootstrap/index.js.map +1 -0
- package/dist/esm/constants.d.ts +3 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +6 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/data-sources/DataSourceUpdates.d.ts +17 -0
- package/dist/esm/data-sources/DataSourceUpdates.d.ts.map +1 -0
- package/dist/esm/data-sources/DataSourceUpdates.js +89 -0
- package/dist/esm/data-sources/DataSourceUpdates.js.map +1 -0
- package/dist/esm/data-sources/createStreamListeners.d.ts +19 -0
- package/dist/esm/data-sources/createStreamListeners.d.ts.map +1 -0
- package/dist/esm/data-sources/createStreamListeners.js +49 -0
- package/dist/esm/data-sources/createStreamListeners.js.map +1 -0
- package/dist/esm/data-sources/index.d.ts +3 -0
- package/dist/esm/data-sources/index.d.ts.map +1 -0
- package/dist/esm/data-sources/index.js +19 -0
- package/dist/esm/data-sources/index.js.map +1 -0
- package/dist/esm/data-sync/DataSyncMode.d.ts +5 -0
- package/dist/esm/data-sync/DataSyncMode.d.ts.map +1 -0
- package/dist/esm/data-sync/DataSyncMode.js +9 -0
- package/dist/esm/data-sync/DataSyncMode.js.map +1 -0
- package/dist/esm/data-sync/IDataSynchronizer.d.ts +15 -0
- package/dist/esm/data-sync/IDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/data-sync/IDataSynchronizer.js +3 -0
- package/dist/esm/data-sync/IDataSynchronizer.js.map +1 -0
- package/dist/esm/data-sync/IRequestor.d.ts +11 -0
- package/dist/esm/data-sync/IRequestor.d.ts.map +1 -0
- package/dist/esm/data-sync/IRequestor.js +3 -0
- package/dist/esm/data-sync/IRequestor.js.map +1 -0
- package/dist/esm/data-sync/NullDataSynchronizer.d.ts +8 -0
- package/dist/esm/data-sync/NullDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/data-sync/NullDataSynchronizer.js +15 -0
- package/dist/esm/data-sync/NullDataSynchronizer.js.map +1 -0
- package/dist/esm/data-sync/PollingDataSynchronizer.d.ts +23 -0
- package/dist/esm/data-sync/PollingDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/data-sync/PollingDataSynchronizer.js +87 -0
- package/dist/esm/data-sync/PollingDataSynchronizer.js.map +1 -0
- package/dist/esm/data-sync/Requestor.d.ts +20 -0
- package/dist/esm/data-sync/Requestor.d.ts.map +1 -0
- package/dist/esm/data-sync/Requestor.js +56 -0
- package/dist/esm/data-sync/Requestor.js.map +1 -0
- package/dist/esm/data-sync/WebSocketDataSynchronizer.d.ts +20 -0
- package/dist/esm/data-sync/WebSocketDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/data-sync/WebSocketDataSynchronizer.js +55 -0
- package/dist/esm/data-sync/WebSocketDataSynchronizer.js.map +1 -0
- package/dist/esm/data-sync/index.d.ts +10 -0
- package/dist/esm/data-sync/index.d.ts.map +1 -0
- package/dist/esm/data-sync/index.js +26 -0
- package/dist/esm/data-sync/index.js.map +1 -0
- package/dist/esm/data-sync/types.d.ts +17 -0
- package/dist/esm/data-sync/types.d.ts.map +1 -0
- package/dist/esm/data-sync/types.js +9 -0
- package/dist/esm/data-sync/types.js.map +1 -0
- package/dist/esm/data-sync/utils.d.ts +3 -0
- package/dist/esm/data-sync/utils.d.ts.map +1 -0
- package/dist/esm/data-sync/utils.js +33 -0
- package/dist/esm/data-sync/utils.js.map +1 -0
- package/dist/esm/errors.d.ts +16 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +41 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/evaluation/EvalResult.d.ts +20 -0
- package/dist/esm/evaluation/EvalResult.d.ts.map +1 -0
- package/dist/esm/evaluation/EvalResult.js +33 -0
- package/dist/esm/evaluation/EvalResult.js.map +1 -0
- package/dist/esm/evaluation/Evaluator.d.ts +15 -0
- package/dist/esm/evaluation/Evaluator.d.ts.map +1 -0
- package/dist/esm/evaluation/Evaluator.js +28 -0
- package/dist/esm/evaluation/Evaluator.js.map +1 -0
- package/dist/esm/evaluation/IEvalDetail.d.ts +21 -0
- package/dist/esm/evaluation/IEvalDetail.d.ts.map +1 -0
- package/dist/esm/evaluation/IEvalDetail.js +3 -0
- package/dist/esm/evaluation/IEvalDetail.js.map +1 -0
- package/dist/esm/evaluation/ReasonKinds.d.ts +11 -0
- package/dist/esm/evaluation/ReasonKinds.d.ts.map +1 -0
- package/dist/esm/evaluation/ReasonKinds.js +15 -0
- package/dist/esm/evaluation/ReasonKinds.js.map +1 -0
- package/dist/esm/evaluation/data/IFlag.d.ts +26 -0
- package/dist/esm/evaluation/data/IFlag.d.ts.map +1 -0
- package/dist/esm/evaluation/data/IFlag.js +12 -0
- package/dist/esm/evaluation/data/IFlag.js.map +1 -0
- package/dist/esm/evaluation/data/index.d.ts +2 -0
- package/dist/esm/evaluation/data/index.d.ts.map +1 -0
- package/dist/esm/evaluation/data/index.js +18 -0
- package/dist/esm/evaluation/data/index.js.map +1 -0
- package/dist/esm/evaluation/index.d.ts +6 -0
- package/dist/esm/evaluation/index.d.ts.map +1 -0
- package/dist/esm/evaluation/index.js +22 -0
- package/dist/esm/evaluation/index.js.map +1 -0
- package/dist/esm/events/DefaultEventProcessor.d.ts +16 -0
- package/dist/esm/events/DefaultEventProcessor.d.ts.map +1 -0
- package/dist/esm/events/DefaultEventProcessor.js +79 -0
- package/dist/esm/events/DefaultEventProcessor.js.map +1 -0
- package/dist/esm/events/DefaultEventQueue.d.ts +18 -0
- package/dist/esm/events/DefaultEventQueue.d.ts.map +1 -0
- package/dist/esm/events/DefaultEventQueue.js +42 -0
- package/dist/esm/events/DefaultEventQueue.js.map +1 -0
- package/dist/esm/events/DefaultEventSender.d.ts +10 -0
- package/dist/esm/events/DefaultEventSender.d.ts.map +1 -0
- package/dist/esm/events/DefaultEventSender.js +67 -0
- package/dist/esm/events/DefaultEventSender.js.map +1 -0
- package/dist/esm/events/DefaultEventSerializer.d.ts +6 -0
- package/dist/esm/events/DefaultEventSerializer.d.ts.map +1 -0
- package/dist/esm/events/DefaultEventSerializer.js +14 -0
- package/dist/esm/events/DefaultEventSerializer.js.map +1 -0
- package/dist/esm/events/EventDispatcher.d.ts +17 -0
- package/dist/esm/events/EventDispatcher.d.ts.map +1 -0
- package/dist/esm/events/EventDispatcher.js +127 -0
- package/dist/esm/events/EventDispatcher.js.map +1 -0
- package/dist/esm/events/EventSerializer.d.ts +5 -0
- package/dist/esm/events/EventSerializer.d.ts.map +1 -0
- package/dist/esm/events/EventSerializer.js +3 -0
- package/dist/esm/events/EventSerializer.js.map +1 -0
- package/dist/esm/events/IEventProcessor.d.ts +7 -0
- package/dist/esm/events/IEventProcessor.d.ts.map +1 -0
- package/dist/esm/events/IEventProcessor.js +3 -0
- package/dist/esm/events/IEventProcessor.js.map +1 -0
- package/dist/esm/events/IEventQueue.d.ts +11 -0
- package/dist/esm/events/IEventQueue.d.ts.map +1 -0
- package/dist/esm/events/IEventQueue.js +3 -0
- package/dist/esm/events/IEventQueue.js.map +1 -0
- package/dist/esm/events/IEventSender.d.ts +13 -0
- package/dist/esm/events/IEventSender.d.ts.map +1 -0
- package/dist/esm/events/IEventSender.js +10 -0
- package/dist/esm/events/IEventSender.js.map +1 -0
- package/dist/esm/events/NullEventProcessor.d.ts +8 -0
- package/dist/esm/events/NullEventProcessor.d.ts.map +1 -0
- package/dist/esm/events/NullEventProcessor.js +16 -0
- package/dist/esm/events/NullEventProcessor.js.map +1 -0
- package/dist/esm/events/event.d.ts +44 -0
- package/dist/esm/events/event.d.ts.map +1 -0
- package/dist/esm/events/event.js +115 -0
- package/dist/esm/events/event.js.map +1 -0
- package/dist/esm/events/index.d.ts +12 -0
- package/dist/esm/events/index.d.ts.map +1 -0
- package/dist/esm/events/index.js +28 -0
- package/dist/esm/events/index.js.map +1 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +37 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/integrations/TestLogger.d.ts +10 -0
- package/dist/esm/integrations/TestLogger.d.ts.map +1 -0
- package/dist/esm/integrations/TestLogger.js +25 -0
- package/dist/esm/integrations/TestLogger.js.map +1 -0
- package/dist/esm/integrations/index.d.ts +3 -0
- package/dist/esm/integrations/index.d.ts.map +1 -0
- package/dist/esm/integrations/index.js +21 -0
- package/dist/esm/integrations/index.js.map +1 -0
- package/dist/esm/integrations/test_data/FlagBuilder.d.ts +19 -0
- package/dist/esm/integrations/test_data/FlagBuilder.d.ts.map +1 -0
- package/dist/esm/integrations/test_data/FlagBuilder.js +56 -0
- package/dist/esm/integrations/test_data/FlagBuilder.js.map +1 -0
- package/dist/esm/integrations/test_data/TestData.d.ts +18 -0
- package/dist/esm/integrations/test_data/TestData.d.ts.map +1 -0
- package/dist/esm/integrations/test_data/TestData.js +38 -0
- package/dist/esm/integrations/test_data/TestData.js.map +1 -0
- package/dist/esm/integrations/test_data/TestDataSynchronizer.d.ts +21 -0
- package/dist/esm/integrations/test_data/TestDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/integrations/test_data/TestDataSynchronizer.js +50 -0
- package/dist/esm/integrations/test_data/TestDataSynchronizer.js.map +1 -0
- package/dist/esm/integrations/test_data/index.d.ts +5 -0
- package/dist/esm/integrations/test_data/index.d.ts.map +1 -0
- package/dist/esm/integrations/test_data/index.js +13 -0
- package/dist/esm/integrations/test_data/index.js.map +1 -0
- package/dist/esm/logging/BasicLogger.d.ts +34 -0
- package/dist/esm/logging/BasicLogger.d.ts.map +1 -0
- package/dist/esm/logging/BasicLogger.js +101 -0
- package/dist/esm/logging/BasicLogger.js.map +1 -0
- package/dist/esm/logging/IBasicLoggerOptions.d.ts +43 -0
- package/dist/esm/logging/IBasicLoggerOptions.d.ts.map +1 -0
- package/dist/esm/logging/IBasicLoggerOptions.js +3 -0
- package/dist/esm/logging/IBasicLoggerOptions.js.map +1 -0
- package/dist/esm/logging/ILogger.d.ts +47 -0
- package/dist/esm/logging/ILogger.d.ts.map +1 -0
- package/dist/esm/logging/ILogger.js +3 -0
- package/dist/esm/logging/ILogger.js.map +1 -0
- package/dist/esm/logging/LogLevel.d.ts +10 -0
- package/dist/esm/logging/LogLevel.d.ts.map +1 -0
- package/dist/esm/logging/LogLevel.js +3 -0
- package/dist/esm/logging/LogLevel.js.map +1 -0
- package/dist/esm/logging/SafeLogger.d.ts +28 -0
- package/dist/esm/logging/SafeLogger.d.ts.map +1 -0
- package/dist/esm/logging/SafeLogger.js +64 -0
- package/dist/esm/logging/SafeLogger.js.map +1 -0
- package/dist/esm/logging/format.d.ts +12 -0
- package/dist/esm/logging/format.d.ts.map +1 -0
- package/dist/esm/logging/format.js +156 -0
- package/dist/esm/logging/format.js.map +1 -0
- package/dist/esm/logging/index.d.ts +7 -0
- package/dist/esm/logging/index.d.ts.map +1 -0
- package/dist/esm/logging/index.js +23 -0
- package/dist/esm/logging/index.js.map +1 -0
- package/dist/esm/options/ClientContext.d.ts +28 -0
- package/dist/esm/options/ClientContext.d.ts.map +1 -0
- package/dist/esm/options/ClientContext.js +21 -0
- package/dist/esm/options/ClientContext.js.map +1 -0
- package/dist/esm/options/IClientContext.d.ts +45 -0
- package/dist/esm/options/IClientContext.d.ts.map +1 -0
- package/dist/esm/options/IClientContext.js +3 -0
- package/dist/esm/options/IClientContext.js.map +1 -0
- package/dist/esm/options/IOptions.d.ts +101 -0
- package/dist/esm/options/IOptions.d.ts.map +1 -0
- package/dist/esm/options/IOptions.js +3 -0
- package/dist/esm/options/IOptions.js.map +1 -0
- package/dist/esm/options/IUser.d.ts +7 -0
- package/dist/esm/options/IUser.d.ts.map +1 -0
- package/dist/esm/options/IUser.js +3 -0
- package/dist/esm/options/IUser.js.map +1 -0
- package/dist/esm/options/IValidatedOptions.d.ts +27 -0
- package/dist/esm/options/IValidatedOptions.d.ts.map +1 -0
- package/dist/esm/options/IValidatedOptions.js +3 -0
- package/dist/esm/options/IValidatedOptions.js.map +1 -0
- package/dist/esm/options/OptionMessages.d.ts +14 -0
- package/dist/esm/options/OptionMessages.d.ts.map +1 -0
- package/dist/esm/options/OptionMessages.js +33 -0
- package/dist/esm/options/OptionMessages.js.map +1 -0
- package/dist/esm/options/UserBuilder.d.ts +17 -0
- package/dist/esm/options/UserBuilder.d.ts.map +1 -0
- package/dist/esm/options/UserBuilder.js +35 -0
- package/dist/esm/options/UserBuilder.js.map +1 -0
- package/dist/esm/options/Validators.d.ts +111 -0
- package/dist/esm/options/Validators.d.ts.map +1 -0
- package/dist/esm/options/Validators.js +247 -0
- package/dist/esm/options/Validators.js.map +1 -0
- package/dist/esm/options/index.d.ts +9 -0
- package/dist/esm/options/index.d.ts.map +1 -0
- package/dist/esm/options/index.js +25 -0
- package/dist/esm/options/index.js.map +1 -0
- package/dist/esm/platform/IInfo.d.ts +92 -0
- package/dist/esm/platform/IInfo.d.ts.map +1 -0
- package/dist/esm/platform/IInfo.js +3 -0
- package/dist/esm/platform/IInfo.js.map +1 -0
- package/dist/esm/platform/IPlatform.d.ts +19 -0
- package/dist/esm/platform/IPlatform.d.ts.map +1 -0
- package/dist/esm/platform/IPlatform.js +3 -0
- package/dist/esm/platform/IPlatform.js.map +1 -0
- package/dist/esm/platform/IStore.d.ts +104 -0
- package/dist/esm/platform/IStore.d.ts.map +1 -0
- package/dist/esm/platform/IStore.js +3 -0
- package/dist/esm/platform/IStore.js.map +1 -0
- package/dist/esm/platform/IWebSocket.d.ts +21 -0
- package/dist/esm/platform/IWebSocket.d.ts.map +1 -0
- package/dist/esm/platform/IWebSocket.js +3 -0
- package/dist/esm/platform/IWebSocket.js.map +1 -0
- package/dist/esm/platform/browser/BrowserInfo.d.ts +7 -0
- package/dist/esm/platform/browser/BrowserInfo.d.ts.map +1 -0
- package/dist/esm/platform/browser/BrowserInfo.js +24 -0
- package/dist/esm/platform/browser/BrowserInfo.js.map +1 -0
- package/dist/esm/platform/browser/BrowserPlatform.d.ts +12 -0
- package/dist/esm/platform/browser/BrowserPlatform.d.ts.map +1 -0
- package/dist/esm/platform/browser/BrowserPlatform.js +17 -0
- package/dist/esm/platform/browser/BrowserPlatform.js.map +1 -0
- package/dist/esm/platform/browser/BrowserRequests.d.ts +5 -0
- package/dist/esm/platform/browser/BrowserRequests.d.ts.map +1 -0
- package/dist/esm/platform/browser/BrowserRequests.js +10 -0
- package/dist/esm/platform/browser/BrowserRequests.js.map +1 -0
- package/dist/esm/platform/browser/BrowserWebSocket.d.ts +38 -0
- package/dist/esm/platform/browser/BrowserWebSocket.d.ts.map +1 -0
- package/dist/esm/platform/browser/BrowserWebSocket.js +129 -0
- package/dist/esm/platform/browser/BrowserWebSocket.js.map +1 -0
- package/dist/esm/platform/browser/FbClient.d.ts +30 -0
- package/dist/esm/platform/browser/FbClient.d.ts.map +1 -0
- package/dist/esm/platform/browser/FbClient.js +52 -0
- package/dist/esm/platform/browser/FbClient.js.map +1 -0
- package/dist/esm/platform/browser/LocalStorageStore.d.ts +12 -0
- package/dist/esm/platform/browser/LocalStorageStore.d.ts.map +1 -0
- package/dist/esm/platform/browser/LocalStorageStore.js +65 -0
- package/dist/esm/platform/browser/LocalStorageStore.js.map +1 -0
- package/dist/esm/platform/index.d.ts +9 -0
- package/dist/esm/platform/index.d.ts.map +1 -0
- package/dist/esm/platform/index.js +29 -0
- package/dist/esm/platform/index.js.map +1 -0
- package/dist/esm/platform/requests.d.ts +64 -0
- package/dist/esm/platform/requests.d.ts.map +1 -0
- package/dist/esm/platform/requests.js +7 -0
- package/dist/esm/platform/requests.js.map +1 -0
- package/dist/esm/store/BaseStore.d.ts +25 -0
- package/dist/esm/store/BaseStore.d.ts.map +1 -0
- package/dist/esm/store/BaseStore.js +125 -0
- package/dist/esm/store/BaseStore.js.map +1 -0
- package/dist/esm/store/DataKinds.d.ts +5 -0
- package/dist/esm/store/DataKinds.d.ts.map +1 -0
- package/dist/esm/store/DataKinds.js +9 -0
- package/dist/esm/store/DataKinds.js.map +1 -0
- package/dist/esm/store/IDataSourceUpdates.d.ts +48 -0
- package/dist/esm/store/IDataSourceUpdates.d.ts.map +1 -0
- package/dist/esm/store/IDataSourceUpdates.js +3 -0
- package/dist/esm/store/IDataSourceUpdates.js.map +1 -0
- package/dist/esm/store/InMemoryStore.d.ts +11 -0
- package/dist/esm/store/InMemoryStore.d.ts.map +1 -0
- package/dist/esm/store/InMemoryStore.js +46 -0
- package/dist/esm/store/InMemoryStore.js.map +1 -0
- package/dist/esm/store/index.d.ts +7 -0
- package/dist/esm/store/index.d.ts.map +1 -0
- package/dist/esm/store/index.js +23 -0
- package/dist/esm/store/index.js.map +1 -0
- package/dist/esm/store/serialization.d.ts +23 -0
- package/dist/esm/store/serialization.d.ts.map +1 -0
- package/dist/esm/store/serialization.js +37 -0
- package/dist/esm/store/serialization.js.map +1 -0
- package/dist/esm/store/store.d.ts +30 -0
- package/dist/esm/store/store.d.ts.map +1 -0
- package/dist/esm/store/store.js +6 -0
- package/dist/esm/store/store.js.map +1 -0
- package/dist/esm/utils/Emits.d.ts +30 -0
- package/dist/esm/utils/Emits.d.ts.map +1 -0
- package/dist/esm/utils/Emits.js +64 -0
- package/dist/esm/utils/Emits.js.map +1 -0
- package/dist/esm/utils/EventEmitter.d.ts +22 -0
- package/dist/esm/utils/EventEmitter.d.ts.map +1 -0
- package/dist/esm/utils/EventEmitter.js +108 -0
- package/dist/esm/utils/EventEmitter.js.map +1 -0
- package/dist/esm/utils/IEventEmitter.d.ts +16 -0
- package/dist/esm/utils/IEventEmitter.d.ts.map +1 -0
- package/dist/esm/utils/IEventEmitter.js +3 -0
- package/dist/esm/utils/IEventEmitter.js.map +1 -0
- package/dist/esm/utils/Regex.d.ts +7 -0
- package/dist/esm/utils/Regex.d.ts.map +1 -0
- package/dist/esm/utils/Regex.js +22 -0
- package/dist/esm/utils/Regex.js.map +1 -0
- package/dist/esm/utils/ValueConverters.d.ts +13 -0
- package/dist/esm/utils/ValueConverters.d.ts.map +1 -0
- package/dist/esm/utils/ValueConverters.js +46 -0
- package/dist/esm/utils/ValueConverters.js.map +1 -0
- package/dist/esm/utils/VoidFunction.d.ts +2 -0
- package/dist/esm/utils/VoidFunction.d.ts.map +1 -0
- package/dist/esm/utils/VoidFunction.js +3 -0
- package/dist/esm/utils/VoidFunction.js.map +1 -0
- package/dist/esm/utils/canonicalizeUri.d.ts +2 -0
- package/dist/esm/utils/canonicalizeUri.d.ts.map +1 -0
- package/dist/esm/utils/canonicalizeUri.js +9 -0
- package/dist/esm/utils/canonicalizeUri.js.map +1 -0
- package/dist/esm/utils/debounce.d.ts +22 -0
- package/dist/esm/utils/debounce.d.ts.map +1 -0
- package/dist/esm/utils/debounce.js +34 -0
- package/dist/esm/utils/debounce.js.map +1 -0
- package/dist/esm/utils/http.d.ts +12 -0
- package/dist/esm/utils/http.d.ts.map +1 -0
- package/dist/esm/utils/http.js +26 -0
- package/dist/esm/utils/http.js.map +1 -0
- package/dist/esm/utils/index.d.ts +7 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +23 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/isNullOrUndefined.d.ts +2 -0
- package/dist/esm/utils/isNullOrUndefined.d.ts.map +1 -0
- package/dist/esm/utils/isNullOrUndefined.js +8 -0
- package/dist/esm/utils/isNullOrUndefined.js.map +1 -0
- package/dist/esm/utils/serializeUser.d.ts +3 -0
- package/dist/esm/utils/serializeUser.d.ts.map +1 -0
- package/dist/esm/utils/serializeUser.js +24 -0
- package/dist/esm/utils/serializeUser.js.map +1 -0
- package/dist/esm/utils/sleep.d.ts +3 -0
- package/dist/esm/utils/sleep.d.ts.map +1 -0
- package/dist/esm/utils/sleep.js +18 -0
- package/dist/esm/utils/sleep.js.map +1 -0
- package/dist/esm/version.d.ts +3 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +6 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/umd/featbit-js-client-sdk-3.0.1.js +2 -0
- package/dist/umd/featbit-js-client-sdk-3.0.1.js.map +1 -0
- package/dist/umd/featbit-js-client-sdk.js +2 -0
- package/dist/umd/featbit-js-client-sdk.js.map +1 -0
- package/package.json +22 -24
- package/src/Configuration.ts +233 -0
- package/src/Context.ts +62 -0
- package/src/FbClientBuilder.ts +161 -0
- package/src/FbClientCore.ts +389 -0
- package/src/IContextProperty.ts +4 -0
- package/src/IDataKind.ts +11 -0
- package/src/IFbClient.ts +30 -0
- package/src/IFbClientCore.ts +291 -0
- package/src/IVersionedData.ts +18 -0
- package/src/bootstrap/IBootstrapProvider.ts +5 -0
- package/src/bootstrap/JsonBootstrapProvider.ts +35 -0
- package/src/bootstrap/NullBootstrapProvider.ts +21 -0
- package/src/bootstrap/index.ts +3 -0
- package/src/constants.ts +2 -6
- package/src/data-sources/DataSourceUpdates.ts +89 -0
- package/src/data-sources/createStreamListeners.ts +66 -0
- package/src/data-sources/index.ts +2 -0
- package/src/data-sync/DataSyncMode.ts +4 -0
- package/src/data-sync/IDataSynchronizer.ts +15 -0
- package/src/data-sync/IRequestor.ts +10 -0
- package/src/data-sync/NullDataSynchronizer.ts +15 -0
- package/src/data-sync/PollingDataSynchronizer.ts +111 -0
- package/src/data-sync/Requestor.ts +61 -0
- package/src/data-sync/WebSocketDataSynchronizer.ts +74 -0
- package/src/data-sync/index.ts +9 -0
- package/src/data-sync/types.ts +20 -0
- package/src/data-sync/utils.ts +32 -0
- package/src/errors.ts +41 -0
- package/src/evaluation/EvalResult.ts +36 -0
- package/src/evaluation/Evaluator.ts +27 -0
- package/src/evaluation/IEvalDetail.ts +24 -0
- package/src/evaluation/ReasonKinds.ts +10 -0
- package/src/evaluation/data/IFlag.ts +29 -0
- package/src/evaluation/data/index.ts +1 -0
- package/src/evaluation/index.ts +5 -0
- package/src/events/DefaultEventProcessor.ts +84 -0
- package/src/events/DefaultEventQueue.ts +50 -0
- package/src/events/DefaultEventSender.ts +75 -0
- package/src/events/DefaultEventSerializer.ts +12 -0
- package/src/events/EventDispatcher.ts +128 -0
- package/src/events/EventSerializer.ts +5 -0
- package/src/events/IEventProcessor.ts +9 -0
- package/src/events/IEventQueue.ts +17 -0
- package/src/events/IEventSender.ts +14 -0
- package/src/events/NullEventProcessor.ts +16 -0
- package/src/events/event.ts +130 -0
- package/src/events/index.ts +11 -0
- package/src/index.ts +20 -4
- package/src/integrations/TestLogger.ts +25 -0
- package/src/integrations/index.ts +2 -0
- package/src/integrations/test_data/FlagBuilder.ts +60 -0
- package/src/integrations/test_data/TestData.ts +58 -0
- package/src/integrations/test_data/TestDataSynchronizer.ts +50 -0
- package/src/integrations/test_data/index.ts +5 -0
- package/src/logging/BasicLogger.ts +108 -0
- package/src/logging/IBasicLoggerOptions.ts +46 -0
- package/src/logging/ILogger.ts +49 -0
- package/src/logging/LogLevel.ts +9 -0
- package/src/logging/SafeLogger.ts +70 -0
- package/src/logging/format.ts +154 -0
- package/src/logging/index.ts +6 -0
- package/src/options/ClientContext.ts +40 -0
- package/src/options/IClientContext.ts +54 -0
- package/src/options/IOptions.ts +124 -0
- package/src/options/IUser.ts +7 -0
- package/src/options/IValidatedOptions.ts +30 -0
- package/src/options/OptionMessages.ts +36 -0
- package/src/options/UserBuilder.ts +36 -0
- package/src/options/Validators.ts +301 -0
- package/src/options/index.ts +8 -0
- package/src/platform/IInfo.ts +103 -0
- package/src/platform/IPlatform.ts +21 -0
- package/src/platform/IStore.ts +113 -0
- package/src/platform/IWebSocket.ts +23 -0
- package/src/platform/browser/BrowserInfo.ts +25 -0
- package/src/platform/browser/BrowserPlatform.ts +20 -0
- package/src/platform/browser/BrowserRequests.ts +7 -0
- package/src/platform/browser/BrowserWebSocket.ts +143 -0
- package/src/platform/browser/FbClient.ts +65 -0
- package/src/platform/browser/LocalStorageStore.ts +60 -0
- package/src/platform/index.ts +12 -0
- package/src/platform/requests.ts +77 -0
- package/src/store/BaseStore.ts +123 -0
- package/src/store/DataKinds.ts +7 -0
- package/src/store/IDataSourceUpdates.ts +49 -0
- package/src/store/InMemoryStore.ts +37 -0
- package/src/store/index.ts +6 -0
- package/src/store/serialization.ts +52 -0
- package/src/store/store.ts +38 -0
- package/src/utils/Emits.ts +76 -0
- package/src/utils/EventEmitter.ts +129 -0
- package/src/utils/IEventEmitter.ts +15 -0
- package/src/utils/Regex.ts +22 -0
- package/src/utils/ValueConverters.ts +56 -0
- package/src/utils/VoidFunction.ts +1 -0
- package/src/utils/canonicalizeUri.ts +4 -0
- package/src/utils/debounce.ts +33 -0
- package/src/utils/http.ts +40 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/isNullOrUndefined.ts +3 -0
- package/src/utils/serializeUser.ts +28 -0
- package/src/utils/sleep.ts +6 -0
- package/src/version.ts +1 -0
- package/esm/constants.d.ts +0 -6
- package/esm/constants.js +0 -7
- package/esm/constants.js.map +0 -1
- package/esm/events.d.ts +0 -14
- package/esm/events.js +0 -27
- package/esm/events.js.map +0 -1
- package/esm/featbit.d.ts +0 -34
- package/esm/featbit.js +0 -382
- package/esm/featbit.js.map +0 -1
- package/esm/index.d.ts +0 -4
- package/esm/index.js +0 -5
- package/esm/index.js.map +0 -1
- package/esm/logger.d.ts +0 -4
- package/esm/logger.js +0 -20
- package/esm/logger.js.map +0 -1
- package/esm/network.service.d.ts +0 -27
- package/esm/network.service.js +0 -288
- package/esm/network.service.js.map +0 -1
- package/esm/optionMessages.d.ts +0 -5
- package/esm/optionMessages.js +0 -16
- package/esm/optionMessages.js.map +0 -1
- package/esm/queue.d.ts +0 -8
- package/esm/queue.js +0 -35
- package/esm/queue.js.map +0 -1
- package/esm/store.d.ts +0 -20
- package/esm/store.js +0 -143
- package/esm/store.js.map +0 -1
- package/esm/throttleutil.d.ts +0 -9
- package/esm/throttleutil.js +0 -133
- package/esm/throttleutil.js.map +0 -1
- package/esm/types.d.ts +0 -94
- package/esm/types.js +0 -24
- package/esm/types.js.map +0 -1
- package/esm/umd.d.ts +0 -2
- package/esm/utils.d.ts +0 -11
- package/esm/utils.js +0 -142
- package/esm/utils.js.map +0 -1
- package/src/events.ts +0 -29
- package/src/featbit.ts +0 -343
- package/src/logger.ts +0 -13
- package/src/network.service.ts +0 -223
- package/src/optionMessages.ts +0 -13
- package/src/queue.ts +0 -23
- package/src/store.ts +0 -169
- package/src/throttleutil.ts +0 -72
- package/src/types.ts +0 -113
- package/src/umd.ts +0 -15
- package/src/utils.ts +0 -173
- package/umd/featbit-js-client-sdk-2.0.2.js +0 -2
- package/umd/featbit-js-client-sdk-2.0.2.js.map +0 -1
- package/umd/featbit-js-client-sdk.js +0 -2
- package/umd/featbit-js-client-sdk.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
> **
|
|
1
|
+
> **Attention**
|
|
2
2
|
>
|
|
3
|
-
>
|
|
3
|
+
> If you are using the v1 or v2 of the SDK, please refer to this [doc](https://github.com/featbit/featbit-js-client-sdk/tree/v2)
|
|
4
4
|
|
|
5
|
-
# FeatBit Client
|
|
5
|
+
# FeatBit Client SDK for JavaScript
|
|
6
6
|
|
|
7
7
|
## Introduction
|
|
8
8
|
|
|
9
|
-
This is the
|
|
9
|
+
This is the Client-Side SDK for the 100% open-source feature flags management platform [FeatBit](https://github.com/featbit/featbit).
|
|
10
10
|
|
|
11
11
|
Be aware, this is a client side SDK, it is intended for use in a single-user context, which can be mobile, desktop or embedded applications. This SDK can only be ran in a browser environment, it is not suitable for NodeJs applications.
|
|
12
12
|
|
|
@@ -15,127 +15,137 @@ Be aware, this is a client side SDK, it is intended for use in a single-user con
|
|
|
15
15
|
### Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install @featbit/js-client-sdk
|
|
18
|
+
npm install --save @featbit/js-client-sdk
|
|
19
19
|
```
|
|
20
|
-
|
|
21
20
|
### Prerequisite
|
|
22
21
|
|
|
23
|
-
Before using the SDK, you need to obtain the environment secret and SDK URLs.
|
|
22
|
+
Before using the SDK, you need to obtain the environment secret (the sdkKey) and SDK URLs.
|
|
24
23
|
|
|
25
24
|
Follow the documentation below to retrieve these values
|
|
26
|
-
|
|
27
|
-
- [How to get
|
|
28
|
-
- [How to get the SDK URLs](https://docs.featbit.co/sdk/faq#how-to-get-the-sdk-urls)
|
|
25
|
+
- [How to get environment secret](https://docs.featbit.co/sdk/faq#how-to-get-the-environment-secret)
|
|
26
|
+
- [How to get SDK URLs](https://docs.featbit.co/sdk/faq#how-to-get-the-sdk-urls)
|
|
29
27
|
|
|
30
28
|
### Quick Start
|
|
31
29
|
|
|
32
|
-
The following code demonstrates
|
|
33
|
-
1. Initialize the SDK
|
|
34
|
-
2. Evaluate flag
|
|
35
|
-
3. Subscribe to flag change
|
|
30
|
+
The following code demonstrates the basic usage of `@featbit/js-client-sdk`.
|
|
36
31
|
|
|
37
32
|
```javascript
|
|
38
|
-
import
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
import { FbClientBuilder, UserBuilder } from "@featbit/js-client-sdk";
|
|
34
|
+
|
|
35
|
+
const bob = new UserBuilder('a-unique-key-of-user')
|
|
36
|
+
.name('bob')
|
|
37
|
+
.custom('age', '18')
|
|
38
|
+
.custom('country', 'FR')
|
|
39
|
+
.build();
|
|
40
|
+
|
|
41
|
+
// setup SDK client with websocket streaming
|
|
42
|
+
const fbClient = new FbClientBuilder()
|
|
43
|
+
.sdkKey("your_sdk_key")
|
|
44
|
+
.streamingUri('ws://localhost:5100')
|
|
45
|
+
.eventsUri("http://localhost:5100")
|
|
46
|
+
.user(bob)
|
|
47
|
+
.build();
|
|
48
|
+
|
|
49
|
+
(async () => {
|
|
50
|
+
// wait for the SDK to be initialized
|
|
51
|
+
try {
|
|
52
|
+
await fbClient.waitForInitialization();
|
|
53
|
+
} catch(err) {
|
|
54
|
+
// failed to initialize the SDK
|
|
55
|
+
console.log(err);
|
|
52
56
|
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// initialization
|
|
56
|
-
fbClient.init(option);
|
|
57
57
|
|
|
58
|
-
//
|
|
59
|
-
const
|
|
58
|
+
// flag to be evaluated
|
|
59
|
+
const flagKey = "game-runner";
|
|
60
60
|
|
|
61
|
-
//
|
|
62
|
-
fbClient.
|
|
63
|
-
// change has this structure {id: 'the feature_flag_key', oldValue: theOldValue, newValue: theNewValue }
|
|
64
|
-
// the type of theOldValue and theNewValue is defined on FeatBit
|
|
61
|
+
// evaluate a feature flag for a given user
|
|
62
|
+
const boolVariation = await fbClient.boolVariation(flagKey, false);
|
|
65
63
|
|
|
66
|
-
//
|
|
67
|
-
const
|
|
68
|
-
|
|
64
|
+
// switch user
|
|
65
|
+
const alice = new UserBuilder('another-unique-key-of-user')
|
|
66
|
+
.name('alice')
|
|
67
|
+
.custom('country', 'UK')
|
|
68
|
+
.custom('age', 36)
|
|
69
|
+
.build();
|
|
70
|
+
|
|
71
|
+
await fbClient.identify(alice);
|
|
72
|
+
})();
|
|
69
73
|
```
|
|
70
74
|
|
|
71
75
|
## Examples
|
|
72
|
-
|
|
73
|
-
- [Vue](https://github.com/featbit/featbit-samples/tree/main/samples/dino-game/interactive-demo-vue)
|
|
76
|
+
- [web App](./examples/console-app)
|
|
74
77
|
- For how to use FeatBit with React, please refer to the [react-client-sdk](https://github.com/featbit/featbit-react-client-sdk)
|
|
75
78
|
|
|
76
79
|
## SDK
|
|
77
80
|
|
|
78
|
-
###
|
|
81
|
+
### FbClient
|
|
79
82
|
|
|
80
|
-
|
|
83
|
+
The `FbClient` is the heart of the SDK which provides access to FeatBit server. Applications should instantiate a single instance for the lifetime of the application.
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
const option = {
|
|
84
|
-
secret: "your env secret",
|
|
85
|
-
streamingUri:"ws://localhost:5100",
|
|
86
|
-
eventsUri:"http://localhost:5100",
|
|
87
|
-
user: {
|
|
88
|
-
name: "Bot",
|
|
89
|
-
keyId: "bot-id",
|
|
90
|
-
customizedProperties: [
|
|
91
|
-
{
|
|
92
|
-
"name": "level",
|
|
93
|
-
"value": "high"
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
};
|
|
85
|
+
`FbClientBuilder` is used to construct a `FbClient` instance. The builder exposes methods to configure the SDK, and finally to create the `FbClient` instance.
|
|
98
86
|
|
|
99
|
-
|
|
87
|
+
#### FbClient Using Streaming
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import { FbClientBuilder, UserBuilder } from "@featbit/js-client-sdk";
|
|
91
|
+
|
|
92
|
+
const user = new UserBuilder('a-unique-key-of-user')
|
|
93
|
+
.name('bob')
|
|
94
|
+
.build();
|
|
95
|
+
|
|
96
|
+
const fbClient = new FbClientBuilder()
|
|
97
|
+
.sdkKey("your_sdk_key")
|
|
98
|
+
.streamingUri('ws://localhost:5100')
|
|
99
|
+
.eventsUri("http://localhost:5100")
|
|
100
|
+
.user(user)
|
|
101
|
+
.build();
|
|
100
102
|
```
|
|
103
|
+
#### FbClient Using Polling
|
|
101
104
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
```javascript
|
|
106
|
+
import { FbClientBuilder, UserBuilder, DataSyncMode } from "@featbit/browser-server-sdk";
|
|
107
|
+
|
|
108
|
+
const user = new UserBuilder('a-unique-key-of-user')
|
|
109
|
+
.name('bob')
|
|
110
|
+
.build();
|
|
111
|
+
|
|
112
|
+
const fbClient = new FbClientBuilder()
|
|
113
|
+
.sdkKey("your_sdk_key")
|
|
114
|
+
.dataSyncMode(DataSyncMode.POLLING)
|
|
115
|
+
.pollingUri('http://localhost:5100')
|
|
116
|
+
.eventsUri("http://localhost:5100")
|
|
117
|
+
.pollingInterval(10000)
|
|
118
|
+
.build();
|
|
115
119
|
```
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
#### IUser
|
|
122
|
+
|
|
123
|
+
`IUser` defines the attributes of a user for whom you are evaluating feature flags. IUser has two built-in attributes: key and name. The only mandatory attribute of a IUser is the key, which must uniquely identify each user.
|
|
124
|
+
|
|
125
|
+
Besides these built-in properties, you can define any additional attributes associated with the user using `custom(string key, string value)` method on UserBuilder. Both built-in attributes and custom attributes can be referenced in targeting rules, and are included in analytics data.
|
|
126
|
+
|
|
127
|
+
`UserBuilder` is used to construct a `IUser` instance. The builder exposes methods to configure the IUser, and finally to create the IUser instance.
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
import { UserBuilder } from "@featbit/js-client-sdk";
|
|
118
131
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
| bootstrap | `[ ]` | Init the SDK with feature flags, this will trigger the ready event immediately instead of requesting from the remote. |
|
|
126
|
-
| streamingUri | `` | The evaluation server streaming URL. |
|
|
127
|
-
| eventsUri | `` | The evaluation server events URL. |
|
|
128
|
-
| appType | `javascript` | The app type. |
|
|
132
|
+
const bob = new UserBuilder("unique_key_for_bob")
|
|
133
|
+
.name("Bob")
|
|
134
|
+
.custom('age', 18)
|
|
135
|
+
.custom('country', 'FR')
|
|
136
|
+
.build();
|
|
137
|
+
```
|
|
129
138
|
|
|
130
139
|
### Bootstrap
|
|
131
|
-
If you already have the feature flags available,
|
|
132
|
-
|
|
140
|
+
If you already have the feature flags available, you can pass them to the SDK instead of requesting from the remote.
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
> **_NOTE:_** The bootstrapped flags will be overridden by the remote flags if they are available.
|
|
133
144
|
|
|
134
145
|
```javascript
|
|
135
146
|
// define the option with the bootstrap parameter
|
|
136
|
-
const
|
|
147
|
+
const options = {
|
|
137
148
|
...
|
|
138
|
-
// the array should contain all your feature flags
|
|
139
149
|
bootstrap = [{
|
|
140
150
|
// feature flag key name
|
|
141
151
|
id: string,
|
|
@@ -143,41 +153,57 @@ const option = {
|
|
|
143
153
|
variation: string,
|
|
144
154
|
// variation data type, string will be used if not specified
|
|
145
155
|
variationType: VariationDataType
|
|
146
|
-
}]
|
|
147
|
-
...
|
|
156
|
+
}]
|
|
148
157
|
}
|
|
149
158
|
|
|
150
|
-
fbClient.
|
|
159
|
+
const fbClient = new FbClientBuilder(options).build();
|
|
160
|
+
// or
|
|
161
|
+
const fbClient = new FbClientBuilder()
|
|
162
|
+
//... other options
|
|
163
|
+
.bootstrap(options.bootstrap)
|
|
164
|
+
.build();
|
|
151
165
|
```
|
|
152
166
|
|
|
153
|
-
|
|
167
|
+
### Evaluation
|
|
168
|
+
|
|
169
|
+
After initialization, the SDK has all the feature flags locally, and it does not need to request the remote server for any feature flag evaluation. All evaluation is done locally and synchronously, the average evaluation time is less than 1 ms.
|
|
170
|
+
|
|
171
|
+
There is a `variation` method that returns a flag value, and a `variationDetail` method that returns an object
|
|
172
|
+
describing how the value was determined for each type.
|
|
173
|
+
|
|
174
|
+
- boolVariation/boolVariationDetail
|
|
175
|
+
- stringVariation/stringVariationDetail
|
|
176
|
+
- numberVariation/numberVariationDetail
|
|
177
|
+
- jsonVariation/jsonVariationDetail
|
|
178
|
+
|
|
179
|
+
Variation calls take the feature flag key and a default value. If any error makes it impossible to
|
|
180
|
+
evaluate the flag (for instance, the feature flag key does not match any existing flag), default value is returned.
|
|
154
181
|
|
|
155
182
|
```javascript
|
|
156
|
-
//
|
|
157
|
-
const
|
|
158
|
-
// feature flag key name
|
|
159
|
-
id: string,
|
|
160
|
-
// variation value
|
|
161
|
-
variation: string,
|
|
162
|
-
// variation data type, string will used if not specified
|
|
163
|
-
variationType: VariationDataType
|
|
164
|
-
}]
|
|
165
|
-
|
|
166
|
-
fbClient.bootstrap(featureflags);
|
|
167
|
-
```
|
|
183
|
+
// flag to be evaluated
|
|
184
|
+
const flagKey = "game-runner";
|
|
168
185
|
|
|
169
|
-
|
|
186
|
+
// evaluate a feature flag for a given user
|
|
187
|
+
const boolVariation = await fbClient.boolVariation(flagKey, false);
|
|
170
188
|
|
|
171
|
-
|
|
189
|
+
// evaluate a boolean flag for a given user with evaluation detail
|
|
190
|
+
const boolVariationDetail = await fbClient.boolVariationDetail(flagKey, false);
|
|
191
|
+
```
|
|
172
192
|
|
|
173
|
-
|
|
193
|
+
### Offline Mode
|
|
174
194
|
|
|
195
|
+
In some situations, you might want to stop making remote calls to FeatBit. Here is how:
|
|
175
196
|
```javascript
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
197
|
+
import { FbClientBuilder } from "@featbit/browser-server-sdk";
|
|
198
|
+
|
|
199
|
+
const fbClient = new FbClientBuilder()
|
|
200
|
+
//... other options
|
|
201
|
+
.offline(true)
|
|
202
|
+
.build();
|
|
203
|
+
|
|
180
204
|
```
|
|
205
|
+
When Offline mode is enabled, you should provide the flags with the [bootstrap](#bootstrap) option,
|
|
206
|
+
otherwise, the SDK would return the defaul value you passed to the `variation` method.
|
|
181
207
|
|
|
182
208
|
### Events
|
|
183
209
|
|
|
@@ -188,27 +214,25 @@ To find out when the client is ready, you can use one of two mechanisms: events
|
|
|
188
214
|
The client object can emit JavaScript events. It emits a ready event when it receives initial flag values from the server. You can listen for this event to determine when the client is ready to evaluate flags.
|
|
189
215
|
|
|
190
216
|
```javascript
|
|
191
|
-
fbClient.on('ready', (
|
|
192
|
-
// data has the following structure [ {id: 'featureFlagKey', variation: variationValue} ]
|
|
193
|
-
// variationValue has the type as defined on remote
|
|
217
|
+
fbClient.on('ready', () => {
|
|
194
218
|
var flagValue = fbClient.variation("YOUR_FEATURE_KEY", defaultValue);
|
|
195
219
|
});
|
|
196
220
|
```
|
|
197
221
|
|
|
198
|
-
Or, you can use a promise instead of an event. The SDK has a method that
|
|
222
|
+
Or, you can use a promise instead of an event. The SDK has a method that returns a promise for initialization: **waitForInitialization()**. The behavior of waitUntilReady() is equivalent to the ready event. The promise resolves when the client receives its initial flag data. As with all promises, you can either use .then() to provide a callback, or use await if you are writing asynchronous code.
|
|
199
223
|
|
|
200
224
|
```javascript
|
|
201
|
-
fbClient.
|
|
225
|
+
fbClient.waitForInitialization().then((data) => {
|
|
202
226
|
// data has the following structure [ {id: 'featureFlagKey', variation: variationValue } ]
|
|
203
227
|
// variationValue has the type as defined on remote
|
|
204
228
|
// initialization succeeded, flag values are now available
|
|
205
229
|
});
|
|
206
230
|
// or, with await:
|
|
207
|
-
const featureFlags = await fbClient.
|
|
231
|
+
const featureFlags = await fbClient.waitForInitialization();
|
|
208
232
|
// initialization succeeded, flag values are now available
|
|
209
233
|
```
|
|
210
234
|
|
|
211
|
-
The SDK only decides initialization has failed if it receives an error response indicating that the environment ID is invalid. If it has trouble connecting to
|
|
235
|
+
The SDK only decides initialization has failed if it receives an error response indicating that the environment ID is invalid. If it has trouble connecting to FeatBit, it will keep retrying until it succeeds.
|
|
212
236
|
|
|
213
237
|
#### Subscribe to flag(s) changes
|
|
214
238
|
|
|
@@ -216,10 +240,7 @@ To get notified when a feature flag is changed, we offer two methods
|
|
|
216
240
|
- subscribe to the changes of any feature flag(s)
|
|
217
241
|
|
|
218
242
|
```javascript
|
|
219
|
-
fbClient.on('
|
|
220
|
-
// changes has this structure [{id: 'the feature_flag_key', oldValue: theOldValue, newValue: theNewValue }]
|
|
221
|
-
// the type of theOldValue and theNewValue is defined on FeatBit
|
|
222
|
-
|
|
243
|
+
fbClient.on('update', (keys: string[]) => {
|
|
223
244
|
// do something when any feature flag changes
|
|
224
245
|
});
|
|
225
246
|
|
|
@@ -228,66 +249,53 @@ fbClient.on('ff_update', (changes) => {
|
|
|
228
249
|
|
|
229
250
|
```javascript
|
|
230
251
|
// replace feature_flag_key with your feature flag key
|
|
231
|
-
fbClient.on('
|
|
232
|
-
// change has this structure {id: 'the feature_flag_key', oldValue: theOldValue, newValue: theNewValue }
|
|
233
|
-
// the type of theOldValue and theNewValue is defined on FeatBit
|
|
234
|
-
|
|
235
|
-
// defaultValue should have the same type as theOldValue and theNewValue
|
|
236
|
-
// this is the prefered way than calling change.newValue as each time you call fbClient.variation,
|
|
237
|
-
// the insight data is sent to server automatically
|
|
252
|
+
fbClient.on('update:feature_flag_key', (key) => {
|
|
238
253
|
const myFeature = fbClient.variation('feature_flag_key', defaultValue);
|
|
239
254
|
});
|
|
240
255
|
|
|
241
256
|
```
|
|
242
257
|
|
|
243
258
|
### Switch user after initialization
|
|
244
|
-
If the user
|
|
259
|
+
If the user changed after some process, login for example, the following method can be used to set the user after initialization.
|
|
245
260
|
|
|
246
261
|
```javascript
|
|
247
262
|
await fbClient.identify(user);
|
|
248
263
|
```
|
|
249
264
|
|
|
250
|
-
We can manually call the method logout, which will switch the current user back to anonymous user if exists already or create a new anonymous user.
|
|
251
|
-
|
|
252
|
-
```javascript
|
|
253
|
-
fbClient.logout(user);
|
|
254
|
-
```
|
|
255
265
|
|
|
256
266
|
### Data synchronization
|
|
257
267
|
|
|
258
|
-
We use
|
|
268
|
+
We use **WebSocket** or **Polling** to make the local data synchronized with the server, and then store them in localStorage by default. Whenever there is any change to a feature flag or its related data, this change will be pushed to the SDK, the average synchronization time is less than **100ms** if WebSocket is configured. Be aware the WebSocket/Polling connection may be interrupted due to internet outage, but it will be resumed automatically once the problem is gone.
|
|
259
269
|
|
|
260
270
|
### Network failure handling
|
|
261
271
|
|
|
262
272
|
As all data is stored locally in the localStorage, in the following situations, the SDK would still work when there is temporarily no internet connection:
|
|
263
273
|
- it has already received the data from previous connections
|
|
264
|
-
- the fbClient.bootstrap(featureFlags) method is called with all necessary feature flags
|
|
274
|
+
- the `fbClient.bootstrap(featureFlags)` method is called with all necessary feature flags
|
|
265
275
|
|
|
266
276
|
In the meantime, the SDK would try to reconnect to the server by an incremental interval, this makes sure that the websocket would be restored when the internet connection is back.
|
|
267
277
|
|
|
268
|
-
|
|
269
278
|
### Experiments (A/B/n Testing)
|
|
270
279
|
|
|
271
|
-
We support automatic experiments for
|
|
280
|
+
We support automatic experiments for pageviews and clicks, you just need to set your experiment on our SaaS platform,
|
|
281
|
+
then you should be able to see the result in near real time after the experiment is started.
|
|
272
282
|
|
|
273
283
|
In case you need more control over the experiment data sent to our server, we offer a method to send custom event.
|
|
274
284
|
|
|
275
285
|
```javascript
|
|
276
|
-
fbClient.
|
|
277
|
-
eventName: 'your event name',
|
|
278
|
-
numericValue: 1
|
|
279
|
-
}])
|
|
286
|
+
fbClient.track(eventName, numericValue);
|
|
280
287
|
```
|
|
281
288
|
|
|
282
|
-
**numericValue** is not mandatory, the default value is **1**.
|
|
289
|
+
**numericValue** is not mandatory, the default value is **1.0**.
|
|
283
290
|
|
|
284
|
-
Make sure
|
|
291
|
+
Make sure `track` is called after the related feature flag is called, otherwise the custom event won't be included
|
|
292
|
+
into the experiment result.
|
|
285
293
|
|
|
286
294
|
## Getting support
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
- If you encounter a bug or would like to request a
|
|
295
|
+
- If you have a specific question about using this sdk, we encourage you
|
|
296
|
+
to [ask it in our slack](https://join.slack.com/t/featbit/shared_invite/zt-1ew5e2vbb-x6Apan1xZOaYMnFzqZkGNQ).
|
|
297
|
+
- If you encounter a bug or would like to request a
|
|
298
|
+
feature, [submit an issue](https://github.com/featbit/dotnet-server-sdk/issues/new).
|
|
290
299
|
|
|
291
300
|
## See Also
|
|
292
|
-
|
|
293
|
-
- [Connect To JavaScript Sdk](https://docs.featbit.co/getting-started/connect-an-sdk#javascript)
|
|
301
|
+
- [Connect To JavaScript Sdk](https://docs.featbit.co/getting-started/connect-an-sdk#javascript)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IOptions } from "./options/IOptions";
|
|
2
|
+
import { ILogger } from "./logging/ILogger";
|
|
3
|
+
import { IValidatedOptions } from "./options/IValidatedOptions";
|
|
4
|
+
import { IStore } from "./platform/IStore";
|
|
5
|
+
import { IClientContext } from "./options/IClientContext";
|
|
6
|
+
import { IDataSynchronizer } from "./data-sync/IDataSynchronizer";
|
|
7
|
+
import { IDataSourceUpdates } from "./store/IDataSourceUpdates";
|
|
8
|
+
import { VoidFunction } from "./utils/VoidFunction";
|
|
9
|
+
import { IBootstrapProvider } from "./bootstrap/IBootstrapProvider";
|
|
10
|
+
import { DataSyncModeEnum } from "./data-sync/DataSyncMode";
|
|
11
|
+
import { IUser } from "./options/IUser";
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare const defaultValues: IValidatedOptions;
|
|
16
|
+
export default class Configuration {
|
|
17
|
+
readonly startWaitTime: number;
|
|
18
|
+
readonly sdkKey: string;
|
|
19
|
+
readonly streamingUri: string;
|
|
20
|
+
readonly pollingUri: string;
|
|
21
|
+
readonly eventsUri: string;
|
|
22
|
+
readonly webSocketPingInterval: number;
|
|
23
|
+
readonly logger?: ILogger;
|
|
24
|
+
readonly flushInterval: number;
|
|
25
|
+
readonly maxEventsInQueue: number;
|
|
26
|
+
readonly pollingInterval: number;
|
|
27
|
+
readonly offline: boolean;
|
|
28
|
+
readonly dataSyncMode: DataSyncModeEnum;
|
|
29
|
+
readonly bootstrapProvider: IBootstrapProvider;
|
|
30
|
+
readonly user: IUser;
|
|
31
|
+
readonly storeFactory: (clientContext: IClientContext) => IStore;
|
|
32
|
+
readonly dataSynchronizerFactory?: (clientContext: IClientContext, store: IStore, dataSourceUpdates: IDataSourceUpdates, initSuccessHandler: VoidFunction, errorHandler?: (e: Error) => void) => IDataSynchronizer;
|
|
33
|
+
constructor(options?: IOptions);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=Configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../src/Configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AA+BxC;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,iBAgB3B,CAAC;AAiEF,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC,SAAgB,qBAAqB,EAAE,MAAM,CAAC;IAE9C,SAAgB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjC,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,SAAgB,gBAAgB,EAAE,MAAM,CAAC;IAEzC,SAAgB,eAAe,EAAE,MAAM,CAAC;IAExC,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,SAAgB,YAAY,EAAE,gBAAgB,CAAC;IAE/C,SAAgB,iBAAiB,EAAE,kBAAkB,CAA+B;IAEpF,SAAgB,IAAI,EAAE,KAAK,CAAC;IAE5B,SAAgB,YAAY,EAAE,CAAC,aAAa,EAAE,cAAc,KAAK,MAAM,CAAC;IAExE,SAAgB,uBAAuB,CAAC,EAAE,CACxC,aAAa,EAAE,cAAc,EAC7B,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,kBAAkB,EACrC,kBAAkB,EAAE,YAAY,EAChC,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,KAC9B,iBAAiB,CAAC;gBAEX,OAAO,GAAE,QAAa;CA6DnC"}
|