Skip to content

Conversation

@mocca102
Copy link
Contributor

@mocca102 mocca102 commented Apr 15, 2025

The bug is that currently, you can’t listen to any of the dispatched events from the ConstructorIO client. Basically, this does not work.

window.addEventListener('cio.client.autocomplete.getAutocompleteResults.completed', () => {});

This line is the reason. waitForBeacon is true by default. Because we don’t load the beacon on OS UI AC the eventDispatcher remains inactive (active = false)

// If `waitForBeacon` option is set, only enable event dispatching once event is received from beacon
if (this.waitForBeacon) {
      this.active = false;
}

To fix the bug we just need to pass this to the cio instance

const cioClient = new ConstructorIOClient({
      ...
      eventDispatcher: { waitForBeacon: false },
});

To test the changes add this anywhere

window.addEventListener('cio.client.autocomplete.getAutocompleteResults.completed', (ev) => {
     console.log('event', event)
});

@mocca102 mocca102 requested a review from a team as a code owner April 15, 2025 21:10
Copy link
Contributor

@stanlp1 stanlp1 left a comment

Choose a reason for hiding this comment

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

Good catch. LGTM

@esezen esezen self-requested a review as a code owner September 22, 2025 15:31
@esezen esezen force-pushed the noci-fix-cio-js-client-events-not-being-fired branch from 40bd24f to a887380 Compare September 22, 2025 15:37
@esezen esezen merged commit 22c61ba into main Sep 22, 2025
7 of 10 checks passed
@esezen esezen deleted the noci-fix-cio-js-client-events-not-being-fired branch September 22, 2025 15:43
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