feat: detect if nuxt is run by an agent#394
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughUpdated dependency Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/context.ts (1)
35-52:⚠️ Potential issue | 🟠 MajorWrap
determineAgent()in a try/catch to prevent telemetry failures.
determineAgent()is an external call that could throw (e.g., unexpected environment, library bug). Since agent detection is non-critical, a failure here should not break context creation and, by extension, all telemetry reporting.🛡️ Proposed fix
- const agent = await determineAgent() + let isAgent = false + let agentName: string | null = null + try { + const agent = await determineAgent() + isAgent = agent.isAgent + agentName = agent.isAgent ? agent.agent.name : null + } + catch { + // Ignore agent detection failures + } return { nuxt, seed, git, projectHash, projectSession, nuxtVersion, nuxtMajorVersion, isEdge, cli: getCLI(), nodeVersion, os: os.type().toLocaleLowerCase(), environment: getEnv(), packageManager: packageManager || 'unknown', - isAgent: agent.isAgent, - agentName: agent.isAgent ? agent.agent.name : null, + isAgent, + agentName, concent: options.consent, }
|
To respond to coderabbit, try/catch is not needed as the only thing capable to fail on the detect-agent is already within a try/catch: https://github.com/vercel/vercel/blob/main/packages/detect-agent/src/index.ts |
|
linking unjs/std-env#179 |
|
It's now using std-env @danielroe |
❓ Type of change
📚 Description
Add
isAgentandagentNameto better understand how many people use Nuxt from agents.