Skip to content
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

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

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AISKU/src/AISku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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

Expand Down
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading