Applicationinsights-js: [BUG] trackException() doesn't send custom properties

Created on 8 Oct 2019  路  2Comments  路  Source: microsoft/ApplicationInsights-JS

Description/Screenshot

When using exception tracking with custom properties, we can't see that trackException is collecting them and sending with along with the exception's baseData to Application Insights.

Looking at https://github.com/microsoft/ApplicationInsights-JS/blob/a7f41a2f76a5143643b9195975eb84b50740aafb/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts#L289-L303 I think that this is why it isn't working. We're missing a line similar to EnvelopeCreator.extractPropsAndMeasurements(telemetryItem.data, customProperties, customMeasurements); in the function above.

Steps to Reproduce

  • OS/Browser: Any
  • SDK Version [e.g. 22]: 2.2.4
  • How you initialized the SDK:
appInsights = new ApplicationInsights({
    config: {
      instrumentationKey: instrumentationKey,
      enableCorsCorrelation: false, 
      disableAjaxTracking: false,
      disableCorrelationHeaders: false,
      enableDebug: true
    }

Expected behavior

When calling:

trackException(new Error('myerror'), { custom1: '1', custom2: '2'})

I expect to a properties array on baseData when the SDK calls POST https://dc.services.visualstudio.com/v2/track with the exception, where the array contains the two objects sent to the trackException-function.

Most helpful comment

Hi @HenrikWM , please use the new API:

appInsights.trackException({
    exception: new Error('some error'),
    properties: {'custom': '1'}
});

Related issue: https://github.com/microsoft/ApplicationInsights-JS/issues/1079

All 2 comments

Related issue for the same problem but for Trace and Metrics: https://github.com/microsoft/ApplicationInsights-JS/pull/1065

Hi @HenrikWM , please use the new API:

appInsights.trackException({
    exception: new Error('some error'),
    properties: {'custom': '1'}
});

Related issue: https://github.com/microsoft/ApplicationInsights-JS/issues/1079

Was this page helpful?
0 / 5 - 0 ratings