DEV Community

Discussion on: Using Azure Application Insights with Angular (5/7)

Collapse
 
shimjithkumar profile image
shimjithkumar

Thanks for the update. I installed the library.
where I need to configure the instrumentation key(the first code snippet)?
how to add the service you created(the second code) ?
Thanks in advance.

Thread Thread
 
jdubois profile image
Julien Dubois

As you can check in this commit I stored the key (look for instrumentationKey) in a dedicated Angular service. We could of course do better, but that key will be shared publicly at some point (as it is used to send the data), and it's probably not going to change much, so that solution should be good enough for most people.
Once the service is created, it is just a normal Angular service, so you need to inject it wherever you need it. In the example, it is done in the constructor of the Account service -> you just reference the Insight Service there, and then you can use it.

Thread Thread
 
shimjithkumar profile image
shimjithkumar

Thanks for the help, basic implementation is just done now with login, will test tomorrow morning and let you know the result, thanks

Thread Thread
 
shimjithkumar profile image
shimjithkumar

Hope every thing looks good expect below issue

passed all param for setAuthenticatedUserContext(validatedId, accountId, boolean) boolean is for saving the details in cookie,. we have two unique ides for the application so passed both in validateId and in accountId boolean made as true. not sure this is a correct approach

the page name is captured as with component name like "HomeComponent home".

Thread Thread
 
shimjithkumar profile image
shimjithkumar

the page view duration capture is not accurate, same second is captured for all pages. any help is appreciated