From e01f62c5ca9f33c19b22e1307a125ae6e6e51832 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Mon, 12 Feb 2024 15:41:28 -0800 Subject: [PATCH 1/2] change types --- AISKU/src/AISku.ts | 4 ++-- shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AISKU/src/AISku.ts b/AISKU/src/AISku.ts index 91afe35d8..e2305689b 100644 --- a/AISKU/src/AISku.ts +++ b/AISKU/src/AISku.ts @@ -651,7 +651,7 @@ export class AppInsightsSku implements IApplicationInsights { * @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty. * @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty. */ - public stopTrackPage(name?: string, url?: string, customProperties?: { [key: string]: any; }, measurements?: { [key: string]: number; }) { + public stopTrackPage(name?: string, url?: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number }) { // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging } @@ -665,7 +665,7 @@ export class AppInsightsSku implements IApplicationInsights { * @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty. * @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty. */ - public stopTrackEvent(name: string, properties?: { [key: string]: string; }, measurements?: { [key: string]: number; }) { + public stopTrackEvent(name: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number }) { // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging } diff --git a/shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts b/shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts index 0b80633fa..711dafe09 100644 --- a/shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts +++ b/shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts @@ -23,9 +23,9 @@ export interface IAppInsights { trackTrace(trace: ITraceTelemetry, customProperties?: {[key: string]: any}): void; trackMetric(metric: IMetricTelemetry, customProperties?: {[key: string]: any}): void; startTrackPage(name?: string): void; - stopTrackPage(name?: string, url?: string, customProperties?: Object): void; + stopTrackPage(name?: string, url?: string, properties?: {[key: string]: string}, measurements?: {[key: string]: number}): void; startTrackEvent(name: string): void; - stopTrackEvent(name: string, properties?: Object, measurements?: Object): void; + stopTrackEvent(name: string, properties?: {[key: string]: string}, measurements?: {[key: string]: number}): void; addTelemetryInitializer(telemetryInitializer: (item: ITelemetryItem) => boolean | void): void; trackPageViewPerformance(pageViewPerformance: IPageViewPerformanceTelemetry, customProperties?: { [key: string]: any }): void; } From 4470cba5d18913a7777566084d7d1fa197f575a5 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Mon, 12 Feb 2024 15:48:16 -0800 Subject: [PATCH 2/2] Update README.md --- README.md | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d9cd3ad9c..0c1b6a756 100644 --- a/README.md +++ b/README.md @@ -215,13 +215,13 @@ appInsights.trackTrace({message: 'some trace'}); appInsights.trackMetric({name: 'some metric', average: 42}); appInsights.trackDependencyData({absoluteUrl: 'some url', responseCode: 200, method: 'GET', id: 'some id'}); appInsights.startTrackPage("pageName"); -appInsights.stopTrackPage("pageName", null, {customProp1: "some value"}); +appInsights.stopTrackPage("pageName", null, {customePropertiesName: "some value"}, {customerMeasurementsName: 144}); appInsights.startTrackEvent("event"); -appInsights.stopTrackEvent("event", null, {customProp1: "some value"}); +appInsights.stopTrackEvent("event", null, {customePropertiesName: "some value"}, {customerMeasurementsName: 150}); appInsights.flush(); ``` -Custom properties can be included in your telemetry through the `properties` named argument. This can be done with *any* of the Track APIs. +Custom properties can be included in your telemetry through the `properties` named argument. This can be done with *any* of the Track APIs except stopTrackPage and stopTrackEvent. ```js appInsights.trackEvent({ @@ -234,16 +234,11 @@ appInsights.trackEvent({ }); ``` -```js -appInsights.startTrackEvent("event name"); -appInsights.stopTrackEvent("event name", { - prop1: 3.14, - prop2: 'string', - prop3: {nested:"objects are okay too"} - } -) -``` -If you wish to organize customer properties into separate sections based on properties and measurements for better visualization on the Azure Portal, consider using the following code: +When using stopTrackPage and stopTrackEvent, you can pass in data categorized by types: + +Strings: These should be included under the properties field. +Numbers: Add these under the measurements field. +Remember, the order of the properties and measurements should not be altered. You can achieve this using the following code structure: ```js appInsights.startTrackEvent("event name");