web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Power Apps Portals - Application Insights Authenticated Users

(0) ShareShare
ReportReport
Posted on by 5

I am trying to leverage App Insights to get authenticated users for my Power Apps portal. Was setting up things as described by Psyionic here: https://www.dancingwithcrm.com/powerappsportals-tracking-using-azure-app-insights/

That approach was working fine until Oct 12th when suddenly user_AuthenticatedId was not populated anymore. Did of course not change anything in the snippet nor any app insights settings. Would be great if anyone could help getting back on track ... Thanks!!

I have the same question (0)
  • schdaef Profile Picture
    5 on at

    adding my code snippet below:

    <script type="text/javascript">
        var appInsights=window.appInsights||function(a){
            function b(a) { c[a] = function () { var b = arguments; c.queue.push(function () { c[a].apply(c, b) }) } }var c={config:a},d=document,e=window;setTimeout(function(){var b=d.createElement("script");b.src=a.url||"">az416426.vo.msecnd.net/.../ai.0.js",d.getElementsByTagName("script")[0].parentNode.appendChild(b)});try{c.cookie = d.cookie}catch(a){ }c.queue=[];for(var f=["Event","Exception","Metric","PageView","Trace","Dependency"];f.length;)b("track"+f.pop());if(b("setAuthenticatedUserContext"),b("clearAuthenticatedUserContext"),b("startTrackEvent"),b("stopTrackEvent"),b("startTrackPage"),b("stopTrackPage"),b("flush"),!a.disableExceptionTracking){f = "onerror", b("_" + f);var g=e[f];e[f]=function(a,b,d,e,h){var i=g&&g(a,b,d,e,h);return!0!==i&&c["_"+f](a,b,d,e,h),i}}return c
         }({
            instrumentationKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
         });
        window.appInsights=appInsights,appInsights.queue&&0===appInsights.queue.length&&appInsights.trackPageView();
        {% if user %}
        appInsights.setAuthenticatedUserContext('{{ user.Id }}', '{{ user.parentcustomerid.Id }}');
        {% else %}
        appInsights.clearAuthenticatedUserContext();
        {% endif %}
    </script>



  • Suggested answer
    Manoj Mane Profile Picture
    1,020 on at

    Hi schdaef,

    please refer the below reference code:- 



    Thanks,
    Manoj.

    Please mark this as VERIFIED if it helps.

  • schdaef Profile Picture
    5 on at

    That is what I did and as I said, it was working initially but then suddenly authenticated user ID was not coming through anymore…

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 86 Super User 2026 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 58 Most Valuable Professional

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 42 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans