Skip to content

Additional user context #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ ReactDOM.render(
| onFlagsChange | function | false | Handler for flag change |
| loadingComponent | Component | false | Loading component / string |

The `user` object can have any of the following properties:

| Prop | Type | Description |
|------------------|-----------|-----------------------------------------------|
| key | String | A unique string identifying the user context |
| name | String | The name given to the user context |
| firstName | String | User's first name |
| lastName | String | User's last name |
| email | String | User's email address |
| avatar | String | URL to user's avatar image |
| ip | String | IP address of user |
| country | String | User country |
| anonymous | Boolean | If true, hide the context in LaunchDarkly |
| custom | Object | Custom metadata of the user |

### Flags
All `Flags` components get the _ldClient_ instance thanks to the `FlagsProvider` component.

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "@lectra/ld-react-feature-flags",
"version": "1.3.0",
"version": "1.4.0",
"description": "Integrate Launch Darkly in your React app in a breeze",
"contributors": [
{
"name": "Guillaume Dumora"
},
{
"name": "Romain Durand Saint Omer"
},
{
"name": "Craig Bailey"
}
],
"license": "MIT",
Expand Down
11 changes: 9 additions & 2 deletions src/FlagsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export default class FlagsProvider extends Component {
children: PropTypes.any,
user: PropTypes.shape({
key: PropTypes.string,
name: PropTypes.string,
firstName: PropTypes.string,
lastName: PropTypes.string,
email: PropTypes.string,
avatar: PropTypes.string,
ip: PropTypes.string,
country: PropTypes.string,
anonymous: PropTypes.bool,
custom: PropTypes.object
}).isRequired,
clientkey: PropTypes.string.isRequired,
Expand Down Expand Up @@ -37,8 +45,7 @@ export default class FlagsProvider extends Component {
clientkey,
{
kind: 'user',
key: user.key,
...user.custom
...user
},
bootstrap
);
Expand Down