From a87c632fe703fb33d26638bcbbb7446cfab29f01 Mon Sep 17 00:00:00 2001 From: Bailey Craig Date: Mon, 16 Oct 2023 09:16:31 -0500 Subject: [PATCH 1/2] feat: Adding defined properties for user context --- README.md | 15 +++++++++++++++ src/FlagsProvider.js | 11 +++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 316cac3..c736b21 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/FlagsProvider.js b/src/FlagsProvider.js index bfb825b..034f01c 100644 --- a/src/FlagsProvider.js +++ b/src/FlagsProvider.js @@ -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, @@ -37,8 +45,7 @@ export default class FlagsProvider extends Component { clientkey, { kind: 'user', - key: user.key, - ...user.custom + ...user }, bootstrap ); From 3145b9a5318f90df00f1455cd2f001783fd249b0 Mon Sep 17 00:00:00 2001 From: Bailey Craig Date: Mon, 16 Oct 2023 10:53:41 -0500 Subject: [PATCH 2/2] chore: Changing package version; Adding contributor --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index cde2436..c4d8bab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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": [ { @@ -8,6 +8,9 @@ }, { "name": "Romain Durand Saint Omer" + }, + { + "name": "Craig Bailey" } ], "license": "MIT",