Skip to content

More analytics#1442

Merged
duckduckhero merged 5 commits intomainfrom
more-analytics
Sep 3, 2025
Merged

More analytics#1442
duckduckhero merged 5 commits intomainfrom
more-analytics

Conversation

@duckduckhero
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

📝 Walkthrough

Walkthrough

Adds analytics instrumentation across AI settings and notifications: integrates useHypr to read userId, converts several event handlers to async, and conditionally calls analyticsCommands.setProperties after user actions (model selection, autonomy selection, STT provider change, notification toggles). Prop types updated to pass userId in local STT view components.

Changes

Cohort / File(s) Summary of changes
AI settings: analytics + user context
apps/desktop/src/components/settings/components/ai/stt-view-local.tsx, apps/desktop/src/components/settings/views/ai-llm.tsx, apps/desktop/src/components/settings/views/ai-stt.tsx
- Read userId from useHypr and propagate to model entry components.
- Add conditional analyticsCommands.setProperties calls after user actions (model selection, autonomy level click, provider switch).
- Convert relevant handlers to async and await analytics calls.
- Update ModelSectionProps to include optional userId?: string; forward userId to BasicModelsSection, ProModelsSection, and ModelEntry.
Notifications: analytics on toggles
apps/desktop/src/components/settings/views/notifications.tsx
- Use useHypr to obtain userId.
- Make mutation onSuccess handlers async; refetch queries, then conditionally await analyticsCommands.setProperties updating event_notification or audio_notification.
- Preserve existing UI and side-effect flows; analytics are skipped when userId is absent.
STT remote API surface change
apps/desktop/src/components/settings/components/ai/stt-view-remote.tsx
- Change prop setProviderToCustom signature from () => void to () => Promise<void> (no behavioral change besides being async).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as Settings UI
  participant Hypr as Hypr Context
  participant API as Backend/API
  participant Analytics as Analytics Service

  rect rgb(240,245,255)
  note right of UI: STT local model selection
  User->>UI: Click ModelEntry
  UI->>Hypr: get userId
  alt userId present
    UI->>Analytics: setProperties {distinct_id: userId, set: {stt: "local-pro"|"local-basic"}}
    Analytics-->>UI: ack
  else no userId
    note over UI: Skip analytics
  end
  UI->>API: select/start model (existing flow)
  API-->>UI: done
  end

  rect rgb(245,255,240)
  note right of UI: LLM autonomy selection
  User->>UI: Click autonomy level
  UI->>Hypr: get userId
  alt userId present
    UI->>Analytics: setProperties {distinct_id: userId, set: {"llm-autonomy": value}}
    Analytics-->>UI: ack
  else
    note over UI: Skip analytics
  end
  UI->>API: mutate AI specificity (existing)
  API-->>UI: done
  end

  rect rgb(255,245,240)
  note right of UI: STT provider -> Custom
  User->>UI: Select "Custom"
  UI->>API: mutate provider=Custom
  API-->>UI: done
  UI->>Hypr: get userId
  alt userId present
    UI->>Analytics: setProperties {distinct_id: userId, set: {stt: "custom"}}
    Analytics-->>UI: ack
  else
    note over UI: Skip analytics
  end
  end

  rect rgb(250,250,250)
  note right of UI: Notification toggles
  User->>UI: Toggle notification
  UI->>API: mutate toggle
  API-->>UI: success
  UI->>API: refetch current state
  API-->>UI: state
  UI->>Hypr: get userId
  alt userId present
    UI->>Analytics: setProperties {distinct_id: userId, set: {event_notification|audio_notification: value}}
    Analytics-->>UI: ack
  else
    note over UI: Skip analytics
  end
  UI->>UI: continue side effects (start/stop, toast)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch more-analytics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
apps/desktop/src/components/settings/views/ai-llm.tsx (1)

733-757: Gate event on userId and tighten comment intent.

  • Keep analytics consistent with other views by guarding the legacy event with userId.
  • Make comments “why”-focused or remove.

Apply:

-                                      // legacy: send analytics event
-                                      analyticsCommands.event({
-                                        event: "autonomy_selected",
-                                        distinct_id: userId,
-                                        level: level,
-                                      });
+                                      // analytics: keep backward-compatible event for funnels
+                                      if (userId) {
+                                        analyticsCommands.event({
+                                          event: "autonomy_selected",
+                                          distinct_id: userId,
+                                          level,
+                                        });
+                                      }

-                                      // set user properties
+                                      // analytics: set autonomy level for segmentation
apps/desktop/src/components/settings/views/notifications.tsx (1)

