Skip to content

add event handler for frontend#2

Open
clifforum wants to merge 2 commits into
masterfrom
cliff/fe-events
Open

add event handler for frontend#2
clifforum wants to merge 2 commits into
masterfrom
cliff/fe-events

Conversation

@clifforum

Copy link
Copy Markdown
Owner

because we dont have visibility on FE side flow for the purview FE.
I added this events system, so in the orum code, we could add listeners to the different events and log metrics accordingly.

Basically so we could track the connection attempts, failures and successes.

In orum code we will need to add custom js code that will listen to events like this:

window.addEventListener('purview', (e: CustomEvent) => {
  const event = e.detail as PurviewEvent;
  switch(event.type) {
    case 'websocket:open':
      console.log('WebSocket open');
      break;
    case 'websocket:error':
      console.log('error', event.detail);
      break;
   case 'websocket:close':
      console.log('closed', event.detail);
      break;
  }
});

Comment thread src/client.ts
dispatchPurviewEvent({ type: 'websocket:close', detail: { retries: state.numRetries } });

if (state.numRetries === MAX_RETRIES) {
location.reload()

@denpoly-orum denpoly-orum Jan 23, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd also consider adding a log event here too, so we have a record of the refresh 😎

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