axios+telemetry cleanup
This commit is contained in:
54
main.tsx
54
main.tsx
@@ -33,7 +33,6 @@ import { init, initializeTelemetryAfterTrust } from './entrypoints/init.js';
|
||||
import { addToHistory } from './history.js';
|
||||
import type { Root } from './ink.js';
|
||||
import { launchRepl } from './replLauncher.js';
|
||||
import { hasGrowthBookEnvOverride, initializeGrowthBook, refreshGrowthBookAfterAuthChange } from './services/analytics/growthbook.js';
|
||||
import { fetchBootstrapData } from './services/api/bootstrap.js';
|
||||
import { type DownloadResult, downloadSessionFiles, type FilesApiConfig, parseFileSpecs } from './services/api/filesApi.js';
|
||||
import { prefetchPassesEligibility } from './services/api/referral.js';
|
||||
@@ -80,10 +79,7 @@ const coordinatorModeModule = feature('COORDINATOR_MODE') ? require('./coordinat
|
||||
const assistantModule = feature('KAIROS') ? require('./assistant/index.js') as typeof import('./assistant/index.js') : null;
|
||||
const kairosGate = feature('KAIROS') ? require('./assistant/gate.js') as typeof import('./assistant/gate.js') : null;
|
||||
import { relative, resolve } from 'path';
|
||||
import { isAnalyticsDisabled } from 'src/services/analytics/config.js';
|
||||
import { getFeatureValue_CACHED_MAY_BE_STALE } from 'src/services/analytics/growthbook.js';
|
||||
import { type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, logEvent } from 'src/services/analytics/index.js';
|
||||
import { initializeAnalyticsGates } from 'src/services/analytics/sink.js';
|
||||
import { getOriginalCwd, setAdditionalDirectoriesForClaudeMd, setIsRemoteMode, setMainLoopModelOverride, setMainThreadAgentType, setTeleportedSessionInfo } from './bootstrap/state.js';
|
||||
import { filterCommandsForRemoteMode, getCommands } from './commands.js';
|
||||
import type { StatsStore } from './context/stats.js';
|
||||
@@ -213,20 +209,6 @@ profileCheckpoint('main_tsx_imports_loaded');
|
||||
* This is called after init() completes to ensure settings are loaded
|
||||
* and environment variables are applied before model resolution.
|
||||
*/
|
||||
function logManagedSettings(): void {
|
||||
try {
|
||||
const policySettings = getSettingsForSource('policySettings');
|
||||
if (policySettings) {
|
||||
const allKeys = getManagedSettingsKeysForLogging(policySettings);
|
||||
logEvent('tengu_managed_settings_loaded', {
|
||||
keyCount: allKeys.length,
|
||||
keys: allKeys.join(',') as unknown as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// Silently ignore errors - this is just for analytics
|
||||
}
|
||||
}
|
||||
|
||||
// Check if running in debug/inspection mode
|
||||
function isBeingDebugged() {
|
||||
@@ -276,18 +258,6 @@ if ("external" !== 'ant' && isBeingDebugged()) {
|
||||
* main.tsx but branch before the interactive startup path, so it needs two
|
||||
* call sites here rather than one here + one in QueryEngine.
|
||||
*/
|
||||
function logSessionTelemetry(): void {
|
||||
const model = parseUserSpecifiedModel(getInitialMainLoopModel() ?? getDefaultMainLoopModel());
|
||||
void logSkillsLoaded(getCwd(), getContextWindowForModel(model, getSdkBetas()));
|
||||
void loadAllPluginsCacheOnly().then(({
|
||||
enabled,
|
||||
errors
|
||||
}) => {
|
||||
const managedNames = getManagedPluginNames();
|
||||
logPluginsEnabledForSession(enabled, managedNames, getPluginSeedDirs());
|
||||
logPluginLoadErrors(errors, managedNames);
|
||||
}).catch(err => logError(err));
|
||||
}
|
||||
function getCertEnvVarTelemetry(): Record<string, boolean> {
|
||||
const result: Record<string, boolean> = {};
|
||||
if (process.env.NODE_EXTRA_CA_CERTS) {
|
||||
@@ -304,21 +274,6 @@ function getCertEnvVarTelemetry(): Record<string, boolean> {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async function logStartupTelemetry(): Promise<void> {
|
||||
if (isAnalyticsDisabled()) return;
|
||||
const [isGit, worktreeCount, ghAuthStatus] = await Promise.all([getIsGit(), getWorktreeCount(), getGhAuthStatus()]);
|
||||
logEvent('tengu_startup_telemetry', {
|
||||
is_git: isGit,
|
||||
worktree_count: worktreeCount,
|
||||
gh_auth_status: ghAuthStatus as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
||||
sandbox_enabled: SandboxManager.isSandboxingEnabled(),
|
||||
are_unsandboxed_commands_allowed: SandboxManager.areUnsandboxedCommandsAllowed(),
|
||||
is_auto_bash_allowed_if_sandbox_enabled: SandboxManager.isAutoAllowBashIfSandboxedEnabled(),
|
||||
auto_updater_disabled: isAutoUpdaterDisabled(),
|
||||
prefers_reduced_motion: getInitialSettings().prefersReducedMotion ?? false,
|
||||
...getCertEnvVarTelemetry()
|
||||
});
|
||||
}
|
||||
|
||||
// @[MODEL LAUNCH]: Consider any migrations you may need for model strings. See migrateSonnet1mToSonnet45.ts for an example.
|
||||
// Bump this when adding a new sync migration so existing users re-run the set.
|
||||
@@ -413,8 +368,6 @@ export function startDeferredPrefetches(): void {
|
||||
}
|
||||
void countFilesRoundedRg(getCwd(), AbortSignal.timeout(3000), []);
|
||||
|
||||
// Analytics and feature flag initialization
|
||||
void initializeAnalyticsGates();
|
||||
void prefetchOfficialMcpUrls();
|
||||
void refreshModelCapabilities();
|
||||
|
||||
@@ -2010,8 +1963,7 @@ async function run(): Promise<CommanderCommand> {
|
||||
// - no env override (which short-circuits _CACHED_MAY_BE_STALE before disk)
|
||||
// - flag absent from disk (== null also catches pre-#22279 poisoned null)
|
||||
const explicitModel = options.model || process.env.ANTHROPIC_MODEL;
|
||||
if ("external" === 'ant' && explicitModel && explicitModel !== 'default' && !hasGrowthBookEnvOverride('tengu_ant_model_override') && getGlobalConfig().cachedGrowthBookFeatures?.['tengu_ant_model_override'] == null) {
|
||||
await initializeGrowthBook();
|
||||
if ("external" === 'ant' && explicitModel && explicitModel !== 'default' && getGlobalConfig().cachedGrowthBookFeatures?.['tengu_ant_model_override'] == null) {
|
||||
}
|
||||
|
||||
// Special case the default model with the null keyword
|
||||
@@ -2284,7 +2236,6 @@ async function run(): Promise<CommanderCommand> {
|
||||
// Clear user data cache BEFORE GrowthBook refresh so it picks up fresh credentials
|
||||
resetUserCache();
|
||||
// Refresh GrowthBook after login to get updated feature flags (e.g., for claude.ai MCPs)
|
||||
refreshGrowthBookAfterAuthChange();
|
||||
// Clear any stale trusted device token then enroll for Remote Control.
|
||||
// Both self-gate on tengu_sessions_elevated_auth_enforcement internally
|
||||
// — enrollTrustedDevice() via checkGate_CACHED_OR_BLOCKING (awaits
|
||||
@@ -2521,7 +2472,6 @@ async function run(): Promise<CommanderCommand> {
|
||||
// Log context metrics once at initialization
|
||||
void logContextMetrics(regularMcpConfigs, toolPermissionContext);
|
||||
void logPermissionContextForAnts(null, 'initialization');
|
||||
logManagedSettings();
|
||||
|
||||
// Register PID file for concurrent-session detection (~/.claude/sessions/)
|
||||
// and fire multi-clauding telemetry. Lives here (not init.ts) so only the
|
||||
@@ -3049,8 +2999,6 @@ async function run(): Promise<CommanderCommand> {
|
||||
numStartups: (current.numStartups ?? 0) + 1
|
||||
}));
|
||||
setImmediate(() => {
|
||||
void logStartupTelemetry();
|
||||
logSessionTelemetry();
|
||||
});
|
||||
|
||||
// Set up per-turn session environment data uploader (ant-only build).
|
||||
|
||||
Reference in New Issue
Block a user