launchdarkly-js-sdk-common 4.1.0 → 4.1.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/.ldrelease/config.yml +1 -1
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/__tests__/configuration-test.js +7 -0
- package/src/configuration.js +10 -6
- package/src/index.js +1 -1
- package/src/messages.js +3 -0
- package/typings.d.ts +2 -1
package/.ldrelease/config.yml
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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
|
+
## [4.1.0] - 2022-04-21
|
|
6
|
+
### Added:
|
|
7
|
+
- `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.
|
|
8
|
+
|
|
9
|
+
### Fixed:
|
|
10
|
+
- The `baseUrl`, `streamUrl`, and `eventsUrl` 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.
|
|
11
|
+
|
|
5
12
|
## [4.0.3] - 2022-02-16
|
|
6
13
|
### Fixed:
|
|
7
14
|
- 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 no `error` event listeners, it is logged. Previously, it would be thrown as an unhandled exception.
|
package/package.json
CHANGED
|
@@ -230,6 +230,13 @@ describe('configuration', () => {
|
|
|
230
230
|
await listener.expectWarningOnly(messages.invalidTagValue('application.id'));
|
|
231
231
|
});
|
|
232
232
|
|
|
233
|
+
it('logs a warning when a tag value is too long', async () => {
|
|
234
|
+
const listener = errorListener();
|
|
235
|
+
const configIn = { application: { id: 'a'.repeat(65), version: 'b'.repeat(64) } };
|
|
236
|
+
expect(configuration.validate(configIn, listener.emitter, null, listener.logger).application.id).toBeUndefined();
|
|
237
|
+
await listener.expectWarningOnly(messages.tagValueTooLong('application.id'));
|
|
238
|
+
});
|
|
239
|
+
|
|
233
240
|
it('handles a valid application version', async () => {
|
|
234
241
|
const listener = errorListener();
|
|
235
242
|
const configIn = { application: { version: 'test-version' } };
|
package/src/configuration.js
CHANGED
|
@@ -48,24 +48,28 @@ const allowedTagCharacters = /^(\w|\.|-)+$/;
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Verify that a value meets the requirements for a tag value.
|
|
51
|
-
* @param {Object} config
|
|
52
51
|
* @param {string} tagValue
|
|
52
|
+
* @param {Object} logger
|
|
53
53
|
*/
|
|
54
|
-
function validateTagValue(name,
|
|
54
|
+
function validateTagValue(name, tagValue, logger) {
|
|
55
55
|
if (typeof tagValue !== 'string' || !tagValue.match(allowedTagCharacters)) {
|
|
56
56
|
logger.warn(messages.invalidTagValue(name));
|
|
57
57
|
return undefined;
|
|
58
58
|
}
|
|
59
|
+
if (tagValue.length > 64) {
|
|
60
|
+
logger.warn(messages.tagValueTooLong(name));
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
59
63
|
return tagValue;
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
function applicationConfigValidator(name,
|
|
66
|
+
function applicationConfigValidator(name, value, logger) {
|
|
63
67
|
const validated = {};
|
|
64
68
|
if (value.id) {
|
|
65
|
-
validated.id = validateTagValue(`${name}.id`,
|
|
69
|
+
validated.id = validateTagValue(`${name}.id`, value.id, logger);
|
|
66
70
|
}
|
|
67
71
|
if (value.version) {
|
|
68
|
-
validated.version = validateTagValue(`${name}.version`,
|
|
72
|
+
validated.version = validateTagValue(`${name}.version`, value.version, logger);
|
|
69
73
|
}
|
|
70
74
|
return validated;
|
|
71
75
|
}
|
|
@@ -136,7 +140,7 @@ function validate(options, emitter, extraOptionDefs, logger) {
|
|
|
136
140
|
const expectedType = optionDef.type || typeDescForValue(optionDef.default);
|
|
137
141
|
const validator = optionDef.validator;
|
|
138
142
|
if (validator) {
|
|
139
|
-
const validated = validator(name, config
|
|
143
|
+
const validated = validator(name, config[name], logger);
|
|
140
144
|
if (validated !== undefined) {
|
|
141
145
|
ret[name] = validated;
|
|
142
146
|
} else {
|
package/src/index.js
CHANGED
|
@@ -313,7 +313,7 @@ function initialize(env, user, specifiedOptions, platform, extraOptionDefs) {
|
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
for (const key in flags) {
|
|
316
|
-
if (utils.objectHasOwnProperty(flags, key)) {
|
|
316
|
+
if (utils.objectHasOwnProperty(flags, key) && !flags[key].deleted) {
|
|
317
317
|
results[key] = variationDetailInternal(key, null, !options.sendEventsOnlyForVariation).value;
|
|
318
318
|
}
|
|
319
319
|
}
|
package/src/messages.js
CHANGED
|
@@ -182,6 +182,8 @@ const debugPostingDiagnosticEvent = function(event) {
|
|
|
182
182
|
|
|
183
183
|
const invalidTagValue = name => `Config option "${name}" must only contain letters, numbers, ., _ or -.`;
|
|
184
184
|
|
|
185
|
+
const tagValueTooLong = name => `Value of "${name}" was longer than 64 characters and was discarded.`;
|
|
186
|
+
|
|
185
187
|
module.exports = {
|
|
186
188
|
bootstrapInvalid,
|
|
187
189
|
bootstrapOldFormat,
|
|
@@ -217,6 +219,7 @@ module.exports = {
|
|
|
217
219
|
streamClosing,
|
|
218
220
|
streamConnecting,
|
|
219
221
|
streamError,
|
|
222
|
+
tagValueTooLong,
|
|
220
223
|
unknownCustomEventKey,
|
|
221
224
|
unknownOption,
|
|
222
225
|
userNotSpecified,
|
package/typings.d.ts
CHANGED
|
@@ -701,7 +701,8 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
701
701
|
alias(user: LDUser, previousUser: LDUser): void;
|
|
702
702
|
|
|
703
703
|
/**
|
|
704
|
-
* Returns a map of all available flags to the current user's values.
|
|
704
|
+
* Returns a map of all available flags to the current user's values. This will send analytics
|
|
705
|
+
* events unless [[LDOptions.sendEventsOnlyForVariation]] is true.
|
|
705
706
|
*
|
|
706
707
|
* @returns
|
|
707
708
|
* An object in which each key is a feature flag key and each value is the flag value.
|