Skip to content

Emit dial events rather than logging them #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

micheal-parks
Copy link
Member

@micheal-parks micheal-parks commented May 21, 2025

Currently we don't allow end-users to consume dial events, we only log them to the JS console. Logging isn't a good idea for production apps because:

  1. It could pose security risks for clients that don't want to expose dial logic.
  2. In cases where we want to make dial logic transparent to the user the JS console is often hidden away.

This PR improves both situations by instead having the RobotClient emit dial events, which we can present in UIs, and removing logs.

@micheal-parks micheal-parks requested a review from a team as a code owner May 21, 2025 20:04
@@ -36,7 +37,7 @@ export class EventDispatcher {
this.listeners[type]?.delete(listener);
}
Copy link
Member

Choose a reason for hiding this comment

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

Why aren't we passing <T> to once, has, and off?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added to once, can't think of any type safety added by the others can you?

Copy link
Member

Choose a reason for hiding this comment

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

No, once make sense.

Copy link
Member

@njooma njooma left a comment

Choose a reason for hiding this comment

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

A few questions

// eslint-disable-next-line no-console
console.debug('Reconnected successfully!');
this.emit(MachineConnectionEvent.DIAL_EVENT, {
message: 'Reconnected successfully',
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a DIAL_EVENT and not CONNECTED?

await client.connect({
priority: conf.priority,
dialTimeout: conf.dialTimeout ?? DIAL_TIMEOUT,
creds: conf.credentials,
});

// eslint-disable-next-line no-console
console.debug('connected via WebRTC');
client.emit(MachineConnectionEvent.DIAL_EVENT, {
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, why is this a DIAL_EVENT and not CONNECTED?

@@ -9,21 +9,22 @@ export enum MachineConnectionEvent {
CONNECTED = 'connected',
DISCONNECTING = 'disconnecting',
DISCONNECTED = 'disconnected',
DIAL_EVENT = 'dialing',
Copy link
Member

Choose a reason for hiding this comment

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

Is DIALING different than CONNECTING?

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.

3 participants