Skip to content

Commit e9e0704

Browse files
authored
Merge pull request #236 from microsoft/vijayu/updateDist
Update dist file
2 parents 7560f5c + 87b7ec6 commit e9e0704

4 files changed

Lines changed: 56 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ reporter.sendTelemetryErrorEvent(
6969
);
7070
```
7171

72-
# Advanced Features (v1.3.0+)
72+
# Advanced Features (v1.4.0+)
7373

7474
## Custom Endpoints and Configuration
7575

dist/telemetryReporter.d.ts

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,31 @@ export interface ReplacementOption {
2626
replacementString?: string;
2727
}
2828

29+
/**
30+
* Options for configuring Application Insights client with custom behavior.
31+
* Allows customization of endpoint URLs, common properties, and tag overrides.
32+
*/
33+
export interface AppInsightsClientOptions {
34+
/**
35+
* Custom endpoint URL for Application Insights telemetry data.
36+
* Use this to send telemetry to a different ingestion endpoint.
37+
*/
38+
endpointUrl?: string;
39+
40+
/**
41+
* Common properties to be added to all telemetry events.
42+
* These properties will be merged into every event sent by the client.
43+
*/
44+
commonProperties?: Record<string, string>;
45+
46+
/**
47+
* Tag overrides to customize Application Insights context tags.
48+
* Maps to the 'ext' object in Application Insights Web Basic SDK.
49+
* Common use case: overriding tracking IDs or session identifiers.
50+
*/
51+
tagOverrides?: Record<string, string>;
52+
}
53+
2954
/**
3055
* A custom fetcher function that can be used to send telemetry data.
3156
* Compatible with the Node.js fetch API signature.
@@ -44,8 +69,9 @@ export class TelemetryReporter {
4469
* @param replacementOptions A list of replacement options for the app insights client. This allows the sender to filter out any sensitive or unnecessary information from the telemetry server.
4570
* @param initializationOptions Options for configuring the telemetry reporter, including additional common properties to be sent with each event.
4671
* @param customFetcher An optional custom fetcher function to use for sending telemetry data. If not provided, the default HTTPS module will be used. Compatible with Node.js fetch API.
72+
* @param appInsightsOptions Optional Application Insights client configuration for custom endpoint URLs, common properties, and tag overrides.
4773
*/
48-
constructor(connectionString: string, replacementOptions?: ReplacementOption[], initializationOptions?: import("vscode").TelemetryLoggerOptions, customFetcher?: CustomFetcher);
74+
constructor(connectionString: string, replacementOptions?: ReplacementOption[], initializationOptions?: import("vscode").TelemetryLoggerOptions, customFetcher?: CustomFetcher, appInsightsOptions?: AppInsightsClientOptions);
4975

5076
/**
5177
* A string representation of the current level of telemetry being collected
@@ -57,23 +83,40 @@ export class TelemetryReporter {
5783
*/
5884
onDidChangeTelemetryLevel: import("vscode").Event<'all' | 'error' | 'crash' | 'off'>;
5985

86+
/**
87+
* Sets a context tag that will be included in all telemetry events.
88+
* Similar to client.context.tags[key] = value in the full Application Insights SDK.
89+
* @param key The tag key (e.g., 'ai.cloud.roleInstance', 'ai.session.id')
90+
* @param value The tag value
91+
*/
92+
setContextTag(key: string, value: string): void;
93+
94+
/**
95+
* Gets a context tag value.
96+
* @param key The tag key to retrieve
97+
* @returns The tag value, or undefined if not set
98+
*/
99+
getContextTag(key: string): string | undefined;
100+
60101
/**
61102
* Sends a telemetry event with the given properties and measurements
62103
* Properties are sanitized on best-effort basis to remove sensitive data prior to sending.
63104
* @param eventName The name of the event
64105
* @param properties The set of properties to add to the event in the form of a string key value pair
65106
* @param measurements The set of measurements to add to the event in the form of a string key number value pair
107+
* @param tagOverrides Optional per-event tag overrides (e.g., dynamic tracking IDs). Takes precedence over context tags.
66108
*/
67-
sendTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
109+
sendTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, tagOverrides?: Record<string, string>): void;
68110

69111
/**
70112
* Sends a raw (unsanitized) telemetry event with the given properties and measurements
71113
* NOTE: This will not be logged to the output channel due to API limitations.
72114
* @param eventName The name of the event
73115
* @param properties The set of properties to add to the event in the form of a string key value pair
74116
* @param measurements The set of measurements to add to the event in the form of a string key number value pair
117+
* @param tagOverrides Optional per-event tag overrides (e.g., dynamic tracking IDs). Takes precedence over context tags.
75118
*/
76-
sendRawTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
119+
sendRawTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, tagOverrides?: Record<string, string>): void;
77120

78121
/**
79122
* **DANGEROUS** Given an event name, some properties, and measurements sends a telemetry event without checking telemetry setting
@@ -82,17 +125,19 @@ export class TelemetryReporter {
82125
* @param eventName The name of the event
83126
* @param properties The properties to send with the event
84127
* @param measurements The measurements (numeric values) to send with the event
128+
* @param tagOverrides Optional per-event tag overrides (e.g., dynamic tracking IDs). Takes precedence over context tags.
85129
*/
86-
sendDangerousTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
130+
sendDangerousTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, tagOverrides?: Record<string, string>): void;
87131

88132
/**
89133
* Sends a telemetry error event with the given properties, measurements.
90134
* **Note**: The errorProps parameter has been removed since v0.6, if you would like to remove a property please use the replacementOptions parameter in the constructor.
91135
* @param eventName The name of the event
92136
* @param properties The set of properties to add to the event in the form of a string key value pair
93137
* @param measurements The set of measurements to add to the event in the form of a string key number value pair
138+
* @param tagOverrides Optional per-event tag overrides (e.g., dynamic tracking IDs). Takes precedence over context tags.
94139
*/
95-
sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
140+
sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, tagOverrides?: Record<string, string>): void;
96141

97142
/**
98143
* **DANGEROUS** Given an event name, some properties, and measurements sends a telemetry error event without checking telemetry setting
@@ -101,8 +146,9 @@ export class TelemetryReporter {
101146
* @param eventName The name of the event
102147
* @param properties The properties to send with the event
103148
* @param measurements The measurements (numeric values) to send with the event
149+
* @param tagOverrides Optional per-event tag overrides (e.g., dynamic tracking IDs). Takes precedence over context tags.
104150
*/
105-
sendDangerousTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
151+
sendDangerousTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, tagOverrides?: Record<string, string>): void;
106152

107153
/**
108154
* Disposes of the telemetry reporter. This flushes the remaining events and disposes of the telemetry client.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@vscode/extension-telemetry",
33
"description": "A module for Visual Studio Code extensions to report consistent telemetry.",
4-
"version": "1.3.0",
4+
"version": "1.4.0",
55
"author": {
66
"name": "Microsoft Corporation"
77
},

0 commit comments

Comments
 (0)