Users
Get user stats
Section titled Get user statsGet some high-level statistics and details about a particular user, who has been identified via the tracker.setUserID
JavaScript function. This endpoint returns things like firstSeen
, lastSeen
and numberSessions
.
Method
Section titled MethodGET
/api/v1/:projectKey/users/:userId
Parameters
Section titled ParametersName | Type | Description |
---|---|---|
projectKey | string | The ID of the project you’re tracking (required) |
userId | string | The ID of your user, set via tracker.setUserID (required) |
Request Headers
Section titled Request HeadersAuthorization: {YOUR_ORGANIZATION_API_KEY}
: The key can be found in ‘Preferences’ > ‘Account’ > ‘Organization API Key’.
Status Codes
Section titled Status Codes200
: Response sent as JSON in body
Example Request
Section titled Example Requestcurl -X GET \
https://openreplay.example.com/api/v1/3sWXSsqHgSKnE87YkNJK/users/mickael@openreplay.com \
-H 'content-type: application/json' \
-H 'Authorization: {YOUR_ORGANIZATION_API_KEY}'
Example Response
Section titled Example Response{
"data": {
"userId": "mickael@openreplay.com",
"sessionCount": 3,
"lastSeen": 1623689478617,
"firstSeen": 1623440822825
}
}
Delete user
Section titled Delete userDelete a user (identified via the tracker.setUserID
JavaScript function) and all its data captured by OpenReplay. This fires up a background 1-time-job for removing all user related data, including sessions, events, metadata, custom events and recordings. The call returns a jobID
that you can use later on to check the status of the delete operation.
This comes in handy for handling GDPR requests you may receive from your end users.
Method
Section titled MethodDELETE
/api/v1/:projectKey/users/:userId
Parameters
Section titled ParametersName | Type | Description |
---|---|---|
projectKey | string | The ID of the project you’re tracking (required) |
userId | string | The ID of your user, set via tracker.setUserID (required) |
Request Headers
Section titled Request HeadersAuthorization: {YOUR_ORGANIZATION_API_KEY}
: The key can be found in ‘Preferences’ > ‘Account’ > ‘Organization API Key’.
Status Codes
Section titled Status Codes200
: Response sent as JSON in body
Example Request
Section titled Example Requestcurl -X DELETE \
https://openreplay.example.com/api/v1/3sWXSsqHgSKnE87YkNJK/users/mickael@example.com \
-H 'content-type: application/json' \
-H 'Authorization: {YOUR_ORGANIZATION_API_KEY}'
Example Response
Section titled Example Response{
"data": {
"jobId": 22345,
"description": "Delete user sessions of userId = mickael@example.com",
"status": "scheduled",
"projectId": 1,
"action": "delete_user_data",
"referenceId": "mehdi@openreplay.com",
"createdAt": 1623912962910,
"updatedAt": 1623912962910,
"startAt": 1623954600000,
"errors": null
}
}
Change the replay-file delete time ?
Section titled Change the replay-file delete time ?The deletion job is a 2 step process: First, sessions and their cascading events get deleted from the database overnight. Second, replay files are scheduled to expire (in 30 days) in the object storage.
If you’re using minio (vanilla installation), and you wish to change the default expiry/lifecycle policy, follow the below instructions:
- In your server, run
openreplay -e
- Under the
chalice
section, define a new env variable called SCH_DELETE_DAYS with a value equal to the number of days you want to keep the replay file before delete (greater or equal to 0) - Save and quit using
:wq
- Run
k9s -n db
- Use the keyboard arrows to navigate the list and get to the
minio-*
container - Press
s
to have shell access the Minio (object storage) container - Run
mc alias set minio http://localhost:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY
- To delete replay files 14 days after the delete-job execution
export EXPIRATION_DAYS=14
mc ilm add --expiry-days $EXPIRATION_DAYS --tags "to_delete_in_days=${EXPIRATION_DAYS}" minio/mobs
- Use
exit
to exit the Minio container - Run
:quit
to exit the Kubernetes CLI