common-js

Common Javascript library for ConfigCat. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.

MIT License

Downloads
459K
Stars
16
common-js - v9.3.0 Latest Release

Published by adams85 7 months ago

Improvements:

  • Make naming of UserComparator members consistent. (#102)
  • Make line terminator character sequence configurable in log messages.
  • Adjust the terminology used in JSDoc comments to the main documentation.
  • Minor performance improvements.

Bug fixes:

  • Align evaluation logging and evaluator error reporting in some edge cases where the config JSON contains errors.
  • Correct grammar mistakes in error messages.

Breaking changes:

  • Change the name of some UserComparator members: Is(Not)OneOf -> TextIs(Not)OneOf, SensitiveIs(Not)OneOf -> SensitiveTextIs(Not)OneOf, (Not)ContainsAnyOf -> Text(Not)ContainsAnyOf. (Low impact expected.)
common-js - v9.2.0

Published by adams85 10 months ago

New features/improvements:

  • Move the createFlagOverridesFromMap function to the configcat-common package to reduce redundancy.
  • Add an optional parameter named watchChanges to createFlagOverridesFromMap which controls whether the client should detect changes to the flag override map after client initialization. (https://github.com/configcat/common-js/pull/101)

Notable internal breaking changes:

  • Remove IOverrideDataSource, FlagOverrides (type is still re-exported) and MapOverrideDataSource from package re-exports.
common-js - v9.1.0

Published by adams85 10 months ago

Improvements:

  • Don't swallow but log exceptions when config JSON deserialization fails so users can get a clue about what went wrong with the deserialization.
  • Improve the message of log event 1103.
  • Minor code quality improvements.

Bug fixes:

  • Fix getKeyAndValueAsync so it doesn't return an unsupported setting value coming from an invalid flag override.

Breaking changes:

  • Correct the generic parameter constraint of IEvaluationDetails and `SettingKey. (Very low impact expected.)
  • Correct minor errors in the config model type definition. (Very low impact expected.)

Notable internal breaking changes:

  • Move config model enums (SettingType, UserComparator, PrerequisiteFlagComparator, SegmentComparator) into the ConfigJson module.
common-js - v9.0.0

Published by adams85 11 months ago

New features and improvements:

  • Add support for the new Config JSON v6 format: update the config model and implement new features in setting evaluation logic. (https://github.com/configcat/common-js/pull/96)
  • Overhaul setting evaluation-related logging and make it consistent across SDKs.
  • Performance improvements to setting evaluation (building of evaluation log is expensive, so it is skipped when info level logging is turned off).

Bug fixes:

  • Hook event handlers which close over the client instance should not prevent the client from being collected by the GC when user has no more references to the client instance. (https://github.com/configcat/common-js/pull/97)
  • Prevent potential issues with weak references when awaiting IConfigCatClient.waitForReady. Also, make observable if the initial cache sync-up fails.

Breaking changes (listed in the order of expected impact):

  • Rename the matchedEvaluationRule property to matchedTargetingRule and the matchedEvaluationPercentageRule property to matchedPercentageOption in IEvaluationDetails.
  • Throw Error when the SDK key passed to ConfigCatClient.get is in invalid format (unless the client is set up to use local-only flag override behavior).
  • Remove the deprecated ClientReadyState enum (it was renamed to ClientCacheState).
  • Change config model (IConfig and related interfaces/enums).
  • Slightly change the behavior of the ClientReady hook in Auto Poll mode to fire after the completion of the first fetch operation - regardless of success or failure - to make the behavior consistent with other SDKs. (https://github.com/configcat/common-js/pull/94)

Notable internal breaking changes:

  • Move the User class into a separate module.
  • Change the signature of IRolloutEvaluator.evaluate.
common-js - v8.2.0

Published by adams85 about 1 year ago

New features and improvements:

  • Add a new property named cacheState to IConfigCatClientSnapshot, which can be used to get information about the "up-to-dateness" of the state captured by the snapshot.
  • Improve initial config cache sync-up: if the client is set up to use a cache strategy whose get operation is synchronous, the sync-up on client construction will also happen synchronously. (As a consequence, in such cases the cacheState property of a snapshot created right after the client instantiation will already reflect the actual cache state.)

Bug fixes:

  • Prevent user application from hanging on exit in Auto Poll mode until maxInitWaitTimeSeconds has passed.
  • Fix typo in the JSDoc documentation.
common-js - v8.1.1

Published by adams85 about 1 year ago

Improvements:

  • For better compatibility, restrict the TypeScript language features used to those which are available in v4.0 by downgrading the TypeScript compiler version.
common-js - v8.1.0

Published by adams85 over 1 year ago

New features and improvements:

  • Provide a way to synchronously evaluate of feature flags/settings: consumers can create a snapshot of the client by IConfigCatClient.snapshot(), which captures the client's state (including the latest config fetched), then, using the returned object, they can execute synchronous evaluation operations.
  • Add a state parameter to the clientReady hook, by means of which consumers can get information about the initialization state of the client.
  • Minor performance improvements.

Bug fixes:

  • Fix error logging of getValueAsync/getValueDetailsAsync calls.
  • Fix JSDoc documentation of Comparator.Contains/NotContains.
common-js - v8.0.2

Published by z4kn4fein over 1 year ago

Bug fixes:

  • In browser environments, the configChanged hook was emitted even when the downloaded config JSON wasn't changed.
common-js - v8.0.1

Published by adams85 over 1 year ago

Bug fixes:

  • Fix return value of getAllValues when one or more settings evaluate with error.

Notable internal breaking changes:

  • Change the return type of IRolloutEvaluator.evaluate to IEvaluateResult.
common-js - v8.0.0

Published by adams85 over 1 year ago

Please note that this version comes with several breaking changes, so you may need to adjust your code when upgrading, especially if you're using deprecated APIs or a custom logger and/or cache implementation. You can find the detailed list of breaking changes below.

New features and improvements:

  • Complete overhaul of SDK logging:
    • Simplify the logger interface (IConfigCatLogger) to make it easier to write custom implementations/adapters to logger frameworks.
    • Enable structured logging.
    • Include event IDs in log messages to make identification of log events easier.
    • Revise log messages and make them consistent across the ConfigCat SDKs.
  • Revise caching of downloaded config data:
    • Change the cache interface (IConfigCatCache, formerly ICache) to get and set the cache payload as a plain string to make it easier to write custom implementations by removing the burden of data serialization from implementers.
    • Use a standardized config cache key generation algorithm and cache payload format to allow shared caches to be used by SDKs of different platforms.
  • Revise JSDoc documentation.
  • Improve the performance of the "IS (NOT) ONE OF (sensitive)" operators by hashing the value once (https://github.com/configcat/common-js/pull/80).

Bug fixes:

  • Fix checks which ensure that IAutoPollOptions.pollIntervalSeconds, IAutoPollOptions.maxInitWaitTimeSeconds and ILazyLoadingOptions.cacheTimeToLiveSeconds settings are in the valid range. (Also, make infinite init wait possible in the case of Auto Polling.)
  • Fix ... is not a function bug which can occur in Auto Polling mode, when IAutoPollOptions.maxInitWaitTimeSeconds is set to 0.

Breaking changes (listed in the order of expected impact):

  • Remove the createClientWithAutoPoll, createClientWithManualPoll and createClientWithLazyLoad factory functions. Alternative: getClient.
  • Remove all callback-style evaluation methods (e.g. getValue, getValueDetails, etc.) from IConfigCatClient. Alternative: get*Async(...).then(result => ...)
  • Remove the callback-style forceRefresh method from IConfigCatClient. Alternative: forceRefreshAsync(...).then(result => ...)
  • Remove the IAutoPollOptions.configChanged callback. Alternative: options.setupHooks = hooks => hooks.on("configChanged", ...).
  • Changes the type of the newConfig argument from ProjectConfig to IConfig in the configChanged hook.
  • Remove the debug, info, warn and error methods from IConfigCatLogger and change the signature of the log method, which is now the single method that needs to be implemented for custom logging.
  • Remove the ICache interface. Alternative: IConfigCatCache.
  • Remove the getVariationIdAsync and getAllVariationIdsAsync methods from IConfigCatClient/ConfigCatClient. Alternative: getValueDetailsAsync and getAllValueDetailsAsync.
  • Slightly change the behavior of flag overrides so default value is returned instead of an unsupported value.
  • Slightly change the behavior of getValuesAsync and getValuesDetailsAsync to fail early with exception when these methods are called with invalid parameters:
    • Error when key is empty.
    • TypeError when defaultValue is not of an allowed type (string, boolean, number, null and undefined).
  • Remove the IOverrideDataSource interface and the FlagOverrides and MapOverrideDataSource classes from the public API.
  • Remove the ProjectConfig, RolloutRule and RolloutPercentageItem classes from the public API.
  • Change the type of the MatchedEvaluationRule to ITargetingRule and MatchedEvaluationPercentageRule to IPercentageOption in IEvaluationDetails.
  • Change the algorithm used to generate the config cache key and the format of the cache payload.

Notable internal breaking changes:

  • Replaces the cache property with defaultCacheFactory in IConfigCatKernel (+ in OptionsBase constructors) to allow platform-specific SDKs to use own external cache implementations (like local storage cache) as default cache implementations. When the factory is not set, InMemoryConfigCache will be used by default.
common-js - v7.0.1

Published by adams85 almost 2 years ago

Fix potential ReferenceError in polyfills.

common-js - v7.0.0

Published by adams85 almost 2 years ago

  • Deprecate factory functions (createClientWith*) in favor of the new factory method getClient,
    which provides single client instances per SDK key.
  • Add convenience method disposeAllClients for disposing all open clients at once.
  • Implement default user feature.
  • Implement offline mode feature.
  • Improve LazyLoad and AutoPoll refresh logic by taking the cache timestamp into account
    to fetch the config only if cached config is unavailable or stale.
  • Add new evaluation methods getValueDetail/getValueDetailAsync and getAllValueDetails/getAllValueDetailsAsync,
    which provide more detailed information about the evaluation result.
  • Deprecate all callback-style get* functions and also deprecate getVariationIdAsync and getAllVariationIdsAsync.
  • Add hooks (events), which provide notifications of the client's actions.
  • Additional minor code quality and performance improvements.

Breaking changes

  • Remove redundancy from the package (lib/cjs folder removed, TS type declarations included only once)
  • Improve type safety of setting evaluation methods:
    • [API] make getValue/getValueAsync and getVariationId/getVariationIdAsync generic to enforce that the compile-time type of default value and return value match,
    • [Behavior] also make sure that run-time type of default value and actual setting value match (if not, an error message is logged and default value is returned).
  • [API] Change IConfigCatClient.refreshConfig/refreshConfigAsync to return information about the success of the operation.
  • [Behavior] Slightly change the behavior of ProjectConfig.Timestamp (updated when communication with the CDN servers succeeds, even in the case of several erroneous status codes like 403 and 404.)
  • [Behavior] Make ProjectConfig.equals consistent with other SDKs (improves tolerance to missing etags)
common-js - v6.0.1

Published by z4kn4fein almost 2 years ago

Fixed

  • When the flagOverrides was set, the { [name: string]: Setting } map transformation of the remote settings didn't work properly.
common-js - v6.0.0

Published by z4kn4fein over 2 years ago

  • Moved the SDK version to the fetch URL as a query parameter. Descendant SDKs will send the SDK version as a query parameter instead of the dedicated X-ConfigCat-UserAgent header.
common-js - v5.3.0

Published by laliconfigcat over 2 years ago

Adding polyfill for Object.fromEntries to support older browsers.

common-js - v5.2.0

Published by laliconfigcat over 2 years ago

Ability to pass the real SDK version though the ConfigCatKernel, instead of using the common-js version for the X-CONFIGCAT-USERAGENT.

Breaking change: from now, the SDK version should be passed to the ConfigCatKernel.

common-js - v5.1.0

Published by z4kn4fein over 2 years ago

  • Export missing types related to feature flag overrides.
common-js - v5.0.2

Published by laliconfigcat over 2 years ago

Extensive debug logging to trace down problems with the SDK.

Breaking change: the IConfigCatLogger interface has been improved with a debug() method that has to be implemented in any custom logger derived from that interface.

common-js - v5.0.1

Published by z4kn4fein over 2 years ago

🐛 Fixed

  • 5 sec delay issue on each first auto poll request.
  • Missing getSetting() function.
common-js - v5.0.0

Published by z4kn4fein over 2 years ago

🐛 Fixed

  • With autopoll initial tryReadFromCache takes 5 seconds #43

🚀 Features

  • Local Flag Overrides

🔨 Breaking changes

  • The IConfigFetcher interface has been changed to minimize the occurrences of JSON serialization/deserialization.