Export Preview Release PRD
Objective
Ship a user-facing preview experience for code artifacts (modal and dedicated route) to improve trust and conversion to copy/download actions in the export module.
Release Goal (Next Week)
- Increase conversion from export panel exposure to code export actions.
- Add preview entrypoint without breaking current export analytics.
Scope
- Add preview CTA in export panel.
- Support modal preview and route preview for a single pattern artifact.
- Reuse visualizer rendering core safely in production.
Non-Goals
- Rewriting the existing export module UX.
- Replacing current copy/download event names.
- Building a new analytics pipeline.
Success Metrics
- Increased ratio of
code_exportedafter preview exposure. - Stable error rate for preview rendering.
- No drop in existing export conversion baseline.
Phase Checklist
Phase 1 - Shared Visualizer Refactor (foundation)
- Add configurable visualizer controls so debug and production can use different UI surfaces.
- Keep current debug behavior as default so existing flows do not regress.
- Add a shared non-debug import surface for preview reuse (
fullandiframe-onlymodes). - Validate TypeScript/build health for touched files.
Phase 2 - Export Module Preview Entry
- Add Preview CTA to export panel (icon or text button).
- Emit
preview_openedanalytics event withpattern_id,pattern_title, andsource_surface. - Open preview in modal using shared iframe-only mode.
- Ensure copy/download analytics remain owned by export panel actions.
Phase 3 - Dedicated Route
- Implement route-level preview page (candidate:
/exports/[id]). - Reuse shared preview renderer on route.
- Add route-open analytics (
preview_opened_in_route). - Add clear back navigation to pattern detail.
Phase 4 - QA and Launch
- Test auth and non-auth behavior matrix.
- Test artifact exists / missing / rendering-error states.
- Test desktop + mobile + keyboard controls.
- Verify analytics payloads in GA/DebugView before release.
- Roll out behind feature flag and monitor conversion trend.
Implementation Notes (Phase 1)
Completed in this iteration:
- Extended
ArtifactComponentPreviewwith visibility flags for toolbar/buttons. - Added
ArtifactPreviewreusable entry component atsrc/components/preview/ArtifactPreview.tsxwith:mode="full"for debug-like behavior.mode="iframe-only"for production preview surfaces without debug actions.
Implementation Notes (Phase 2)
- Added a
PreviewCTA toPatternCodePaneland opened a modal preview surface. - Modal preview uses shared
ArtifactPreviewiniframe-onlymode. - Modal keeps
Copy codeandDownloadvisible and wired to the same handlers used by the export panel. - Added
preview_openedanalytics event helper viatrackCodePreviewOpened(...)withsource_surfacemetadata.
Risks and Mitigations
- Risk: duplicate copy actions can split analytics semantics.
-
Mitigation: production preview should use iframe-only mode; keep copy/download only in export panel.
- Risk: iframe rendering failures reduce trust.
- Mitigation: maintain error hints and add preview failure analytics in Phase 2.
Open Decisions
- Final route shape:
/exports/[id]vs/patterns/[id]/preview. - Modal routing strategy: URL-backed or local UI state.
- Whether maximize control appears in production modal.