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

🔮 [HADXVI-53] Browser SDK extension search bar improvement #2771

Merged
merged 23 commits into from
Jun 19, 2024

Conversation

cy-moi
Copy link
Contributor

@cy-moi cy-moi commented May 22, 2024

Motivation

The search bar living in the event tab has only minimal support now. We want to improve it for a better user experience. This PR is an experiment on one of the approaches.

Changes

Search in descriptions Copy search query from cell value directly
Screenshot 2024-05-22 at 11 56 32 Screenshot 2024-05-22 at 13 57 10
Search with * Escape whitespace with backlash
Screenshot 2024-05-22 at 14 50 37 Screenshot 2024-05-22 at 14 56 48

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2024

Codecov Report

Attention: Patch coverage is 62.50000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 93.04%. Comparing base (0783df4) to head (bcc6402).
Report is 22 commits behind head on main.

Files Patch % Lines
...xtension/src/panel/hooks/useEvents/eventFilters.ts 62.50% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2771      +/-   ##
==========================================
- Coverage   93.61%   93.04%   -0.58%     
==========================================
  Files         243      244       +1     
  Lines        7098     7161      +63     
  Branches     1583     1598      +15     
==========================================
+ Hits         6645     6663      +18     
- Misses        453      498      +45     

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

Copy link

cit-pr-commenter bot commented May 22, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 158.75 KiB 158.75 KiB 0 B 0.00%
Logs 57.02 KiB 57.02 KiB 0 B 0.00%
Rum Slim 105.22 KiB 105.22 KiB 0 B 0.00%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.001 0.002 0.000
addaction 0.031 0.043 0.012
adderror 0.031 0.038 0.007
addtiming 0.001 0.001 0.000
startview 0.835 1.060 0.225
startstopsessionreplayrecording 0.700 1.071 0.371
logmessage 0.004 0.006 0.002
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 20.58 KiB 19.43 KiB -1181 B
addaction 69.94 KiB 68.84 KiB -1128 B
adderror 85.08 KiB 86.78 KiB 1.69 KiB
addtiming 16.68 KiB 16.12 KiB -573 B
startview 312.73 KiB 317.13 KiB 4.40 KiB
startstopsessionreplayrecording 11.72 KiB 12.44 KiB 733 B
logmessage 68.30 KiB 67.40 KiB -927 B

@cy-moi cy-moi marked this pull request as ready for review May 22, 2024 14:24
@cy-moi cy-moi requested a review from a team as a code owner May 22, 2024 14:24
@@ -75,18 +75,42 @@ function filterOutdatedVersions(events: SdkEvent[]): SdkEvent[] {

function parseQuery(query: string) {
const queryParts = query
.split(' ')
.split(/(?<!\\)\s/gm) // Hack it to escape whitespace with backslashes
Copy link
Collaborator

Choose a reason for hiding this comment

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

👏 praise: ‏ nice!

@cy-moi cy-moi requested a review from thomas-lebeau May 23, 2024 07:54
@@ -256,6 +259,7 @@ function JsonText({
menuItems = (
<>
<CopyMenuItem value={descriptor.value}>Copy value</CopyMenuItem>
<CopyMenuItem value={getSearchQuery(descriptor, columnPath)}>Copy search query</CopyMenuItem>
Copy link
Member

Choose a reason for hiding this comment

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

💭 thought: ‏I don't think it makes sense to have this menu everywhere Json is used (like, in the Info tab). What about moving this item in getMenuItemsForPath function in eventRow.tsx? This would also remove the need to have the columnPath in Json.

Copy link
Contributor Author

@cy-moi cy-moi Jun 17, 2024

Choose a reason for hiding this comment

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

I created the item with getCopyMenuItemsForPath for copying search query, separating the two for the ease of understanding, because column.path and path might be too mixed up. wdyt?

@@ -75,18 +75,42 @@ function filterOutdatedVersions(events: SdkEvent[]): SdkEvent[] {

function parseQuery(query: string) {
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏it could be nice to have a few unit tests for that this 😄

return (
<Menu.Item
onClick={() => {
copy(JSON.stringify(value, null, 2))
// Remove the outer quotation marks from copied string
Copy link
Member

Choose a reason for hiding this comment

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

🥜 nitpick: ‏this comment isn't accurate anymore

return (
<>
{getMenuItemsForPath(fullPath)}
{typeof value === 'string' ? getCopyMenuItemsForPath(column.path, value) : undefined}
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏move this code to getMenuItemsForPath. It could look like this:

 function getMenuItemsForPath(path: string, value: unknown) {
      const menuItems: React.ChildNode[] = []

      const newColumn: EventListColumn = { type: 'field', path }
      if (path && !includesColumn(columns, newColumn)) {
        menuItems.push(
          <Menu.Item
            key="add-column"
            onClick={() => {
              onColumnsChange(addColumn(columns, newColumn))
            }}
            leftSection={<IconColumnInsertRight size={14} />}
          >
            Add column
          </Menu.Item>
        )
      }

      if (typeof value === "string") {
        const searchTerm = String(value).replace(/ /g, '\\ ')
        menuItems.push(
          <CopyMenuItem value={`${path}:${searchTerm}`}>Copy search query</CopyMenuItem>
        )
      }

      return <>{menuItems}</>
    }

@cy-moi cy-moi merged commit 1561617 into main Jun 19, 2024
20 checks passed
@cy-moi cy-moi deleted the congyao/HADXVI-53-extension-search-bar branch June 19, 2024 09:31
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.

4 participants