Reduce misleading telemetry shims in the open build
The open build already treated analytics and tracing as inert, but several empty sink and shutdown modules still made startup and exit paths look like they initialized or flushed telemetry. This trims those dead compatibility layers, updates the surrounding comments to match reality, and adds small regression tests that lock in the inert analytics boundary and disabled transcript sharing behavior. Constraint: Preserve the no-op logEvent/logOTelEvent compatibility surface for existing call sites Constraint: Avoid touching unrelated bridge and session work already in progress in the worktree Rejected: Remove every remaining logEvent/logOTelEvent call site | Too broad for a safe first cleanup pass Rejected: Keep the empty sink/shutdown modules | Continued to mislead future audits and maintenance Confidence: high Scope-risk: narrow Reversibility: clean Directive: Treat remaining analytics and GrowthBook helpers as compatibility surfaces until each call path is individually proven dead Tested: bun test src/services/analytics/index.test.ts src/components/FeedbackSurvey/submitTranscriptShare.test.ts Tested: bun run ./scripts/build.ts Not-tested: bun x tsc --noEmit (repository has pre-existing unrelated type errors)
This commit is contained in:
@@ -3,8 +3,6 @@ import { randomUUID } from 'crypto'
|
||||
import { tmpdir } from 'os'
|
||||
import { basename, join, resolve } from 'path'
|
||||
import { getRemoteSessionUrl } from '../constants/product.js'
|
||||
import { shutdownDatadog } from '../services/analytics/datadog.js'
|
||||
import { shutdown1PEventLogging } from '../services/analytics/firstPartyEventLogger.js'
|
||||
import { checkGate_CACHED_OR_BLOCKING } from '../services/analytics/growthbook.js'
|
||||
import {
|
||||
type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
||||
@@ -30,7 +28,7 @@ import {
|
||||
import { formatDuration } from './bridgeStatusUtil.js'
|
||||
import { createBridgeLogger } from './bridgeUI.js'
|
||||
import { createCapacityWake } from './capacityWake.js'
|
||||
import { describeAxiosError } from './debugUtils.js'
|
||||
import { describeAxiosError, summarizeBridgeErrorForDebug } from './debugUtils.js'
|
||||
import { createTokenRefreshScheduler } from './jwtUtils.js'
|
||||
import { getPollIntervalConfig } from './pollConfig.js'
|
||||
import { toCompatSessionId, toInfraSessionId } from './sessionIdCompat.js'
|
||||
@@ -2041,16 +2039,15 @@ export async function bridgeMain(args: string[]): Promise<void> {
|
||||
)
|
||||
enableConfigs()
|
||||
|
||||
// Initialize analytics and error reporting sinks. The bridge bypasses the
|
||||
// setup() init flow, so we call initSinks() directly to attach sinks here.
|
||||
// Initialize shared sinks. The bridge bypasses setup(), so it attaches the
|
||||
// local error-log sink directly here.
|
||||
const { initSinks } = await import('../utils/sinks.js')
|
||||
initSinks()
|
||||
|
||||
// Gate-aware validation: --spawn / --capacity / --create-session-in-dir require
|
||||
// the multi-session gate. parseArgs has already validated flag combinations;
|
||||
// here we only check the gate since that requires an async GrowthBook call.
|
||||
// Runs after enableConfigs() (GrowthBook cache reads global config) and after
|
||||
// initSinks() so the denial event can be enqueued.
|
||||
// Runs after enableConfigs() because GrowthBook cache reads global config.
|
||||
const multiSessionEnabled = await isMultiSessionSpawnEnabled()
|
||||
if (usedMultiSessionFeature && !multiSessionEnabled) {
|
||||
await logEventAsync('tengu_bridge_multi_session_denied', {
|
||||
@@ -2058,14 +2055,6 @@ export async function bridgeMain(args: string[]): Promise<void> {
|
||||
used_capacity: parsedCapacity !== undefined,
|
||||
used_create_session_in_dir: parsedCreateSessionInDir !== undefined,
|
||||
})
|
||||
// logEventAsync only enqueues — process.exit() discards buffered events.
|
||||
// Flush explicitly, capped at 500ms to match gracefulShutdown.ts.
|
||||
// (sleep() doesn't unref its timer, but process.exit() follows immediately
|
||||
// so the ref'd timer can't delay shutdown.)
|
||||
await Promise.race([
|
||||
Promise.all([shutdown1PEventLogging(), shutdownDatadog()]),
|
||||
sleep(500, undefined, { unref: true }),
|
||||
]).catch(() => {})
|
||||
// biome-ignore lint/suspicious/noConsole: intentional error output
|
||||
console.error(
|
||||
'Error: Multi-session Remote Control is not enabled for your account yet.',
|
||||
|
||||
Reference in New Issue
Block a user