Azure-docs: Add Example using App Insights in the Browser

Created on 21 Oct 2019  ·  10Comments  ·  Source: MicrosoftDocs/azure-docs

How about adding a snippet about how to use app insights in the browser now that I've configured my ASP.NET Core MVC app for app insights?

Can I just use appInsights.trackEvent({ name: 'blah' }); now?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Azure-Monitosvc Pri1 application-insightsubsvc assigned-to-author doc-enhancement triaged

All 10 comments

@spottedmahn Thank you for your feedback. I'll take a look and get back to you shortly.

You are correct that the site is now setup for using the Javascript SDK and you can call methods like appInsights.trackevent(). I will assign this to the doc author to decide whether or not to add an example in addition to the linked documentation.

FYI appInsights.trackEvent({ name: 'blah' }); didn't "work". The event gets logged but the name was something like '[object object]'.

appInsights.trackEvent('blah'); does work though.

I got the first approach from here. Seems like that doc page is wrong 🚫. Thoughts?

The JS SDK Github repo has the appInsights.trackEvent({ name: 'blah' }); syntax as well, so it doesn't look like that particular doc is the problem. I'll investigate that further.

I happen to be doing some more work around this today and I re-tested.

appInsights.trackEvent({ name: 'mike d event name test' }); produces:

image

The API reference has been updated 👍

I opened another issue b/c I results are not lining up with the API reference: https://github.com/microsoft/ApplicationInsights-JS/issues/1101

Closing out as this article now covers all the latest config for the client side JS:https://docs.microsoft.com/azure/azure-monitor/app/javascript

please-close

great, thanks @mrbullwinkle 🤝

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamesgallagher-ie picture jamesgallagher-ie  ·  3Comments

jharbieh picture jharbieh  ·  3Comments

behnam89 picture behnam89  ·  3Comments

bityob picture bityob  ·  3Comments

bdcoder2 picture bdcoder2  ·  3Comments