trackDependencyData() TS signature is not clear
Upgrading the v2 I am trying to update our manual dependency tracking, however it is not clear what the call signature should be.
- the readme at https://github.com/microsoft/ApplicationInsights-JS
- docs at https://github.com/microsoft/ApplicationInsights-JS/blob/329d77b15250ae8dfa25b86eae0146a65422a62b/vNext/AISKU/API.md is the same
However the typescript typings in code is
Which I assume is correct for the server side calls. At the moment I'm using any to cast the call to appInsights.trackDependencyData().
Only id is actually required for the item to be accepted, but as many fields should be set as possible so that the telemetry is actually useful. I will update the docs to account for a useful bare minimum (id + responseCode)
@markwolff thanks for updating the docs, the primary issue I faced is with the Typescript interfaces not being correct so my code wouldn't compile without the use of any.
@JRGranell actually I believe this is because the docs incorrectly reference resultCode. Use responseCode instead. I've updated the docs to account for this as well!
Also the docs at /vNext/AISKU/API.md have been moved to https://github.com/microsoft/ApplicationInsights-JS/blob/master/API.md
Hi @markwolff thanks for the updated link, sorry to continue on this, I believe it may be a TypeScript definition or importing issue. Within the applicationinsights-common package IDependencyTelemetry is defined as
{
id: string;
name?: string;
duration?: number;
success?: boolean;
responseCode: number;
correlationContext?: string;
type?: string;
data?: string;
target?: string;
properties?: {
[key: string]: any;
};
measurements?: {
[key: string]: number;
};
}
https://github.com/microsoft/ApplicationInsights-JS/blob/9879276b5a3951d3187de91d9575bfb354aa6e25/vNext/shared/AppInsightsCommon/src/Interfaces/IDependencyTelemetry.ts
and can be imported from
import {
ApplicationInsights,
IDependencyTelemetry,
} from '@microsoft/applicationinsights-web';
I initialise using
const ai = new ApplicationInsights({
config: {
...
}
});
and the issue is when I try to do
ai.trackDependencyData({
id,
method,
absoluteUrl,
duration,
success,
responseCode,
properties,
measurements
});
An example error would be'method' does not exist on type IDependencyTelemetry.
It may be the case that method, absoluteUrl, commandName (which is what the docs say are supported) could be added to IDependencyTelemetry. However if that definition is also used server side, and is not applicable to server side dependency requests, that could cause confusion.
Many thanks for continuing to look into this.
Sorry to comment in a closed issue, but i think the mismatch still occurs: https://github.com/microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackdependencydata vs. https://github.com/microsoft/ApplicationInsights-JS/blob/master/shared/AppInsightsCommon/src/Interfaces/IDependencyTelemetry.ts
E.g. the field "method" is not part of the interface. Can this issue be reopened?
https://github.com/microsoft/ApplicationInsights-JS/blob/master/extensions/applicationinsights-dependencies-js/src/ajaxRecord.ts#L329-L340