flagon-useralejs icon indicating copy to clipboard operation
flagon-useralejs copied to clipboard

Added websockets for sending logs if available

Open rc10house opened this issue 1 year ago • 2 comments

Adds functionality to main.ts to check if the provided config.url is running a WebSocket server. If so, we upgrade the connection to send data over WebSockets and use this for sending all logs. If not, we send data with the existing REST functionality. I also added a test/example WebSockets server examples/ws-server.js.

Note: WebSockets will not run when using Jest to test currently, so the application skips attempting to create a WebSockets connection if it detects running in a test environment (headless browser).

Closes: #444

rc10house avatar Aug 19 '24 19:08 rc10house

Had to separate some tests to avoid websockets being ran from within jsdom environment. Also had to add some helper methods for manually turning on/off websockets for testing purposes.

rc10house avatar Aug 21 '24 20:08 rc10house

You can add another webserver to test/e2e/playwright.config.ts and specify which webserver to use for different projects. Set existing projects to use the existing webserver, and create a new project with a websocket server.

I would set http and websockets to different ports within the same server and specify "reuseExistingServer: True"

Relevant docs: https://playwright.dev/docs/test-webserver

Jyyjy avatar Aug 29 '24 16:08 Jyyjy

@rc10house Bumping this. Would be nice to get this over the finish line if you have time.

EandrewJones avatar Oct 09 '24 16:10 EandrewJones

@Jyyjy for some reason, the previous jest-environment specification (in package.json) lead to some of the tests using node as the environment anyway. Node would then throw errors because it tries to use ws module, which is not available in the browser. I added the @jest-environment jsdom individually to avoid these errors.

rc10house avatar Oct 16 '24 18:10 rc10house

@Jyyjy the specific tests with the added @jest-environment jsdom were the ones throwing the node errors.

rc10house avatar Oct 16 '24 18:10 rc10house

@EandrewJones gonna leave this up for a couple days in case you want to review, if not I'll merge.

Jyyjy avatar Oct 16 '24 19:10 Jyyjy

Go ahead and merge. I'm unlikely to find the time to give this an in-depth look in the next few days.

Best

Evan Jones Website: www.ea-jones.com

On Wed, Oct 16, 2024 at 12:11 PM Jason Young @.***> wrote:

@EandrewJones https://github.com/EandrewJones gonna leave this up for a couple days in case you want to review, if not I'll merge.

— Reply to this email directly, view it on GitHub https://github.com/apache/flagon-useralejs/pull/489#issuecomment-2417731010, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ2T6ALM22IGBIC63TYZPPDZ3226NAVCNFSM6AAAAABMYNXDD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJXG4ZTCMBRGA . You are receiving this because you were mentioned.Message ID: @.***>

EandrewJones avatar Oct 16 '24 19:10 EandrewJones