All notable changes to the launchdarkly-js-sdk-common
package will be documented in this file. Changes that affect the dependent SDKs such as launchdarkly-js-client-sdk
should also be logged in those projects, in the next release that uses the updated version of this package. This project adheres to Semantic Versioning.
5.4.0 (2024-10-18)
5.3.0 (2024-06-18)
- Add inExperiment to evaluation reason. (#105) (cf69770)
- Allow for synchronous inspectors. (#103) (7e490f4)
- Added an optional timeout to the
waitForInitialization
method. When a timeout is specified the returned promise will be rejected after the timeout elapses if the client has not finished initializing within that time. When no timeout is specified the returned promise will not be resolved or rejected until the initialization either completes or fails.
- The track method now validates that the provided metricValue is a number. If a metric value is provided, and it is not a number, then a warning will be logged.
- Fixed the documentation for
evaluationReasons
for theidentify
method.
- Redact anonymous attributes within feature events
- Always inline contexts for feature events
- Pin dev version of node to compatible types.
- HTTP fallback ping
- Update
LDContext
to allow for key to be optional. This is used when making an anonymous context with a generated key.
- Removed usage of optional chaining (
?.
) to improve compatibility with projects which are using older transpilation tooling.
- Updated all types in
typings.d.ts
to be exported. This is to ensure that those types are included in generated documentation of dependent SDKs.
This major version release of js-sdk-common
corresponds to the upcoming releases of the js-client-sdk
v3 and react-client-sdk
v3, and cannot be used with earlier SDK versions.
- Replaced users with contexts. A context is a generalized way of referring to the people, services, machines, or other resources that encounter feature flags in your product. All methods which previously operated on
LDUser
now operate onLDContext
.
LDClient.getUser
has been replaced withLDClient.getContext
.privateAttributeNames
has been replaced withprivateAttributes
. Private attributes now allow using attribute references, which allow for marking nodes in nested JSON private.
- Alias events are no longer supported and the
alias
method has been removed fromLDClient
. - Support for the
secondary
attribute has been removed fromLDUser
. If a secondary attribute is included in a context, then it is a normal attribute that can be used in rule evaluation, but it will not affect bucketing. allowFrequentDuplicateEvents
has been removed fromLDOptions
. This had been deprecated in a previous version. The default behavior is as if this option had been set to true.autoAliasingOptOut
has been removed fromLDOptions
. This functionality has been superseded by multi-context support.inlineUsersInEvents
has been removed fromLDOptions
. Changes associated with contexts has removed the needed for this option.
- The
LDUser
object has been deprecated. Support forLDUser
is maintained to simplify the upgrade process, but it is recommended to useLDContext
in the shape of eitherLDSingleKindContext
orLDMultiKindContext
.
- Implemented
jitter
andbackoff
for streaming connections. When a connection fails the retry will start at thestreamReconnectDelay
and will double on each unsuccessful consecutive connection attempt (backoff
) to a max of 30 seconds. The delay will be adjusted from 50%-100% of the calculated delay to prevent many clients from attempting to reconnect at the same time (jitter
).
- Removed usage of
flatMap
. (Thanks @mateuszsikora)
- Fixed an issue that prevented the
flag-used
inspector from being called.
- Added support for
Inspectors
that can be used for collecting information for monitoring, analytics, and debugging.
- Removed
seenRequests
cache. This cache was used to de-duplicate events, but it has been supplanted with summary events.
- The
allowFrequentDuplicateEvents
configuration has been deprecated because it controlled the behavior of theseenRequests
cache.
- Enforce a 64 character limit for
application.id
andapplication.version
configuration options.
- Do not include deleted flags in
allFlags
.
LDOptionsBase.application
, for configuration of application metadata that may be used in LaunchDarkly analytics or other product features. This does not affect feature flag evaluations.
- The
baseUrl
,streamUrl
, andeventsUrl
properties now work properly regardless of whether the URL string has a trailing slash. Previously, a trailing slash would cause request URL paths to have double slashes.
- If the SDK receives invalid JSON data from a streaming connection (possibly as a result of the connection being cut off), it now uses its regular error-handling logic: the error is emitted as an
error
event or, if there are noerror
event listeners, it is logged. Previously, it would be thrown as an unhandled exception.
- Removed the
version
export which was originally a constant inserted by the Rollup build, but was no longer usable since Rollup is no longer being used. The SDKs never used this export, since they haveversion
properties of their own; the version string oflaunchdarkly-js-sdk-common
was never meant to be exposed to applications.
- This package is now published as a regular Node module. Previously, it was published as minified bundles created by Rollup. There was no need for this since Rollup is only needed for web code, and the
js-client-sdk
build already runs Rollup to embed thejs-sdk-common
code. Using Rollup caused the platform-dependent behavior ofuuid
to fail because the code for only one platform (browser or Node) was embedded.
- Updated
uuid
package to 8.x. - In TypeScript, the property
LDEvaluationDetail.reason
is now nullable, which correctly reflects the fact that evaluation reasons may not always be available.
- Removed the type
NonNullableLDEvaluationReason
, which was a side effect of theLDEvaluationDetail.reason
being incorrectly defined before. - Removed all types, properties, and functions that were deprecated as of the last 3.x release.
- If the SDK receives invalid JSON data from a streaming connection (possibly as a result of the connection being cut off), it now uses its regular error-handling logic: the error is emitted as an
error
event or, if there are noerror
event listeners, it is logged. Previously, it would be thrown as an unhandled exception.
- New configurable logger factory
commonBasicLogger
andBasicLoggerOptions
. ThecommonBasicLogger
method is not intended to be exported directly in the SDKs, but wrapped to provide platform-specific behavior.
- Any exceptions thrown by the platform-specific local storage implementation (for instance, if we are in a browser and
window.localstorage
is available but disabled) are now consistently caught, and will only be logged the first time to avoid repetitive logging.
- Added LDOptionsBase.requestHeaderTransform allowing custom headers to be added to all requests.
- Reverted change to
uuid
dependency while working on some compatibility issues.
- Updated
uuid
dependency to 8.x to remove deprecated usage. (#46)
- Events for the LaunchDarkly debugger are now properly pre-processed to omit private user attributes, as well as enforce only expected top level attributes are sent.
- Events for the LaunchDarkly debugger now include the index of the variation responsible for the evaluation result.
- The property
LDOptionsBase.inlineUsersInEvents
was not included in the TypeScript definitions. - Fixed an outdated documentation link (thanks, sinchang!)
- Fixed a documentation typo (thanks, Doesntmeananything!)
- Added the
alias
method. This method can be used to associate two user objects for analytics purposes. When invoked, this method will queue a new alias event to be sent to LaunchDarkly. - Added the
autoAliasingOptOut
configuration option. This can be used to control the new automatic aliasing behavior of theidentify
method; by passingautoAliasingOptOut: true
,identify
will not automatically generate alias events.
- The
identify
method will now automatically generate an alias event when switching from an anonymous to a known user. This event associates the two users for analytics purposes as they most likely represent a single person.
- When creating a stream connection, we now set a
streamReadTimeoutMillis
option which is hard-coded to the standard LaunchDarkly stream timeout of 5 minutes. This option is implemented bylaunchdarkly-eventsource
1.4.0 and higher, and should be ignored by SDKs that are not using that EventSource implementation.
- Updated the
LDEvaluationDetail.reason
type definition to be nullable. This value will benull
whenLDOptions.evaluationReasons
isfalse
.
- In streaming mode, when connecting to the Relay Proxy rather than directly to the LaunchDarkly streaming service, if the current user was changed twice within a short time it was possible for the SDK to revert to flag values from the previous user.
- Removed uses of
String.startsWith
that caused errors in Internet Explorer unless a polyfill for that function was present.
- The TypeScript declaration for
track()
was missing the optionalmetricValue
parameter. (#23)
- Some diagnostic event data was being sent twice, resulting in extra HTTP requests. This did not affect analytics events, so customer data on the dashboard and in data export would still be correct.
- The default logging implementation (
createConsoleLogger
) could throw errors in Internet Explorer 11 if log output (of an enabled level) happened while the developer tools were not open. This is because in IE 11, theconsole
object does not exist unless the tools are open. This has been fixed so the logger does not try to useconsole
unless it currently has a value.
- Fixed incorrect usage of
Object.hasOwnProperty
which could have caused an error if a feature flag hadhasOwnProperty
as its flag key.
- Some users reported an error where the SDK said that the content type of a response was
"application/json, application/json; charset=utf8"
. It is invalid to have multiple Content-Type values in a response and the LaunchDarkly service does not do this, but an improperly configured proxy/gateway might add such a header. Now the SDK will tolerate a value like this as long as it starts with"application/json"
.
- At client initialization time, if the initial flag polling request failed, it would cause an unhandled promise rejection unless the application had called
waitForInitialization()
and provided an error handler for the promise that was returned by that method. While that is correct behavior if the application did callwaitForInitialization()
(any promise that might be rejected should have an error handler attached), it is highly undesirable if the application did not callwaitForInitialization()
at all-- which is not mandatory, since the application could use events instead, orwaitUntilReady()
, or might simply not care about waiting for initialization. This has been fixed so that no such promise is created until the first time the application callswaitForInitialization()
; subsequent calls to the same method will return the same promise (since initialization can only happen once). - A bug in the event emitter made its behavior unpredictable if an event handler called
on
oroff
while handling an event. This has been fixed so that all event handlers that were defined at the time the event was fired will be called; any changes made will not take effect until the next event.
- When sending stream connection statistics in diagnostic event data, always specify the
failed
property even if it is false. This only affects LaunchDarkly's internal analytics.
- When using secure mode in conjunction with streaming mode, if an application specified a new
hash
parameter while changing the current user withidentify()
, the SDK was not using the newhash
value when recomputing the stream URL, causing the stream to fail. (#13)
- The SDKs now periodically send diagnostic data to LaunchDarkly, describing the version and configuration of the SDK, the architecture and version of the runtime platform (provided by the platform-specific SDK packages), and performance statistics. No credentials, hostnames, or other identifiable values are included. This behavior can be disabled with the
diagnosticOptOut
option or configured withdiagnosticRecordingInterval
.
- Removed an unused dependency on
@babel/polyfill
. (Thanks, bdwain!) - Changed exact version dependencies to "highest compatible" dependencies, to avoid having modules that are also used by the host application loaded twice by NPM. (#8)
- The SDK now specifies a uniquely identifiable request header when sending events to LaunchDarkly to ensure that events are only processed once, even if the SDK sends them two times due to a failed initial attempt.
- Configuration options
wrapperName
andwrapperVersion
. - Platform option
httpFallbackPing
(to be used for the browser image mechanism - see below).
- When calling
identify
, the current user (as reported bygetUser()
) was being updated before the SDK had received the new flag values for that user, causing the client to be temporarily in an inconsistent state where flag evaluations would be associated with the wrong user in analytics events. Now, the current-user state will stay in sync with the flags and change only when they have finished changing. (Thanks, edvinerikson!)
- Logic for sending a one-way HTTP request in a browser by creating an image has been moved to the browser-specific code (
js-client-sdk
).
- Configuration property
eventCapacity
: the maximum number of analytics events (not counting evaluation counters) that can be held at once, to prevent the SDK from consuming unexpected amounts of memory in case an application generates events unusually rapidly. In JavaScript code this would not normally be an issue, since the SDK flushes events every two seconds by default, but you may wish to increase this value if you will intentionally be generating a high volume of custom or identify events. The default value is 100.
- (Breaking change) The
extraDefaults
parameter to the internal commoninitialize
method is nowextraOptionDefs
and has a different format, allowing for more flexible validation. - The SDK now logs a warning if any configuration property has an inappropriate type, such as
baseUri:3
orsendEvents:"no"
. For boolean properties, the SDK will still interpret the value in terms of truthiness, which was the previous behavior. For all other types, since there's no such commonly accepted way to coerce the type, it will fall back to the default setting for that property; previously, the behavior was undefined but most such mistakes would have caused the SDK to throw an exception at some later point. - Removed or updated some development dependencies that were causing vulnerability warnings.
- The
samplingInterval
configuration property was deprecated in the code in the previous minor version release, and in the changelog, but the deprecation notice was accidentally omitted from the documentation comments. It is hereby deprecated again.
- Removed uses of
Object.assign
that caused errors in Internet Explorer unless a polyfill for that function was present.
Prior to the 2.15.0 release, this code was a monorepo subpackage in the js-client-sdk
repo. See the changelog in that repo for changes prior to that version. It is now maintained in this repo and has its own versioning and changelog.