Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

Power Apps Portals - Application Insights Authenticated Users

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!!

  • schdaef Profile Picture
    schdaef 5 on at
    RE: Power Apps Portals - Application Insights Authenticated Users

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

  • Suggested answer
    Manoj Mane Profile Picture
    Manoj Mane 1,012 on at
    RE: Power Apps Portals - Application Insights Authenticated Users

    Hi schdaef,

    please refer the below reference code:- 



    Thanks,
    Manoj.

    Please mark this as VERIFIED if it helps.

  • schdaef Profile Picture
    schdaef 5 on at
    RE: Power Apps Portals - Application Insights Authenticated Users

    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>



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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,556 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,625 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans