Skip to content

feat: add PostHog custom survey modal on second app launch#4604

Open
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin/1773652691-survey-modal
Open

feat: add PostHog custom survey modal on second app launch#4604
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin/1773652691-survey-modal

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Mar 16, 2026

Summary

Adds a 4-question onboarding survey that appears as a modal dialog on the user's second app launch (after a full quit). Responses are captured as PostHog custom survey events via the existing analytics plugin.

Backend (Rust): Two new persisted store keys (AppOpenCount, SurveyDismissed) with Tauri commands to increment the open count and track whether the survey was dismissed/submitted.

Frontend (React): SurveyModal component rendered inside EventListeners. On mount, it increments the app open count and shows the dialog when count is ≥ 2 and the survey hasn't been dismissed. The modal steps through 4 questions (select/multi-select), then fires a "survey sent" event with PostHog's $survey_id / $survey_response property convention.

Questions:

  1. How did you find us? (single select)
  2. Why did you choose Char over other options? (multi-select)
  3. What's your role? (single select)
  4. How are you currently taking notes? (multi-select)

Review & Testing Checklist for Human

  • PostHog survey ID: SURVEY_ID is set to "onboarding_survey_v1" — you'll need to create a matching API-mode survey in the PostHog dashboard (or replace with the actual UUID) for responses to appear correctly in the PostHog survey UI.
  • TypeScript bindings were manually edited (tauri.gen.ts). Run cargo test export_types in apps/desktop/src-tauri to regenerate and confirm the manual additions match specta's output.
  • analyticsCommands.event payload cast: The PostHog event payload is built as Record<string, unknown> then cast via as. Verify the analytics plugin actually accepts arbitrary properties, or the extra $survey_response_* keys may be silently dropped.
  • Test plan: Build the desktop app, launch it twice (quit fully between launches), and verify the survey modal appears on the second launch. Submit responses, confirm "survey sent" event appears in PostHog. Relaunch a third time and confirm the survey does not reappear. Also test dismissing (clicking X / closing) and confirm "survey dismissed" fires and the modal does not return.

Notes

  • On macOS, closing the window without Cmd+Q keeps the app alive in the background. Reopening from the dock recreates the webview and will increment the count — so the "2nd launch" may actually be a "2nd window open" rather than a true process restart. This matches the stated intent ("mostly after updates") but is worth being aware of.
  • The survey response format uses $survey_response for Q1 and $survey_response_N for subsequent questions. Multi-select answers are sent as arrays; single-select as strings.
  • The trigger uses >= 2 (not strict equality) combined with the SurveyDismissed flag, so if something goes wrong on the second launch the user will still see the survey on subsequent launches.
  • Linux desktop_ci failures in this PR are pre-existing (missing libpipewire-0.3 in CI environment) and unrelated to these changes. macOS desktop_ci and fmt checks pass.

Link to Devin session: https://app.devin.ai/sessions/3f4f1d83f2dd40a5aa6d39fd8b0bbe9f
Requested by: @ComputelessComputer

- Add AppOpenCount and SurveyDismissed store keys in Rust backend
- Add increment_app_open_count, get/set_survey_dismissed Tauri commands
- Create SurveyModal component with 4 select/multi-select questions
- Show survey on second app open, capture 'survey sent' PostHog event
- Questions: discovery source, why Char, role, current note-taking

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@netlify
Copy link

netlify bot commented Mar 16, 2026

Deploy Preview for hyprnote canceled.

Name Link
🔨 Latest commit 621243a
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/69b7cfc17422440008f85e8f

@netlify
Copy link

netlify bot commented Mar 16, 2026

Deploy Preview for hyprnote-storybook canceled.

Name Link
🔨 Latest commit 621243a
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/69b7cfc1c5e05c0008625147

ComputelessComputer and others added 2 commits March 16, 2026 09:26
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

1 participant