MAGES 5 Analytics Architecture

MAGES 5 uses a T-SQL relational model to store analytics data.

vs22

Analytics data is stored based on the above relational diagram.

When uploading a session’s analytics, Analytics API stores the data as follows:

  • User Applications

  • Application Sessions

  • Sessions

Note

  • A User-Application relationship is one-to-many. A user may have analytics in many applications

  • An Application-Session relationship is one-to-many. An application has many sessions

  • Session holds the session analytics for each application

The base functionalities of Analytics API are

  • Upload Analytics

  • Get Analytics

Important

To use Analytics API for debugging and testing you will have to use a API debug tool like Postman

The request to upload analytics:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
[HttpPost("uploadnxt/{version}")]
public async Task<IActionResult> UploadAnalyticsNXT([FromBody] string _analytics, [FromRoute] string version)
{
    string clientId = TokenHelper.GetClientId(User);
    if (!clientId.Equals("UnityModuleWithoutSSO") &&
        !clientId.Equals("SDKORamaVRUnityClient") &&
        !clientId.Equals("UnityModule"))
    {
        return Unauthorized();
    }

    var res = "";
    if ((res = await _uploadService.UploadAnalyticsNXT(_analytics, version)) != "true")
    {
        return BadRequest(res);
    }

    return Ok("Upload Complete");
}

This endpoint’s URL is:

http://localhost:5002/api/upload/uploadnxt

The request to retrieve a session:

1
2
3
4
5
6
7
8
9
[HttpGet("analyticsnxt")]
public async Task<IActionResult> GetNXTAnalytics(string username, string productName, int sessionNumber)
{
    var res = await _analyticsService.DownloadAnalyticsNXT(username, productName, sessionNumber);
    if (res == null)
        return BadRequest("No analytics found for user: " + username + " and product: " + productName);

    return Ok(res);
}

This endpoint’s URL is:

http://localhost:5002/analytics/analyticsnxt

Upload Analytics uses JSON formatted strings as arguments.

Hint

