axios+telemetry cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import axios from 'axios';
|
||||
import { isHttpError, nativeRequest } from './http.js';
|
||||
import chalk from 'chalk';
|
||||
import { randomUUID } from 'crypto';
|
||||
import React from 'react';
|
||||
@@ -604,7 +604,7 @@ export async function teleportFromSessionsAPI(sessionId: string, orgUUID: string
|
||||
const err = toError(error);
|
||||
|
||||
// Handle 404 specifically
|
||||
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
||||
if (isHttpError(error) && error.status === 404) {
|
||||
logEvent('tengu_teleport_error_session_not_found_404', {
|
||||
sessionId: sessionId as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
|
||||
});
|
||||
@@ -659,11 +659,9 @@ export async function pollRemoteSessionEvents(sessionId: string, afterId: string
|
||||
const sdkMessages: SDKMessage[] = [];
|
||||
let cursor = afterId;
|
||||
for (let page = 0; page < MAX_EVENT_PAGES; page++) {
|
||||
const eventsResponse = await axios.get(eventsUrl, {
|
||||
const eventsUrlWithCursor = cursor ? `${eventsUrl}?after_id=${encodeURIComponent(cursor)}` : eventsUrl;
|
||||
const eventsResponse = await nativeRequest<EventsResponse>(eventsUrlWithCursor, {
|
||||
headers,
|
||||
params: cursor ? {
|
||||
after_id: cursor
|
||||
} : undefined,
|
||||
timeout: 30000
|
||||
});
|
||||
if (eventsResponse.status !== 200) {
|
||||
@@ -878,7 +876,9 @@ export async function teleportToRemote(options: {
|
||||
environment_id: options.environmentId
|
||||
};
|
||||
logForDebugging(`[teleportToRemote] explicit env ${options.environmentId}, ${Object.keys(envVars).length} env vars, ${seedBundleFileId ? `bundle=${seedBundleFileId}` : `source=${gitSource?.url ?? 'none'}@${options.branchName ?? 'default'}`}`);
|
||||
const response = await axios.post(url, requestBody, {
|
||||
const response = await nativeRequest<SessionResource>(url, {
|
||||
method: 'POST',
|
||||
body: requestBody,
|
||||
headers,
|
||||
signal
|
||||
});
|
||||
@@ -1161,7 +1161,9 @@ export async function teleportToRemote(options: {
|
||||
logForDebugging(`Creating session with payload: ${jsonStringify(requestBody, null, 2)}`);
|
||||
|
||||
// Make API call
|
||||
const response = await axios.post(url, requestBody, {
|
||||
const response = await nativeRequest<SessionResource>(url, {
|
||||
method: 'POST',
|
||||
body: requestBody,
|
||||
headers,
|
||||
signal
|
||||
});
|
||||
@@ -1209,10 +1211,11 @@ export async function archiveRemoteSession(sessionId: string): Promise<void> {
|
||||
};
|
||||
const url = `${getOauthConfig().BASE_API_URL}/v1/sessions/${sessionId}/archive`;
|
||||
try {
|
||||
const resp = await axios.post(url, {}, {
|
||||
const resp = await nativeRequest(url, {
|
||||
method: 'POST',
|
||||
body: {},
|
||||
headers,
|
||||
timeout: 10000,
|
||||
validateStatus: s => s < 500
|
||||
timeout: 10000
|
||||
});
|
||||
if (resp.status === 200 || resp.status === 409) {
|
||||
logForDebugging(`[archiveRemoteSession] archived ${sessionId}`);
|
||||
|
||||
Reference in New Issue
Block a user