Skip to content

Conversation

@zanesq
Copy link
Collaborator

@zanesq zanesq commented Dec 15, 2025

Summary

Expands analytics coverage across both the backend (Rust) and frontend (TypeScript) to provide better insights into feature usage and error patterns.

All frontend analytics are sent through a new endpoint and the existing posthog.rs api integration. I first attempted the posthog js library but it was having authentication issues and we reuse a lot of code anyway so might as well leave it in the backend for now.

Key Design Decisions

  • Privacy-first: Extension names only tracked for builtin extensions; recipe names never tracked
  • Success/failure tracking: All operations track both success and failure with error details
  • Source attribution: Events include source: "backend" or source: "frontend" for debugging
  • Consistent error handling: getErrorType() helper standardizes error classification

Backend Changes (Rust)

New Events

  • slash_command_used - Tracks slash command usage with:
    • command_type: "builtin" | "recipe" | "unknown"
    • command_name: Only for builtin commands (privacy-safe)
    • success: true for valid commands, false for unknown
  • schedule_job_started / schedule_job_completed - Tracks automated scheduled job execution with duration

Enhanced session_started Event

Now includes additional properties:

  • is_dev - Whether running in debug/dev mode
  • db_schema_version - Current database schema version
  • Router/lead model settings: setting_mode, setting_max_turns, setting_router_enabled, setting_lead_model, setting_lead_provider, setting_lead_turns, setting_lead_failure_threshold, setting_lead_fallback_turns

Enhanced error Event

  • Added error_category classification
  • Added source: "backend" marker
  • New ErrorContext struct with optional component and action fields
  • Added provider/model context to error events

New Infrastructure

  • emit_event() - Generic event emitter for custom events with arbitrary properties
  • emit_slash_command_used() - Dedicated slash command tracking
  • emit_error_with_context() - Error tracking with additional context
  • New /telemetry/event API endpoint for frontend-to-backend event forwarding

Frontend Changes (TypeScript)

New Analytics Module (utils/analytics.ts)

Comprehensive type-safe analytics including:

Schedule Events:

  • schedule_created (with source_type: file/deeplink)
  • schedule_updated, schedule_deleted, schedule_paused, schedule_unpaused
  • schedule_run_now, schedule_killed, schedule_inspected, schedule_viewed

Recipe Events:

  • recipe_created, recipe_imported, recipe_edited, recipe_deleted
  • recipe_started (with in_new_window flag)
  • recipe_deeplink_copied
  • recipe_scheduled, recipe_slash_command_set (with action: add/edit/remove)

Extension Events:

  • extension_added, extension_enabled, extension_disabled, extension_deleted
  • Includes is_builtin flag; extension_name only tracked for builtin extensions

Chat Input Bar Events:

  • input_file_attached (file/directory)
  • input_voice_dictation (start/stop/transcribed/error with duration)
  • input_mode_changed (from/to mode)
  • input_diagnostics_opened, input_create_recipe_opened, input_edit_recipe_opened

Core Events:

  • page_view with referrer tracking
  • model_changed, settings_tab_viewed, setting_toggled
  • telemetry_preference_set
  • Enhanced error tracking: error_occurred, app_crashed, app_reloaded
  • Onboarding funnel: onboarding_started, onboarding_provider_selected, onboarding_completed, onboarding_abandoned, onboarding_setup_failed

New Hook (hooks/useAnalytics.ts)

  • usePageViewTracking() - Automatic page view tracking on route changes

Components Updated

  • SchedulesView.tsx - Schedule CRUD operations
  • ScheduleDetailView.tsx - Schedule inspection/kill
  • RecipesView.tsx - Recipe management
  • ChatInput.tsx - File attachments, voice dictation, mode changes
  • BottomMenuModeSelection.tsx - Mode switching
  • extension-manager.ts - Extension lifecycle
  • SettingsView.tsx, TelemetrySettings.tsx, SecurityToggle.tsx, etc. - Settings toggles
  • ErrorBoundary.tsx - Crash tracking
  • ProviderGuard.tsx - Provider setup tracking
  • SwitchModelModal.tsx - Model changes
  • App.tsx / renderer.tsx - Global error handlers and page view tracking


#[utoipa::path(
post,
path = "/telemetry/event",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is ok - as it means we could in theory swap out what is at the backend from posthog

#[derive(Debug, Clone)]
pub enum SlashCommandType {
/// Builtin command (e.g., /compact) - name is safe to track
Builtin(String),
Copy link
Collaborator

Choose a reason for hiding this comment

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

how come we want to track slash commands? will this be the same from GUI vs CLI? (I didn't realise they were that heavily used - but I guess idea is to track it? not sure why but seems fairly fine grained but I guess there is no info in it)

Copy link
Collaborator Author

@zanesq zanesq Dec 16, 2025

Choose a reason for hiding this comment

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

yeah just to see how much its used, then again maybe we don't need the fine grain just general usage on non built ins would be enough, will follow up with that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed built in tracking logic

import cronstrue from 'cronstrue';
import { formatToLocalDateWithTimezone } from '../../utils/date';
import { getSession, Session } from '../../api';
import {
Copy link
Collaborator

Choose a reason for hiding this comment

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

with recipes and schedule tracking - do we want to track it this fine grained vs just seeing if people use either feature in some meaningful way? (maybe need to do this but seems like a lot!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hard to say the point is to see what fine grained features are really needed cluttering up our ui... will take another look and see if can be pruned more

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good call removed some low value fine-grained tracking for these scheduling features but I think the recipe ones are valid to get an idea if they are even used

trackScheduleUpdated - editing schedules
trackSchedulePaused / trackScheduleUnpaused - pause toggle
trackScheduleKilled - killing running jobs
trackScheduleInspected - inspecting running jobs
trackScheduleViewed - viewing schedule details


const App = lazy(() => import('./App'));

const TELEMETRY_CONFIG_KEY = 'GOOSE_TELEMETRY_ENABLED';
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would have thought the backend would take care of this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah it does also but the frontend needs to check the config also so it can avoid sending all the events for no reason if it is disabled

@michaelneale
Copy link
Collaborator

I think looks ok - is a lot of extra stuff, just had some Qs if we realy want schedules/recipes that fine grained (I guess idea is to know if used or not) but seems ok

Copy link
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

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

approving to not block this if we need more insight to know what is used

@zanesq
Copy link
Collaborator Author

zanesq commented Dec 16, 2025

@michaelneale thanks valid concerns, removed a few low signal ones. Will leave this open for a bit longer in case anyone has other feedback.

@zanesq zanesq merged commit 8a91f15 into main Dec 16, 2025
18 checks passed
@zanesq zanesq deleted the zane/more-analytics branch December 16, 2025 16:59
zanesq added a commit that referenced this pull request Dec 16, 2025
* 'main' of github.com:block/goose: (22 commits)
  OpenRouter & Xai streaming (#5873)
  fix: resolve mcp-hermit cleanup path expansion issue (#5953)
  feat: add goose PR reviewer workflow (#6124)
  perf: Avoid repeated MCP queries during streaming responses (#6138)
  Fix YAML serialization for recipes with special characters (#5796)
  Add more posthog analytics (privacy aware) (#6122)
  docs: add Sugar MCP server to extensions registry (#6077)
  Fix tokenState loading on new sessions (#6129)
  bump bedrock dep versions (#6090)
  Don't persist ephemeral extensions when resuming sessions (#5974)
  chore(deps): bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /ui/desktop (#5939)
  chore(deps): bump node-forge from 1.3.1 to 1.3.2 in /documentation (#5898)
  Add Scorecard supply-chain security workflow (#5810)
  Don't show subagent tool when we're a subagent (#6125)
  Fix keyboard shortcut conflict for Focus Goose Window (#5809)
  feat(goose-cli): add feature to disable update (#5886)
  workflow: enable docs-update-recipe-ref (#6132)
  fix: filter tools in Ollama streaming when chat mode is enabled (#6118)
  feat(mcp): platform extension for "code mode" MCP tool calling (#6030)
  workflow: auto-update recipe-reference on release (#5988)
  ...

# Conflicts:
#	ui/desktop/src/App.tsx
#	ui/desktop/src/api/sdk.gen.ts
#	ui/desktop/src/components/ChatInput.tsx
#	ui/desktop/src/components/recipes/RecipesView.tsx
zanesq added a commit that referenced this pull request Dec 16, 2025
…s-predefined-models

* 'main' of github.com:block/goose: (81 commits)
  fix: display shell output as static text instead of spinner (#6041)
  fix : Custom providers with empty API keys show as configured in desktop (#6105)
  Add .agents/skills and ~/.config/agent/skills to skills discovery paths (#6139)
  fix: use instructions for system prompt and prompt for user message in subagents (#6121)
  Fix compaction loop for small models or large input (#5803)
  feat: Centralize theme management with ThemeContext (#6137)
  OpenRouter & Xai streaming (#5873)
  fix: resolve mcp-hermit cleanup path expansion issue (#5953)
  feat: add goose PR reviewer workflow (#6124)
  perf: Avoid repeated MCP queries during streaming responses (#6138)
  Fix YAML serialization for recipes with special characters (#5796)
  Add more posthog analytics (privacy aware) (#6122)
  docs: add Sugar MCP server to extensions registry (#6077)
  Fix tokenState loading on new sessions (#6129)
  bump bedrock dep versions (#6090)
  Don't persist ephemeral extensions when resuming sessions (#5974)
  chore(deps): bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /ui/desktop (#5939)
  chore(deps): bump node-forge from 1.3.1 to 1.3.2 in /documentation (#5898)
  Add Scorecard supply-chain security workflow (#5810)
  Don't show subagent tool when we're a subagent (#6125)
  ...

# Conflicts:
#	crates/goose/src/providers/formats/databricks.rs
aharvard added a commit that referenced this pull request Dec 17, 2025
* main:
  fix: we don't need to warn about tool count when in code mode (#6149)
  deps: upgrade agent-client-protocol to 0.9.0 (#6109)
  fix(providers): fix for gemini-cli on windows to work around cmd's multiline prompt limitations #5911 (#5966)
  More slash commands (#5858)
  fix: MCP UI not rendering due to CallToolResult structure change (#6143)
  fix: display shell output as static text instead of spinner (#6041)
  fix : Custom providers with empty API keys show as configured in desktop (#6105)
  Add .agents/skills and ~/.config/agent/skills to skills discovery paths (#6139)
  fix: use instructions for system prompt and prompt for user message in subagents (#6121)
  Fix compaction loop for small models or large input (#5803)
  feat: Centralize theme management with ThemeContext (#6137)
  OpenRouter & Xai streaming (#5873)
  fix: resolve mcp-hermit cleanup path expansion issue (#5953)
  feat: add goose PR reviewer workflow (#6124)
  perf: Avoid repeated MCP queries during streaming responses (#6138)
  Fix YAML serialization for recipes with special characters (#5796)
  Add more posthog analytics (privacy aware) (#6122)
  docs: add Sugar MCP server to extensions registry (#6077)
dianed-square added a commit that referenced this pull request Dec 17, 2025
* origin/main: (57 commits)
  docs: create/edit recipe button (#6145)
  fix(google): Fix 400 Bad Request error with Gemini 3 thought signatures (#6035)
  fix: we don't need to warn about tool count when in code mode (#6149)
  deps: upgrade agent-client-protocol to 0.9.0 (#6109)
  fix(providers): fix for gemini-cli on windows to work around cmd's multiline prompt limitations #5911 (#5966)
  More slash commands (#5858)
  fix: MCP UI not rendering due to CallToolResult structure change (#6143)
  fix: display shell output as static text instead of spinner (#6041)
  fix : Custom providers with empty API keys show as configured in desktop (#6105)
  Add .agents/skills and ~/.config/agent/skills to skills discovery paths (#6139)
  fix: use instructions for system prompt and prompt for user message in subagents (#6121)
  Fix compaction loop for small models or large input (#5803)
  feat: Centralize theme management with ThemeContext (#6137)
  OpenRouter & Xai streaming (#5873)
  fix: resolve mcp-hermit cleanup path expansion issue (#5953)
  feat: add goose PR reviewer workflow (#6124)
  perf: Avoid repeated MCP queries during streaming responses (#6138)
  Fix YAML serialization for recipes with special characters (#5796)
  Add more posthog analytics (privacy aware) (#6122)
  docs: add Sugar MCP server to extensions registry (#6077)
  ...
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