mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-16 12:36:07 +00:00
🐛 fix: improve mcp tracing with user config (#8827)
* improve plugin result report * improve plugin result report
This commit is contained in:
@@ -11,8 +11,6 @@ import { Flexbox } from 'react-layout-kit';
|
||||
import Notification from '@/components/Notification';
|
||||
import { BRANDING_NAME } from '@/const/branding';
|
||||
import { PRIVACY_URL } from '@/const/url';
|
||||
import { useServerConfigStore } from '@/store/serverConfig';
|
||||
import { serverConfigSelectors } from '@/store/serverConfig/selectors';
|
||||
import { useUserStore } from '@/store/user';
|
||||
import { preferenceSelectors } from '@/store/user/selectors';
|
||||
|
||||
@@ -30,7 +28,6 @@ const TelemetryNotification = memo<{ mobile?: boolean }>(({ mobile }) => {
|
||||
const { styles, theme } = useStyles();
|
||||
|
||||
const { t } = useTranslation('common');
|
||||
const shouldCheck = useServerConfigStore(serverConfigSelectors.enabledTelemetryChat);
|
||||
const isPreferenceInit = useUserStore(preferenceSelectors.isPreferenceInit);
|
||||
|
||||
const [useCheckTrace, updatePreference] = useUserStore((s) => [
|
||||
@@ -38,7 +35,7 @@ const TelemetryNotification = memo<{ mobile?: boolean }>(({ mobile }) => {
|
||||
s.updatePreference,
|
||||
]);
|
||||
|
||||
const { data: showModal, mutate } = useCheckTrace(shouldCheck && isPreferenceInit);
|
||||
const { data: showModal, mutate } = useCheckTrace(isPreferenceInit);
|
||||
|
||||
const updateTelemetry = (telemetry: boolean) => {
|
||||
updatePreference({ telemetry });
|
||||
|
||||
@@ -10,8 +10,6 @@ import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import { BRANDING_EMAIL, BRANDING_NAME, SOCIAL_URL } from '@/const/branding';
|
||||
import { BLOG, OFFICIAL_SITE, PRIVACY_URL, TERMS_URL, mailTo } from '@/const/url';
|
||||
import { useServerConfigStore } from '@/store/serverConfig';
|
||||
import { serverConfigSelectors } from '@/store/serverConfig/selectors';
|
||||
|
||||
import AboutList from './features/AboutList';
|
||||
import Analytics from './features/Analytics';
|
||||
@@ -30,7 +28,6 @@ const useStyles = createStyles(({ css, token }) => ({
|
||||
const Page = memo<{ mobile?: boolean }>(({ mobile }) => {
|
||||
const { t } = useTranslation('common');
|
||||
const { styles } = useStyles();
|
||||
const enabledTelemetryChat = useServerConfigStore(serverConfigSelectors.enabledTelemetryChat);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -122,7 +119,7 @@ const Page = memo<{ mobile?: boolean }>(({ mobile }) => {
|
||||
/>
|
||||
</Flexbox>
|
||||
</Form.Group>
|
||||
{enabledTelemetryChat && <Analytics />}
|
||||
<Analytics />
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -540,17 +540,14 @@ export const marketRouter = router({
|
||||
z.object({
|
||||
callDurationMs: z.number(),
|
||||
clientId: z.string().optional(),
|
||||
clientIp: z.string().optional(),
|
||||
customPluginInfo: z.any().optional(),
|
||||
errorCode: z.string().optional(),
|
||||
errorMessage: z.string().optional(),
|
||||
identifier: z.string(),
|
||||
inputParams: z.any().optional(),
|
||||
isCustomPlugin: z.boolean().optional(),
|
||||
metadata: z.record(z.any()).optional(),
|
||||
methodName: z.string(),
|
||||
methodType: z.enum(['tool', 'prompt', 'resource']),
|
||||
outputResult: z.any().optional(),
|
||||
platform: z.string().optional(),
|
||||
requestSizeBytes: z.number().optional(),
|
||||
responseSizeBytes: z.number().optional(),
|
||||
|
||||
@@ -3,6 +3,8 @@ import { CallReportRequest, InstallReportRequest } from '@lobehub/market-types';
|
||||
|
||||
import { lambdaClient } from '@/libs/trpc/client';
|
||||
import { globalHelpers } from '@/store/global/helpers';
|
||||
import { useUserStore } from '@/store/user';
|
||||
import { preferenceSelectors } from '@/store/user/selectors';
|
||||
import {
|
||||
AssistantListResponse,
|
||||
AssistantQueryParams,
|
||||
@@ -162,6 +164,10 @@ class DiscoverService {
|
||||
* 上报插件调用结果
|
||||
*/
|
||||
reportPluginCall = async (reportData: CallReportRequest) => {
|
||||
const allow = useUserStore(preferenceSelectors.userAllowTrace);
|
||||
|
||||
if (!allow) return;
|
||||
|
||||
await this.injectMPToken();
|
||||
|
||||
lambdaClient.market.reportCall.mutate(cleanObject(reportData)).catch((reportError) => {
|
||||
|
||||
@@ -103,7 +103,6 @@ class MCPService {
|
||||
errorCode,
|
||||
errorMessage,
|
||||
identifier,
|
||||
inputParams,
|
||||
isCustomPlugin,
|
||||
metadata: {
|
||||
appVersion: CURRENT_VERSION,
|
||||
@@ -112,7 +111,6 @@ class MCPService {
|
||||
},
|
||||
methodName: apiName,
|
||||
methodType: 'tool' as const,
|
||||
outputResult: success ? result : undefined,
|
||||
requestSizeBytes,
|
||||
responseSizeBytes,
|
||||
sessionId: topicId,
|
||||
|
||||
Reference in New Issue
Block a user