Skip to content

Commit e500656

Browse files
authored
Merge pull request #11 from cashfree/new-skills
update skills
2 parents 8869507 + e8f8b2e commit e500656

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/telemetry.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
170176
export 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),

0 commit comments

Comments
 (0)