-
Notifications
You must be signed in to change notification settings - Fork 404
RI-6953: Send telemetry events for ReJSON used editor #4537
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
RI-6953: Send telemetry events for ReJSON used editor #4537
Conversation
import { AppDispatch, RootState } from '../store' | ||
|
||
export const JSON_LENGTH_TO_FORCE_RETRIEVE = 200 | ||
const TELEMETRY_KEY_LEVEL_WHOLE_KEY = 'entireKey' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key is named ..._WHOLE_KEY
the value entireKey
. Why not ..._ENTIRE_KEY
// Suppress Redux warnings about missing reducers | ||
beforeAll(() => { | ||
console.error = (...args: any[]) => { | ||
const message = args[0] | ||
if ( | ||
typeof message === 'string' && | ||
message.includes('No reducer provided for key') | ||
) { | ||
return | ||
} | ||
|
||
originalConsoleError(...args) | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why for this test specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a brand new test suite, and I'm adding it here. I'm suppressing the expected Redux warnings to keep the logs clean and free of noise.
} | ||
}) | ||
|
||
const rejson = await import('uiSrc/slices/browser/rejson') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the dynamic imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mocking process for this file is a bit tricky. It seems something gets imported before Jest has a chance to apply the usual jest.mock()
logic, so the standard mocking approach doesn’t work here. That’s why this file uses jest.resetModules()
- to force a clean module state.
} | ||
|
||
const getJsonPathLevel = (path: string): string => { | ||
const getJsonPathLevel = (path: string): number => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some tests verifying this funciton works as expected won't hurt
5b2587f
rejson
slice is hard to test due to its architecture. As a temporary solution, I added a new test suite, where modules can be dynamically reloaded in order to use thejest
mocks. Ideally, the business logic from this slice should be extracted and properly tested.Apart from the event properties, this CL fixes a bug with reporting the JSON path level of nesting.