launchdarkly-js-sdk-common 5.0.0 → 5.0.2
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/CHANGELOG.md +24 -0
- package/package.json +1 -1
- package/src/InspectorManager.js +11 -10
- package/src/configuration.js +1 -1
- package/src/context.js +1 -1
- package/typings.d.ts +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
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](http://semver.org).
|
|
4
4
|
|
|
5
|
+
## [5.0.1] - 2023-01-10
|
|
6
|
+
### Changed:
|
|
7
|
+
- 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.
|
|
8
|
+
|
|
9
|
+
## [5.0.0] - 2022-11-30
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
### Added:
|
|
13
|
+
- 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 on `LDContext`.
|
|
14
|
+
|
|
15
|
+
### Changed:
|
|
16
|
+
- `LDClient.getUser` has been replaced with `LDClient.getContext`.
|
|
17
|
+
- `privateAttributeNames` has been replaced with `privateAttributes`. Private attributes now allow using attribute references, which allow for marking nodes in nested JSON private.
|
|
18
|
+
|
|
19
|
+
### Removed:
|
|
20
|
+
- Alias events are no longer supported and the `alias` method has been removed from `LDClient`.
|
|
21
|
+
- Support for the `secondary` attribute has been removed from `LDUser`. 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.
|
|
22
|
+
- `allowFrequentDuplicateEvents` has been removed from `LDOptions`. This had been deprecated in a previous version. The default behavior is as if this option had been set to true.
|
|
23
|
+
- `autoAliasingOptOut` has been removed from `LDOptions`. This functionality has been superseded by multi-context support.
|
|
24
|
+
- `inlineUsersInEvents` has been removed from `LDOptions`. Changes associated with contexts has removed the needed for this option.
|
|
25
|
+
|
|
26
|
+
### Deprecated:
|
|
27
|
+
- The `LDUser` object has been deprecated. Support for `LDUser` is maintained to simplify the upgrade process, but it is recommended to use `LDContext` in the shape of either `LDSingleKindContext` or `LDMultiKindContext`.
|
|
28
|
+
|
|
5
29
|
## [4.3.2] - 2022-10-20
|
|
6
30
|
### Added:
|
|
7
31
|
- Implemented `jitter` and `backoff` for streaming connections. When a connection fails the retry will start at the `streamReconnectDelay` 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`).
|
package/package.json
CHANGED
package/src/InspectorManager.js
CHANGED
|
@@ -31,16 +31,17 @@ function InspectorManager(inspectors, logger) {
|
|
|
31
31
|
[InspectorTypes.clientIdentityChanged]: [],
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const safeInspectors = inspectors
|
|
34
|
+
const safeInspectors = inspectors && inspectors.map(inspector => SafeInspector(inspector, logger));
|
|
35
35
|
|
|
36
|
-
safeInspectors
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
inspectorsByType
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
safeInspectors &&
|
|
37
|
+
safeInspectors.forEach(safeInspector => {
|
|
38
|
+
// Only add inspectors of supported types.
|
|
39
|
+
if (Object.prototype.hasOwnProperty.call(inspectorsByType, safeInspector.type)) {
|
|
40
|
+
inspectorsByType[safeInspector.type].push(safeInspector);
|
|
41
|
+
} else {
|
|
42
|
+
logger.warn(messages.invalidInspector(safeInspector.type, safeInspector.name));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Check if there is an inspector of a specific type registered.
|
|
@@ -48,7 +49,7 @@ function InspectorManager(inspectors, logger) {
|
|
|
48
49
|
* @param {string} type The type of the inspector to check.
|
|
49
50
|
* @returns True if there are any inspectors of that type registered.
|
|
50
51
|
*/
|
|
51
|
-
manager.hasListeners = type => inspectorsByType[type]
|
|
52
|
+
manager.hasListeners = type => inspectorsByType[type] && inspectorsByType[type].length;
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* Notify registered inspectors of a flag being used.
|
package/src/configuration.js
CHANGED
package/src/context.js
CHANGED
|
@@ -107,7 +107,7 @@ function getContextKeys(context, logger = commonBasicLogger()) {
|
|
|
107
107
|
Object.entries(context)
|
|
108
108
|
.filter(([key]) => key !== 'kind')
|
|
109
109
|
.forEach(([key, value]) => {
|
|
110
|
-
if (value
|
|
110
|
+
if (value && value.key) {
|
|
111
111
|
keys[key] = value.key;
|
|
112
112
|
}
|
|
113
113
|
});
|
package/typings.d.ts
CHANGED
|
@@ -337,7 +337,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
337
337
|
* parts that compose a multi context. For more information see {@link LDSingleKindContext} and
|
|
338
338
|
* {@link LDMultiKindContext}.
|
|
339
339
|
*/
|
|
340
|
-
interface LDContextCommon {
|
|
340
|
+
export interface LDContextCommon {
|
|
341
341
|
/**
|
|
342
342
|
* If true, the context will _not_ appear on the Contexts page in the LaunchDarkly dashboard.
|
|
343
343
|
*/
|
|
@@ -386,7 +386,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
386
386
|
* The above context would be a single kind context representing an organization. It has a key
|
|
387
387
|
* for that organization, and a single attribute 'someAttribute'.
|
|
388
388
|
*/
|
|
389
|
-
interface LDSingleKindContext extends LDContextCommon {
|
|
389
|
+
export interface LDSingleKindContext extends LDContextCommon {
|
|
390
390
|
/**
|
|
391
391
|
* The kind of the context.
|
|
392
392
|
*/
|
|
@@ -424,7 +424,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
424
424
|
* The above multi-context contains both an 'org' and a 'user'. Each with their own key,
|
|
425
425
|
* attributes, and _meta attributes.
|
|
426
426
|
*/
|
|
427
|
-
interface LDMultiKindContext {
|
|
427
|
+
export interface LDMultiKindContext {
|
|
428
428
|
/**
|
|
429
429
|
* The kind of the context.
|
|
430
430
|
*/
|
|
@@ -555,7 +555,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
555
555
|
* Describes the reason that a flag evaluation produced a particular value. This is
|
|
556
556
|
* part of the {@link LDEvaluationDetail} object returned by {@link LDClient.variationDetail]].
|
|
557
557
|
*/
|
|
558
|
-
interface LDEvaluationReason {
|
|
558
|
+
export interface LDEvaluationReason {
|
|
559
559
|
/**
|
|
560
560
|
* The general category of the reason:
|
|
561
561
|
*
|
|
@@ -996,7 +996,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
996
996
|
* This interface should not be used by the application to access flags for the purpose of controlling application
|
|
997
997
|
* flow. It is intended for monitoring, analytics, or debugging purposes.
|
|
998
998
|
*/
|
|
999
|
-
interface LDInspectionFlagUsedHandler {
|
|
999
|
+
export interface LDInspectionFlagUsedHandler {
|
|
1000
1000
|
type: 'flag-used',
|
|
1001
1001
|
|
|
1002
1002
|
/**
|
|
@@ -1023,7 +1023,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
1023
1023
|
* This interface should not be used by the application to access flags for the purpose of controlling application
|
|
1024
1024
|
* flow. It is intended for monitoring, analytics, or debugging purposes.
|
|
1025
1025
|
*/
|
|
1026
|
-
interface LDInspectionFlagDetailsChangedHandler {
|
|
1026
|
+
export interface LDInspectionFlagDetailsChangedHandler {
|
|
1027
1027
|
type: 'flag-details-changed',
|
|
1028
1028
|
|
|
1029
1029
|
/**
|
|
@@ -1049,7 +1049,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
1049
1049
|
* This interface should not be used by the application to access flags for the purpose of controlling application
|
|
1050
1050
|
* flow. It is intended for monitoring, analytics, or debugging purposes.
|
|
1051
1051
|
*/
|
|
1052
|
-
interface LDInspectionFlagDetailChangedHandler {
|
|
1052
|
+
export interface LDInspectionFlagDetailChangedHandler {
|
|
1053
1053
|
type: 'flag-detail-changed',
|
|
1054
1054
|
|
|
1055
1055
|
/**
|
|
@@ -1072,7 +1072,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
1072
1072
|
* This interface should not be used by the application to access flags for the purpose of controlling application
|
|
1073
1073
|
* flow. It is intended for monitoring, analytics, or debugging purposes.
|
|
1074
1074
|
*/
|
|
1075
|
-
interface LDInspectionIdentifyHandler {
|
|
1075
|
+
export interface LDInspectionIdentifyHandler {
|
|
1076
1076
|
type: 'client-identity-changed',
|
|
1077
1077
|
|
|
1078
1078
|
/**
|
|
@@ -1086,6 +1086,6 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
1086
1086
|
method: (context: LDContext) => void;
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
|
-
type LDInspection = LDInspectionFlagUsedHandler | LDInspectionFlagDetailsChangedHandler
|
|
1089
|
+
export type LDInspection = LDInspectionFlagUsedHandler | LDInspectionFlagDetailsChangedHandler
|
|
1090
1090
|
| LDInspectionFlagDetailChangedHandler | LDInspectionIdentifyHandler;
|
|
1091
1091
|
}
|