Javascript SDK
Identify Users
If your application has logged-in users, you can identify users by calling the identify
method. This is helpful to associate feedback with logged-in users and view their information like name, email, and company details directly in the feedback details. Additionally, your logged-in users will not have to fill in their details like name and email when they provide feedback.
This method takes an object with user's details. You need to call this method once your users log in to your application. You can call this method before or after the Userowl.initialize(..)
method.
Identity verification
You can use the hash
parameter to verify the identity of the user. If you use this method, we strongly recommend you also set up identity verification to prevent bad actors to impersonate other users.
Userowl.identify({
id: 'abc123456', //User's unique identifier
email: '[email protected]', //User's email
name: 'Simone Miles' //User's name
});
- Name
user
- Type
- User
- Required
- Required
- Description
- Details of the user to identify.
- Name
hash
- Type
- string
- Description
- Used for identity verification.
- Name
id
- Type
- string
- Required
- Required
- Description
- Unique identifier of the logged in user
- Name
email
- Type
- string
- Description
- Email address of the logged in user
- Name
name
- Type
- string
- Description
- Full name of the user
- Name
created
- Type
- number
- Description
- Unix timestamp (in seconds) when the user signed up to your system
- Name
avatarUrl
- Type
- string
- Description
- URL of the user's avatar
- Name
company
- Type
- Company
- Description
- Company details of the user
- Name
id
- Type
- string
- Description
- Unique identifier of the company
- Name
name
- Type
- string
- Description
- Name of the company
- Name
value
- Type
- number
- Description
- How much monthly revenue the company generates for your business
- Name
created
- Type
- number
- Description
- Unix timestamp (in seconds) when the company is created in your system
This method clears the user's information for current session. You can use this method when the user logs out from your application.
Userowl.clearUser();
You can use the hash
parameter in the identify
method to verify the identity of the user.
This helps to make sure that that one user can't impersonate another. You can generate a hash on your server and pass it to the identify
method.
Userowl.identify({
id: 'abc123456',
email: '[email protected]',
name: 'Simone Miles'
}, 'INSERT_HMAC_VALUE_HERE');
Identity Verification works by using a server-side generated HMAC (hash-based message authentication code), using SHA256, on user's id.
You can generate HMAC on your server using the user's id and your secret key. Here is an example code snippet in different programming languages to generate HMAC using SHA256 encoding.
import hmac
import hashlib
import base64
def generate_hmac(data, key):
key_bytes = bytes(key, 'utf-8')
data_bytes = bytes(data, 'utf-8')
hmac_bytes = hmac.new(key_bytes, data_bytes, hashlib.sha256).digest()
return base64.b64encode(hmac_bytes).decode('utf-8')
user_id = "user-id-to-be-signed"
secret = "your-secret-key"
hmac = generate_hmac(user_id, secret)
print(f"Generated HMAC-SHA256: {hmac}")
Finding your secret
You can find the secret specific to your project at the installation page. Be sure to keep your secret key secure and never expose it in your client-side code.
You can include additional custom data about the user with the identify
method. When the identified user sends a feedback, this data will be shown in the feedback details in Userowl dashboard.
You can just pass the custom fields as key-value pairs in the User
object. Only simple data types like string, number, and boolean are supported.
Userowl.identify({
id: 'abc123456',
email: '[email protected]',
name: 'Simone Miles'
customField1: 'value1', //Custom field 1
yearsOfExperience: 13 //Custom field 2
});
You can also pass additional data to the Company
object.
Userowl.identify({
id: 'abc123456',
email: '[email protected]',
name: 'Simone Miles'
company: {
id: 'company123',
name: 'Acme Inc',
value: 10000,
customField1: 'value1', //Custom company field 1
numberOfEmployees: 25 //Custom company field 2
}
});