launchdarkly-js-sdk-common 4.1.1 → 4.2.0

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 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.1] - 2022-06-07
6
+ ### Changed:
7
+ - Enforce a 64 character limit for `application.id` and `application.version` configuration options.
8
+
9
+ ### Fixed:
10
+ - Do not include deleted flags in `allFlags`.
11
+
5
12
  ## [4.1.0] - 2022-04-21
6
13
  ### Added:
7
14
  - `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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launchdarkly-js-sdk-common",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "description": "LaunchDarkly SDK for JavaScript - common code",
5
5
  "author": "LaunchDarkly <team@launchdarkly.com>",
6
6
  "license": "Apache-2.0",
@@ -44,26 +44,24 @@ describe('configuration', () => {
44
44
  await listener.expectNoErrors();
45
45
  }
46
46
 
47
- // As of the latest major version, there are no deprecated options. This logic can be restored
48
- // the next time we deprecate something.
49
- // function checkDeprecated(oldName, newName, value) {
50
- // const desc = newName
51
- // ? 'allows "' + oldName + '" as a deprecated equivalent to "' + newName + '"'
52
- // : 'warns that "' + oldName + '" is deprecated';
53
- // it(desc, async () => {
54
- // const listener = errorListener();
55
- // const config0 = {};
56
- // config0[oldName] = value;
57
- // const config1 = configuration.validate(config0, listener.emitter, null, listener.logger);
58
- // if (newName) {
59
- // expect(config1[newName]).toBe(value);
60
- // expect(config1[oldName]).toBeUndefined();
61
- // } else {
62
- // expect(config1[oldName]).toEqual(value);
63
- // }
64
- // await listener.expectWarningOnly(messages.deprecated(oldName, newName));
65
- // });
66
- // }
47
+ function checkDeprecated(oldName, newName, value) {
48
+ const desc = newName
49
+ ? 'allows "' + oldName + '" as a deprecated equivalent to "' + newName + '"'
50
+ : 'warns that "' + oldName + '" is deprecated';
51
+ it(desc, async () => {
52
+ const listener = errorListener();
53
+ const config0 = {};
54
+ config0[oldName] = value;
55
+ const config1 = configuration.validate(config0, listener.emitter, null, listener.logger);
56
+ if (newName) {
57
+ expect(config1[newName]).toBe(value);
58
+ expect(config1[oldName]).toBeUndefined();
59
+ } else {
60
+ expect(config1[oldName]).toEqual(value);
61
+ }
62
+ await listener.expectWarningOnly(messages.deprecated(oldName, newName));
63
+ });
64
+ }
67
65
 
68
66
  function checkBooleanProperty(name) {
69
67
  it('enforces boolean type and default for "' + name + '"', async () => {
@@ -103,13 +101,14 @@ describe('configuration', () => {
103
101
  checkBooleanProperty('allAttributesPrivate');
104
102
  checkBooleanProperty('sendLDHeaders');
105
103
  checkBooleanProperty('inlineUsersInEvents');
106
- checkBooleanProperty('allowFrequentDuplicateEvents');
107
104
  checkBooleanProperty('sendEventsOnlyForVariation');
108
105
  checkBooleanProperty('useReport');
109
106
  checkBooleanProperty('evaluationReasons');
110
107
  checkBooleanProperty('diagnosticOptOut');
111
108
  checkBooleanProperty('streaming');
112
109
 
110
+ checkDeprecated('allowFrequentDuplicateEvents', undefined, true);
111
+
113
112
  function checkNumericProperty(name, validValue) {
114
113
  it('enforces numeric type and default for "' + name + '"', async () => {
115
114
  await expectDefault(name);
@@ -101,7 +101,6 @@ describe('DiagnosticsManager', () => {
101
101
  };
102
102
  const defaultConfigInEvent = {
103
103
  allAttributesPrivate: false,
104
- allowFrequentDuplicateEvents: false,
105
104
  autoAliasingOptOut: false,
106
105
  bootstrapMode: false,
107
106
  customBaseURI: false,
@@ -189,7 +188,6 @@ describe('DiagnosticsManager', () => {
189
188
  it('sends init event on start() with custom config', async () => {
190
189
  const configAndResultValues = [
191
190
  [{ allAttributesPrivate: true }, { allAttributesPrivate: true }],
192
- [{ allowFrequentDuplicateEvents: true }, { allowFrequentDuplicateEvents: true }],
193
191
  [{ bootstrap: {} }, { bootstrapMode: true }],
194
192
  [{ baseUrl: 'http://other' }, { customBaseURI: true }],
195
193
  [{ eventsUrl: 'http://other' }, { customEventsURI: true }],
@@ -78,9 +78,10 @@ function validate(options, emitter, extraOptionDefs, logger) {
78
78
  const optionDefs = utils.extend({ logger: { default: logger } }, baseOptionDefs, extraOptionDefs);
79
79
 
80
80
  const deprecatedOptions = {
81
- // As of the latest major version, there are no deprecated options. Next time we deprecate
82
- // something, add an item here where the property name is the deprecated name, and the
83
- // property value is the preferred name if any, or null/undefined if there is no replacement.
81
+ // The property name is the deprecated name, and the property value is the preferred name if
82
+ // any, or null/undefined if there is no replacement. This should be removed, along with
83
+ // the option, in the next major version.
84
+ allowFrequentDuplicateEvents: undefined,
84
85
  };
85
86
 
86
87
  function checkDeprecatedOptions(config) {
@@ -201,7 +201,6 @@ function DiagnosticsManager(
201
201
  usingSecureMode: !!config.hash,
202
202
  bootstrapMode: !!config.bootstrap,
203
203
  fetchGoalsDisabled: !config.fetchGoals,
204
- allowFrequentDuplicateEvents: !!config.allowFrequentDuplicateEvents,
205
204
  sendEventsOnlyForVariation: !!config.sendEventsOnlyForVariation,
206
205
  autoAliasingOptOut: !!config.autoAliasingOptOut,
207
206
  };
package/src/index.js CHANGED
@@ -63,7 +63,6 @@ function initialize(env, user, specifiedOptions, platform, extraOptionDefs) {
63
63
 
64
64
  const requestor = Requestor(platform, options, environment);
65
65
 
66
- const seenRequests = {};
67
66
  let flags = {};
68
67
  let useLocalStorage;
69
68
  let streamActive;
@@ -181,15 +180,6 @@ function initialize(env, user, specifiedOptions, platform, extraOptionDefs) {
181
180
  const user = ident.getUser();
182
181
  const now = new Date();
183
182
  const value = detail ? detail.value : null;
184
- if (!options.allowFrequentDuplicateEvents) {
185
- const cacheKey = JSON.stringify(value) + (user && user.key ? user.key : '') + key; // see below
186
- const cached = seenRequests[cacheKey];
187
- // cache TTL is five minutes
188
- if (cached && now - cached < 300000) {
189
- return;
190
- }
191
- seenRequests[cacheKey] = now;
192
- }
193
183
 
194
184
  const event = {
195
185
  kind: 'feature',
package/typings.d.ts CHANGED
@@ -173,10 +173,13 @@ declare module 'launchdarkly-js-sdk-common' {
173
173
  inlineUsersInEvents?: boolean;
174
174
 
175
175
  /**
176
- * Whether or not to send an analytics event for a flag evaluation even if the same flag was
177
- * evaluated with the same value within the last five minutes.
176
+ * This option is deprecated, and setting it has no effect.
178
177
  *
179
- * By default, this is false (duplicate events within five minutes will be dropped).
178
+ * The behavior is now to allow frequent duplicate events.
179
+ *
180
+ * This is not a problem because most events will be summarized, and
181
+ * events which are not summarized are important to the operation of features such as
182
+ * experimentation.
180
183
  */
181
184
  allowFrequentDuplicateEvents?: boolean;
182
185