How to use Advanced Insights to track how long users published to a session How to use Advanced Insights to track how long users published to a session

How to use Advanced Insights to track how long users published to a session

Douglas Szeto

Question

Using advanced insights, you can track how long uses publish and subscribe in a session.

Applies To

  • Advanced Insights

Answer

1. In the GraphiQL explorer, paste the following query:

{
project(projectId: yourProjectAPIKey) {
sessionData {
sessions(

sessionIds : ["sessionid_1","sessionid_2","sessionid_n"]
) {
resources {
sessionId
meetings(first: 10) {
resources {
meetingId
createdAt
publisherMinutes
subscriberMinutes
destroyedAt
publishers(first: 1000) {
resources {
connectionId
createdAt
destroyedAt
stream {
streamId
hasAudioTrack
hasVideoTrack
videoType
}
streamStatsCollection(first: 1000) {
resources {
createdAt
audioCodec
audioLatencyMs
audioBitrateKbps
audioPacketLoss
videoCodec
videoLatencyMs
videoBitrateKbps
videoPacketLoss
videoResolution
}
}
}
}
subscribers(first: 1000) {
pageInfo {
hasNextPage
endCursor
}
resources {
subscriberId
connectionId
createdAt
destroyedAt
stream {
streamId
hasAudioTrack
hasVideoTrack
videoType
}
streamStatsCollection(first: 1000) {
pageInfo {
hasNextPage
endCursor
}
resources {
createdAt
audioCodec
audioLatencyMs
audioBitrateKbps
audioPacketLoss
videoCodec
videoLatencyMs
videoBitrateKbps
videoPacketLoss
videoResolution
}
}
}
}
}
}
}
}
}
}
}

 

2. Take note of the following parameters:

"connectionId"
"createdAt"
"destroyedAt"

 

Each user is associated with one or more connectionIDs, which you can use to refer back to the user that connected to the session. When you take the difference between "createdAt" and "destroyedAt", you'll get the amount of time this connectionID published. In the event a user publishes to a session multiple times (assuming the connectionIDs each belong to the same user) add these together and the sum total is the amount of time a user is connected to a session.

 

Consider the following snippet from a sessionID returned after executing the above GraphiQL query:

"resources": [
{
"destroyedAt": "2023-12-29T22:13:52.754Z",
"publishers": {
"resources": [
{
"connectionId": "C1378808-2FAA-4D6F-B398-D95C222B7484",
"createdAt": "2023-12-29T20:12:53.210Z",
"destroyedAt": "2023-12-29T20:13:55.254Z"
},
{
"connectionId": "4256C60A-0ED6-476E-9129-3148A0171EAA",
"createdAt": "2023-12-29T20:13:31.721Z",
"destroyedAt": "2023-12-29T20:14:02.154Z"
}

This section starts with the phrase 'publishers', thereby indicating all connectionIds found within this body are for publishers. When you take the difference between the destroyedAt and createAt parameters, this is the amount of time this user has been publishing. Furthermore, each connectionId is associated with one user, as shown in the screenshot below, which you'll find when using the session inspector tool, then expanding the user data area: Screenshot 2023-12-29 at 2.17.53 PM.png

To obtain the total amount of time User 1 is publishing, you'll want to sum total the amount of time per connectionId for User 1:

"connectionId": "C1378808-2FAA-4D6F-B398-D95C222B7484"
"destroyedAt" - "createdAt": "2023-12-29T20:13:55.254Z" - "2023-12-29T20:12:53.210Z" = 1 minute, 2 seconds

 

"connectionId": "4256C60A-0ED6-476E-9129-3148A0171EAA",
"destroyedAt" - "createdAt": "2023-12-29T20:14:02.154Z" - "2023-12-29T20:13:31.721Z" = 31 seconds
 
 Total publishing duration for User 1 = 1 minute, 2 seconds + 31 seconds = 1 minute, 33 seconds

Additional Information

Insights API documentation

Advanced Insights API information

User data in session inspector