File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,6 +167,12 @@ export function createProgressFeedbackSubmittedEvent(
167167 } ;
168168}
169169
170+ function buildTelemetryUrl ( base : string , endpoint : string ) : string {
171+ const trimmedBase = base . replace ( / \/ + $ / , "" ) ;
172+ const normalizedEndpoint = endpoint . startsWith ( "/" ) ? endpoint : `/${ endpoint } ` ;
173+ return `${ trimmedBase } ${ normalizedEndpoint } ` ;
174+ }
175+
170176export async function sendTelemetryEvents (
171177 events : InstallTelemetryEvent [ ] ,
172178) : Promise < void > {
@@ -183,7 +189,7 @@ export async function sendTelemetryEvents(
183189 const timeout = setTimeout ( ( ) => controller . abort ( ) , 3000 ) ;
184190
185191 try {
186- await fetch ( new URL ( endpoint , TELEMETRY_BASE_URL ) . toString ( ) , {
192+ await fetch ( buildTelemetryUrl ( TELEMETRY_BASE_URL , endpoint ) , {
187193 method : "POST" ,
188194 headers : { "Content-Type" : "application/json" } ,
189195 body : JSON . stringify ( event . properties ) ,
You can’t perform that action at this time.
0 commit comments