Skip to content

Conversation

arvinxx
Copy link
Member

@arvinxx arvinxx commented Aug 17, 2025

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

📝 补充信息 | Additional Information

Summary by Sourcery

Enhance MCP tracing by enforcing user opt-in, simplifying telemetry gating, and cleaning up trace payloads

Enhancements:

  • Respect userAllowTrace preference to disable plugin call reporting when tracing is off
  • Simplify TelemetryNotification to trigger on preference initialization without server config check
  • Always display analytics component in the settings About page
  • Remove clientIp, inputParams, and outputResult from lambda market and MCP trace payloads

Copy link

vercel bot commented Aug 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lobe-chat-database Ready Ready Preview Comment Aug 17, 2025 4:54am
lobe-chat-preview Ready Ready Preview Comment Aug 17, 2025 4:54am

Copy link
Contributor

sourcery-ai bot commented Aug 17, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This pull request enforces user opt-in for MCP tracing by short-circuiting reportPluginCall based on user preference, removes server-config gating from telemetry notifications and settings to streamline the UI, and cleans up deprecated fields in the market and MCP tracing schemas.

Sequence diagram for plugin call reporting with user opt-in tracing

sequenceDiagram
    participant User
    participant DiscoverService
    participant UserStore
    participant LambdaClient
    User->>DiscoverService: Initiate plugin call
    DiscoverService->>UserStore: Check userAllowTrace
    alt User has not opted in
        DiscoverService-->>User: Skip reporting
    else User has opted in
        DiscoverService->>LambdaClient: Report plugin call
        LambdaClient-->>DiscoverService: Response
    end
Loading

Entity relationship diagram for updated market and MCP tracing schemas

erDiagram
    MARKET_REPORT {
      callDurationMs int
      clientId string
      customPluginInfo any
      errorCode string
      errorMessage string
      identifier string
      isCustomPlugin boolean
      metadata object
      methodName string
      methodType enum
      platform string
      requestSizeBytes int
      responseSizeBytes int
    }
    MCP_TRACE {
      errorCode string
      errorMessage string
      identifier string
      isCustomPlugin boolean
      metadata object
      methodName string
      methodType enum
      requestSizeBytes int
      responseSizeBytes int
      sessionId string
    }
Loading

Class diagram for DiscoverService and MCPService tracing changes

classDiagram
    class DiscoverService {
      +reportPluginCall(reportData: CallReportRequest)
      - Skips reporting if !userAllowTrace
    }
    class MCPService {
      +trace(...)
      - inputParams removed
      - outputResult removed
    }
Loading

File-Level Changes

Change Details Files
Enforce user opt-in for plugin call reporting
  • Retrieve user’s trace permission via useUserStore
  • Return early in reportPluginCall if tracing is not allowed
  • Wrap existing reportCall mutation with the new permission check
src/services/discover.ts
Simplify TelemetryNotification by removing server-config gating
  • Remove serverConfigSelectors.enabledTelemetryChat import and usage
  • Adjust useCheckTrace call to depend only on isPreferenceInit
  • Clean up related conditional logic and imports
src/app/[variants]/(main)/chat/(workspace)/features/TelemetryNotification.tsx
Always display Analytics in About settings
  • Remove serverConfigSelectors.enabledTelemetryChat import
  • Eliminate conditional rendering around
  • Ensure Analytics section is unconditionally rendered
src/app/[variants]/(main)/settings/about/index.tsx
Clean up trace payload schemas by removing deprecated fields
  • Remove clientIp, inputParams, outputResult from marketRouter schema
  • Omit inputParams and outputResult from MCPService payload construction
src/server/routers/lambda/market/index.ts
src/services/mcp.ts

Possibly linked issues

  • #0: The PR implements user opt-in for MCP tracing and refines telemetry, addressing the issue's data collection concerns.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@lobehubbot
Copy link
Member

👍 @arvinxx

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link
Contributor

claude bot commented Aug 17, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link
Contributor

gru-agent bot commented Aug 17, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail 0553aa2 ✅ Finished

History Assignment

Files

