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

Debug turbo events in development

Oliver Günthere7a97f94438e
diff --git a/frontend/src/turbo/constants.ts b/frontend/src/turbo/constants.ts
new file mode 100644
index 00000000000..267b6882de0
--- /dev/null
+++ b/frontend/src/turbo/constants.ts
@@ -0,0 +1,17 @@
+export const TURBO_EVENTS:string[] = [
+ 'turbo:click',
+ 'turbo:before-visit',
+ 'turbo:visit',
+ 'turbo:submit-start',
+ 'turbo:before-fetch-request',
+ 'turbo:before-fetch-response',
+ 'turbo:submit-end',
+ 'turbo:before-cache',
+ 'turbo:before-render',
+ 'turbo:before-stream-render',
+ 'turbo:render',
+ 'turbo:load',
+ 'turbo:frame-render',
+ 'turbo:frame-load',
+ 'turbo:fetch-request-error',
+];
diff --git a/frontend/src/turbo/setup.ts b/frontend/src/turbo/setup.ts
index 4c4f9f54bce..f9db91d4dcf 100644
--- a/frontend/src/turbo/setup.ts
+++ b/frontend/src/turbo/setup.ts
@@ -5,12 +5,23 @@ import { registerDialogStreamAction } from './dialog-stream-action';
import { addTurboEventListeners } from './turbo-event-listeners';
import { registerFlashStreamAction } from './flash-stream-action';
import { applyTurboNavigationPatch } from './turbo-navigation-patch';
+import { debugLog, whenDebugging } from 'core-app/shared/helpers/debug_output';
+import { TURBO_EVENTS } from './constants';
// Disable default turbo-drive for now as we don't need it for now AND it breaks angular routing
Turbo.session.drive = false;
// Start turbo
Turbo.start();
+// Register logging of events
+whenDebugging(() => {
+ TURBO_EVENTS.forEach((name:string) => {
+ document.addEventListener(name, (event) => {
+ debugLog(`[TURBO EVENT ${name}] %O`, event);
+ });
+ });
+});
+
// Register our own actions
addTurboEventListeners();
registerDialogStreamAction();