feat: Add HTTP API to export captured network logs#526
feat: Add HTTP API to export captured network logs#526abdullahsohailcs wants to merge 7 commits into
Conversation
…mestamp filtering - Create NetworkLogsExportModel data classes with serialization support - Implement ExportNetworkLogsAsJsonUseCase for filtering network logs - Add GET /api/export/network-logs endpoint with query parameter filtering - Support filtering by deviceId, startTimestamp, and endTimestamp - Return JSON response with metadata about exported data
… network export endpoint - Add NetworkRepository as a dependency to ServerJvm - Update Server.desktop.kt to pass networkRepository to ServerJvm constructor - Integrate networkExportRoutes into the HTTP routing - Update HTTP server initialization to include the new export endpoint
…DomainModel parameters
- Add GET /api/network-logs to fetch all captured network calls across all devices
- Add GET /api/network-logs/{deviceId} to fetch calls for a specific device
- Add GET /api/network-logs/{deviceId}/filter?startTimestamp=&endTimestamp= for time-range filtering
- Add getAllRequests/getAllRequestsByDevice DAO queries reading deviceId directly from DB
- Propagate getAllNetworkCalls(deviceId?) through NetworkLocalDataSource, NetworkRepository, and NetworkRepositoryImpl
- Fix Koin circular dependency (NetworkRepositoryImpl -> NetworkRemoteDataSourceImpl -> Server -> NetworkRepository) by using Lazy<NetworkRepository> in ServerJvm
- Use respondText with manual JSON serialization to avoid requiring ContentNegotiation plugin
- Fix deprecated dayOfMonth/monthNumber in TimeFormatter
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a feature to export network logs, adding new Ktor API endpoints under /api/network-logs along with corresponding Room database queries, data sources, and a new use case (ExportNetworkLogsAsJsonUseCase). Key feedback points out a compilation error in TimeFormatter.kt due to invalid datetime properties, suggests returning an empty list instead of a failure when no logs match the filter, advises using a proper serializer instead of manual JSON string interpolation for error responses, and recommends performing timestamp filtering at the database level rather than in memory to prevent performance bottlenecks.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
- Add startTimestamp/endTimestamp params to FloconNetworkDao queries so time-range filtering happens at DB level instead of in memory, preventing high memory usage on large datasets - Thread startTimestamp/endTimestamp through NetworkLocalDataSource, NetworkLocalDataSourceRoom, NetworkRepository, and NetworkRepositoryImpl - Remove in-memory timestamp filter from NetworkExportEndpoint - Replace fragile string-interpolated error JSON with MapSerializer to safely handle special characters in error messages - Revert TimeFormatter to dayOfMonth/monthNumber as day/month.number do not exist in the project's kotlinx.datetime version Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
abdullahsohailcs
left a comment
There was a problem hiding this comment.
Added improvements please check now
Summary
Adds a built-in HTTP export API to the Flocon desktop server, allowing
external tools (test frameworks, CI pipelines, scripts) to query captured
network logs directly over HTTP without opening the desktop UI.
Endpoints
All endpoints are served on the existing HTTP server (port
9024).GET/api/network-logsGET/api/network-logs/{deviceId}GET/api/network-logs/{deviceId}/filterQuery Parameters (endpoint 3)
startTimestampLong(Unix ms)endTimestampLong(Unix ms)Example Response
{ "data": [ { "callId": "7b6f09e6-...", "method": "GET", "url": "https://api.example.com/endpoint", "startTime": 1779192773561, "startTimeFormatted": "17:12:53.561", "statusCode": 200, "durationMs": 398.84, "requestHeaders": { "Authorization": "Bearer ..." }, "responseHeaders": { "Content-Type": "application/json" }, "requestBody": null, "responseBody": "{ ... }", "contentType": "application/json", "deviceId": "87b5d37fd3c32ce3", "appInstance": 1780479786702 } ], "metadata": { "exportedAt": 1779200000000, "totalItems": 1, "filteredBy": { "deviceId": "87b5d37fd3c32ce3", "startTimestamp": 1779192773000, "endTimestamp": 1779199999999 } } }