MCPcopy Index your code
hub / github.com/codeaashu/claude-code / logFileOperation

Function logFileOperation

src/utils/fileOperationAnalytics.ts:37–71  ·  view source on GitHub ↗
(params: {
  operation: 'read' | 'write' | 'edit'
  tool: 'FileReadTool' | 'FileWriteTool' | 'FileEditTool'
  filePath: string
  content?: string
  type?: 'create' | 'update'
})

Source from the content-addressed store, hash-verified

35 * Logs file operation analytics to Statsig
36 */
37export function logFileOperation(params: {
38 operation: 'read' | 'write' | 'edit'
39 tool: 'FileReadTool' | 'FileWriteTool' | 'FileEditTool'
40 filePath: string
41 content?: string
42 type?: 'create' | 'update'
43}): void {
44 const metadata: Record<
45 string,
46 | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
47 | number
48 | boolean
49 > = {
50 operation:
51 params.operation as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
52 tool: params.tool as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
53 filePathHash: hashFilePath(params.filePath),
54 }
55
56 // Only hash content if it's provided and below size limit
57 // This prevents memory exhaustion from hashing large files (e.g., base64-encoded images)
58 if (
59 params.content !== undefined &&
60 params.content.length <= MAX_CONTENT_HASH_SIZE
61 ) {
62 metadata.contentHash = hashFileContent(params.content)
63 }
64
65 if (params.type !== undefined) {
66 metadata.type =
67 params.type as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
68 }
69
70 logEvent('tengu_file_operation', metadata)
71}
72

Callers 3

callInnerFunction · 0.85
callFunction · 0.85
callFunction · 0.85

Calls 3

hashFilePathFunction · 0.85
hashFileContentFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected