From c26d831f280bad02b79a9e4ddd82ccef5708d662 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Fri, 14 Jan 2022 17:51:50 -0800 Subject: [PATCH] remove deprecated things (#48) * remove deprecated options and function * rm references to obsolete function * restore deprecation logic, just leave the data empty * remove samplingInterval from TS test code * fix TS test code again --- src/__tests__/configuration-test.js | 42 ++++++++++++++--------------- src/configuration.js | 8 +++--- src/index.js | 5 ++-- src/loggers.js | 5 ---- test-types.ts | 3 +-- typings.d.ts | 23 ---------------- 6 files changed, 26 insertions(+), 60 deletions(-) diff --git a/src/__tests__/configuration-test.js b/src/__tests__/configuration-test.js index 68e86bb..0f0bcc3 100644 --- a/src/__tests__/configuration-test.js +++ b/src/__tests__/configuration-test.js @@ -44,28 +44,26 @@ describe('configuration', () => { await listener.expectNoErrors(); } - function checkDeprecated(oldName, newName, value) { - const desc = newName - ? 'allows "' + oldName + '" as a deprecated equivalent to "' + newName + '"' - : 'warns that "' + oldName + '" is deprecated'; - it(desc, async () => { - const listener = errorListener(); - const config0 = {}; - config0[oldName] = value; - const config1 = configuration.validate(config0, listener.emitter, null, listener.logger); - if (newName) { - expect(config1[newName]).toBe(value); - expect(config1[oldName]).toBeUndefined(); - } else { - expect(config1[oldName]).toEqual(value); - } - await listener.expectWarningOnly(messages.deprecated(oldName, newName)); - }); - } - - checkDeprecated('all_attributes_private', 'allAttributesPrivate', true); - checkDeprecated('private_attribute_names', 'privateAttributeNames', ['foo']); - checkDeprecated('samplingInterval', null, 100); + // As of the latest major version, there are no deprecated options. This logic can be restored + // the next time we deprecate something. + // function checkDeprecated(oldName, newName, value) { + // const desc = newName + // ? 'allows "' + oldName + '" as a deprecated equivalent to "' + newName + '"' + // : 'warns that "' + oldName + '" is deprecated'; + // it(desc, async () => { + // const listener = errorListener(); + // const config0 = {}; + // config0[oldName] = value; + // const config1 = configuration.validate(config0, listener.emitter, null, listener.logger); + // if (newName) { + // expect(config1[newName]).toBe(value); + // expect(config1[oldName]).toBeUndefined(); + // } else { + // expect(config1[oldName]).toEqual(value); + // } + // await listener.expectWarningOnly(messages.deprecated(oldName, newName)); + // }); + // } function checkBooleanProperty(name) { it('enforces boolean type and default for "' + name + '"', async () => { diff --git a/src/configuration.js b/src/configuration.js index 466c9c9..e6f832b 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -44,11 +44,9 @@ export function validate(options, emitter, extraOptionDefs, logger) { const optionDefs = utils.extend({ logger: { default: logger } }, baseOptionDefs, extraOptionDefs); const deprecatedOptions = { - // eslint-disable-next-line camelcase - all_attributes_private: 'allAttributesPrivate', - // eslint-disable-next-line camelcase - private_attribute_names: 'privateAttributeNames', - samplingInterval: null, + // As of the latest major version, there are no deprecated options. Next time we deprecate + // something, add an item here where the property name is the deprecated name, and the + // property value is the preferred name if any, or null/undefined if there is no replacement. }; function checkDeprecatedOptions(config) { diff --git a/src/index.js b/src/index.js index 7020d62..c239e1e 100644 --- a/src/index.js +++ b/src/index.js @@ -10,7 +10,7 @@ import Identity from './Identity'; import UserValidator from './UserValidator'; import * as configuration from './configuration'; import * as diagnostics from './diagnosticEvents'; -import { commonBasicLogger, createConsoleLogger } from './loggers'; +import { commonBasicLogger } from './loggers'; import * as utils from './utils'; import * as errors from './errors'; import * as messages from './messages'; @@ -95,7 +95,7 @@ export function initialize(env, user, specifiedOptions, platform, extraOptionDef if (specifiedOptions && specifiedOptions.logger) { return specifiedOptions.logger; } - return (extraOptionDefs && extraOptionDefs.logger && extraOptionDefs.logger.default) || createConsoleLogger('warn'); + return (extraOptionDefs && extraOptionDefs.logger && extraOptionDefs.logger.default) || commonBasicLogger('warn'); } function readFlagsFromBootstrap(data) { @@ -762,7 +762,6 @@ export function initialize(env, user, specifiedOptions, platform, extraOptionDef export const version = VERSION; export { commonBasicLogger }; -export { createConsoleLogger }; export { errors }; export { messages }; export { utils }; diff --git a/src/loggers.js b/src/loggers.js index 7d2f26c..efc28f3 100644 --- a/src/loggers.js +++ b/src/loggers.js @@ -86,8 +86,3 @@ export function validateLogger(logger) { } }); } - -// Deprecated equivalent to commonBasicLogger -export function createConsoleLogger(level, maybePrefix) { - return commonBasicLogger({ level, prefix: maybePrefix }); -} diff --git a/test-types.ts b/test-types.ts index 9c5bac5..7cf765a 100644 --- a/test-types.ts +++ b/test-types.ts @@ -6,7 +6,6 @@ import * as ld from 'launchdarkly-js-sdk-common'; var ver: string = ld.version; -var logger: ld.LDLogger = ld.createConsoleLogger("info"); var userWithKeyOnly: ld.LDUser = { key: 'user' }; var anonUserWithNoKey: ld.LDUser = { anonymous: true }; var anonUserWithKey: ld.LDUser = { key: 'anon-user', anonymous: true }; @@ -31,6 +30,7 @@ var user: ld.LDUser = { }, privateAttributeNames: [ 'name', 'email' ] }; +var logger: ld.LDLogger = ld.commonBasicLogger({ level: 'info' }); var allBaseOptions: ld.LDOptionsBase = { bootstrap: { }, baseUrl: '', @@ -48,7 +48,6 @@ var allBaseOptions: ld.LDOptionsBase = { allowFrequentDuplicateEvents: true, sendEventsOnlyForVariation: true, flushInterval: 1, - samplingInterval: 1, streamReconnectDelay: 1, logger: logger }; diff --git a/typings.d.ts b/typings.d.ts index fb050b4..8bcbe4e 100644 --- a/typings.d.ts +++ b/typings.d.ts @@ -46,18 +46,6 @@ declare module 'launchdarkly-js-sdk-common' { error: (message: string) => void; } - /** - * A basic implementation of logging that uses the global `console` object. This is used by - * default in the browser SDK. It sends messages of "debug", "info", "warn", or "error" - * level (if enable) to `console.log()`, `console.info()`, `console.warn()`, and `console.error()` - * respectively. - * - * To make LDClient use this logger, put it in the `logger` property of [[LDOptions]]. - * - * @deprecated Please use `basicLogger` instead. - */ - export function createConsoleLogger(minimumLevel: string): LDLogger; - /** * LaunchDarkly initialization options that are supported by all variants of the JS client. * The browser SDK and Electron SDK may support additional options. @@ -223,17 +211,6 @@ declare module 'launchdarkly-js-sdk-common' { */ flushInterval?: number; - /** - * If specified, enables event sampling so that only some fraction of analytics events will be - * sent pseudo-randomly. - * - * When set to greater than zero, there is a 1 in `samplingInterval` chance that events will be - * sent: for example, a value of 20 means that on average 1 in 20, or 5%, of all events will be sent. - * - * @deprecated This feature will be removed in a future version. - */ - samplingInterval?: number; - /** * How long (in milliseconds) to wait after a failure of the stream connection before trying to * reconnect.