Skip to content

Commit

Permalink
Fix support for debugging in the web client (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonrobot authored Sep 26, 2023
1 parent 10ecbbe commit f6bc690
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-dogs-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@envyjs/web': patch
---

Fix debugging in web sender package
4 changes: 4 additions & 0 deletions packages/web/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export function WebSocketClient(options: WebSocketClientOptions) {

return {
send: (data: Event) => {
if (options.debug) {
log.debug('sending', data);
}

try {
if (ws.readyState === ws.OPEN) {
ws.send(JSON.stringify(data));
Expand Down
3 changes: 1 addition & 2 deletions packages/web/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ export async function enableTracing(options: TracingOptions): Promise<void> {
if (options.debug) log.info('Starting in debug mode');

const port = options.port ?? DEFAULT_WEB_SOCKET_PORT;
const serviceName = options.serviceName;

// custom websocket client
const ws = WebSocketClient({ port, serviceName });
const ws = WebSocketClient({ ...options, port });

// middleware transforms event data
const middleware: Middleware[] = [Meta, Sanity];
Expand Down

0 comments on commit f6bc690

Please sign in to comment.