Skip to content

Commit 1e53616

Browse files
ericllnvbabichdgodinez-dh
authored
refactor: Cherry-pick latest log export changes into v0.78 (#2401)
Cherry-pick changes made to `LogExport.ts` in `main` into `v0.78` to address [DH-18984](https://deephaven.atlassian.net/browse/DH-18984) - #2396 - #2382 - #2279 [DH-18984]: https://deephaven.atlassian.net/browse/DH-18984?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Vlad Babich <vladbabich@deephaven.io> Co-authored-by: dgodinez-dh <davidgodinez@deephaven.io>
1 parent 0c3b7fa commit 1e53616

File tree

8 files changed

+285
-59
lines changed

8 files changed

+285
-59
lines changed

package-lock.json

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/code-studio/src/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import ReactDOM from 'react-dom';
33
import '@deephaven/components/scss/BaseStyleSheet.scss';
44
import { LoadingOverlay, preloadTheme } from '@deephaven/components';
55
import { ApiBootstrap } from '@deephaven/jsapi-bootstrap';
6-
import logInit from './log/LogInit';
6+
import { logInit } from '@deephaven/log';
77

8-
logInit();
8+
logInit(
9+
parseInt(import.meta.env.VITE_LOG_LEVEL ?? '', 10),
10+
import.meta.env.VITE_ENABLE_LOG_PROXY === 'true'
11+
);
912

1013
preloadTheme();
1114

packages/code-studio/src/settings/SettingsMenu.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ import {
2020
ThemePicker,
2121
Tooltip,
2222
} from '@deephaven/components';
23-
import { ServerConfigValues, User } from '@deephaven/redux';
23+
import { type ServerConfigValues, type User, store } from '@deephaven/redux';
2424
import {
2525
BROADCAST_CHANNEL_NAME,
2626
BROADCAST_LOGOUT_MESSAGE,
2727
makeMessage,
2828
} from '@deephaven/jsapi-utils';
2929
import { assertNotNull } from '@deephaven/utils';
3030
import { PluginModuleMap } from '@deephaven/plugin';
31+
import { exportLogs, logHistory } from '@deephaven/log';
3132
import FormattingSectionContent from './FormattingSectionContent';
3233
import LegalNotice from './LegalNotice';
3334
import SettingsMenuSection from './SettingsMenuSection';
3435
import ShortcutSectionContent from './ShortcutsSectionContent';
35-
import { exportLogs } from '../log/LogExport';
3636
import './SettingsMenu.scss';
3737
import ColumnSpecificSectionContent from './ColumnSpecificSectionContent';
3838
import {
@@ -136,10 +136,16 @@ export class SettingsMenu extends Component<
136136
handleExportSupportLogs(): void {
137137
const { serverConfigValues, pluginData } = this.props;
138138
const pluginInfo = getFormattedPluginInfo(pluginData);
139-
exportLogs(undefined, {
140-
...Object.fromEntries(serverConfigValues),
141-
pluginInfo,
142-
});
139+
exportLogs(
140+
logHistory,
141+
{
142+
uiVersion: import.meta.env.npm_package_version,
143+
userAgent: navigator.userAgent,
144+
...Object.fromEntries(serverConfigValues),
145+
pluginInfo,
146+
},
147+
store.getState()
148+
);
143149
}
144150

145151
render(): ReactElement {

packages/log/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"build:babel": "babel ./src --out-dir ./dist --extensions \".ts,.tsx,.js,.jsx\" --source-maps --root-mode upward"
2222
},
2323
"dependencies": {
24-
"event-target-shim": "^6.0.2"
24+
"event-target-shim": "^6.0.2",
25+
"jszip": "^3.10.1"
2526
},
2627
"files": [
2728
"dist"

packages/log/src/LogExport.test.ts

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
import { getReduxDataString } from './LogExport';
2+
3+
describe('getReduxDataString', () => {
4+
it('should return a JSON string of the redux data', () => {
5+
const reduxData = {
6+
key1: 'value1',
7+
key2: 2,
8+
key3: true,
9+
};
10+
const result = getReduxDataString(reduxData);
11+
const expected = JSON.stringify(reduxData, null, 2);
12+
expect(result).toBe(expected);
13+
});
14+
15+
it('should handle circular references', () => {
16+
const reduxData: Record<string, unknown> = {
17+
key1: 'value1',
18+
};
19+
reduxData.key2 = reduxData;
20+
const result = getReduxDataString(reduxData);
21+
const expected = JSON.stringify(
22+
{
23+
key1: 'value1',
24+
key2: 'Circular ref to root',
25+
},
26+
null,
27+
2
28+
);
29+
expect(result).toBe(expected);
30+
});
31+
32+
it('should handle BigInt values', () => {
33+
const reduxData = {
34+
key1: BigInt('12345678901234567890'),
35+
};
36+
const result = getReduxDataString(reduxData);
37+
const expected = JSON.stringify(
38+
{
39+
key1: '12345678901234567890',
40+
},
41+
null,
42+
2
43+
);
44+
expect(result).toBe(expected);
45+
});
46+
47+
it('should apply blacklist paths', () => {
48+
const reduxData = {
49+
key1: 'should be blacklisted',
50+
key2: {
51+
'key2.1': 'should also be blacklisted',
52+
},
53+
key3: 'value',
54+
};
55+
const result = getReduxDataString(reduxData, [
56+
['key1'],
57+
['key2', 'key2.1'],
58+
]);
59+
const expected = JSON.stringify(
60+
{
61+
key2: {},
62+
key3: 'value',
63+
},
64+
null,
65+
2
66+
);
67+
expect(result).toBe(expected);
68+
});
69+
70+
it('should stringify Maps', () => {
71+
const reduxData = {
72+
key1: new Map([
73+
['key1.1', 'value1.1'],
74+
['key1.2', 'value1.2'],
75+
]),
76+
};
77+
const result = getReduxDataString(reduxData);
78+
const expected = JSON.stringify(
79+
{
80+
key1: [
81+
['key1.1', 'value1.1'],
82+
['key1.2', 'value1.2'],
83+
],
84+
},
85+
null,
86+
2
87+
);
88+
expect(result).toBe(expected);
89+
});
90+
91+
it('should handle wildcards in blacklist paths', () => {
92+
const reduxData = {
93+
key1: 'not blacklisted',
94+
key2: {
95+
keyA: {
96+
key1: 'blacklisted',
97+
},
98+
keyB: {
99+
key1: 'blacklisted',
100+
},
101+
keyC: {
102+
key1: 'blacklisted',
103+
},
104+
},
105+
};
106+
const result = getReduxDataString(reduxData, [['key2', '*', 'key1']]);
107+
const expected = JSON.stringify(
108+
{
109+
key1: 'not blacklisted',
110+
key2: {
111+
keyA: {},
112+
keyB: {},
113+
keyC: {},
114+
},
115+
},
116+
null,
117+
2
118+
);
119+
expect(result).toBe(expected);
120+
});
121+
122+
it('should handle nested wildcards in blacklist paths', () => {
123+
const reduxData = {
124+
key1: 'not blacklisted',
125+
key2: {
126+
keyA: {
127+
key1: 'blacklisted',
128+
key2: {
129+
key3: 'blacklisted',
130+
},
131+
},
132+
keyB: {
133+
key1: 'blacklisted',
134+
key2: {
135+
key3: 'blacklisted',
136+
key4: 'blacklisted',
137+
},
138+
},
139+
},
140+
};
141+
const result = getReduxDataString(reduxData, [['key2', '*', '*']]);
142+
const expected = JSON.stringify(
143+
{
144+
key1: 'not blacklisted',
145+
key2: {
146+
keyA: {},
147+
keyB: {},
148+
},
149+
},
150+
null,
151+
2
152+
);
153+
expect(result).toBe(expected);
154+
});
155+
156+
it('should handle wildcard blacklist paths with no matches', () => {
157+
const reduxData = {
158+
key1: 'not blacklisted',
159+
key2: {
160+
keyA: {
161+
key1: 'not blacklisted',
162+
key2: {
163+
key3: 'not blacklisted',
164+
},
165+
},
166+
},
167+
};
168+
const result = getReduxDataString(reduxData, [['*', '*', '*', '*', '*']]); // Matching more than the depth of the object
169+
const expected = JSON.stringify(reduxData, null, 2);
170+
expect(result).toBe(expected);
171+
});
172+
173+
it('root wildcard should blacklist all', () => {
174+
const reduxData = {
175+
key1: 'should not be blacklisted',
176+
};
177+
const result = getReduxDataString(reduxData, [['*']]);
178+
expect(result).toBe('{}');
179+
});
180+
});

0 commit comments

Comments
 (0)