feat: Add Structured Telemetry Logging for dApp Generation & Compile Metrics - #49
Open
ugoocreates-pixel wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this pr closes #32
📖 Description
We currently lack visibility into which AI models and generation parameters (such as the target blockchain network, prompts, or edits) lead to successful builds versus causing Vite compile or HMR errors in the sandbox.
This PR introduces structured telemetry logging in MongoDB to track these metrics. By assigning a unique
generationIdto each code generation stream, we are able to correlate initial LLM generation parameters with subsequent client-side compilation outcomes (either a clean loadsuccessor a list of specificcompile-errorobjects).🛠️ Key Changes
1. Database Layer (
lib/mongo.ts)generationIdin thetelemetrycollection to ensure fast and structured queries.2. Backend Telemetry and Tracking
app/api/generate-ai-code-stream/route.ts:generationIdat the start of a request.generationId,sandboxId,model,chain,isEdit,promptLength,promptSummary, and initial status ('generating').generationIdback to the frontend in the first status event.'generated'on stream completion, or'generation-failed'(along with the error message) if generation fails.app/api/telemetry/route.ts(New Endpoint):/api/telemetryto receive compile status updates ('success'or'compile-error') from the client and update/upsert the corresponding record in MongoDB.3. Client Integration (
app/generation/page.tsx)currentGenerationIdand status checking tracking refs.generationIdfrom streaming status updates.useEffecthook that listens to thebuildErrorsstate and immediately posts a'compile-error'status to the telemetry API with the error details.'success'.