Hi,
Just started using the Rest API (Javascript), and looking to generate the quivalent data we see in People>[user]>History. Ideally I am loooking to get general ibnformnation such as assets viewed and login / logout info etc.
I am able to get human_user information via activity_stream, but there are far less entries. I have read in posts from years ago, that the Shotgrid API might be limited in this way, is that the case, or should I be leveraging another part of the API?
You’d instead want to search for Event Log Entries linked to the human_user.
That will detail their activity
2 Likes
@schicky Thanks for the pointer, much appreciated.
For anyone else, here is a JS function that I got working:
async function GetUserEventLogEntries()
{
const accessToken = await authenticate();
const url = `${apiUrl}/entity/EventLogEntry/_search`;
const filters = [
['user', 'type_is', 'HumanUser'],
['user', 'is', {'type': 'HumanUser', 'id': userId}]
];
const fields = ['id', 'event_type', 'attribute_name', 'meta', 'entity'];
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/vnd+shotgun.api3_array+json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify({
entity_type: 'EventLogEntry',
filters: filters,
fields: fields
})
})
.then(response => response.json())
.then(data => {
// Process the data
console.log(data);
})
.catch(error => {
// Handle the error
console.error(error);
});
}
1 Like