Canvas Apps: Add Custom Logging using Trace Function

You are currently viewing Canvas Apps: Add Custom Logging using Trace Function

In the last post, Log telemetry for your Canvas Apps using Azure Application Insights, we discuss this interesting new feature to capture the telemetry of your Canvas App in Azure Application Insights and use its feature to monitor, analyse and improve your App for better customer experience.
In this post, we will check out how we can add Custom Logging to our Canvas App, and therefore, use it to gather information specific to user’s need.

Trace Function

Trace function can be used to provide additional information that can be viewed in the Power Apps Monitor tool along with other app activities, to help in debugging or identifying issues with real-time diagnostic information for your app.
If you have allowed your app to send telemetry data to Azure Application Insights, the Trace function can also be used to send custom event or diagnostic information to your Application Insights resource. You can inspect this data in Application Insights to help diagnose problems or understand the usage of your apps and features. Trace information used in Tests will also be recorded in Application Insights.

Syntax: Trace(message, trace_severity, custom_record )
where,
Message – Required. The information to be traced. In tests, this creates a record in the Traces table in the TestCaseResult record.
Trace_severity – Optional. The severity level of the Trace recorded in Application Insights. Options are TraceSeverity.Information, TraceSeverity.Warning or TraceSeverity.Error.
custom_record – Optional. A record containing custom data that will be recorded in Application Insights.

Add Trace in Canvas App

We can use Error Function to obtain the details of any errors and then log an Error Event using Trace.
From App Insights, we can then create an alert to automatically notify us if errors get logged, or if there was a sudden increase in errors experienced in the app.

Querying Application Insights Logs

Once we start capturing different types of traces in Application Insights, we can dig deep to leverage the full power of the data we are collecting, and for that, we will likely need to write log queries to analyze the App Insights data tables.
Log queries are extremely powerful and you can use them to join multiple tables, aggregate large amounts of data and perform complex operations.

Query Logs in App Insight

We can Export the Query to Power BI and further analyse the data like Total Number of Errors in Month, slice it based on Screen, Country etc.

Funnel View in Application Insight

Once you have started capturing custom logs using Trace, you can utilize the Funnel View in Application Insight to further understand the customer experience. If your application involves multiple stages, you need to know if most customers are progressing through the entire process, or if they are ending the process at some point.
The progression through a series of steps in a web application is known as a funnel. You can use Azure Application Insights Funnels to gain insights into your users and monitor step-by-step conversion rates.

Funnel View in App Insight

This is just an introduction to add basic custom logging in canvas app and analyse the traces using Application Insights. We can further extend this feature by analysing the telemetry in Power BI.
For now, just try this feature and play around to think about various use cases of this amazing feature.
Till next time, Cheers 😉

Manish Rawat

Microsoft Certified: Dynamics 365 + Power Platform Solution Architect Expert, with little Knowledge of Scrum (PSM-I) & keen to learn about Power Platform 😎

This Post Has 3 Comments

  1. mostness

    This is terrific. Great article. Thank you!

  2. Manish Rawat

    Thanks all for your nice comments.

Comments are closed.