fix: ensure first tracking events for html/python projects only fire once#1502
Open
DNR500 wants to merge 1 commit into
Open
fix: ensure first tracking events for html/python projects only fire once#1502DNR500 wants to merge 1 commit into
DNR500 wants to merge 1 commit into
Conversation
Contributor
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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