Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Improve debug logging for turbo streams

Oliver Günther7f397c7ee3b3
diff --git a/frontend/src/turbo/setup.ts b/frontend/src/turbo/setup.ts
index f79ab801f6c..710c18d6276 100644
--- a/frontend/src/turbo/setup.ts
+++ b/frontend/src/turbo/setup.ts
@@ -11,6 +11,7 @@ import { debugLog, whenDebugging } from 'core-app/shared/helpers/debug_output';
import { TURBO_EVENTS } from './constants';
import { StreamActions } from '@hotwired/turbo';
import { addTurboAngularWrapper } from 'core-turbo/turbo-angular-wrapper';
+import { TurboStreamElement } from 'core-typings/turbo';
Turbo.session.drive = true;
Turbo.setProgressBarDelay(100);
@@ -20,11 +21,18 @@ Turbo.start();
// Register logging of events
whenDebugging(() => {
- TURBO_EVENTS.forEach((name:string) => {
+ TURBO_EVENTS
+ .filter((name) => name !== 'turbo:before-stream-render')
+ .forEach((name:string) => {
document.addEventListener(name, (event) => {
debugLog(`[TURBO EVENT ${name}] %O`, event);
});
});
+
+ document.addEventListener('turbo:before-stream-render', (event) => {
+ const stream:TurboStreamElement = (event.detail as { newStream:TurboStreamElement }).newStream;
+ debugLog(`[TURBO EVENT turbo-before-stream-render] ${stream.action.toUpperCase()} target=${stream.target} %O`, event);
+ });
});
// Register our own actions