File Pull Request
src/services/discover.ts ❌ Failed (I failed to setup the environment.)
src/services/mcp.ts ❌ Failed (I failed to setup the environment.)
src/server/routers/lambda/market/index.ts ❌ Failed (I failed to setup the environment.)

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐛 Bug Something isn't working | 缺陷 labels Aug 17, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Move the permission check out of the service class instead of calling useUserStore inside DiscoverService—consider passing an allowTrace flag into reportPluginCall so you’re not using a React hook in a non-component context.
  • Since the Analytics section is now always visible, double-check that this change aligns with the intended UX and doesn’t reintroduce unwanted telemetry prompts for users who should be gated by server or product settings.
  • After removing deprecated fields from the tracing schemas, ensure any downstream consumers or analytics pipelines gracefully handle the absence of clientIp, inputParams, and outputResult.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Move the permission check out of the service class instead of calling `useUserStore` inside `DiscoverService`—consider passing an `allowTrace` flag into `reportPluginCall` so you’re not using a React hook in a non-component context.
- Since the Analytics section is now always visible, double-check that this change aligns with the intended UX and doesn’t reintroduce unwanted telemetry prompts for users who should be gated by server or product settings.
- After removing deprecated fields from the tracing schemas, ensure any downstream consumers or analytics pipelines gracefully handle the absence of `clientIp`, `inputParams`, and `outputResult`.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@arvinxx arvinxx changed the title 🐛 fix: improve mcp tracing 🐛 fix: improve mcp tracing with user config Aug 17, 2025
@arvinxx arvinxx merged commit 5cab2ee into main Aug 17, 2025
32 of 33 checks passed
@arvinxx arvinxx deleted the refactor/improve-mcp-tracing branch August 17, 2025 05:22
@lobehubbot
Copy link
Member

❤️ Great PR @arvinxx ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx@canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。

github-actions bot pushed a commit that referenced this pull request Aug 17, 2025
### [Version 1.112.5](v1.112.4...v1.112.5)
<sup>Released on **2025-08-17**</sup>

#### 🐛 Bug Fixes

- **misc**: Improve mcp tracing with user config.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's fixed

* **misc**: Improve mcp tracing with user config, closes [#8827](#8827) ([5cab2ee](5cab2ee))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

🎉 This PR is included in version 1.112.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to jaworldwideorg/OneJA-Bot that referenced this pull request Aug 18, 2025
## [Version&nbsp;1.113.0](v1.112.0...v1.113.0)
<sup>Released on **2025-08-18**</sup>

#### ♻ Code Refactoring

- **misc**: Refactor const folder to a new package, refactor prompts folder to the `@lobechat/prompts` pacakge, 重构ArgsInput组件.

#### ✨ Features

- **provider**: Add BFL provider support for image generation.

#### 🐛 Bug Fixes

- **db**: Desktop local db can't vectorization.
- **misc**: Improve mcp tracing with user config.

#### 💄 Styles

- **misc**: Add Imagen 4 GA models, style improve auth sign in box loading.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Refactor const folder to a new package, closes [lobehub#8756](https://github.com/jaworldwideorg/OneJA-Bot/issues/8756) ([30a4734](30a4734))
* **misc**: Refactor prompts folder to the `@lobechat/prompts` pacakge, closes [lobehub#8810](https://github.com/jaworldwideorg/OneJA-Bot/issues/8810) ([d82e7bb](d82e7bb))
* **misc**: 重构 ArgsInput 组件, closes [lobehub#8765](https://github.com/jaworldwideorg/OneJA-Bot/issues/8765) ([0905559](0905559))

#### What's improved

* **provider**: Add BFL provider support for image generation, closes [lobehub#8806](https://github.com/jaworldwideorg/OneJA-Bot/issues/8806) ([519e03e](519e03e))

#### What's fixed

* **db**: Desktop local db can't vectorization, closes [lobehub#8830](https://github.com/jaworldwideorg/OneJA-Bot/issues/8830) ([a00fd9d](a00fd9d))
* **misc**: Improve mcp tracing with user config, closes [lobehub#8827](https://github.com/jaworldwideorg/OneJA-Bot/issues/8827) ([5cab2ee](5cab2ee))

#### Styles

* **misc**: Add Imagen 4 GA models, closes [lobehub#8799](https://github.com/jaworldwideorg/OneJA-Bot/issues/8799) ([2e9ad20](2e9ad20))
* **misc**: Style improve auth sign in box loading, closes [lobehub#8805](https://github.com/jaworldwideorg/OneJA-Bot/issues/8805) ([62f5a1b](62f5a1b))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working | 缺陷 released size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants