Skip to content

feat(analytics): unify cross-platform tracking#90

Merged
debugtheworldbot merged 4 commits intomainfrom
feat/unify-cross-platform-tracking
Apr 3, 2026
Merged

feat(analytics): unify cross-platform tracking#90
debugtheworldbot merged 4 commits intomainfrom
feat/unify-cross-platform-tracking

Conversation

@debugtheworldbot
Copy link
Copy Markdown
Owner

Summary

  • Unify analytics event names, property keys, and helper methods across macOS and Windows so both platforms emit identical PostHog events
  • Add shared base properties (app_build, os, os_version, first_open_utc, etc.) registered once at startup
  • Introduce trackPageView / trackClick / trackEvent helpers on both platforms to replace ad-hoc PostHogSDK.shared.capture calls
  • Standardize property values to English (clicks, key_presses, 7d/30d, line/bar) replacing Chinese strings

Changes

  • macOS AppDelegate.swift: Added analyticsBaseProperties(), trackEvent/trackPageView/trackClick static helpers, app_install/app_open/app_exit lifecycle events, first_open_utc tracking
  • macOS views: All window controllers and popover now call trackPageView/trackClick instead of raw PostHog calls; removed direct import PostHog from leaf files
  • Windows App.xaml.cs: Extended super-properties with app_build, os, os_major_version, os_version, $app_name, $app_version
  • Windows StatsPopupViewModel.cs: Switched chart metric/range/style property values to English
  • Windows views: Added TrackPageView calls to settings, app-stats, mouse-calibration, and notification-settings windows; added TrackClick calls to settings button handlers
  • AGENTS.md: Added analytics coding guideline for both platforms

Test Plan

  • Launch macOS app → verify app_open and app_install (first run only) events appear in PostHog with all base properties
  • Open each window/popover → verify pageview events with correct page_name
  • Click chart range/metric/style toggles → verify click events with English property values
  • Launch Windows app → verify matching super-properties in PostHog
  • Toggle chart controls on Windows → verify English property values match macOS

🤖 Generated with Claude Code

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 15:41
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements a unified analytics tracking system for both Windows and macOS platforms, introducing standardized event names for page views and clicks. It also enhances the base properties collected with each event to include more granular OS and application version details. The review feedback focuses on maintaining consistency in the app_build property across platforms and streamlining the event tracking code by removing redundant checks.

Comment thread KeyStats.Windows/KeyStats/App.xaml.cs
Comment thread KeyStats/AppDelegate.swift
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes analytics tracking across macOS and Windows so both platforms emit the same PostHog event names and property keys, using shared “pageview/click/event” helper methods and consistent English property values.

Changes:

  • macOS: register shared analytics base/super properties at startup; add trackEvent / trackPageView / trackClick helpers; emit app_install, app_open, app_exit.
  • macOS + Windows: replace ad-hoc tracking calls with standardized pageview/click events across windows/popovers and key interactions.
  • Windows: standardize chart metric/range/style property values to English and extend base properties.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
KeyStats/StatsPopoverViewController.swift Track chart control changes and navigation clicks via AppDelegate.trackClick; remove direct PostHog usage.
KeyStats/SettingsWindowController.swift Emit pageview for Settings window.
KeyStats/SettingsViewController.swift Replace PostHog captures with standardized helpers for settings actions and data import/export/reset.
KeyStats/MouseDistanceCalibrationWindowController.swift Emit pageview for mouse calibration window.
KeyStats/MenuBarController.swift Track tray interactions and popover pageview; remove direct PostHog usage.
KeyStats/KeyboardHeatmapWindowController.swift Emit pageview for keyboard heatmap window.
KeyStats/AppStatsWindowController.swift Emit pageview for app stats window.
KeyStats/AppDelegate.swift Register unified base properties; emit lifecycle events; add shared tracking helper methods.
KeyStats/AllTimeStatsWindowController.swift Emit pageview for all-time stats window.
KeyStats.Windows/KeyStats/Views/SettingsWindow.xaml.cs Emit settings pageview and track key settings actions as click.
KeyStats.Windows/KeyStats/Views/NotificationSettingsWindow.xaml.cs Emit notification settings pageview.
KeyStats.Windows/KeyStats/Views/MouseCalibrationWindow.xaml.cs Emit mouse calibration pageview.
KeyStats.Windows/KeyStats/Views/AppStatsWindow.xaml.cs Emit app stats pageview.
KeyStats.Windows/KeyStats/ViewModels/StatsPopupViewModel.cs Standardize chart control analytics property values to English.
KeyStats.Windows/KeyStats/App.xaml.cs Extend base properties (app/os metadata) and align lifecycle events.
KeyStats.Windows/AGENTS.md Add guideline to include standardized analytics for new windows/pages.
AGENTS.md Add guideline to include standardized analytics for new windows/pages.
.claude/settings.local.json Expand allowed Claude tools (WebSearch/WebFetch).
Comments suppressed due to low confidence (1)

.claude/settings.local.json:18

  • This change expands Claude tool permissions (adds WebSearch and WebFetch for external domains). Since this impacts repo-wide contributor tooling and has security/process implications, it should be called out explicitly in the PR description (or moved to a non-*.local.json file if the intent is to keep local developer configuration out of version control).

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

Comment thread KeyStats/AppDelegate.swift
Comment thread KeyStats/StatsPopoverViewController.swift Outdated
Comment thread KeyStats.Windows/KeyStats/ViewModels/StatsPopupViewModel.cs
Comment thread KeyStats.Windows/KeyStats/App.xaml.cs
debugtheworldbot and others added 2 commits April 2, 2026 23:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated no new comments.


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

@debugtheworldbot debugtheworldbot merged commit 57c3d5a into main Apr 3, 2026
4 checks passed
@debugtheworldbot debugtheworldbot deleted the feat/unify-cross-platform-tracking branch April 3, 2026 03:00
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.

2 participants