All notable changes to the LaunchDarkly client-side JavaScript SDKs will be documented in this file. This project adheres to Semantic Versioning.
3.5.0 (2024-10-18)
- Updated to launchdarkly-js-sdk-common 5.3.0 which supports synchronous inspectors.
- 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
- #283 Catch xhr errors on page close and ignore them to reduce noise.
- Fixed an issue that was preventing page view/click events from being sent. (Thanks, seanr-cardless!)
- Update
LDContext
to allow for key to be optional. This is used when making an anonymous context with a generated key.
- Upgrade to
js-sdk-common
version5.0.2
. This removes usage of optional chaining (?.
) to allow for use with older transpilers.
- Changed event flushing on page close to be based on page visibility. This should increase compatibility with the bfcache.
- Updated
launchdarkly-js-sdk-common
to version 5.0.1 for improved documentation generation.
The latest version of this SDK supports LaunchDarkly's new custom contexts feature. Contexts are an evolution of a previously-existing concept, "users." Contexts let you create targeting rules for feature flags based on a variety of different information, including attributes pertaining to users, organizations, devices, and more. You can even combine contexts to create "multi-contexts."
For detailed information about this version, please refer to the list below. For information on how to upgrade from the previous version, please read the migration guide.
- The types
LDContext
,LDSingleKindContext
, andLDMultiKindContext
define the new "context" model. - All SDK methods that took an
LDUser
parameter now take anLDContext
.LDUser
is now a subset ofLDContext
, so existing code based on users will still work.
- There is no longer such a thing as a
secondary
meta-attribute that affects percentage rollouts. If you set an attribute with that name inLDContext
, it will simply be a custom attribute like any other. - Evaluations now treat the
anonymous
attribute as a simple boolean, with no distinction between a false state and an undefined state. LDClient.getUser
has been replaced withLDClient.getContext
.privateAttributeNames
has been replaced withprivateAttributes
inLDOptions
. Private attributes now allow using attribute references.
- Analytics event data now uses a new JSON schema due to differences between the context model and the old user model.
- Removed all types, fields, and methods that were deprecated as of the most recent 3.x release.
- Removed the
secondary
meta-attribute inLDUser
. - The
alias
method no longer exists because alias events are not needed in the new context model. - The
autoAliasingOptOut
andinlineUsersInEvents
options no longer exist because they are not relevant in the new context model.
- 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
.
- Updated to
js-sdk-common
3.8.2
which includes jitter and backoff for re-connection attempts for streaming connections.
- Upgrade to
js-sdk-common
3.8.1
which added support forInspectors
that can be used for collecting information for monitoring, analytics, and debugging.
-
Updated
js-sdk-common
version which removed event de-duplication functionality which was made redundant by support of summary events. This will improve the default event behavior when using experimentation. -
Updated
escape-string-regexp
to version 4. -
Updated development dependencies to recent versions.
- Deprecated the
allowFrequentDuplicateEvents
configuration option. Setting the option will no longer have any effect, and it will be removed in a future version.
This release is functionally identical to the 2.22.0 release. Due to an oversight the release process re-introduced the package-lock.json
.
- The
package-lock.json
file is no longer in source control. As this is a library project, the lockfile never affected application code that used the SDK, but only affected the SDK's CI build. It is preferable for the CI build to refer only to package.json so that it resolves dependencies the same way an application using the SDK would, rather than using pinned dependencies that an application would not use.
LDOptions.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.
- The
package-lock.json
file is no longer in source control. As this is a library project, the lockfile never affected application code that used the SDK, but only affected the SDK's CI build. It is preferable for the CI build to refer only topackage.json
so that it resolves dependencies the same way an application using the SDK would, rather than using pinned dependencies that an application would not use.
- Added
basicLogger
, a replacement for the deprecatedcreateConsoleLogger
.
- 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, the error would be thrown as an unhandled exception.
- If the browser local storage mechanism throws an exception (for instance, if it is disabled or if storage is full), the SDK now correctly catches the exception and logs a message about the failure. It will only log this message once during the lifetime of the SDK client. (#54)
- New property
LDOptions.requestHeaderTransform
allows custom headers to be added to all HTTP requests. This may be necessary if you have an Internet gateway that uses a custom header for authentication. Note that custom headers may cause cross-origin browser requests to be rejected unless you have a way to ensure that the header name also appears inAccess-Control-Allow-Headers
for CORS preflight responses; if you are connecting to the LaunchDarkly Relay Proxy, it has a way to configure this.
- Removed an obsolete warning that would appear in the browser console after calling
track
:Custom event "_____" does not exist
. Originally, the SDK had an expectation thattrack
would be used only for event keys that had been previously defined as custom goals in the LaunchDarkly dashboard. That is still often the case, but it is not required and LaunchDarkly no longer sends custom goal names to the SDK, so the warning was happening even if such a goal did exist.
This release is broken and cannot be used.
- 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
LDOptions.inlineUsersInEvents
was not included in the TypeScript definitions.
- 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.
- Updated the
LDEvaluationDetail.reason
type definition to be nullable. This value will benull
whenLDOptions.evaluationReasons
isfalse
.
- With goals that use substring or regex mode for URL matching, the SDK previously was not able to match anything in a URL's hash fragment. Since some applications use path-like hash fragments (
http://example.com/url/path#/additional/path
), the SDK now considers any hash string that contains a slash to be part of the URL for matching purposes, if the matching mode is substring or regex. Hash strings that do not contain a slash are assumed to be simple HTML anchors and are not included in matching.
- 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.
- Configuration option
disableSyncEventPost
, for preventing the SDK from trying to do a synchronous HTTP request to deliver analytics events while the page is closing. Such requests are not supported in current versions of Chrome, and although the SDK uses browser detection to avoid doing them if they are not supported, the browser detection mechanism does not work in some test environments.
- 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.
- 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. - Updated some dependency versions to resolve a security vulnerability in the transitive
acorn
dependency. This dependency is only used for development and as a result the security vulnerability did not affect customers.
- 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 withapplication/json
. (#205) - Fixed incorrect usage of
Object.hasOwnProperty
which could have caused an error if a feature flag hadhasOwnProperty
as its flag key.
- 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 inappropriate 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.
Note: if you are using the LaunchDarkly Relay Proxy to forward events, update the Relay to version 5.10.0 or later before updating to this Node SDK version.
- The SDK now periodically sends diagnostic data to LaunchDarkly, describing the version and configuration of the SDK, the architecture and version of the runtime platform, and performance statistics. No credentials, hostnames, or other identifiable values are included. This behavior can be disabled with the
diagnosticOptOut
option, or configured withdiagnosticRecordingInterval
.
- 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. (Thanks, andrao!) - The
LICENSE.txt
file was accidentally replaced with an incomplete license in an earlier release. The standard Apache 2.0 license file has been restored. (#202)
- Changed some exact version dependencies to "highest compatible" dependencies, to avoid having modules that are also used by the host application loaded twice by NPM. The dependency on
js-sdk-common
is still an exact version dependency so that each release ofjs-client-sdk
has well-defined behavior for that internal code.
- Removed an unused transitive dependency on
@babel/polyfill
. (Thanks, bdwain!)
- If the user started to navigate away from the page, but then did not actually do so (for instance, if the application cancelled the
beforeunload
event, or if a nonstandard URL scheme caused the browser to launch an external app), the SDK could be left in a state where all of its HTTP requests would be made synchronously. This has been fixed so the only synchronous request the SDK makes is when it needs to flush events during abeforeunload
. (Thanks, edvinerikson!)
Note: If you use the Relay Proxy, and have configured it to forward events, please update it to version 5.9.4 or later before using this version of the browser SDK. Otherwise you may encounter CORS errors in the browser.
- 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 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. - Configuration properties
wrapperName
andwrapperVersion
: used by the React SDK, and potentially by third-party libraries, to identify a JS SDK instance that is being used with a wrapper API.
- 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.
- 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!)
- 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.
- Releases after 2.14.1 were continuing to report the
version
property as "2.14.1". This property will now once again be consistent with the actual release version.
- A runtime dependency on
typedoc
was mistakenly added in the 2.15.0 release. This has been removed.
- Changed the behavior of the warning message that is logged on failing to establish a streaming connection. Rather than the current behavior where the warning message appears upon each failed attempt, it will now only appear on the first failure in each series of attempts. Also, the message has been changed to mention that retries will occur. (#182)
- The source code for the
launchdarkly-js-sdk-common
package has been moved out of this repository intojs-sdk-common
, and will now be versioned separately. Applications should never refer to the common package directly; it is brought in automatically bylaunchdarkly-js-client-sdk
. Changes made in the common code that affect JS SDK functionality will be noted in the main changelog here. - There is a new, much fuller-featured demo application in the
example
directory, which may be useful for testing not only of the JS SDK but of feature flag evaluation in general.
- The
beforeunload
event handler no longer callsclose
on the client, which was causing the SDK to become unusable if the page did not actually close after this event fired (for instance if the browser navigated to a URL that launched an external application, or if anotherbeforeunload
handler cancelled leaving the page). Instead, it now only flushes events. There is also anunload
handler that flushes any additional events that might have been created by any code that ran during thebeforeunload
stage. (#181) - Removed uses of
Object.assign
that caused errors in Internet Explorer unless a polyfill for that function was present. These were removed earlier in the 2.1.1 release, but had been mistakenly added again.
- The
samplingInterval
configuration property is deprecated and will be removed in a future version. The intended use case for thesamplingInterval
feature was to reduce analytics event network usage in high-traffic applications. This feature is being deprecated in favor of summary counters, which are meant to track all events.
- Added support for upcoming LaunchDarkly experimentation features. See
LDClient.track()
. - The
createConsoleLogger()
function now has an optional second parameter for customizing the log prefix.
- Log messages now include the level ("[warn]", "[error]", etc.) and have a prefix of "LD:" by default.
- The source code for the
launchdarkly-react-client-sdk
package is no longer part of this monorepo. It is now in its own repository,react-client-sdk
. Future updates to the LaunchDarkly React interface will be tracked there.
Note that the React SDK code has moved to its own repository, react-client-sdk
. The 2.13.0 release was the last one that had the React wrapper code in the same repository, and from this point on the React package will be versioned separately.
- A
jsdelivr
entry topackage.json
to specify the primary build artifact and simplify the jsDelivr snippet URL. - In the React SDK, the new
reactOptions
parameter towithLDProvider
provides React-specific options that do not affect the underlying JavaScript SDK. Currently, the only such option isuseCamelCaseFlagKeys
, which is true by default but can be set to false to disable the automatic camel-casing of flag keys.
- In the React SDK, when omitting the
user
parameter towithLDProvider
, an anonymous user will be created. This user will remain constant across browser sessions. Previously a new user was generated on each page load.
- The error messages logged upon having an invalid environment/client-side ID have been updated to better clarify what went wrong. (#165)
- The React SDK was incompatible with Internet Explorer 11 due to using
String.startsWith()
. (Thanks, cvetanov!) - There was a broken documentation link in the error message logged when initially sending an event without identifying a user. The broken link has been fixed.
- The
useReport
property, which tells the SDK to use the REPORT method for HTTP requests so that user data will not appear in the URL path, was only actually using REPORT for requesting all flags at once— not for streaming updates, because streaming uses the EventSource API which normally can only use the GET method; so, to avoid exposing user data in the URL for the streaming connection, the SDK had to use a different and slower mechanism (in which all of the flags are reloaded whenever there is a change) ifuseReport
was true. That is still the case by default; but, if you load the specific EventSource polyfill implementationlaunchdarkly-eventsource
(v1.1.0 or later), the SDK can now use REPORT for streaming connections.
- The
homepage
attribute in thelaunchdarkly-react-client-sdk
andlaunchdarkly-react-client-sdk-example
packages has been updated to the correct value.
- The SDK now logs a message at
info
level when the stream connection is started or stopped. It also logs a message atwarn
level if it detects that the stream had to be restarted due to a connection failure; however, in browsers that have native support for EventSource, connection restarts may be handled internally by the browser in which case there will be no log message.
- When providing precomputed flag values to the SDK via the
bootstrap
option, these values will now be immediately available as soon asinitialize()
returns. That was already the behavior in earlier versions of the SDK, but ever since version 2.10.0 the values only became available once the client was officially ready (i.e. theready
event had fired or thewaitUntilInitialized()
promise had resolved), so they could not be used in non-asynchronous application code. The correct behavior had never been explicitly defined, so this had not been documented as a change. The behavior is now as it was prior to 2.10.0, and is now documented as such. (#162)
- Under some circumstances, the SDK would fail to restart a streaming connection if it had already been dropped and restarted before. This normally would not happen when using a built-in browser implementation of EventSource, but could happen with some EventSource polyfills.
- Fixed a broken link in the project README.
- The
eventUrlTransformer
property that was added in 2.12.0 had no effect. It now works.
- The SDK now logs a message at
info
level when the stream connection is started or stopped. It also logs a message atwarn
level if it detects that the stream had to be restarted due to a connection failure; however, in browsers that have native support for EventSource, connection restarts may be handled internally by the browser in which case there will be no log message.
- Under some circumstances, the SDK would fail to restart a streaming connection if it had already been dropped and restarted before. This normally would not happen when using a built-in browser implementation of EventSource, but could happen with some EventSource polyfills.
- Fixed a broken link in the project README.
- Configuration property
eventUrlTransformer
allows application code to modify the URL that is sent in analytics events.
- If the SDK receives data from the service that does not have the expected JSON content type, it will now log an appropriate error message, rather than "Error fetching flags: 200".
- Added support for hooks to the React SDK.
unpkg
entry topackage.json
to specify primary build artifact to simplify the unpkg snippet URL.
- Streaming updates did not work if
useReport
was enabled, or if the SDK was connecting through the LaunchDarkly relay proxy. This bug was introduced in version 2.10.0.
- Changed the package names from
ldclient-js
,ldclient-react
, andldclient-js-common
tolaunchdarkly-js-client-sdk
,launchdarkly-react-client-sdk
, andlaunchdarkly-js-sdk-common
, respectively.
There are no other changes in this release. Substituting ldclient-js
, ldclient-react
, and ldclient-js-common
version 2.10.2 with launchdarkly-js-client-sdk
, launchdarkly-react-client-sdk
, and launchdarkly-js-sdk-common
version 2.10.3 will not affect functionality.
- Fixed some broken links in the package READMEs.
- Fixed a problem that prevented the Electron and client-side Node SDKs from reporting their own version strings correctly. This fix does not affect the browser JS SDK, so there is no need to upgrade if you are using that.
The LaunchDarkly SDK repositories are being renamed for consistency. This repository is now js-client-sdk
rather than js-client
.
The package names will also change. In the 2.10.2 release, there were packages for ldclient-js
, ldclient-react
and ldclient-js-common
; in all future releases, they will be launchdarkly-js-client-sdk
, launchdarkly-react-client-sdk
, and launchdarkly-js-sdk-common
, respectively.
- The 2.10.0 release added a usage of the
Promise.finally()
method, which made it incompatible with some older browsers. This has been removed. (#151)
- Generated TypeDoc documentation for all types, properties, and methods is now available online at https://launchdarkly.github.io/js-client/. Currently this will only be for the latest released version.
- The SDK now allows you to specify an anonymous user without a key (i.e. the
anonymous
property istrue
, and there is nokey
property). In that case, the SDK will generate a UUID and send that as the user key. It will also cache this generated key in local storage (if local storage is available) so that anonymous users in the same browser will always get the same key.
- Setting user attributes to non-string values when a string was expected would prevent evaluations and analytics events from working. The SDK will now convert attribute values to strings as needed.
- If there are pending analytics events when the page is being closed, the SDK normally attempts to deliver them by making a synchronous HTTP request. Chrome, as of version 73, does not allow this and logs an error. An upcoming release will change how events are sent, but as a temporary measure to avoid these errors, the SDK will now simply discard any pending events when the page is being closed if the browser is Chrome version 73 or higher. In other browsers, there is no change. Note that this means that in Chrome 73, some events may be lost; that was already the case. The purpose of this patch is simply to avoid triggering errors. (#178)
This release was an error and has been removed.
- In React, when using the
bootstrap
property to preload the SDK client with flag values, the client will now become ready immediately and make the flags available to other components as soon as it is initialized; previously this did not happen until aftercomponentDidMount
. - The user attribute
secondary
was not included in the TypeScript declarations and therefore could not be used from TypeScript code.
- Running inside an iframe on Chrome with third-party cookies disabled-- which also disables HTML5 local storage-- would cause a security exception (due to the SDK attempting to check whether
window.localStorage
exists). This was a long-standing problem, but became worse in the 2.9.0 release since the SDK now checks for browser capabilities like this regardless of whether you've attempted to use them yet. It should now simply log a warning if you try to usebootstrap: "localstorage"
when local storage is disabled. (#138) - If the SDK received streaming updates out of order (rare, but possible) such that it received "flag X was deleted" prior to "flag X was created", an uncaught exception would be logged in the browser console (but would not otherwise affect anything).
- A supported user property,
privateAttributeNames
, was not usable from TypeScript because it was omitted from the TypeScript declarations. - Several TypeScript declarations had been changed from
interface
totype
. They all now useinterface
, except forLDFlagValue
which is a type alias. This should not affect regular usage of the SDK in TypeScript, but it is easier to extend aninterface
than atype
if desired. - Removed a window message listener that was previously used for integration with the LaunchDarkly dashboard, but is no longer used.
- The React SDK was pulling in the entire
lodash
package. This has been improved to only require the much smallercamelcase
tool fromlodash
. - The React SDK now lists React itself as a peer dependency rather than a regular dependency, so it will not included twice in an application that already requires React.
- Corrected the TypeScript declaration for the
identify
method to indicate that its asynchronous result type isLDFlagSet
, notvoid
. (Thanks, impressiver!) - Corrected and expanded many documentation comments in the TypeScript declarations.
(The 2.9.2 release was broken and has been removed.)
- The previous release of
ldclient-react
was broken: the package did not contain the actual files. The packaging script has been fixed. There are no other changes.
- The new
ldclient-react
package provides a convenient mechanism for using the LaunchDarkly SDK within the React framework. - The new
getUser()
method returns the current user object. - The client options can now have a
logger
property that defines a custom logging mechanism. The default is still to useconsole.warn
andconsole.error
; you could override this to send log messages to another destination or to suppress them. SeeLDLogger
andcreateConsoleLogger
in the TypeScript definitions.
- The SDK now uses an additional package,
ldclient-js-common
, consisting of code that is also used by other LaunchDarkly SDKs. This is automatically loaded as a dependency ofldclient-js
so you should notice any difference. However, the source code has been reorganized so that this project is now a monorepo containing multiple packages.
- The use of a streaming connection to LaunchDarkly for receiving live updates can now be controlled with the new
client.setStreaming()
method, or the equivalent booleanstreaming
property in the client configuration. If you set this tofalse
, the client will not open a streaming connection even if you subscribe to change events (you might want to do this if, for instance, you just want to be notified when the client gets new flag values due to having switched users). If you set it totrue
, the client will open a streaming connection regardless of whether you subscribe to change events or not (the flag values will simply be updated in the background). If you don't set it either way then the default behavior still applies, i.e. the client opens a streaming connection if and only if you subscribe to change events.
- If the client opened a streaming connection because you called
on('change', ...)
one or more times, it will not close the connection until you calloff()
for all of your event listeners. Previously, it was closing the connection wheneveroff('change')
was called, even if you still had a listener for'change:specific-flag-key'
. - The client's logic for signaling a
change
event was using a regular Javascript===
comparison, so it could incorrectly decide that a flag had changed if its value was a JSON object or an array. This has been fixed to use deep equality checking for object and array values.
- When using the
event-source-polyfill
package to allow streaming mode in browsers with no native EventSource support, the polyfill was using a default read timeout of 45 seconds, so if no updates arrived within 45 seconds it would log an error and reconnect the stream. The SDK now sets its own timeout (5 minutes) which will be used if this particular polyfill is active. LaunchDarkly normally sends a heartbeat every 3 minutes, so you should not see a timeout happen unless the connection has been lost. - The SDK's use of the "Base64" package caused problems for build tools that strictly enforce the lowercase package name rule. It now uses the "base64-js" package instead. (#124)
(This version was skipped due to a release problem.)
- The TypeScript definitions were incorrectly restricting the possible values for event types in
on()
andoff()
. Also, added documentation for event types which were not documented before. (#122)
- Disconnecting from the stream does not close the browser tab anymore. (Thanks, Sawtaytoes.)
- The configuration property
evaluationReasons
was misnamed asevaluationExplanations
in the TypeScript definitions.
- Event posts did not include the HTTP header that specifies the SDK version. They now do again. Note that the
sendLDHeaders
option does not affect this; if the header is turned off for flag requests, it should still be sent in events, since events always require a CORS preflight check anyway (and are delivered asynchronously, so the OPTIONS request does not slow down page loads).
- New client method
waitForInitialization
returns a Promise, likewaitUntilReady
; but whilewaitUntilReady
will be resolved as soon as client initialization either succeeds or fails,waitForInitialization
will be resolved only if initialization succeeds, and will be rejected (with an error object) if it fails. - New config option
fetchGoals
(default: true) allows you to control whether the client will request A/B testing parameters from LaunchDarkly. If you do not use A/B testing, you may wish to disable this to reduce the number of HTTP requests. - New config option
sendLDHeaders
(default: true) allows you to control whether the client will add a custom HTTP header to LaunchDarkly flag requests (to indicate the SDK version). You may wish to disable this behavior if you have performance concerns, as it causes browsers to make an additional CORS preflight check (since it is no longer a simple request).
- The new configuration option
evaluationReasons
causes LaunchDarkly to report information about how each feature flag value was determined; you can access this information with the new client methodvariationDetail
. The new method returns an object that contains both the flag value and a "reason" object which will tell you, for instance, if the user was individually targeted for the flag or was matched by one of the flag's rules, or if the flag returned the default value due to an error.
- In streaming mode, the client will attempt to reconnect if it receives an HTTP error status from LaunchDarkly. Previously, it would only retry if the connection was lost.
- Starting in version 2.0.0, there was a problem where analytics events would not be generated correctly if you initialized the client with bootstrap data, because the bootstrap data did not include some flag metadata that the front end uses for events. The client now supports an extended format for bootstrap data that fixes this problem; this is generated by calling a new method that has been added to the server-side SDKs,
allFlagsState
/all_flags_state
(previouslyallFlags
/all_flags
). Therefore, if you want analytics event data and you are using bootstrap data from the back end, you should upgrade both your JavaScript SDK and your server-side SDK, and useallFlagsState
on the back end. This does not require any changes in your JavaScript code. If you use bootstrap data in the old format, the SDK will still be usable but events will not work correctly. - When posting events to LaunchDarkly, if a request fails, it will be retried once.
- The TypeScript mappings for the SDK were omitted from the distribution in the previous release. They are now in the distribution again, in the root folder instead of in
src
, and have been renamed fromindex.d.ts
totypings.d.ts
.
- The result value of
identify()
(provided by either a promise or a callback, once the flag values for the new user have been retrieved) used to be a simple map of flag keys to values, until it was accidentally changed to an internal data structure in version 2.0.0. It is now a map of flag keys to values again, consistent with what is returned byallFlags()
. - Added TypeScript definitions for the result values of
identify()
. (Thanks, 1999!) - Documented all optional compatibility polyfills in
README.md
.
- Named exports for the
initialize
method andversion
number exports.
- Default exports, use named exports instead.
- Updated
package.json
to only export minified files.
- If a polling request has failed due to an invalid environment key, calling
variation
now returns the default value; previously, it sometimes caused a null reference error.
- The client will now stop trying to send analytics events if it receives almost any HTTP 4xx error from LaunchDarkly; such errors indicate either a configuration problem (invalid SDK key) or a bug, which is not likely to resolve without a restart or an upgrade. This does not apply if the error is 400, 408, or 429.
- New event
goalsReady
(and new methodwaitUntilGoalsReady
, which returns a Promise based on that event) indicates when the client has loaded goals-- i.e. when it is possible for pageview events and click events to be triggered.
- Fixed a bug where calling
variation
would throw an error if the client was bootstrapped from local storage and there were no flags in local storage yet, and the initial HTTP request for flags from LaunchDarkly had not yet completed. (thanks, mpcowan!)
- Fix the TypeScript definitions to properly support the ES default export.
- Removed two function calls that are not supported in Internet Explorer:
string.startsWith()
andObject.assign()
.
- The client now sends the current SDK version to LaunchDarkly in an HTTP header. This information will be visible in a future version of the LaunchDarkly UI.
- Fixed a bug that caused summary events to combine the counts for flag evaluations that produced the flag's first variation (variation index 0) with the counts for flag evaluations that fell through to the default value.
- To reduce the network bandwidth used for analytics events, feature request events are now sent as counters rather than individual events, and user details are now sent only at intervals rather than in each event. These behaviors can be modified through the LaunchDarkly UI and with the new configuration option
inlineUsersInEvents
. For more details, see Data Export. - In every function that takes an optional callback parameter, if you provide a callback, the function will not return a promise; a promise will be returned only if you omit the callback. Previously, it would always return a promise which would be resolved/rejected at the same time that the callback (if any) was called; this caused problems if you had not registered an error handler for the promise.
- When sending analytics events, if there is a connection error or an HTTP 5xx response, the client will try to send the events again one more time after a one-second delay.
- Analytics are now sent with an HTTP
POST
request if the browser supports CORS, or via image loading if it does not. Previously, they were always sent via image loading.
- The new configuration option
sendEventsOnlyForVariation
, if set totrue
, causes analytics events for feature flags to be sent only when you callvariation
. Otherwise, the default behavior is to also send events when you callallFlags
, and whenever a changed flag value is detected in streaming mode. - The new configuration option
allowFrequentDuplicateEvents
, if set totrue
, turns off throttling for feature flag events. Otherwise, the default behavior is to block the sending of an analytics event if another event with the same flag key, flag value, and user key was generated within the last five minutes.
- If
identify
is called with a null user, or a user with no key, the function no longer tries to do an HTTP request to the server (which would always fail); instead, it just returns an error.
- The configuration options
all_attributes_private
andprivate_attribute_names
are deprecated. UseallAttributesPrivate
andprivateAttributeNames
instead.
- Fixed a bug that caused events not to be sent if
options.sendEvents
was explicitly set totrue
. - HTTP requests will no longer fail if there is a
charset
specified in the response'sContent-Type
header. (#87)
- The client no longer creates an empty
XMLHttpRequest
at startup time (which could interfere with unit tests).
This release was broken and should not be used.
This release was broken and should not be used.
- The build now uses Rollup, Babel and Jest.
- Fixed a bug that caused a syntax error when running in Internet Explorer 11.
- Fixed an IE 11 incompatibility in the example page index.html.
- Fixed a bug that caused the SDK to send events on beforeunload even if it should not send events.
LDClient.track
properly sets the user for custom events.
- The SDK now polls the URL for changes if (and only if) there are page view goals,to ensure it is accurately reporting page views.
- Added support for a future update to LaunchDarkly that will deliver individual feature flag changes over the streaming connection as they occur, rather than requiring the client to re-request all flags for each change.
- The new flush method on the client object tells the client to deliver any stored analytics events as soon as possible, rather than waiting for the regularly scheduled event-flushing interval.
- Fixed a bug that could prevent events from being generated for page view goals.
- Removed usage of the
const
keyword, to maintain IE10 compatibility. (Thanks, turnerniles!)
- The
options
object now supports asamplingInterval
property. If greater than zero, this causes a fraction of analytics events to be sent to LaunchDarkly: one per that number of events (pseudo-randomly). For instance, setting it to 5 would cause 20% of events to be sent on average.
- The SDK now supports multiple environments. Calling
initialize
returns a new client each time. - The
waitUntilReady
Promise
will now resolve even after theready
event was emitted — thanks @rmanalan!
- Methods that expose a
Promise
interface now properly return the resolution or rejection value to the caller.
- Support for private user attributes.
- New
sendEvents
option to control whether the SDK should send events back to LaunchDarkly or not. Defaults totrue
. - It is now possible to wait for SDK readiness using
waitUntilReady
which returns aPromise
.identify
also returns aPromise
(while still supporting the callback argument), which should make it easier to integrate into code that relies heavily onPromise
's for asynchronous code. - The SDK now respects the user's do-not-track setting
- Added
useReport
initialization option to useREPORT
instead ofGET
when communicating with LaunchDarkly. - Authentication errors will now be logged — the root cause for these errors is usually an invalid client-side ID.
- Emit an
error
event — separately from theready
event — in case fetching initial data fails. This allows consumers to respond accordingly.
- Improve error handling
- Add typescript definitions
- Add a warning when tracking unknown custom goal events
- Changed default stream url
- Cached
localStorage
copy is not overwritten anymore when connection to LD fails
onDone
argument toidentify
method is now optional
- Removed dependency on Sizzle and direct to polyfill for older browser support
- Fix bug in
Emitter.off()
- Fix bug caused by accessing
undefined
flags
- Fix bug caused by accessing
undefined
settings
- Ensure callbacks only ever get called once
- Fix flag setting request cancellation logic
- Add a new
allFlags
method that returns a map of all feature flag keys and their values for a user
- Added 'undefined' check on VERSION otherwise unbundled usage from npm fails
- Expose SDK version at
LDClient.version
- Added check for EventSource before trying to connect Stream.
- Fixed an error that occurred on
hashchage
/popstate
if the account had no goals.
- Added window check for server side rendering compatibility before loading Sizzle.