Skip to content

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

Open
DNR500 wants to merge 2 commits into
mainfrom
1483-tracking-events
Open

fix: ensure first tracking events for html/python projects only fire once#1502
DNR500 wants to merge 2 commits 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 review requested due to automatic review settings June 17, 2026 17:18
@DNR500 DNR500 temporarily deployed to previews/1502/merge June 17, 2026 17:18 — with GitHub Actions Inactive

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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1174d2a. Configure here.

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