Skip to content

Commit

Permalink
remove deprecated things (#48)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
eli-darkly authored Jan 15, 2022
1 parent 9474648 commit c26d831
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 60 deletions.
42 changes: 20 additions & 22 deletions src/__tests__/configuration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
8 changes: 3 additions & 5 deletions src/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 };
5 changes: 0 additions & 5 deletions src/loggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,3 @@ export function validateLogger(logger) {
}
});
}

// Deprecated equivalent to commonBasicLogger
export function createConsoleLogger(level, maybePrefix) {
return commonBasicLogger({ level, prefix: maybePrefix });
}
3 changes: 1 addition & 2 deletions test-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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: '',
Expand All @@ -48,7 +48,6 @@ var allBaseOptions: ld.LDOptionsBase = {
allowFrequentDuplicateEvents: true,
sendEventsOnlyForVariation: true,
flushInterval: 1,
samplingInterval: 1,
streamReconnectDelay: 1,
logger: logger
};
Expand Down
23 changes: 0 additions & 23 deletions typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit c26d831

Please sign in to comment.