Early February we released an exciting new feature that enables you to add telemetry logging to your application using Application Insights.
That blog post can be found here:
This blog post is a walk through for getting that running specifically for creating a send a smile experience from your Power Apps.
You can also find a video of this walk through here: https://youtu.be/Kv8TOOeyj48
The walk through steps:
- Log into your Azure Subscription.While this walk through requires an Azure subscription, that subscription does not have to be in the same directory in your Power Apps tenant

- Create an Application Insights resource

- Name your resource instance. If you don’t already have a resource group you can create one.

- Create the resource Instance

- Copy the instrumentation Key

3. Create a new Power Apps application

4. Set the Instrumentation key


- Create a new component

- Resize the component screen

- Add a smile and frown Icon to the component.

- Select the frown icons and add the following code:Trace(“SendASmile”, TraceSeverity.Information,{ChucksappName : “Blog App”, Satvalue: “-1“, AppUser: User().FullName })

- Select the smiley face and insert the following code in on the OnSelect event
Trace(“SendASmile”, TraceSeverity.Information,{ChucksappName : “Blog App”, Satvalue: “1“, AppUser: User().FullName })

- Rename the component. You can do this by double clicking or right clicking on the component name > Rename

- Navigate back to Screens

- Navigate to Custom and insert our component SendASmile

- Go to file Save and Save your application.

- To find the play URL. Navigate to File > Settings and select Edit App Name

- Navigate to the Web Link. This is required as the telemetry is only collected in “play” mode rather than design mode.

- Run the application and click on your icons a couple of times

- Navigate back tot the Azure Portal and Application Insights.
In Application Insights choose the application you create

- In about 5 minutes you should be able to see your telemetry start coming through.

Exporting your Application Insights resource data to Power BI
Now that you have your Power Apps application connected to Application Insights you can configure Power BI to automatically import log data from Azure Monitor to take advantage of these additional visualizations.
- In your query window remove the limit line so the entire query is simply “traces”. Select Export > Export to Power BI. This will export the M Query that you can use in Power BI desktop.

- Open Power BI Desktop. Select Get Data > Blank Query > Connect

- In the Power Query Editor, select the Advanced Editor option. In the advanced editor erase the default query and paste in the query downloaded from the Export step above.

- Here is an image of this in a completed state. Select “Done”

- Transform the customDimensions column to JSON

- Select the customDeminsions column and select the columns you are interested. Note: you will almost certainly need to click “Load More” to see all the values.

- Select the customDeminsions column and select the columns you are intereste in.

- Remove Errors. As we expanded a column that doesn’t have all the values there will be errors in the dataset. If you do not do this you will get the error:
Failed to save modifications to the server. Error returned: ‘OLE DB or ODBC error: [Expression.Error] The parameter is expected to be of type Text.Type or Binary.Type.. ‘

- Change the data type of our SatValuue to whole number. Note: In later releases you will be able to pass in numbers from Power Apps and this step won’t be needed.

- Select Close and Apply. Note if you get errors from other columns you can either ignore them remove them by repeating the remove error step as shown above for the other columns.

- You can now work with this dataset as any other Power BI Dataset….In this case a card is displaying the average Satvalue. Note since this dynamically retrieving data from Application Insights you would likely want to use a DataFlow to persist the data over time.

Reference:
Sterlings, C. (2020). Creating a send-smile-component for Power Apps using Power BI and Application Insights. Available at: [Accessed: 24th March 2020-.
Find more great Power Platform content here.