Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug turbo events in development #16706

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions frontend/src/turbo/constants.ts
Original file line number Diff line number Diff line change
@@ -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',
Comment on lines +2 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to sort alphabetically

Also why not all events, maybe turbo:before-morph-element, turbo:before-morph-attribute andturbo:morph-element will spam, and turbo:frame-missing will be visible anyway, but why not turbo:morph, turbo:before-frame-morph, turbo:before-frame-render, turbo:before-prefetch, turbo:reload?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add them 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

];
11 changes: 11 additions & 0 deletions frontend/src/turbo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading