Ideally, it would be great to be able to retrieve the session ID from App signal, as suggested by Eric Thomas in his idea post here:
In the meantime, a workaround is to retrieve the session ID by calling a Flow. When we call a flow from Power Apps, we can retrieve a wide range of details from the trigger body, including the session ID. We can then pass this value back to Power Apps through a 'Respond to a Power App' action. Here are the steps to implement this technique.
What's the Trigger Body in Flow?
When we call a Flow from Power Apps, Power Apps triggers the flow through a web request. Like every web request, this includes a HTTP header and body. The trigger body effectively returns the HTTP body of the call from Power Apps.
To demonstrate, the screenshot beneath shows the result from a flow run history where I stored the trigger body content into a variable.
When we examine the content of the trigger body, we see that it includes a wide range of meta data. This includes the content that we typically expect to see in an HTTP request, including the referrer details, and the browser agent. The interesting value here is 'x-ms-client-session-id' - this is the key value that corresponds to the session ID.
Creating a Flow that retrieves the Session ID
Now that we understand exactly where the session id appears in the trigger body, we can construct a flow to retrieve the value.
First, we create an 'Instant cloud flow' with a PowerApps trigger. Next, we can retrieve the session ID into a string variable by addin an 'initialize variable' action, and setting the value to the following expression: