launchdarkly-js-sdk-common 5.0.0-alpha.4 → 5.0.0-alpha.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launchdarkly-js-sdk-common",
3
- "version": "5.0.0-alpha.4",
3
+ "version": "5.0.0-alpha.5",
4
4
  "description": "LaunchDarkly SDK for JavaScript - common code",
5
5
  "author": "LaunchDarkly <team@launchdarkly.com>",
6
6
  "license": "Apache-2.0",
package/src/context.js CHANGED
@@ -3,6 +3,8 @@
3
3
  * @param {string} kind
4
4
  * @returns true if the kind is valid.
5
5
  */
6
+ const { commonBasicLogger } = require('./loggers');
7
+
6
8
  function validKind(kind) {
7
9
  return typeof kind === 'string' && kind !== 'kind' && kind.match(/^(\w|\.|-)+$/);
8
10
  }
@@ -89,7 +91,7 @@ function getCanonicalKey(context) {
89
91
  }
90
92
  }
91
93
 
92
- function getContextKeys(context, logger) {
94
+ function getContextKeys(context, logger = commonBasicLogger()) {
93
95
  if (!context) {
94
96
  return undefined;
95
97
  }
@@ -111,10 +113,10 @@ function getContextKeys(context, logger) {
111
113
  });
112
114
  break;
113
115
  case null:
114
- logger?.warn(`null is not a valid context kind: ${context}`);
116
+ logger.warn(`null is not a valid context kind: ${context}`);
115
117
  break;
116
118
  case '':
117
- logger?.warn(`'' is not a valid context kind: ${context}`);
119
+ logger.warn(`'' is not a valid context kind: ${context}`);
118
120
  break;
119
121
  default:
120
122
  keys[kind] = `${key}`;
package/test-types.ts CHANGED
@@ -91,3 +91,5 @@ var flagSetValue: ld.LDFlagValue = flagSet['key'];
91
91
 
92
92
  client.close(() => {});
93
93
  client.close().then(() => {});
94
+
95
+ var contextKeys = ld.getContextKeys(user);
package/typings.d.ts CHANGED
@@ -984,6 +984,11 @@ declare module 'launchdarkly-js-sdk-common' {
984
984
  */
985
985
  export type LDLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
986
986
 
987
+ export function getContextKeys(
988
+ context: LDContext,
989
+ logger?: LDLogger,
990
+ ): {[attribute: string]: string} | undefined;
991
+
987
992
  /**
988
993
  * Callback interface for collecting information about the SDK at runtime.
989
994
  *