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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans