Feat/posthog integration#2
Merged
Merged
Conversation
…d analytics foundation Backend: wire PostHog posthog-python client; instrument every phase function (discovery, alignment, generation, refinement, audit, completion) with $ai_trace / $ai_span events via a new services/observability.py helper. Guardrails also capture span events on violations. Frontend: initialise posthog-js (opt-out by default), add CookieConsentBanner that drives opt-in/opt-out, wire Clerk user identity to PostHog, add initial product events (phase_entered, document_created) and session-recording mask selectors for editor content. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…CP events - Add capture_event helper to observability service for custom PostHog events - Fire alignment_section_reopened per rejected section in alignment phase - Fire mcp_document_created, mcp_section_written, mcp_snapshot_saved, mcp_version_activated at HTTP layer via api_key_id detection - Add document_opened, phase_completed, phase_entered events in DocumentPage - Add discovery_question_answered/skipped in FollowUpQuestions - Add alignment_section_reopened in AlignmentLayout - Add refinement_edit_requested, refinement_question_asked, refinement_section_finalized in workspace store - Add refinement_version_branched in TimelinePanel - Add refinement_local_changes_saved, document_exported in EditorLayout - Add editor_version_created, editor_version_restored in EditorVersionPanel - Add document_exported in CompletedLayout - Add data-ph-mask to SummaryCard, AuditProblems, CompletedLayout textareas/findings - Guard posthog.identify behind consent in useClerkPosthogIdentity Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_document_completed - Remove auto-save debounce from EditorLayout (was misfiring refinement_local_changes_saved) - Add editor_changes_saved to EditorVersionPanel.handleSaveChanges (explicit save only) - Add refinement_version_restored to TimelinePanel.handleRestore - Add refinement_changes_saved + Save changes button to TimelinePanel - Add saveActiveContent action to workspace store - Add first_document_completed event on audit → completed phase transition Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
key was only assigned inside the if block, crashing on unauthenticated requests like the initial GET /mcp handshake from MCP clients. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
first_document_completedmilestone event..editor-content,.markdown-preview,data-ph-mask). Gated behind cookie consent (opt_out_capturing_by_default: true).document_id. Per-call context includes phase, section type, document type, and retry flag. Prompt bodies redacted viaPOSTHOG_REDACT_PROMPTS.first_document_completed,phase_completed,document_exported,document_opened).UnboundLocalErrorin_ApiKeyMiddlewarewhen a request arrives without aBearertoken (e.g. the initialGET /mcphandshake from MCP clients).refinement_local_changes_savedauto-save event fromEditorLayout. Replaced witheditor_changes_saved(explicit save, free editor) andrefinement_changes_saved(explicit save, refinement workspace). Auto-save debounce removed fromEditorLayoutentirely.New events
document_openedphase_completedfirst_document_completedaudit→completededitor_changes_savededitor_version_restoredrefinement_changes_savedrefinement_version_restoredTest plan
document_openedfires in PostHog live eventsphase_completed+phase_enteredboth firefirst_document_completedfires onceeditor_changes_savedfires; no event fires from typing alonerefinement_changes_savedfiresrefinement_version_restoredfiresGET /mcphandshake