* Remove internal-only tooling without changing external runtime contracts This trims the lowest-risk internal-only surfaces first: deleted internal modules are replaced by build-time no-op stubs, the bundled stuck skill is removed, and the insights S3 upload path now stays local-only. The privacy verifier is expanded and the remaining bundled internal Slack/Artifactory strings are neutralized without broad repo-wide renames. Constraint: Keep the first PR deletion-heavy and avoid mass rewrites of USER_TYPE, tengu, or claude_code identifiers Rejected: One-shot DMCA cleanup branch | too much semantic risk for a first PR Confidence: medium Scope-risk: moderate Reversibility: clean Directive: Treat full-repo typecheck as a baseline issue on this upstream snapshot; do not claim this commit introduced the existing non-Phase-A errors without isolating them first Tested: bun run build Tested: bun run smoke Tested: bun run verify:privacy Not-tested: Full repo typecheck (currently fails on widespread pre-existing upstream errors outside this change set) * Keep minimal source shims so CI can import Phase A cleanup paths The first PR removed internal-only source files entirely, but CI provider and context tests import those modules directly from source rather than through the build-time no-telemetry stubs. This restores tiny no-op source shims so tests and local source imports resolve while preserving the same external runtime behavior. Constraint: GitHub Actions runs source-level tests in addition to bundled build/privacy checks Rejected: Revert the entire deletion pass | unnecessary once the import contract is satisfied by small shims Confidence: high Scope-risk: narrow Reversibility: clean Directive: For later cleanup phases, treat build-time stubs and source-test imports as separate compatibility surfaces Tested: bun run build Tested: bun run smoke Tested: bun run verify:privacy Tested: bun run test:provider Tested: bun run test:provider-recommendation Not-tested: Full repo typecheck (still noisy on this upstream snapshot) --------- Co-authored-by: anandh8x <test@example.com>
287 lines
11 KiB
TypeScript
287 lines
11 KiB
TypeScript
/**
|
|
* No-Telemetry Build Plugin for OpenClaude
|
|
*
|
|
* Replaces all analytics, telemetry, and phone-home modules with no-op stubs
|
|
* at compile time. Zero runtime cost, zero network calls to Anthropic.
|
|
*
|
|
* This file is NOT tracked upstream — merge conflicts are impossible.
|
|
* Only build.ts needs a one-line import + one-line array entry.
|
|
*
|
|
* Kills:
|
|
* - GrowthBook remote feature flags (api.anthropic.com)
|
|
* - Datadog event intake
|
|
* - 1P event logging (api.anthropic.com/api/event_logging/batch)
|
|
* - BigQuery metrics exporter (api.anthropic.com/api/claude_code/metrics)
|
|
* - Perfetto / OpenTelemetry session tracing
|
|
* - Auto-updater (storage.googleapis.com, npm registry)
|
|
* - Plugin fetch telemetry
|
|
* - Transcript / feedback sharing
|
|
*/
|
|
|
|
import type { BunPlugin } from 'bun'
|
|
|
|
// Module path (relative to src/, without extension) → stub source
|
|
const stubs: Record<string, string> = {
|
|
|
|
// ─── Analytics core ─────────────────────────────────────────────
|
|
|
|
'services/analytics/index': `
|
|
export function stripProtoFields(metadata) { return metadata; }
|
|
export function attachAnalyticsSink() {}
|
|
export function logEvent() {}
|
|
export async function logEventAsync() {}
|
|
export function _resetForTesting() {}
|
|
`,
|
|
|
|
'services/analytics/growthbook': `
|
|
const noop = () => {};
|
|
export function onGrowthBookRefresh() { return noop; }
|
|
export function hasGrowthBookEnvOverride() { return false; }
|
|
export function getAllGrowthBookFeatures() { return {}; }
|
|
export function getGrowthBookConfigOverrides() { return {}; }
|
|
export function setGrowthBookConfigOverride() {}
|
|
export function clearGrowthBookConfigOverrides() {}
|
|
export function getApiBaseUrlHost() { return undefined; }
|
|
export const initializeGrowthBook = async () => null;
|
|
export async function getFeatureValue_DEPRECATED(feature, defaultValue) { return defaultValue; }
|
|
export function getFeatureValue_CACHED_MAY_BE_STALE(feature, defaultValue) { return defaultValue; }
|
|
export function getFeatureValue_CACHED_WITH_REFRESH(feature, defaultValue) { return defaultValue; }
|
|
export function checkStatsigFeatureGate_CACHED_MAY_BE_STALE() { return false; }
|
|
export async function checkSecurityRestrictionGate() { return false; }
|
|
export async function checkGate_CACHED_OR_BLOCKING() { return false; }
|
|
export function refreshGrowthBookAfterAuthChange() {}
|
|
export function resetGrowthBook() {}
|
|
export async function refreshGrowthBookFeatures() {}
|
|
export function setupPeriodicGrowthBookRefresh() {}
|
|
export function stopPeriodicGrowthBookRefresh() {}
|
|
export async function getDynamicConfig_BLOCKS_ON_INIT(configName, defaultValue) { return defaultValue; }
|
|
export function getDynamicConfig_CACHED_MAY_BE_STALE(configName, defaultValue) { return defaultValue; }
|
|
`,
|
|
|
|
'services/analytics/sink': `
|
|
export function initializeAnalyticsGates() {}
|
|
export function initializeAnalyticsSink() {}
|
|
`,
|
|
|
|
'services/analytics/config': `
|
|
export function isAnalyticsDisabled() { return true; }
|
|
export function isFeedbackSurveyDisabled() { return true; }
|
|
`,
|
|
|
|
'services/analytics/datadog': `
|
|
export const initializeDatadog = async () => false;
|
|
export async function shutdownDatadog() {}
|
|
export async function trackDatadogEvent() {}
|
|
`,
|
|
|
|
'services/analytics/firstPartyEventLogger': `
|
|
export function getEventSamplingConfig() { return {}; }
|
|
export function shouldSampleEvent() { return null; }
|
|
export async function shutdown1PEventLogging() {}
|
|
export function is1PEventLoggingEnabled() { return false; }
|
|
export function logEventTo1P() {}
|
|
export function logGrowthBookExperimentTo1P() {}
|
|
export function initialize1PEventLogging() {}
|
|
export async function reinitialize1PEventLoggingIfConfigChanged() {}
|
|
`,
|
|
|
|
'services/analytics/firstPartyEventLoggingExporter': `
|
|
export class FirstPartyEventLoggingExporter {
|
|
constructor() {}
|
|
async export(logs, resultCallback) { resultCallback({ code: 0 }); }
|
|
async getQueuedEventCount() { return 0; }
|
|
async shutdown() {}
|
|
async forceFlush() {}
|
|
}
|
|
`,
|
|
|
|
'services/analytics/metadata': `
|
|
export function sanitizeToolNameForAnalytics(toolName) { return toolName; }
|
|
export function isToolDetailsLoggingEnabled() { return false; }
|
|
export function isAnalyticsToolDetailsLoggingEnabled() { return false; }
|
|
export function mcpToolDetailsForAnalytics() { return {}; }
|
|
export function extractMcpToolDetails() { return undefined; }
|
|
export function extractSkillName() { return undefined; }
|
|
export function extractToolInputForTelemetry() { return undefined; }
|
|
export function getFileExtensionForAnalytics() { return undefined; }
|
|
export function getFileExtensionsFromBashCommand() { return undefined; }
|
|
export async function getEventMetadata() { return {}; }
|
|
export function to1PEventFormat() { return {}; }
|
|
`,
|
|
|
|
// ─── Telemetry subsystems ───────────────────────────────────────
|
|
|
|
'utils/telemetry/bigqueryExporter': `
|
|
export class BigQueryMetricsExporter {
|
|
constructor() {}
|
|
async export(metrics, resultCallback) { resultCallback({ code: 0 }); }
|
|
async shutdown() {}
|
|
async forceFlush() {}
|
|
selectAggregationTemporality() { return 0; }
|
|
}
|
|
`,
|
|
|
|
'utils/telemetry/perfettoTracing': `
|
|
export function initializePerfettoTracing() {}
|
|
export function isPerfettoTracingEnabled() { return false; }
|
|
export function registerAgent() {}
|
|
export function unregisterAgent() {}
|
|
export function startLLMRequestPerfettoSpan() { return ''; }
|
|
export function endLLMRequestPerfettoSpan() {}
|
|
export function startToolPerfettoSpan() { return ''; }
|
|
export function endToolPerfettoSpan() {}
|
|
export function startUserInputPerfettoSpan() { return ''; }
|
|
export function endUserInputPerfettoSpan() {}
|
|
export function emitPerfettoInstant() {}
|
|
export function emitPerfettoCounter() {}
|
|
export function startInteractionPerfettoSpan() { return ''; }
|
|
export function endInteractionPerfettoSpan() {}
|
|
export function getPerfettoEvents() { return []; }
|
|
export function resetPerfettoTracer() {}
|
|
export async function triggerPeriodicWriteForTesting() {}
|
|
export function evictStaleSpansForTesting() {}
|
|
export const MAX_EVENTS_FOR_TESTING = 0;
|
|
export function evictOldestEventsForTesting() {}
|
|
`,
|
|
|
|
'utils/telemetry/sessionTracing': `
|
|
const noopSpan = {
|
|
end() {}, setAttribute() {}, setStatus() {},
|
|
recordException() {}, addEvent() {}, isRecording() { return false; },
|
|
};
|
|
export function isBetaTracingEnabled() { return false; }
|
|
export function isEnhancedTelemetryEnabled() { return false; }
|
|
export function startInteractionSpan() { return noopSpan; }
|
|
export function endInteractionSpan() {}
|
|
export function startLLMRequestSpan() { return noopSpan; }
|
|
export function endLLMRequestSpan() {}
|
|
export function startToolSpan() { return noopSpan; }
|
|
export function startToolBlockedOnUserSpan() { return noopSpan; }
|
|
export function endToolBlockedOnUserSpan() {}
|
|
export function startToolExecutionSpan() { return noopSpan; }
|
|
export function endToolExecutionSpan() {}
|
|
export function endToolSpan() {}
|
|
export function addToolContentEvent() {}
|
|
export function getCurrentSpan() { return null; }
|
|
export async function executeInSpan(spanName, fn) { return fn(noopSpan); }
|
|
export function startHookSpan() { return noopSpan; }
|
|
export function endHookSpan() {}
|
|
`,
|
|
|
|
// ─── Auto-updater (phones home to GCS + npm) ──────────────────
|
|
|
|
'utils/autoUpdater': `
|
|
export async function assertMinVersion() {}
|
|
export async function getMaxVersion() { return undefined; }
|
|
export async function getMaxVersionMessage() { return undefined; }
|
|
export function shouldSkipVersion() { return true; }
|
|
export function getLockFilePath() { return '/tmp/openclaude-update.lock'; }
|
|
export async function checkGlobalInstallPermissions() { return { hasPermissions: false, npmPrefix: null }; }
|
|
export async function getLatestVersion() { return null; }
|
|
export async function getNpmDistTags() { return { latest: null, stable: null }; }
|
|
export async function getLatestVersionFromGcs() { return null; }
|
|
export async function getGcsDistTags() { return { latest: null, stable: null }; }
|
|
export async function getVersionHistory() { return []; }
|
|
export async function installGlobalPackage() { return 'success'; }
|
|
`,
|
|
|
|
// ─── Plugin fetch telemetry (not the marketplace itself) ───────
|
|
|
|
'utils/plugins/fetchTelemetry': `
|
|
export function logPluginFetch() {}
|
|
export function classifyFetchError() { return 'disabled'; }
|
|
`,
|
|
|
|
// ─── Transcript / feedback sharing ─────────────────────────────
|
|
|
|
'components/FeedbackSurvey/submitTranscriptShare': `
|
|
export async function submitTranscriptShare() { return { success: false }; }
|
|
`,
|
|
|
|
// ─── Internal employee logging (not needed in the external build) ─────
|
|
|
|
'services/internalLogging': `
|
|
export async function logPermissionContextForAnts() {}
|
|
export const getContainerId = async () => null;
|
|
`,
|
|
|
|
// ─── Deleted Anthropic-internal modules ───────────────────────────────
|
|
|
|
'services/api/dumpPrompts': `
|
|
export function createDumpPromptsFetch() { return undefined; }
|
|
export function getDumpPromptsPath() { return ''; }
|
|
export function getLastApiRequests() { return []; }
|
|
export function clearApiRequestCache() {}
|
|
export function clearDumpState() {}
|
|
export function clearAllDumpState() {}
|
|
export function addApiRequestToCache() {}
|
|
`,
|
|
|
|
'utils/undercover': `
|
|
export function isUndercover() { return false; }
|
|
export function getUndercoverInstructions() { return ''; }
|
|
export function shouldShowUndercoverAutoNotice() { return false; }
|
|
`,
|
|
|
|
'types/generated/events_mono/claude_code/v1/claude_code_internal_event': `
|
|
export const ClaudeCodeInternalEvent = {
|
|
fromJSON: value => value,
|
|
toJSON: value => value,
|
|
create: value => value ?? {},
|
|
fromPartial: value => value ?? {},
|
|
};
|
|
`,
|
|
|
|
'types/generated/events_mono/growthbook/v1/growthbook_experiment_event': `
|
|
export const GrowthbookExperimentEvent = {
|
|
fromJSON: value => value,
|
|
toJSON: value => value,
|
|
create: value => value ?? {},
|
|
fromPartial: value => value ?? {},
|
|
};
|
|
`,
|
|
|
|
'types/generated/events_mono/common/v1/auth': `
|
|
export const PublicApiAuth = {
|
|
fromJSON: value => value,
|
|
toJSON: value => value,
|
|
create: value => value ?? {},
|
|
fromPartial: value => value ?? {},
|
|
};
|
|
`,
|
|
|
|
'types/generated/google/protobuf/timestamp': `
|
|
export const Timestamp = {
|
|
fromJSON: value => value,
|
|
toJSON: value => value,
|
|
create: value => value ?? {},
|
|
fromPartial: value => value ?? {},
|
|
};
|
|
`,
|
|
}
|
|
|
|
function escapeForResolvedPathRegex(modulePath: string): string {
|
|
return modulePath
|
|
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
.replace(/\//g, '[/\\\\]')
|
|
}
|
|
|
|
export const noTelemetryPlugin: BunPlugin = {
|
|
name: 'no-telemetry',
|
|
setup(build) {
|
|
for (const [modulePath, contents] of Object.entries(stubs)) {
|
|
// Build regex that matches the resolved file path on any OS
|
|
// e.g. "services/analytics/growthbook" → /services[/\\]analytics[/\\]growthbook\.(ts|js)$/
|
|
const escaped = escapeForResolvedPathRegex(modulePath)
|
|
const filter = new RegExp(`${escaped}\\.(ts|js)$`)
|
|
|
|
build.onLoad({ filter }, () => ({
|
|
contents,
|
|
loader: 'js',
|
|
}))
|
|
}
|
|
|
|
console.log(` 🔇 no-telemetry: stubbed ${Object.keys(stubs).length} modules`)
|
|
},
|
|
}
|