Applicationinsights-js: trackEvent API Reference Wrong?

Created on 31 Oct 2019  路  6Comments  路  Source: microsoft/ApplicationInsights-JS

Description/Screenshot
When I call: appInsights.trackEvent({ name: 'mike d event name test' }); it produces _'[object Object]'_ for an Event name:

image


But according to Sending Telemetry to the Azure Portal in the readme I should be using: appInsights.trackEvent({name: 'some event'});

Also, the API reference for trackEvent says it takes in an ITelemetryEvent which is defined as:

export interface IEventTelemetry extends IPartC {
    /**
     * @description An event name string
     * @type {string}
     * @memberof IEventTelemetry
     */
    name: string;
}

When I search through the code I see tests that are passing strings not objects:

image

Steps to Reproduce

  • OS/Browser:
  • SDK Version: Microsoft.ApplicationInsights.AspNetCore (2.8.1) via NuGet
  • How you initialized the SDK: I didn't directly, I just add app insights to my ASP.NET Core project via Visual Studio and it wired up the magic. Looks like it added @inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet to my _'_Layout.cshtml'_ file.

Expected behavior

Additional context

All 6 comments

I just noticed _Legacy_ in the path for my search results.

I'm guessing the old way it was just a string, i.e. appInsights.trackEvent('mike d event name test');


How do I determine the SDK version for App Insights JS when using the NuGet package? 馃

When will the NuGet package have the new pattern? 馃

You are probably using the legacy version of the SDK as you've determined. We are in the process of updating all dotnet integrations after we ensure the SDK works properly on window.appInsights.version in your console, but I could be wrong... Else the sdk version will show up in the "tags" section of your telemetry

I think you can do window.appInsights.version in your console

no dice 馃槩:
image

the sdk version will show up in the "tags" section of your telemetry

_v1.0.20_ apparently

image

Actually that nuget package may be updated with the latest JS SDK soon. This PR was just merged to move it to the latest https://github.com/microsoft/ApplicationInsights-dotnet/pull/1276#event-2758134114

/cc @timothyMothra can provide a rough ETA

Hi @spottedmahn.
We're going to be releasing an update to AspNetCore probably next week (2.12-Beta2) with the stable release coming in December.

Was this page helpful?
0 / 5 - 0 ratings