Skip to content

Count Windows and Linux users in analytics, and report the real version - #45

Merged
burhankhanzada merged 2 commits into
mainfrom
feat/analytics-coverage
Oct 22, 2026
Merged

burhankhanzada merged 2 commits into
mainfrom
feat/analytics-coverage

Conversation

@burhankhanzada

@burhankhanzada burhankhanzada commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What and why

Windows and Linux users were never counted. The Firebase Flutter SDK has no Windows/Linux implementation, so TelemetrySupport.analytics was false there and those installs sent nothing. AnalyticsService now sends through an AnalyticsBackend: the Firebase SDK where it exists, and the GA4 Measurement Protocol (lib/core/telemetry/measurement_protocol.dart) on Windows/Linux, into the same property, under the same consent. Nothing is created, not even the client ID, until the user agrees. An edition supplies the stream through the new optional TelemetryConfig.measurementProtocol; TelemetryConfig.firebase is now optional too.

On Windows/Linux, the backend handles the parts the SDK normally does:

  • Users: a random client ID per install. GA4 refuses first_visit over the protocol, so a new ID sends first_launch instead.
  • Sessions and active users: every event carries session_id, which renews after 30 minutes idle, and engagement_time_msec, capped at 1 minute. GA4 needs both to count the user as active.
  • Screens: sent as page_view, because web streams refuse screen_view.
  • Batching: events are sent 25 at a time or every 10 s, and flushed on exit. A failed send is dropped, not retried.
  • Consent withdrawn: anything unsent is dropped.
  • Debug builds: post to /debug/mp/collect, which validates and records nothing.

Also in this PR:

  • Fixed: every analytics report said version 0.0.1. app_version came from a constant that never moved. It is now read from the build (PackageInfo), and OpenTelemetry's service.version gets the same value.
  • New user property: signed_in (yes/no, never the account).
  • New milestones: first_template_open, first_component_added, first_compile_attempt.
  • User properties are re-sent when consent is given mid-session. Theme was only ever set at startup, while analytics was still off. Consent is now applied before the answer is published, so listeners find analytics already on.
  • Flush on exit: buffered analytics is flushed on exit alongside OpenTelemetry.
  • Unrelated commit (b129760): a dragged part's wires follow it live. The drag edited the lists in place, and the wire painter only repaints when it is handed a new list.

Merge before PinBench/pro#6 (pro depends on pinbench_edition_api at main).

How it was verified

  • flutter analyze: clean
  • dart format lib test: no changes
  • flutter test: 579 passed, 7 skipped. That includes 13 new tests in test/core/telemetry/measurement_protocol_test.dart (sessions, engagement, batching, consent, client-ID persistence, request shape) and the new drag test.
  • Tried it in the running app. It hasn't been run on Windows/Linux yet, because that needs the GA stream and secret (see the pro PR).

Notes for the reviewer

  • Measurement Protocol data has no geography (the protocol doesn't geolocate the sender). Windows/Linux new users show up as the first_launch event, not in GA's "New users" metric.
  • To use the new properties in reports, register signed_in and the existing run_platform, app_version, theme and entry_mode as user-scoped custom dimensions in GA4. Mark the first_* milestones as key events.

🤖 Generated with Claude Code

burhankhanzada and others added 2 commits October 22, 2026 22:15
The Firebase SDK has no Windows/Linux implementation, so those installs
were never counted. AnalyticsService now sends through an AnalyticsBackend:
the Firebase SDK where it exists, and the GA4 Measurement Protocol on
Windows/Linux, into the same property, under the same consent. An edition
supplies the stream through TelemetryConfig.measurementProtocol.

Also:
- app_version came from a constant stuck at 0.0.1; it is read from the build.
- signed_in user property; first_template_open, first_component_added and
  first_compile_attempt milestones.
- User properties are set again when consent is given mid-session (they
  were dropped while analytics was off), and consent is applied before the
  answer is published so listeners see analytics already on.
- Buffered analytics is flushed on exit, alongside OpenTelemetry.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The drag edited the node and wire lists in place, and the wire painter
only repaints when handed a different list, so the wires stayed behind
until the drop. The drag now hands over fresh lists.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@burhankhanzada
burhankhanzada merged commit ba2066b into main Oct 22, 2026
21 checks passed
@burhankhanzada
burhankhanzada deleted the feat/analytics-coverage branch October 22, 2026 20:45
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