[main] correct types define for stopTrackEvent and stopTrackPage for #2209 (#2270)

* change types

* Update README.md
This commit is contained in:
siyuniu-ms 2024-02-12 19:03:56 -08:00 коммит произвёл GitHub
Родитель b5b9eeade5
Коммит d4b3c27934
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 12 добавлений и 17 удалений

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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");

Просмотреть файл

@ -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;
}