fix: ensure first tracking events for html/python projects only fire once#1502
fix: ensure first tracking events for html/python projects only fire once#1502DNR500 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a web-component analytics/eventing bug where HTML and Python projects could dispatch editor-runStarted twice on the first Run click by decoupling “run started” from “run completed” side-effects and gating runStarted to only fire on the codeRunTriggered rising edge.
Changes:
- Split
runStartedandrunCompleteddispatch logic into separateuseEffecthooks. - Add a
useRefguard to ensureeditor-runStartedonly fires whencodeRunTriggeredtransitionsfalse → true. - Strengthen the unit test to assert
editor-runStartedfires exactly once.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/components/WebComponentProject/WebComponentProject.jsx |
Prevents duplicate editor-runStarted dispatch by tracking prior codeRunTriggered state and separating effects. |
src/components/WebComponentProject/WebComponentProject.test.js |
Updates test setup and assertion to verify editor-runStarted fires only once. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d992e34 to
1174d2a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1174d2a. Configure here.
| isErrorFree: error === "", | ||
| step: currentStepPosition, | ||
| errorDetails, | ||
| friendlyErrorShown: Boolean(friendlyError?.html), |
There was a problem hiding this comment.
Stale friendly error tracking flag
Medium Severity
The new friendlyErrorShown field on editor-runCompleted is derived only from friendlyError?.html in Redux. Skulpt clears error and errorDetails at run start but does not clear friendlyError, so a successful run after a failed one can still emit friendlyErrorShown: true while isErrorFree is true.
Reviewed by Cursor Bugbot for commit 1174d2a. Configure here.


relates to issue: 1483
Fixes a bug where HTML and Python projects dispatched editor-runStarted twice on the first Run click.
The run-started and run-completed logic lived in one useEffect. After the first runStarted dispatch, setCodeHasRun(true) re-ran that effect while codeRunTriggered was still true, so the event fired again. Later runs were unaffected because codeHasRun was already true.
This change splits those into separate effects and only dispatches runStarted when codeRunTriggered goes from false to true.
Relates to the changes here - https://github.com/RaspberryPiFoundation/editor-standalone/pull/954