2

I want to display the UserId on the website, so users can communicate it to us whenever they encounter a problem. However, in code, appInsights.context is undefined. How can I access this?

    window.appInsights = appInsights;
    appInsights.trackPageView();
    console.log(appInsights.context);

is logged as undefined. However, I can access it in the developer console when I run the application. It seems like the context is being removed/not added yet.

1 Answer 1

4

I believe this is because the appInsights context is not necessarily created right away?

you may need to do this work "asynchronously" by adding events to the ai queue:

appInsights.queue.push(function () {
    console.log(appInsights.context);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.