Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Add an option to enable emitting the JS required to track authenticated users #311

Closed
DamianEdwards opened this issue Jan 10, 2017 · 0 comments

Comments

@DamianEdwards
Copy link
Member

DamianEdwards commented Jan 10, 2017

Add a new property ApplicationInsightsServiceOptions.EnableAuthenticatedUserTracking that adds the following to the emitted JS:

appInsights.setAuthenticatedUserContext("username".replace(/[,;=| ]+/g, "_"));

Note that it has to essentially be as if the user had done the following in the Razor view (this is from the AppInsights docs):

@if (User.Identity.IsAuthenticated)
{
    <script>
        appInsights.setAuthenticatedUserContext("@User.Identity.Name.Replace("\\", "\\\\")".replace(/[,;=| ]+/g, "_"));
    </script>
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant