-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] stopTrackEvent requires property values to be strings #2209
Comments
Hi @50Wliu Based on my local test, the following call was successful:
I have verified in my Azure portal, and the telemetry appears as expected. We will update the README accordingly to include this example. The current one may cause confusion as it contains "properties: {}". Your feedback is greatly appreciated. If there are any edge cases or further suggestions, please let us know. |
Hi @siyuniu-ms, thanks for looking into this. I'm referring to the TypeScript types which seem to be incorrect in this case. ApplicationInsights-JS/AISKU/src/AISku.ts Line 668 in 6365dad
|
You are corret. This behavior is intentional. As you may have observed in the Azure portal, telemetry data is organized into two distinct tables: one for measurements and another for properties. When our telemetry is transmitted to Azure, we ensure that the fields are segregated based on their data types — numeric values are categorized as measurements, while strings and nested objects are categorized as properties. While the current functionality has been validated through local testing, we acknowledge the importance of providing clarity on this process and ensuring consistency between different track function. As such, we plan to incorporate additional documentation and ensure consistency of converting customer properties. |
PS example in #2268 may help for better understanding |
Thanks, but I'm still confused. I understand that numbers, nested objects, etc. can be transmitted, but my point is that the typings in this repo forbid that. In #2268 one of your examples is |
I'm referring exclusively to the compile-time TypeScript types, not runtime behavior (which from your comments, I understand works correctly if you decide to ignore the TypeScript errors). The following code snippet is sufficient to reproduce the issue when using import { ApplicationInsights } from "@microsoft/applicationinsights-web";
const appInsights = new ApplicationInsights({
config: {
connectionString: "the connection string",
},
});
appInsights.loadAppInsights();
appInsights.stopTrackEvent("test", { property: { p1: 3, p2: 4 } }); // ts2332: Type '{ p1: number; p2: number; }' is not assignable to type 'string'. E:\devprod.wave.analysis.ado [main ≡ +1 ~0 -0 !] ➜ npx tsc
src/Contributions/LinkProvider/test.ts:8:38 - error TS2322: Type '{ p1: number; p2: number; }' is not assignable to type 'string'.
8 appInsights.stopTrackEvent("test", { property: { p1: 3, p2: 4 } });
~~~~~~~~
Found 1 error in src/Contributions/LinkProvider/test.ts:8 |
Description/Screenshot
The README says that
properties
accepts any type: https://github.com/microsoft/ApplicationInsights-JS/blob/HEAD/README.md#sending-telemetry-to-the-azure-portalHowever,
stopTrackEvent
is typed to only accept a{ [key: string]: string }
which is in direct contradiction with the above.Steps to Reproduce
Expected behavior
I can include anything I want in properties.
Additional context
Version 3.0.5.
The text was updated successfully, but these errors were encountered: