Sometimes users can’t seem to send proper error message and instead of calling/mailing them back and forth you can always use telemetry to get the error message with the corresponding call stack and other useful info. And if you set up the data proper you can also filter on error messages by user. In fact, it doesn’t need to be error message you can filter on all available telemetry signals that contains the UserId as dimension. This entry will cover that.
Before you open up Application Insights for the specific customer you need to get the Telemetry ID for that user.
Open the user list, pick the specific user and copy the Telemetry ID for that user.
If you don’t have any Telemetry ID for the user, then follow the guide Assign Telemetry ID to users.
If you have problem with copying it, just double click the GUID (1), a mini bar appears, click the three dots (2) and choose copy (3).
Now, we got the Telemetry ID for the specific user. Time to open application insights and get a query for error messages.
I’m using following query from the BCTech repo
// Error dialog shown (raw data)
// available from 20.0
traces
| where timestamp > ago(60d) // adjust as needed
| where customDimensions.eventId == 'RT0030'
| project timestamp
// in which environment/company did it happen
, aadTenantId = customDimensions.aadTenantId
, environmentName = customDimensions.environmentName
, environmentType = customDimensions.environmentType
, companyName = customDimensions.companyName
// in which extension/app
, extensionId = customDimensions.extensionId
, extensionName = customDimensions.extensionName
, extensionVersion = customDimensions.extensionVersion
, extensionPublisher = customDimensions.extensionPublisher
// in which object
, alObjectId = customDimensions.alObjectId
, alObjectName = customDimensions.alObjectName
, alObjectType = customDimensions.alObjectType
// which user got the error
, usertelemetryId = case(
toint( substring(customDimensions.componentVersion,0,2)) >= 20, user_Id // user telemetry id was introduced in the platform in version 20.0
, 'N/A'
)
// error information
, clientType = customDimensions.clientType
, errorMessageInUsersLanguage = customDimensions.alErrorMessage
, errorMessageInEnglish = customDimensions.alEnglishLanguageDiagnosticsMessage // This dimension was introduced in Business Central 2023 release wave 1, version 21.4.
, alStackTrace = customDimensions.alStackTrace
, failureReason = customDimensions.failureReason
But I will change so it only looks 1 day back. 60 days is a little bit overkill when the user contacted us some hours ago.
| where timestamp > ago(60d) ———> | where timestamp > ago(1d)
Before the line project timestamp I will create a new line with | where user_Id == “<TelemetryID_For_User>”
Paste the Telemetry ID ({01ef6b60-7753-4f53-9df9-bd4eada9099a}) which we got earlier but remove the { } so it looks like something this:
| where user_Id == “01ef6b60-7753-4f53-9df9-bd4eada9099a“
Now the beginning of the script should look like this:
// Error dialog shown (raw data)
// available from 20.0
traces
| where timestamp > ago(1d) // adjust as needed
| where customDimensions.eventId == 'RT0030'
| where user_Id == "01ef6b60-7753-4f53-9df9-bd4eada9099a"
| project timestamp
// in which environment/company did it happen
...
And when we run it looks something like this which is nice since we also get the AL callstack (not shown in picture):
If you would like filter on what the user has been up to lately you can use the following query to see the 1000 latest signals emitted from that user. However, this doesn’t show which pages or queries the user has run. More about that later.
traces
| where user_Id == "01ef6b60-7753-4f53-9df9-bd4eada9099a"
| take 1000
Or if you would like to search on certain date range:
traces
| where user_Id == "01ef6b60-7753-4f53-9df9-bd4eada9099a"
| where (timestamp >= datetime(2024-01-01 23:00)) and (timestamp < datetime(2024-01-03 06:00))
When it comes to user activity and which pages and queries the user has been running there are separate queries to use. I’m using the examples from BCTech repo. Here is a shorter and modified version:
pageViews
| where timestamp > ago(7d) // adjust as needed
| parse kind=regex client_Browser with browserName:string ' ' browserVersion:string
| project timestamp
// in which object
, alObjectId = customDimensions.alObjectId
, alObjectName = customDimensions.alObjectName
, alObjectType = customDimensions.alObjectType
, usertelemetryId = case(
// user telemetry id was introduced in the platform in version 23.0 for pageVies
toint( substring(customDimensions.componentVersion,0,2)) >= 23, user_Id
, 'N/A'
)
And here is a picture of how it looks. Unfortunately my demo environment is on a BC 22 machine Telemetry Id was introduced for PageViews first in BC 23.
Summary
In this entry I have showed you on how set up/get Telemetry ID for a specific user and how to use it to search for the users activity which could be latest error messages or viewed objects.
This can be very efficient if the user has problem with sending information about the error or accidentally closed the message before screen dump was taken.