The following example demonstrates a single-player MAGES 5 session You can use this for testing on Analytics API but, in case you go with Postman, the JSON needs to be stringified first!

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
{
"Report": [
    {
    "OperationReport": [
        {
        "OperationName": "Example Project",
        "Username": "user1",
        "FinalScore": 69.44444,
        "Errors": 5,
        "Objectives": 7,
        "Events": 11,
        "Scores": 9,
        "Duration": 101.5
        }
    ]
    }
],
"Events": [
    {
    "SessionStartedEvent(1)": [
        {
        "Name": "SessionStartedEvent(1)",
        "Timestamp": 0.0
        }
    ],
    "ActionPerformedEvent(1)": [
        {
        "Name": "ActionPerformedEvent(1)",
        "Timestamp": 13.37,
        "Action": "Injection Question"
        }
    ],
    "ActionPerformedEvent(2)": [
        {
        "Name": "ActionPerformedEvent(2)",
        "Timestamp": 43.35,
        "Action": "Pour Alcohol on cotton ball"
        }
    ],
    "ActionPerformedEvent(3)": [
        {
        "Name": "ActionPerformedEvent(3)",
        "Timestamp": 59.16,
        "Action": "Disinfect skin area"
        }
    ],
    "ActionPerformedEvent(4)": [
        {
        "Name": "ActionPerformedEvent(4)",
        "Timestamp": 73.14,
        "Action": "Dispose the Cotton Ball"
        }
    ],
    "SessionEndedEvent(1)": [
        {
        "Name": "SessionEndedEvent(1)",
        "Timestamp": 101.5
        }
    ]
    }
],
"Errors": [
    {
    "Injection Question(1).Wrong Answer Error(1)": [
        {
        "Name": "Injection Question(1).Wrong Answer Error(1)",
        "Timestamp": 13.37,
        "Action": "Injection Question",
        "Type": "KnowledgeGap",
        "Penalty(%)": 100,
        "Info": "The wrong answer was chosen in the Injection Question"
        }
    ],
    "Pour Alcohol on cotton ball(1).CollisionError1(1)": [
        {
        "Name": "Pour Alcohol on cotton ball(1).CollisionError1(1)",
        "Timestamp": 22.28,
        "Action": "Pour Alcohol on cotton ball",
        "Type": "DecisionMaking",
        "Penalty(%)": 25,
        "Info": "Do not drop the cotton ball to the floor."
        }
    ],
    "Pour Alcohol on cotton ball(1).TimeLimitError(2)": [
        {
        "Name": "Pour Alcohol on cotton ball(1).TimeLimitError(2)",
        "Timestamp": 43.35,
        "Action": "Pour Alcohol on cotton ball",
        "Type": "Procedural",
        "Penalty(%)": 50,
        "Info": "Action took more than 10s."
        }
    ],
    "Disinfect skin area(1).TimeLimitError1(1)": [
        {
        "Name": "Disinfect skin area(1).TimeLimitError1(1)",
        "Timestamp": 59.16,
        "Action": "Disinfect skin area",
        "Type": "Procedural",
        "Penalty(%)": 50,
        "Info": "Action took more than 15s."
        }
    ],
    "Dispose the Cotton Ball(1).TimeLimitError1(1)": [
        {
        "Name": "Dispose the Cotton Ball(1).TimeLimitError1(1)",
        "Timestamp": 73.14,
        "Action": "Dispose the Cotton Ball",
        "Type": "Procedural",
        "Penalty(%)": 50,
        "Info": "Action took more than 5s."
        }
    ]
    }
],
"Objectives": [
    {
    "TimeLimitObjective1": [
        {
        "Name": "TimeLimitObjective1",
        "Timestamp": 101.5,
        "Succeeded": true,
        "Description": "Finish the operation in less than 2 minutes."
        }
    ],
    "TimeLimitObjective2": [
        {
        "Name": "TimeLimitObjective2",
        "Timestamp": 101.5,
        "Succeeded": false,
        "Description": "Finish the operation in less than 30 seconds."
        }
    ],
    "CollisionObjective1": [
        {
        "Name": "CollisionObjective1",
        "Timestamp": 101.5,
        "Succeeded": false,
        "Description": "Do not drop the cottom ball to the floor for the entire operation."
        }
    ],
    "PerformActionObjective1": [
        {
        "Name": "PerformActionObjective1",
        "Timestamp": 101.5,
        "Succeeded": true,
        "Description": "Disinfect the skin area of the patient."
        }
    ],
    "PerformActionObjective2": [
        {
        "Name": "PerformActionObjective2",
        "Timestamp": 101.5,
        "Succeeded": true,
        "Description": "Pour alcohol on the cotton ball."
        }
    ],
    "ScoreLimitObjective1": [
        {
        "Name": "ScoreLimitObjective1",
        "Timestamp": 101.5,
        "Succeeded": false,
        "Description": "Finish the operation with a score higher than 90%"
        }
    ],
    "ScoreLimitObjective2": [
        {
        "Name": "ScoreLimitObjective2",
        "Timestamp": 101.5,
        "Succeeded": true,
        "Description": "Finish the operation with a score higher than 50%"
        }
    ]
    }
],
"Scores": [
    {
    "Injection Question(1)": [
        {
        "Name": "Injection Question(1)",
        "Timestamp": 0.03,
        "count": 2,
        "initial": 11.1111107,
        "final": 0.0
        }
    ],
    "Cut the fake skin(1)": [
        {
        "Name": "Cut the fake skin(1)",
        "Timestamp": 0.06,
        "count": 1,
        "initial": 11.1111107,
        "final": 11.1111107
        }
    ],
    "Pour Alcohol on cotton ball(1)": [
        {
        "Name": "Pour Alcohol on cotton ball(1)",
        "Timestamp": 13.38,
        "count": 3,
        "initial": 11.1111107,
        "final": 2.77777767
        }
    ],
    "Disinfect skin area(1)": [
        {
        "Name": "Disinfect skin area(1)",
        "Timestamp": 43.36,
        "count": 2,
        "initial": 11.1111107,
        "final": 5.55555534
        }
    ],
    "Dispose the Cotton Ball(1)": [
        {
        "Name": "Dispose the Cotton Ball(1)",
        "Timestamp": 59.17,
        "count": 2,
        "initial": 11.1111107,
        "final": 5.55555534
        }
    ],
    "Insert the syringe into the arm(1)": [
        {
        "Name": "Insert the syringe into the arm(1)",
        "Timestamp": 73.15,
        "count": 1,
        "initial": 11.1111107,
        "final": 11.1111107
        }
    ],
    "Activate Syringe(1)": [
        {
        "Name": "Activate Syringe(1)",
        "Timestamp": 80.85,
        "count": 1,
        "initial": 11.1111107,
        "final": 11.1111107
        }
    ],
    "Remove the syringe from the arm(1)": [
        {
        "Name": "Remove the syringe from the arm(1)",
        "Timestamp": 85.11,
        "count": 1,
        "initial": 11.1111107,
        "final": 11.1111107
        }
    ],
    "Dispose the Syringe(1)": [
        {
        "Name": "Dispose the Syringe(1)",
        "Timestamp": 87.92,
        "count": 1,
        "initial": 11.1111107,
        "final": 11.1111107
        }
    ]
    }
],
"SessionParticipants": []
}

Hint

Example usage of Postman with Analytics API can be found here in the following section