Skip to content

fix: ensure first tracking events for html/python projects only fire once#1502

Open
DNR500 wants to merge 1 commit into
mainfrom
1483-tracking-events
Open

fix: ensure first tracking events for html/python projects only fire once#1502
DNR500 wants to merge 1 commit into
mainfrom
1483-tracking-events

Conversation

@DNR500

@DNR500 DNR500 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 runStarted and runCompleted dispatch logic into separate useEffect hooks.
  • Add a useRef guard to ensure editor-runStarted only fires when codeRunTriggered transitions false → true.
  • Strengthen the unit test to assert editor-runStarted fires 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.

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