react-launch-darkly
Advanced tools
Comparing version
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.getAllFeatureFlags = exports.FeatureFlag = exports.LaunchDarkly = undefined; | ||
exports.identify = exports.getAllFeatureFlags = exports.FeatureFlag = exports.LaunchDarkly = undefined; | ||
@@ -17,2 +17,8 @@ var _utils = require("./lib/utils"); | ||
}); | ||
Object.defineProperty(exports, "identify", { | ||
enumerable: true, | ||
get: function get() { | ||
return _utils.identify; | ||
} | ||
}); | ||
@@ -19,0 +25,0 @@ var _LaunchDarkly2 = require("./components/LaunchDarkly"); |
@@ -10,2 +10,3 @@ "use strict"; | ||
exports.getAllFeatureFlags = getAllFeatureFlags; | ||
exports.identify = identify; | ||
@@ -107,2 +108,22 @@ var _ldclientJs = require("ldclient-js"); | ||
}); | ||
} | ||
/* | ||
https://docs.launchdarkly.com/docs/js-sdk-reference#section-changing-the-user-context | ||
"The hash parameter is the hash for the new user, assuming that the user's key has changed. | ||
It is only required in secure mode-- if secure mode is not enabled, | ||
you can pass in `null` for the hash." | ||
*/ | ||
function identify(key, user) { | ||
var hash = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var ldClient = ldClientWrapper(key, user); | ||
return new Promise(function (resolve) { | ||
ldClient.onReady(function () { | ||
resolve(ldClient.identify(user, hash)); | ||
}); | ||
}); | ||
} |
{ | ||
"name": "react-launch-darkly", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./build/index", |
@@ -62,2 +62,3 @@ # React-Launch-Darkly | ||
- [Overriding Feature Flags](https://github.com/TrueCar/react-launch-darkly#overriding-feature-flags) | ||
- [Identifying new users](https://github.com/TrueCar/react-launch-darkly#Identify-a-new-user) | ||
@@ -208,2 +209,16 @@ --- | ||
--- | ||
### Identify a new user | ||
If you need to change the configured user for the launch darkly client you can do that by calling `identify`. | ||
``` | ||
import { identify } from "react-launch-darkly"; | ||
identify(launchDarklyClientKey, launchDarklyUser, optionalUserHash); | ||
``` | ||
See Launch Darkly's [documentation](https://docs.launchdarkly.com/docs/js-sdk-reference#section-changing-the-user-context) for more information. | ||
#### Examples | ||
@@ -210,0 +225,0 @@ ``` |
24411
5.56%308
7.69%236
6.79%