axios+telemetry cleanup
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import axios from 'axios'
|
||||
import { getOauthConfig } from 'src/constants/oauth.js'
|
||||
import { getOrganizationUUID } from 'src/services/oauth/client.js'
|
||||
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../../../services/analytics/growthbook.js'
|
||||
@@ -12,6 +11,7 @@ import { logForDebugging } from '../../debug.js'
|
||||
import { detectCurrentRepository } from '../../detectRepository.js'
|
||||
import { errorMessage } from '../../errors.js'
|
||||
import { findGitRoot, getIsClean } from '../../git.js'
|
||||
import { isHttpError, nativeRequest } from '../../http.js'
|
||||
import { getOAuthHeaders } from '../../teleport/api.js'
|
||||
import { fetchEnvironments } from '../../teleport/environments.js'
|
||||
|
||||
@@ -105,7 +105,7 @@ export async function checkGithubAppInstalled(
|
||||
|
||||
logForDebugging(`Checking GitHub app installation for ${owner}/${repo}`)
|
||||
|
||||
const response = await axios.get<{
|
||||
const response = await nativeRequest<{
|
||||
repo: {
|
||||
name: string
|
||||
owner: { login: string }
|
||||
@@ -116,6 +116,7 @@ export async function checkGithubAppInstalled(
|
||||
relay_enabled: boolean
|
||||
} | null
|
||||
}>(url, {
|
||||
method: 'GET',
|
||||
headers,
|
||||
timeout: 15000,
|
||||
signal,
|
||||
@@ -142,8 +143,8 @@ export async function checkGithubAppInstalled(
|
||||
return false
|
||||
} catch (error) {
|
||||
// 4XX errors typically mean app is not installed or repo not accessible
|
||||
if (axios.isAxiosError(error)) {
|
||||
const status = error.response?.status
|
||||
if (isHttpError(error)) {
|
||||
const status = error.status
|
||||
if (status && status >= 400 && status < 500) {
|
||||
logForDebugging(
|
||||
`checkGithubAppInstalled: Got ${status} error, app likely not installed on ${owner}/${repo}`,
|
||||
@@ -183,7 +184,8 @@ export async function checkGithubTokenSynced(): Promise<boolean> {
|
||||
|
||||
logForDebugging('Checking if GitHub token is synced via web-setup')
|
||||
|
||||
const response = await axios.get(url, {
|
||||
const response = await nativeRequest<any>(url, {
|
||||
method: 'GET',
|
||||
headers,
|
||||
timeout: 15000,
|
||||
})
|
||||
@@ -195,8 +197,8 @@ export async function checkGithubTokenSynced(): Promise<boolean> {
|
||||
)
|
||||
return synced
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
const status = error.response?.status
|
||||
if (isHttpError(error)) {
|
||||
const status = error.status
|
||||
if (status && status >= 400 && status < 500) {
|
||||
logForDebugging(
|
||||
`checkGithubTokenSynced: Got ${status}, token not synced`,
|
||||
|
||||
Reference in New Issue
Block a user