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

feat: Add global shortcut to export logs #2336

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ericlln
Copy link

@ericlln ericlln commented Jan 9, 2025

  • Added Ctrl+Alt+Shift+L/Cmd-Option-Shift-L as a global shortcut for exporting support logs
  • When pressed in code-studio, it will download logs with the same contents as logs produced by pressing the 'Export Logs' button in the settings menu
  • When pressed in other contexts: when not logged in, on a reconnect error, or in embed-widgets, the logs are exported without the plugin and server info
  • Tested by E2E tests that navigate to the various contexts, presses the shortcut, and checks if a file was downloaded. Can further inspect the file downloaded in the tests but unsure if that's necessary

Closes #1963

@ericlln ericlln requested a review from mofojed January 9, 2025 15:03
@ericlln ericlln self-assigned this Jan 9, 2025
Copy link
Contributor

github-actions bot commented Jan 9, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@ericlln
Copy link
Author

ericlln commented Jan 9, 2025

I have read the CLA Document and I hereby sign the CLA

deephaven-internal added a commit to deephaven/cla that referenced this pull request Jan 9, 2025
Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

I think the e2e test is failing in CI because the timeout may not be long enough - it may take a while for the UI to load in a resource constrained environment. You can increase the timeout for this call specifically by passing in the option: https://playwright.dev/docs/test-timeouts

@@ -11,7 +11,7 @@ export default defineConfig(({ mode }) => {

let port = Number.parseInt(env.PORT, 10);
if (Number.isNaN(port) || port <= 0) {
port = 4030;
port = 4010;
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch! This was originally 4030 as we had two other packages embed-grid and embed-chart that were 4010 and 4020 respectively, but then we added embed-widget which deprecated both of those. Since they've both been removed, embed-widget has moved to 4010 but seems we missed changing it here.

@@ -1,12 +1,11 @@
import React, { type ReactElement } from 'react';
import { ContextMenuRoot, ToastContainer } from '@deephaven/components';
import { ToastContainer } from '@deephaven/components';
Copy link
Member

Choose a reason for hiding this comment

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

You should also remove the ContextMenuRoot from App.tsx in embed-widget.

@@ -19,6 +25,9 @@ export type AppBootstrapProps = {
/** URL of the server. */
serverUrl: string;

/** Version of front-end. */
uiVersion: string;
Copy link
Member

Choose a reason for hiding this comment

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

This prop should be optional - it's not really required, and by adding it we're making this a breaking change for anybody consuming this package (since they'd need to provide uiVersion or TypeScript will fail:

Suggested change
uiVersion: string;
uiVersion?: string;

I'd actually go one further, and just take a logMetadata?: Record<string, unknown> prop, in case we want to include any other properties in there.

Comment on lines +70 to +86
const contextActions = [
{
// Exporting logs in a general context
action: () => {
exportLogs(
logHistory,
{
uiVersion,
userAgent: navigator.userAgent,
},
store.getState()
);
},
shortcut: GLOBAL_SHORTCUTS.EXPORT_LOGS,
isGlobal: true,
},
];
Copy link
Member

Choose a reason for hiding this comment

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

I had mentioned on our 1:1 that the action was only in two places, so we didn't need to factor it out again. But now we've got it in a few places, I'd make a method in the app-utils package to create the context action.

function createExportLogsContextAction(metadata?: ..., reduxData?: ...) {
  ...
}

We should also memoize the contextActions here using useMemo so we're not re-rendering unnecessarily.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 46.69%. Comparing base (6a08198) to head (9a3b143).

Files with missing lines Patch % Lines
packages/code-studio/src/main/AppMainContainer.tsx 0.00% 4 Missing ⚠️
packages/app-utils/src/components/AppBootstrap.tsx 33.33% 2 Missing ⚠️
packages/code-studio/src/index.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2336      +/-   ##
==========================================
- Coverage   46.70%   46.69%   -0.01%     
==========================================
  Files         704      704              
  Lines       39044    39052       +8     
  Branches     9757     9942     +185     
==========================================
+ Hits        18234    18235       +1     
- Misses      20799    20806       +7     
  Partials       11       11              
Flag Coverage Δ
unit 46.69% <12.50%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to export support logs before logging in or after there's a connection error
2 participants