Added websockets for sending logs if available
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
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.
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
@rc10house Bumping this. Would be nice to get this over the finish line if you have time.
@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.
@Jyyjy the specific tests with the added @jest-environment jsdom were the ones throwing the node errors.
@EandrewJones gonna leave this up for a couple days in case you want to review, if not I'll merge.
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: @.***>