Skip to content

Align event logging/compliance with ml-trainer - #1303

Draft
microbit-matt-hillsdon wants to merge 4 commits into
mainfrom
analytics-ga4
Draft

Align event logging/compliance with ml-trainer#1303
microbit-matt-hillsdon wants to merge 4 commits into
mainfrom
analytics-ga4

Conversation

@microbit-matt-hillsdon

Copy link
Copy Markdown
Collaborator

No description provided.

Logging, Sentry and the shared-assets cookie consent previously lived in
the private theme package. They now live here, mirroring ml-trainer's
Logger + WebSink layout, with the theme package reduced to brand config
plus a `product` slug injected on every event. gtag only exists on
Foundation builds (VITE_FOUNDATION_BUILD), so OSS forks and local dev
log events to the console; compliance falls back to a stub there so the
welcome dialog still shows.

Replaces the UA-shaped events and their bucketed fan-outs with flat
snake_case events and primitive params, documented in
docs/analytics-events.md with a migration table. Device events share
ml-trainer's device_* family (task / transport / step / at_step / code)
and now cover flash duration and unexpected disconnects. Project stats
are sent raw as metrics, with a default_main boolean replacing the
undefined-lines special case in FileSystem.statistics().

Logging.error now takes (message, e), matching the connection library,
and Logging gains setUserProperty for the webusb_available user
property. Adds @sentry/browser as a direct dependency.

Requires @microbit-foundation/python-editor-v3-microbit 0.3.0.
Rename params so one GA4 custom definition serves both this app and
ml-trainer: tab -> surface, slug/idea/sensor -> id, action -> state,
default_main -> is_default, and editor_paste's lines -> count so the
lines metric consistently means program length.

Cuts the new dimensions to register from eight to four (format, id,
is_default, state).
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Preview build will be at
https://review-python-editor-v3.microbit.org/analytics-ga4/

Comment thread AGENTS.md
Comment on lines +24 to +29
Events go through `Logging` (`src/logging/`) and are documented in
`docs/analytics-events.md`; update the doc when adding or changing an event.
Names are snake_case with flat primitive params. gtag only exists on
Foundation builds (`VITE_FOUNDATION_BUILD`, see `index.html`), so OSS and
local dev log events to the console instead. The private theme package
supplies brand config only, including the `product` analytics slug.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
Events go through `Logging` (`src/logging/`) and are documented in
`docs/analytics-events.md`; update the doc when adding or changing an event.
Names are snake_case with flat primitive params. gtag only exists on
Foundation builds (`VITE_FOUNDATION_BUILD`, see `index.html`), so OSS and
local dev log events to the console instead. The private theme package
supplies brand config only, including the `product` analytics slug.
Events go through `Logging` (`src/logging/`) and are documented in
`docs/analytics-events.md`; update the doc when adding or changing an event.
Names are snake_case with flat primitive params. gtag only exists on
Foundation builds (`VITE_FOUNDATION_BUILD`, see `index.html`), so OSS and
local dev log events to the console instead.

Remove irrelevant note.

Comment thread docs/analytics-events.md
@@ -0,0 +1,299 @@
# Analytics events

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Needs recasting to be PM facing.

The event detail field feeds routerState.tab and is read as `tab` by the
listener in CodeMirror.tsx, so renaming it to `surface` left the tab
undefined and the API/Reference docs entry never opened. Elsewhere on
this branch the internal field stays `tab` and is mapped to `surface`
only at the logging.event call; do the same here.

Caught by the four autocomplete e2e tests that follow the API/Help link
from a completion or signature popup.
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