Skip to content

Add PostHog storytelling v2 tracking for notebook usage flows. - #105

Merged
suguanYang merged 6 commits into
Ontos-AI:stagingfrom
kaiyu96:event-tracking
Jun 17, 2026
Merged

Add PostHog storytelling v2 tracking for notebook usage flows.#105
suguanYang merged 6 commits into
Ontos-AI:stagingfrom
kaiyu96:event-tracking

Conversation

@kaiyu96

@kaiyu96 kaiyu96 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add PostHog SDK integration and storytelling v2 analytics for notebook flows (upload, chat, dashboard navigation, workspace lifecycle).
  • Merge latest staging (official library, diagram, chat updates) and resolve conflicts while preserving analytics instrumentation.

Test plan

  • Confirm PostHog events fire in dev with NEXT_PUBLIC_POSTHOG_KEY configured
  • Upload document: notebook_upload_button_clicked, notebook_document_upload_completed / _failed
  • Ask assistant question: notebook_assistant_question_submitted, answer completed/failed events
  • Click dashboard link: notebook_dashboard_link_clicked
  • Verify official library and diagram features still work after merge
  • CI passes on this PR

Made with Cursor

kaiyu96 and others added 2 commits June 16, 2026 21:40
Instrument upload, chat, dashboard navigation, and workspace lifecycle events with shared analytics context, tests, and GA4 alignment docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep official library and diagram changes from staging while preserving PostHog analytics instrumentation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings June 17, 2026 04:00
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@kaiyu96 is attempting to deploy a commit to the Ontos AI Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds client-side PostHog analytics to Notebook, including initialization, event helpers, and UI instrumentation for key product actions.

Changes:

  • Introduces a client-only PostHog wrapper (src/lib/posthog.ts) plus app-level initialization via PostHogProvider.
  • Instruments Notebook UX flows (uploads, chat, dashboard link, page views) with structured analytics context.
  • Adds Vitest coverage for the new tracking hooks/components and documents event/parameter conventions.

Reviewed changes

Copilot reviewed 23 out of 25 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/providers/posthog-provider.tsx Initializes PostHog on the client via a wrapper component.
src/lib/posthog.ts Adds PostHog init + typed tracking helpers for Notebook events.
src/lib/posthog.test.ts Tests PostHog enablement and identify/reset behaviors.
src/components/workspace-shell.tsx Wires identify/reset, pageview tracking, and “first doc uploaded” tracking.
src/components/workspace-shell-layout.tsx Threads analytics context + snapshot counts into panels and nav.
src/components/workspace-chat-workflow.ts Tracks assistant question/answer success/failure + first question asked.
src/components/top-nav.tsx Tracks dashboard link clicks and passes context metadata.
src/components/top-nav.test.tsx Verifies dashboard click triggers tracking with expected payload.
src/components/sources-panel.tsx Passes analytics context and source count snapshot into upload dialog.
src/components/source-upload-dialog.tsx Tracks upload button clicks; passes context into upload workflow.
src/components/source-upload-dialog.test.tsx Verifies upload-button click tracking is invoked.
src/components/source-upload-dialog-workflow.ts Tracks upload success/failure with metadata and counts.
src/components/source-upload-dialog-workflow.test.ts Verifies upload-completed tracking payload.
src/components/chunks-panel.tsx Threads analytics props into empty-state upload flow.
src/components/chat-panel.tsx Passes analytics + source counts into the chat composer.
src/components/chat-composer.tsx Tracks question submission with thread + source metadata.
src/components/chat-composer.test.tsx Verifies question-submitted tracking payload.
src/app/layout.tsx Wraps app in PostHogProvider to ensure initialization.
package.json Adds posthog-js dependency.
docs/posthog-notebook-tracking.md Runbook for PostHog insights/dashboard setup.
docs/ga4-alignment.md Documents GA4 alignment for event names/parameters.
README.md Documents env vars and high-level event list and setup.
.env.local.example Adds PostHog env var examples and notes.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/posthog.ts
Comment thread src/components/workspace-shell.tsx Outdated
Comment thread src/components/workspace-shell-layout.tsx Outdated
Comment thread src/components/chunks-panel.tsx
Comment thread src/components/workspace-shell-layout.tsx
Comment thread src/providers/posthog-provider.tsx Outdated
Comment thread src/lib/posthog.ts
kaiyu96 and others added 2 commits June 17, 2026 14:55
Use full page URLs, dedupe pageview tracking, rename the initializer component, and tighten analytics prop typing.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve chat-panel conflict by keeping PostHog analytics props and staging diagram creation updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kaiyu96

kaiyu96 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Update on follow-up items

Hi — I’ve pushed additional fixes to event-tracking. Current status:

Code / conflicts

  • Copilot review (7 items) addressed in 9bcd1be (pageview URL, deduped pageview effect, PostHogInitializer rename, host trim, etc.)
  • Staging moved again (#106 chat diagram resilience) — merged and conflict resolved in b5360a5 (chat-panel.tsx: kept PostHog analytics props + staging diagram changes)
  • PR is mergeable with staging again (no open merge conflicts as of latest fetch)

Checks still blocked (needs team action)

  • GitHub Actions CI / CodeQL: action_required — fork PR workflows need maintainer approval to run
  • Vercel: Authorization required to deploy on both preview targets

Ask

Could someone please:

  1. Approve/run the pending GitHub Actions workflows for this PR
  2. Authorize the Vercel deployment (if preview is required)
  3. Re-review when convenient — latest head is b5360a5

Thanks!

@suguanYang
suguanYang merged commit 9b4a1b6 into Ontos-AI:staging Jun 17, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants