Files
OpenSquawk/server/models/BugReport.ts
itsrubberduck ccab0e7116 feat(pm): add bug-report button with screenshot annotation and admin panel
- New BugReport MongoDB model (comment, contact, userId, screenshot, pmState, status)
- POST /api/bug-reports — authenticated submit; emails emanuel@faktorxmensch.com on receipt
- GET/PATCH /api/admin/bug-reports + /[id] — admin list, detail with screenshot, status toggle
- /pm: "Bug" button in HUD captures viewport screenshot (html2canvas), shows annotation
  canvas where testers can draw arrows; submits comment + contact + state snapshot
- /admin: new "Bug Reports" tab with open-count badge, screenshot expand, "Erledigt" toggle,
  and "In /pm öffnen" link that restores captured engine state via ?restoreBugReport=<id>

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 10:05:25 +02:00

46 lines
1.6 KiB
TypeScript

import mongoose from 'mongoose'
export type BugReportStatus = 'open' | 'resolved'
export interface PmStateSnapshot {
flowSlug?: string
scenarioId?: string
currentStateId?: string
variables?: Record<string, any>
flags?: Record<string, boolean>
flightContext?: Record<string, any>
communicationLog?: any[]
}
export interface BugReportDocument extends mongoose.Document {
comment: string
contact: string
userId?: mongoose.Types.ObjectId
screenshot?: string
pmState?: PmStateSnapshot
status: BugReportStatus
createdAt: Date
}
const bugReportSchema = new mongoose.Schema<BugReportDocument>({
comment: { type: String, required: true, trim: true, maxlength: 4000 },
contact: { type: String, required: true, trim: true, maxlength: 200 },
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', index: true },
screenshot: { type: String },
pmState: {
flowSlug: { type: String },
scenarioId: { type: String },
currentStateId: { type: String },
variables: { type: mongoose.Schema.Types.Mixed, default: {} },
flags: { type: mongoose.Schema.Types.Mixed, default: {} },
flightContext: { type: mongoose.Schema.Types.Mixed, default: {} },
communicationLog: { type: [mongoose.Schema.Types.Mixed], default: [] },
},
status: { type: String, enum: ['open', 'resolved'], default: 'open', index: true },
createdAt: { type: Date, default: () => new Date(), index: true },
})
export const BugReport =
(mongoose.models.BugReport as mongoose.Model<BugReportDocument> | undefined) ||
mongoose.model<BugReportDocument>('BugReport', bugReportSchema)