80-81: Trim “what” comments.

Prefer brief “why” or omit; code is self-explanatory.

Apply:

-      // Track notification setting change in analytics
+      // analytics: persist user setting for targeting

Also applies to: 117-118

apps/desktop/src/components/settings/components/ai/stt-view-local.tsx (3)

46-47: Reduce prop drilling (optional).

Instead of threading userId through sections, ModelEntry can read useHypr() directly. Keeps props slimmer.

Also applies to: 59-59, 144-145, 161-162, 181-182, 211-212, 230-231, 284-285


376-395: Model selection analytics is solid; minor UX nit.

Awaiting setProperties is fine; if you prefer non-blocking UI, fire-and-forget.

Apply:

-        await analyticsCommands.setProperties({
+        void analyticsCommands.setProperties({
           distinct_id: userId,
           set: {
             stt: sttType,
           },
         });

385-387: Replace prefix-based pro detection with explicit model list
All current pro keys (“am-parakeet-v2”, “am-parakeet-v3”) start with “am-”, but use the existing pro models array (used in your query filters) instead of startsWith("am-") to avoid future misclassification.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3fb0219 and 78e4d92.

⛔ Files ignored due to path filters (2)
  • apps/desktop/src/locales/en/messages.po is excluded by !**/*.po
  • apps/desktop/src/locales/ko/messages.po is excluded by !**/*.po
📒 Files selected for processing (4)
  • apps/desktop/src/components/settings/components/ai/stt-view-local.tsx (11 hunks)
  • apps/desktop/src/components/settings/views/ai-llm.tsx (1 hunks)
  • apps/desktop/src/components/settings/views/ai-stt.tsx (1 hunks)
  • apps/desktop/src/components/settings/views/notifications.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

**/*.{js,ts,tsx,rs}: 1. Do not add any error handling. Keep the existing one.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop/src/components/settings/views/ai-llm.tsx
  • apps/desktop/src/components/settings/views/notifications.tsx
  • apps/desktop/src/components/settings/views/ai-stt.tsx
  • apps/desktop/src/components/settings/components/ai/stt-view-local.tsx
🧬 Code graph analysis (2)
apps/desktop/src/components/settings/views/notifications.tsx (1)
apps/desktop/src/contexts/hypr.tsx (1)
  • useHypr (63-69)
apps/desktop/src/components/settings/components/ai/stt-view-local.tsx (1)
apps/desktop/src/contexts/hypr.tsx (1)
  • useHypr (63-69)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci (macos, macos-14)
🔇 Additional comments (5)
apps/desktop/src/components/settings/views/ai-stt.tsx (1)

52-59: LGTM: analytics property set is correctly gated and awaited.

Consistent with the PR pattern (uses distinct_id, “stt: custom”).

apps/desktop/src/components/settings/views/notifications.tsx (3)

9-11: LGTM: user context and analytics imports are correctly introduced and used.

Also applies to: 29-29


77-89: LGTM: event toggle analytics runs post-refetch and is user-gated.


114-126: LGTM: detect toggle analytics mirrors event toggle flow.

apps/desktop/src/components/settings/components/ai/stt-view-local.tsx (1)

7-10: LGTM: added context and analytics deps are used.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/desktop/src/components/settings/components/ai/stt-view-remote.tsx (1)

17-17: Discard returned Promise from setProviderToCustom to avoid floating-promise lint errors

setProviderToCustom() now returns a Promise<void>. In apps/desktop/src/components/settings/components/ai/stt-view-remote.tsx, prepend void to each invocation to explicitly discard the promise and satisfy the linter:

  • onClick at line 94
  • onFocus at lines 154, 182, 209
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 78e4d92 and ca93c38.

⛔ Files ignored due to path filters (2)
  • apps/desktop/src/locales/en/messages.po is excluded by !**/*.po
  • apps/desktop/src/locales/ko/messages.po is excluded by !**/*.po
📒 Files selected for processing (1)
  • apps/desktop/src/components/settings/components/ai/stt-view-remote.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

**/*.{js,ts,tsx,rs}: 1. Do not add any error handling. Keep the existing one.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop/src/components/settings/components/ai/stt-view-remote.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (macos, macos-14)
  • GitHub Check: ci (windows, windows-latest)

@duckduckhero duckduckhero merged commit 854a817 into main Sep 3, 2025
9 checks passed
@ComputelessComputer ComputelessComputer deleted the more-analytics branch December 14, 2025 15:22
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