Skip to content

Emit host-facing events for stop, save, download and sidebar - #1635

Merged
patch0 merged 8 commits into
mainfrom
add-more-events
Sep 11, 2026
Merged

Emit host-facing events for stop, save, download and sidebar#1635
patch0 merged 8 commits into
mainfrom
add-more-events

Conversation

@patch0

@patch0 patch0 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

These interactions were tracked by calling window.plausible directly from components. Custom events are the documented channel out of the shadow DOM, and the host owns both the vendor choice and the context the payload needs (projectSlug, locale, consent), so emit events rather than pushing to window.dataLayer from here.

  editor-runStopped         { embedded }
  editor-saveTriggered      { loggedIn }
  editor-projectDownloaded  { projectType }
  editor-sidebarToggled     { panel, expanded }

In order to measure interactions with the sidebar, instructions etc,
more events are required.
@patch0
patch0 temporarily deployed to previews/1635/merge September 10, 2026 16:43 — with GitHub Actions Inactive
@patch0 patch0 self-assigned this Sep 10, 2026

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.

🟡 Changes recommended

Several tests add global document event listeners without removal (risking cross-test pollution/flakes), and there’s an open question about retaining direct window.plausible calls given the PR’s stated intent.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds new host-facing custom events for key user interactions (stop run, save click, project download, and sidebar panel changes) so host pages can handle analytics and context outside the Shadow DOM.

Changes:

  • Added custom event factories for editor-runStopped, editor-saveTriggered, editor-projectDownloaded, and editor-sidebarToggled.
  • Emitted these events from StopButton, SaveButton, DownloadButton, and Sidebar respectively.
  • Extended unit tests and README documentation to cover the new events and payload shapes.
File summaries
File Description
src/events/WebComponentCustomEvents.js Adds event creator helpers for new host-facing events.
src/components/SaveButton/SaveButton.jsx Dispatches editor-saveTriggered when save is clicked.
src/components/SaveButton/SaveButton.test.jsx Adds assertions for editor-saveTriggered payload.
src/components/RunButton/StopButton.jsx Dispatches editor-runStopped when stop is clicked.
src/components/RunButton/StopButton.test.jsx Adds assertions for editor-runStopped payload.
src/components/Menus/Sidebar/Sidebar.jsx Dispatches editor-sidebarToggled when the selected sidebar option changes.
src/components/Menus/Sidebar/Sidebar.test.jsx Adds assertions for editor-sidebarToggled payload.
src/components/DownloadButton/DownloadButton.jsx Dispatches editor-projectDownloaded when download is clicked.
src/components/DownloadButton/DownloadButton.test.jsx Adds assertions for editor-projectDownloaded payload.
README.md Documents the newly emitted custom events and their detail payloads.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/SaveButton/SaveButton.jsx
Comment thread src/components/DownloadButton/DownloadButton.test.jsx
Comment thread src/components/Menus/Sidebar/Sidebar.test.jsx
Comment thread src/components/RunButton/StopButton.test.jsx
Comment thread src/components/SaveButton/SaveButton.test.jsx
@patch0
patch0 temporarily deployed to previews/1635/merge September 10, 2026 16:54 — 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.

🟢 Approval recommended

No unresolved issues remain, and the event contracts are covered by tests and documentation.

Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Comment thread src/components/Menus/Sidebar/Sidebar.jsx
Comment thread src/components/RunButton/StopButton.jsx
Comment thread src/components/SaveButton/SaveButton.jsx
Comment thread src/components/ProjectBar/ScratchProjectBar.jsx
Comment thread src/components/RunButton/StopButton.jsx
Comment thread src/events/WebComponentCustomEvents.js
Comment thread src/components/DownloadButton/DownloadButton.jsx
Comment thread src/components/Menus/Sidebar/Sidebar.test.jsx
Comment thread src/components/DownloadButton/DownloadButton.test.jsx
Comment thread src/components/ProjectBar/ScratchProjectBar.test.jsx Outdated
Comment thread src/components/DownloadButton/DownloadButton.test.jsx

@adrian-rpf adrian-rpf 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.

A few comments but I think you can merge when ready.

* Tidies the tests a little
* Clarifies readme
* Defends against a missing `project_type` when downloading
@patch0
patch0 enabled auto-merge (squash) September 11, 2026 11:21
@patch0
patch0 merged commit bc49412 into main Sep 11, 2026
8 checks passed
@patch0
patch0 deleted the add-more-events branch September 11, 2026 11:24
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.

4 participants