-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Description
Description:
Currently, when developing scripts for Incoming or Outgoing Webhooks, developers are forced to check the server’s stdout/system logs to see the output of console.log() statements. For many administrators (especially those using cloud or containerized environments), accessing these logs is difficult or impossible.
Since scripts run in an isolated-vm sandbox, the execution is a "black box." If the script compiles but fails to produce the expected output due to logic errors (e.g., a failed if condition on an incoming payload), there is no way to trace the execution within the Rocket.Chat interface.
Proposed Solution
I propose intercepting the console methods within the sandbox environment and persisting the output to the database so it can be viewed directly in the Integration settings.
- Log Interception: Wrap the console.log, console.warn, and console.error calls inside the integration runner.
- Log Persistence: Store the last
$N$ lines (e.g., 20 lines) of the most recent execution in a new field (e.g., lastLogs) in the Integrations collection. - UI Enhancement: Add a "Recent Execution Logs" section in the Integration Edit view that displays these persisted logs.
- Auto-Cleanup: Overwrite the logs on every execution to ensure the database doesn't grow indefinitely.
Steps to reproduce / Current behavior
- Create an Incoming Webhook with a script.
- Add console.log(request.content); to the script.
- Trigger the webhook.
- Observation: There is no way to see the result of that log within the Rocket.Chat UI. You must have access to the server terminal/logs.
Expected behavior
A developer should be able to trigger a webhook and immediately see their console.log output in the "Logs" tab or a dedicated section of the Integration Admin UI to verify payload structures and logic flow.
Server Setup Information
Rocket.Chat Version: 7.x.x (and develop)
Operating System: AllDeployment
Method: All