@ eddydesk/ 核心
EddyDesk QA平台的核心客户端和公用事业.
说明: 大多数用户应安装
@eddydesk/react或者说@eddydesk/react-native而不是自动包含此软件包.
安装
npm install @eddydesk/core
使用量
import { createEddyDesk } from '@eddydesk/core';
const eddydesk = createEddyDesk({
projectId: 'your-project-id',
getCurrentUser: async () => ({
id: 'user-123',
email: '[email protected]',
name: 'Jane Doe', // Optional, used for reporter identity
}),
});
// Submit a report
await eddydesk.submitReport({
type: 'bug',
description: 'Button does not work',
severity: 'high',
appContext: { currentRoute: '/dashboard' },
});
// Check if user is a tester
const isTester = await eddydesk.isTester();
// Get assigned test cases
const assignments = await eddydesk.getAssignedTests();
配置
interface EddyDeskConfig {
// Required
projectId: string;
getCurrentUser: () => Promise<{ id: string; email: string; name?: string } | null>;
// Optional — context
getAppContext?: () => AppContext; // Rich app context (userRole, etc.)
getNavigationHistory?: () => string[]; // Custom navigation tracking
// Optional — callbacks
onReportSubmitted?: (report: EddyDeskReport) => void;
onNavigate?: (route: string) => void; // Deep linking from test cases
// Optional — self-hosted
supabaseUrl?: string;
supabaseAnonKey?: string;
}
附录
提供 getAppContext 在每份错误报告中附加丰富的上下文。 这有助于开发者修复错误 理解用户的状态 :
const eddydesk = createEddyDesk({
projectId: 'your-project-id',
getCurrentUser: async () => ({ id: user.id, email: user.email }),
getAppContext: () => ({
currentRoute: window.location.pathname,
userRole: currentUser?.role, // e.g. 'owner', 'manager', 'guest'
propertyId: currentProperty?.id, // App-specific context
custom: { // Any additional context
theme: 'dark',
locale: 'en-US',
},
}),
});
自动上下文抓取
EddyDesk 初始化时自动抓取调试上下文 EddyDeskProvider (反应或反应原生). 不需要手动设置 .
自动捕获的东西:
| 数据 | 细节 |
|---|---|
| 控制台日志 | 倒数 50 console.log/warn/error/info 电话 |
| 网络请求 | 最后20个 fetch() 有方法、 URL、 状态、 持续时间的呼叫 |
| 失败的应对机构 | 4xx/5xxx错误的首500个响应对象字符 |
| 导航历史 | 最后20条路由变化(通过) pushState编号 :replaceState编号 :popstate(中文(简体) ) |
| 业绩计量 | 页面加载时间、内存使用( Chrome) |
| 环境 | 语言、时区、在线状态、饼干、本地Storage |
此数据作为附件附于每份错误报告 enhanced_context 并可供 MCP 服务器使用 get_report_context 工具.
手动抓取(框架作者)
如果你没有用 EddyDeskProvider,手动开始抓取 :
import { contextCapture } from '@eddydesk/core';
// Start capturing (call once at app init)
contextCapture.startCapture();
// For React Native: manually track screen changes
contextCapture.trackNavigation('/home');
contextCapture.trackNavigation('/settings');
// Get captured data (automatically included in submitReport)
const context = contextCapture.getEnhancedContext();
客户方法
| 方法 | 说明 |
|---|---|
submitReport(report) | 提交错误报告、反馈或测试结果 |
isTester() | 检查当前用户是否是注册测试器 |
isQAEnabled() | 检查工程是否启用 QA 模式 |
shouldShowWidget() | 检查部件是否可见( QA 启用 + 是测试器) |
getTesterInfo() | 获取当前测试者的信息 |
getAssignedTests() | 获取指定给当前测试器的测试例 |
getAppContext() | 获取当前应用程序上下文( 使用配置回调或自动抓取) |
getNavigationHistory() | 获取导航历史( 配置调回 > 手动 > 自动抓取) |
trackNavigation(route) | 手动跟踪路由更改 |
getIssueCounts() | 按类别进行问题清点( 打开、 完成、 重新打开) |
getIssues(category) | 以校验证明和原始错误上下文来丰富问题列表 |
uploadScreenshot(file) | 上传截图 |
类型
interface EddyDeskReport {
type: 'bug' | 'feedback' | 'suggestion' | 'test_pass' | 'test_fail';
description: string;
title?: string;
severity?: 'critical' | 'high' | 'medium' | 'low';
screenshots?: string[];
appContext?: AppContext;
enhancedContext?: EnhancedBugContext;
}
interface AppContext {
currentRoute: string;
screenName?: string;
userRole?: string;
propertyId?: string;
custom?: Record<string, unknown>;
}
interface TesterInfo {
id: string;
name: string;
email: string;
assignedTests: number;
completedTests: number;
}
interface TestAssignment {
id: string;
status: string;
testCase: {
id: string;
title: string;
description: string;
steps: TestStep[];
expectedResult: string;
priority: string;
};
}
type IssueCategory = 'open' | 'done' | 'reopened';
interface IssueCounts {
open: number;
done: number;
reopened: number;
}
interface TesterIssue {
id: string;
title: string;
description: string;
reportType: ReportType;
severity: Severity | null;
status: ReportStatus;
screenshotUrls: string[];
route?: string;
reporterName?: string;
createdAt: string;
updatedAt: string;
verifiedByName?: string; // Who retested (done issues)
verifiedAt?: string; // When verification passed (done issues)
originalBugId?: string; // Original report ID (reopened issues)
originalBugTitle?: string; // Original bug title (reopened issues)
}
问题跟踪
SDK为测试者提供了跟踪其bug生命周期的方法:
// Get counts for issue cards (open, done, reopened)
const counts = await eddydesk.getIssueCounts();
// { open: 3, done: 12, reopened: 1 }
// Get enriched issue list by category
const openIssues = await eddydesk.getIssues('open');
const doneIssues = await eddydesk.getIssues('done');
const reopenedIssues = await eddydesk.getIssues('reopened');
// Done issues include verification proof
doneIssues[0].verifiedByName; // "Jane Doe"
doneIssues[0].verifiedAt; // "2026-02-05T12:00:00Z"
// Reopened issues include original bug context
reopenedIssues[0].originalBugTitle; // "Login button unresponsive"
reopenedIssues[0].originalBugId; // "uuid-of-original-report"
对于框架作者
如果您正在为不同的框架(Vue, Svelte等)构建一个 EddyDesk 集成, 请使用此包作为基础 :
import { EddyDeskClient, createEddyDesk, contextCapture, EddyDeskConfig } from '@eddydesk/core';
// Start context capture at app init
contextCapture.startCapture();
// Create your framework-specific wrapper around the client
const client = createEddyDesk(config);