Koople
Search…
Users
A user is an identified unique individual evaluated on each project environment. Each time your application sent via SDK a new user with id and attributes, it's created as a user in Koople platform.
Let's see how this works with the SDK
Javascript
C#
Java
1
import {PFClient} from "@pataflags/sdk-js";
2
3
const user = {
4
"id": "anonymous",
5
"context": {
6
"country": "atlantis"
7
}
8
};
9
10
const user1 = {
11
"id": "1",
12
"context": {
13
"email": "[email protected]",
14
"firstname": "user",
15
"lastname": "one",
16
"country": "gondor",
17
"age": 33
18
}
19
};
20
21
const user2 = {
22
"id": "2",
23
"context": {
24
"email": "[email protected]",
25
"firstname": "user",
26
"lastname": "two",
27
"country": "lilliput",
28
"age": 19
29
}
30
};
31
32
const pfclient = PFClient.initialize('YOUR_API_KEY', user);
33
const pfclient1 = PFClient.initialize('YOUR_API_KEY', user1);
34
const pfclient2 = PFClient.initialize('YOUR_API_KEY', user2);
Copied!
1
var pfclient = PfClient.Initialize('YOUR_API_KEY');
2
3
var user = PfUser.Anonymous();
4
5
var user1 = PfUser.Create('[email protected].io')
6
.With("firstname", "user")
7
.With("lastname", "one")
8
.With("country", "gondor")
9
.With("age", 33);
10
11
var user2 = PfUser.Create('[email protected].io')
12
.With("firstname", "user")
13
.With("lastname", "two")
14
.With("country", "lilliput")
15
.With("age", 19);
16
17
var isEnabled = pfclient.IsEnabled('social-media-button', user);
18
var isEnabled1 = pfclient.IsEnabled('social-media-button', user1);
19
var isEnabled2 = pfclient.IsEnabled('social-media-button', user2);
Copied!
1
PFClient pfclient = PFClient.initialize('YOUR_API_KEY');
2
3
PFUser user = PFUser.Anonymous();
4
5
PFUser user1 = PFUser.create('user1@koople.io')
6
.with("firstname", "user")
7
.with("lastname", "one")
8
.with("country", "gondor")
9
.with("age", 33);
10
11
PFUser user2 = PFUser.create('user2@koople.io')
12
.with("firstname", "user")
13
.with("lastname", "two")
14
.with("country", "lilliput")
15
.with("age", 19);
16
17
Boolean isEnabled = pfclient.isEnabled('myAwesomeFeature', user);
18
Boolean isEnabled1 = pfclient.isEnabled('myAwesomeFeature', user1);
19
Boolean isEnabled2 = pfclient.isEnabled('myAwesomeFeature', user2)
Copied!
When the SDK calls Koople platform, each user and his context is saved. Then you can see this information in the Users section.
The user icon is getting from Gravatar, so if the user has an image associated with the email, it will be displayed in the logs.
The email, identity, firstname and lastname are recognized data in the audit logs. Consider adding this information in your context to provide more information to the logs.
Moreover, when you click in the user row, you can see the saved additional information (the context). As you can see in the below image, in the top bar, the user is identified by his identifier. The left box has the user context data, and the right box has the last evaluation result of all active release toggles for the user.
Let's change add a new attribute to the user 2.
Javascript
C#
Java
1
import {PFClient} from "@pataflags/sdk-js";
2
3
const user2 = {
4
"id": "2",
5
"context": {
6
"email": "[email protected]",
7
"firstname": "user",
8
"lastname": "two",
9
"country": "lilliput",
10
"age": 19,
11
"vip": true
12
}
13
};
14
15
const pfclient2 = PFClient.initialize('YOUR_API_KEY', user2);
Copied!
1
user2.With("vip", true);
2
3
var isEnabled2 = pfclient.IsEnabled('social-media-button', user2);
Copied!
1
user2.with("vip", true);
2
3
Boolean isEnabled2 = pfclient.isEnabled('myAwesomeFeature', user2)
Copied!
Then the user data and evaluation results change automatically.
Copy link